English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General

 
 
Thread Tools
Old 19 June 2019, 20:05   #1
BippyM
Global Moderator
 
BippyM's Avatar
 
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??
BippyM is offline  
Old 19 June 2019, 20:58   #2
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
Quote:
Originally Posted by BippyM View Post
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??
Yes. The simplest approach is to define the speed in pixels per frame.

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:
Would the process be the same for slowing down?
Yes. See above.

Quote:
At what point does the speed start looking jerky or disjointed??
Hmm. Don't know what you mean. With 50fps it is always as good as it can get. You cannot draw intermediate positions of a fast moving objects. Only 50 new positions per second.
phx is offline  
Old 19 June 2019, 21:13   #3
BippyM
Global Moderator
 
BippyM's Avatar
 
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?
BippyM is offline  
Old 19 June 2019, 21:30   #4
mcgeezer
Registered User
 
Join Date: Oct 2017
Location: Sunderland, England
Posts: 2,702
Quote:
Originally Posted by BippyM View Post
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?
What you do is simply increase the resolution of the screen canvas.

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
Geezer
mcgeezer is offline  
Old 19 June 2019, 23:05   #5
DanScott
Lemon. / Core Design
 
DanScott's Avatar
 
Join Date: Mar 2016
Location: Tier 5
Posts: 1,209
Quote:
Originally Posted by mcgeezer View Post
(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
Geezer
That's a very rough example, as you would lose any of the fractional part when you shift it right and store it back :P
DanScott is offline  
Old 19 June 2019, 23:16   #6
mcgeezer
Registered User
 
Join Date: Oct 2017
Location: Sunderland, England
Posts: 2,702
Quote:
Originally Posted by DanScott View Post
That's a very rough example, as you would lose any of the fractional part when you shift it right and store it back :P
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.
mcgeezer is offline  
Old 20 June 2019, 10:27   #7
zero
Registered User
 
Join Date: Jun 2016
Location: UK
Posts: 428
Many games use sub-pixel positioning, the most famous being Mario Bros.
zero is offline  
 


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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 11:30.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.15395 seconds with 15 queries