Page 1 of 1
Control the game loop
Posted: Wed Jun 23, 2021 9:11 am
by HudsonBr
Hi,
how can i control the game loop ? tried to some sleep(), but caused flickering.
any tips?
Regards
Re: Control the game loop
Posted: Sat Jun 26, 2021 12:30 am
by WinterMute
What is it you mean by "control the game loop"?
Try to describe your problem in as much detail as you can. You mentioned sleep. Are you trying to make objects move slower?
Re: Control the game loop
Posted: Sat Jun 26, 2021 2:02 am
by HudsonBr
WinterMute wrote: ↑Sat Jun 26, 2021 12:30 am
What is it you mean by "control the game loop"?
Try to describe your problem in as much detail as you can. You mentioned sleep. Are you trying to make objects move slower?
The actions inside fe game loop is being executed very fast. game loop like this
https://github.com/devkitPro/gamecube-e ... late.c#L19
Yes, i want to move the objects slower.
Regards
Re: Control the game loop
Posted: Thu Jul 01, 2021 2:51 am
by WinterMute
Rather than trying to adjust the speed of the game loop you should adjust the speed of your objects. Normally a game loop will run at a constant speed (normally the screen refresh rate) .
The gxSprites example uses fixed point numbers to represent postions & velocities. See
https://github.com/devkitPro/wii-exampl ... /gxSprites. The co-ordinates and velocities there use 24 bits for integer part & 8 bits for fractional parts - that means the numbers are multiplied by 256 when being set and the co-ordinates are divided by 256 when used as screen co-ordinates. The wikipedia article is OK if you want to know more about that
https://en.wikipedia.org/wiki/Fixed-point_arithmetic
You could just use floats for this though if you're more comfortable.