English Amiga Board Game speed discussion
 User Name Remember Me? Password
 Register Amiga FAQ Rules & Help Members List  /  Moderators List Today's Posts Mark Forums Read

 19 June 2019, 21:05 #1 BippyM Global Moderator   Join Date: Nov 2001 Location: Nottingham, UK Age: 44 Posts: 8,875 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, 21:58   #2
phx
Natteravn

Join Date: Nov 2009
Location: Herford / Germany
Posts: 1,484
Quote:
 Originally Posted by BippyM 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.

 19 June 2019, 22:13 #3 BippyM Global Moderator   Join Date: Nov 2001 Location: Nottingham, UK Age: 44 Posts: 8,875 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, 22:30   #4
mcgeezer
Registered User

Join Date: Oct 2017
Location: Sunderland, England
Posts: 1,506
Quote:
 Originally Posted by BippyM 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

20 June 2019, 00:05   #5
DanScott
Lemon. / Core Design

Join Date: Mar 2016
Location: Sunny Bournemouth, UK
Posts: 478
Quote:
 Originally Posted by mcgeezer (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

20 June 2019, 00:16   #6
mcgeezer
Registered User

Join Date: Oct 2017
Location: Sunderland, England
Posts: 1,506
Quote:
 Originally Posted by DanScott 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.

 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.

 Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 Similar Threads Thread Thread Starter Forum Replies Last Post Predseda Coders. Contest 32 14 November 2019 14:08 Cherno Nostalgia & memories 139 07 May 2019 21:17 TheFoxSoft project.Amiga Game Factory 44 29 October 2017 14:43 Winterjaeger support.Games 0 23 September 2012 21:03 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 Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home News Main     Amiga scene     Retrogaming General Discussion     Nostalgia & memories Support     New to Emulation or Amiga scene         Member Introductions     support.WinUAE     support.WinFellow     support.OtherUAE     support.FS-UAE         project.AmigaLive     support.Hardware         Hardware mods         Hardware pics     support.Games     support.Demos     support.Apps     support.Amiga Forever     support.Amix     support.Other Requests     request.UAE Wishlist     request.Old Rare Games     request.Demos     request.Apps     request.Modules     request.Music     request.Other     Looking for a game name ?     Games images which need to be WHDified abime.net - Hall Of Light     HOL news     HOL suggestions and feedback     HOL data problems     HOL contributions abime.net - Amiga Magazine Rack     AMR news     AMR suggestions and feedback     AMR data problems     AMR contributions abime.net - Home Projects     project.Amiga Lore     project.EAB     project.IRC     project.Mods Jukebox     project.Wiki abime.net - Hosted Projects     project.aGTW     project.APoV     project.ClassicWB     project.Jambo!     project.Green Amiga Alien GUIDES     project.Maptapper     project.Sprites     project.WinUAE - Kaillera Other Projects     project.Amiga Demo DVD     project.Amiga Game Factory     project.CARE     project.EAB File Server     project.CD32 Conversion     project.Game Cover Art         GCA.Feedback and Suggestions         GCA.Work in Progress         GCA.Cover Requests         GCA.Usefull Programs         GCA.Helpdesk     project.KGLoad     project.MAGE     project.Missing Full Shareware Games     project.SPS (was CAPS)     project.TOSEC (amiga only)     project.WHDLoad         project.Killergorilla's WHD packs Misc     Amiga websites reviews     MarketPlace         Swapshop     Kinky Amiga Stuff     Collections     EAB's competition Coders     Coders. General         Coders. Releases         Coders. Tutorials     Coders. Asm / Hardware     Coders. System         Coders. Scripting         Coders. Nextgen     Coders. Language         Coders. C/C++         Coders. AMOS         Coders. Blitz Basic     Coders. Contest         Coders. Entries Creation     Graphics         Graphics. Work In Progress         Graphics. Finished Work         Graphics. Tutorials     Music         Music. Work In Progress         Music. Finished Work         Music. Tutorials Off Topic     OT - General     OT - Entertainment     OT - Sports     OT - Technical     OT - Gaming

All times are GMT +2. The time now is 17:31.

 -- EAB3 skin ---- EAB2 skin ---- Mobile skin Archive - Top