English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General

 
 
Thread Tools
Old 19 June 2019, 21:05   #1
BippyM
Global Moderator

BippyM's Avatar
 
Join Date: Nov 2001
Location: Nottingham, UK
Age: 44
Posts: 8,830
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, 21:58   #2
phx
Natteravn

phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 1,479
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, 22:13   #3
BippyM
Global Moderator

BippyM's Avatar
 
Join Date: Nov 2001
Location: Nottingham, UK
Age: 44
Posts: 8,830
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, 22:30   #4
mcgeezer
Registered User

 
Join Date: Oct 2017
Location: Sunderland, England
Posts: 1,485
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 20 June 2019, 00:05   #5
DanScott
Lemon. / Core Design

DanScott's Avatar
 
Join Date: Mar 2016
Location: Sunny Bournemouth, UK
Posts: 471
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 20 June 2019, 00:16   #6
mcgeezer
Registered User

 
Join Date: Oct 2017
Location: Sunderland, England
Posts: 1,485
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, 11:27   #7
zero
Registered User

 
Join Date: Jun 2016
Location: UK
Posts: 338
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
EAB Game Competition - Discussion related to possible next one Predseda Coders. Contest 32 14 November 2019 14:08
"Hunter HD" - Fan Remake & nostalgic discussion of a classic Amiga game :) Cherno Nostalgia & memories 139 07 May 2019 21:17
Power Disc [new Amiga game] discussion TheFoxSoft project.Amiga Game Factory 44 29 October 2017 14:43
Game Speed under WHDLoad Winterjaeger support.Games 0 23 September 2012 21:03
WHDLoad game speed Washac project.WHDLoad 7 26 February 2012 18: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 03:57.


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