19 June 2019, 20:05 | #1 |
Global Moderator
Join Date: Nov 2001
Location: Derby, UK
Age: 48
Posts: 9,355
|
Game speed discussion
Hi Guys,
Been a while since I have created a new thread, but here we go. What are the common methods used for determining speed withion games? for example. If a game runs at 50fps, how do you determine the speed the character moves at? Is it just simply skipping the number of frames drawn to the screen, moving the character more pixels to show the increased speed etc?? Would the process be the same for slowing down? At what point does the speed start looking jerky or disjointed?? |
19 June 2019, 20:58 | #2 | |||
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,537
|
Quote:
If you need more fine-grained speeds, like 1.35 px/frame, you would store the coordinates in fixed point format. For example one word for the full pixels and one word for the 1/65536 fractions. With 1.35 px/frame you would add 1 in the integer word and 22938 in the fractional word. Or in assembler: add.l #$0001599a,xpos For drawing the object on screen you only use the integer word. Quote:
Quote:
|
|||
19 June 2019, 21:13 | #3 |
Global Moderator
Join Date: Nov 2001
Location: Derby, UK
Age: 48
Posts: 9,355
|
How can you move in fractions though? Like 1 quarter pixel scrolling or moving half a pixel.. Surely it'll only show full pixel movement?
|
19 June 2019, 21:30 | #4 | |
Registered User
Join Date: Oct 2017
Location: Sunderland, England
Posts: 2,702
|
Quote:
So if you think of a typical 320x200 screen, if you zoomed out by a multiple of 16 the screen size would be 5120x3200. This then allows you to move objects in fractions (1/16th). If you have a sprite that has coordinates of 100x100 and you want to move it an entire 1 pixel to the right you'd do something like this.... (rough example...) Code:
move .w SPRITE_XPOS,d0 ; 100 xpos move .w SPRITE_YPOS,d1 ; 100 ypos lsl.w #4,d0 lsl.w #4,d1 add.w #16,d0 ; Speed 1-16 - 1=slowest, 16=fast (1 pixel). lsr.w #4,d0 lsr.w #4,d1 move.w d0,SPRITE_XPOS ; 101 xpos move.w d1,SPRITE_YPOS ; 100 ypos |
|
19 June 2019, 23:05 | #5 | |
Lemon. / Core Design
Join Date: Mar 2016
Location: Tier 5
Posts: 1,213
|
Quote:
|
|
19 June 2019, 23:16 | #6 |
Registered User
Join Date: Oct 2017
Location: Sunderland, England
Posts: 2,702
|
Yeah, I did say rough example. It was just to try and simplify the logic for the OP. PHX's example is much more efficient but might not be obvious as to what's going on for some.
|
20 June 2019, 10:27 | #7 |
Registered User
Join Date: Jun 2016
Location: UK
Posts: 428
|
Many games use sub-pixel positioning, the most famous being Mario Bros.
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
"Hunter HD" - Fan Remake & nostalgic discussion of a classic Amiga game :) | Cherno | Nostalgia & memories | 147 | 07 April 2022 21:20 |
EAB Game Competition - Discussion related to possible next one | Predseda | Coders. Contest | 32 | 14 November 2019 13:08 |
Power Disc [new Amiga game] discussion | TheFoxSoft | project.Amiga Game Factory | 44 | 29 October 2017 13:43 |
Game Speed under WHDLoad | Winterjaeger | support.Games | 0 | 23 September 2012 20:03 |
WHDLoad game speed | Washac | project.WHDLoad | 7 | 26 February 2012 17:40 |
|
|