Understanding the language, error messages, etc.
by MicroGames » Fri Jul 07, 2017 7:15 am
Hi,
I am programing now my own game for the Gamebuino called EPIC MINI GAMES!
Now, I know i shouldn't use delays but I ran to many situations where i needed to use it...
Unfortunately the delay wasn't working at all!
When the program should wait for a second (because i typed in delay(1000); ) the program ran like the delay wasn't eaven there!
Does any one know how to fix it?
-
MicroGames
-
- Posts: 40
- Joined: Wed Jul 05, 2017 5:46 am
by rodot » Fri Jul 07, 2017 7:30 am
Hey,
You are right, *DO NOT* use delay() in your games, because it's blocking and will just freeze your Gamebuino. Instead, time your events using the variable
gb.frameCount.
Alternatively but not advised, you can use Arduino's
millis() function. It's not advised because it's "real" time, it's not synced with your game, so if you game get slower because CPU usage is over 100% millis will *NOT* slow down. It could be useful to make a chronograph though, for example.
If you give more information about what your are trying to do, we might help you find a solution.
-
rodot
- Site Admin
-
- Posts: 1290
- Joined: Mon Nov 19, 2012 11:54 pm
- Location: France
-
by MicroGames » Fri Jul 07, 2017 4:31 pm
Thanks for help
-
MicroGames
-
- Posts: 40
- Joined: Wed Jul 05, 2017 5:46 am
Return to Programming Questions
Who is online
Users browsing this forum: No registered users and 2 guests