Dedicated to my friend Lionel, whom made me revisit my interest in playing the Rubik’s Cube Puzzle.

A Rubik’s Cube Timer, it is created to time time taken to solve the cube (Mine timings are usually between 1 and 3mins so no hours, or milliseconds implemented yet). The idea came after watching speed cubing videos online, we saw they had a special timer which they bang on to mark their completion.
Written in PaLib, here’s the code.
Visit this thread at PALib’s forums to download the files too.
/*
Zz85 Rubik Cube's Timer
App for Speed Cubing, for timing completion of puzzle.
RELEASES
Version 1.0 May 1, 2007 - Labour Day's Treat for my doctor-to-be friend Lionel
PLANS
Use hardware clock
Use nice sprints
Use sounds
*/
// Includes
#include <pa9 .h> // Include for PA_Lib
u16 RESET = 0;
u16 START = 1;
u16 END = 2;
u16 status = RESET;
void reset()
{
PA_OutputText(1, 6, 6, "%c1Ready...");
PA_OutputText(1, 6, 8, " ");
PA_OutputText(1, 6, 12, " ");
status = RESET;
}
void start()
{
PA_OutputText(1, 6, 6, " ");
PA_OutputText(1, 6, 8, "%c5Start!");
status = START;
}
void end()
{
PA_OutputText(1, 6, 12, "%c5End!");
status = END;
}
int main()
{
PA_Init(); // Initializes PA_Lib
PA_InitVBL(); // Initializes a standard VBL
PA_InitText(1, 2);
PA_OutputText(1, 4, 2, "%c4Zz85's %c1Rubik %c2Cube %c3Timer!");
PA_OutputText(1, 0, 16, "%c2Instructions:");
PA_OutputText(1, 0, 18, "%c2Press Start for reset. Any keys or touchpad to start and stop.");
PA_OutputText(1, 0, 21, "%c2Happy Cubing!");
u32 ticks = 0;
// Infinite loop to keep the program running
while (1)
{
if (status == END && Pad.Released.Start) reset();
else if (status == RESET)
{
ticks = 0;
if (Pad.Released.Anykey || Stylus.Released) start();
}
else if (status == START)
{
ticks++;
PA_OutputText(1, 6, 10, "%c5Time: %c0%d mins %d s ",(ticks/3600),(ticks/60 %60));
if (Pad.Newpress.Anykey || Stylus.Newpress) end();
}
PA_WaitForVBL(); // Wait for 1/60 of a second
}
return 0;
}


Recent Comments