Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Multiplayer Sprite movement settings help

Author
Message
Alex Goaga
9
Years of Service
User Offline
Joined: 6th Nov 2015
Location:
Posted: 29th Jan 2016 11:36
Hi guys, I have a question regarding the sprite movement in multiplayer , by using the Accelerometer / keyboard arrows.

The basic multiplayer code is here : https://www.appgamekit.com/documentation/examples/multiplayer/0_getting_started.htm

My question is , after switching on SetVirtualResolution(1024, 768 ) or more, the sprite speed has decreased very much. Where or how do I increase the speed of arrow keys or Accelerometer ?

I tried this but the sprite does not recognize my inputs after modifying it.

x# = GetSpriteX ( 1 )
x# = x# + 20.0
SetSpriteX ( 1, x# )

Thank you for your time
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 29th Jan 2016 11:42
The movement is in virtual pixels. If you increase the screen width from 640 to 1980, it will take 3 times longer to get across.

Your design process should be:

1. Decide on virtual resolution
2. Write movement and positioning code or this resolution

If you are likely to alter your virtual resolution, then include a small calculation at the top of your program, something like:

speedMultiplier# = getVirtualWidth() / 640.0

and in your code,

setSpriteX(1, x# + (20 * speedMultiplier#))
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
Digital Awakening
AGK Developer
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 29th Jan 2016 11:47
When you use SetVirtualResolution(1024, 768 ) you change the internal coordinate system from 100x100 to 1024x768. This will drastically change everything that are based on pixels such as size, position and physics.

You need to add multipliers to these lines:
x# = GetSpriteX ( 1 ) + GetDirectionX ( )
y# = GetSpriteY ( 1 ) + GetDirectionY ( )

Like so for example:
x# = GetSpriteX ( 1 ) + GetDirectionX ( ) * 10.0
y# = GetSpriteY ( 1 ) + GetDirectionY ( ) * 10.0

Login to post a reply

Server time is: 2024-11-25 11:17:25
Your offset time is: 2024-11-25 11:17:25