Control the game loop

Post Reply
User avatar
HudsonBr
Posts: 29
Joined: Wed May 05, 2021 8:15 pm

Control the game loop

Post by HudsonBr » Wed Jun 23, 2021 9:11 am

Hi,
how can i control the game loop ? tried to some sleep(), but caused flickering.
any tips?

Regards
..::Game Developer::..

WinterMute
Site Admin
Posts: 1986
Joined: Tue Aug 09, 2005 3:21 am
Location: UK
Contact:

Re: Control the game loop

Post by WinterMute » 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?
Help keep devkitPro toolchains free, Donate today

Personal Blog

User avatar
HudsonBr
Posts: 29
Joined: Wed May 05, 2021 8:15 pm

Re: Control the game loop

Post by HudsonBr » Sat Jun 26, 2021 2:02 am

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
..::Game Developer::..

WinterMute
Site Admin
Posts: 1986
Joined: Tue Aug 09, 2005 3:21 am
Location: UK
Contact:

Re: Control the game loop

Post by WinterMute » Thu Jul 01, 2021 2:51 am

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.
Help keep devkitPro toolchains free, Donate today

Personal Blog

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests