Login | Register

Draw a digital clock

June 30, 2006, 21:13 by Calle
[loading]
-->
This article is very simple and describes how you can do the simplest digital clock in Game Maker. This is really made easy in v6.0:

time = string(current_hour)+":"
+string(current_minute)+":"+string(current_second)


Game Maker can also tell year, current_year, and month, current_month, and each weekday, current_weekday. Only problem is that all of those functions return numbers, which is usually not what we want when presenting the current month or weekday. Then this is how you could do to manually make sure that the right thing is drawn, not very elegant but it works:

if (current_month==1) {
month = “January” //draw the variable month
}
if (current_month==2) {
month = “February”;
}
if (current_weekday==1) {
day = “Monday” //draw the variable day
}


And so it continues, I bet you get the system. For drawing method I would suggest draw_text, but that very choose able.

Comments

Loading comments... [loading]
.
Users logged in:

game maker articles, game maker examples, game maker tutorials, gmtutorials, game maker questions and answers, game maker crash course, how to create games