Advanced Gamemaker
Date, time, timestamps (mobile) [Game Maker Studio 2 | Advanced]
Image this, you want to have create a mobile game where you time game your content. The problem is once you close you application you cannot count the time passed directly. How to fix this? With saving in an .ini file the old time stamp/date and read it out (plus compare) once you open the applicaion/game again.
There are different things you can do with the internal time (time_current) or time stamps. First of all you can read out from your local machine (pc/mobile) the time there like minutes, hours up to years if you like, change the time zone or create your own time (stamps) or read out how many days have passed in this year/month/week etc. . That is in most cases not very useful information but you can use those metrics to store them in a time stamp which you create once you close the application. Next time you open the game/application you can compare the old time stored with the current one and even calculate the difference which the most common use case for mobile games. That’s it!
// for clarification
current_time: read out internal time passed in application
current_day/current_hour etc. : local values from pc/mobile
date_get_hour: read out also hour but with a argument time
date_current_datetime: the timestamp of the local machine’s current time
date_datetime_String: read out a full readable string of the timestamp
date_hour_span: Calculate the difference (here in hours) between two timestamps
// Video on saving with .ini:
https://youtu.be/r6N_mAmpT7s
Official manual on date and time:
https://manual-en.yoyogames.com/#t=GameMaker_Language%2FGML_Reference%2FMaths_And_Numbers%2FDate_And_Time%2FDate_And_Time.htm
// images from the thumbnail:
https://opengameart.org/content/some-phone-templates-ctatz
https://opengameart.org/content/fight-20-kids-game-concept
👑 Support me and get fresh game art and game maker projects every month:
https://www.patreon.com/1upindie
Follow me on:
📸 Instangram: https://www.instagram.com/1upindie
🐦 Twitter: https://twitter.com/1upIndie
💬 Discord: https://discord.gg/gvr98nb
📜 Udemy: https://www.udemy.com/course/become-a-video-game-developer-with-gms-23/ (See youtube about page for discount)
—————————————————————————————-
0:00 What we will do
1:01 Subscribe
1:12 Use case for storing time
2:32 General uses
6:45 Practical part for mobiles
Add comment