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 / Asteroids ship wrap around while using SetSpritePhysicsImpulse

Author
Message
Scotty1973
AGK Backer
12
Years of Service
User Offline
Joined: 2nd Jun 2011
Location: Burton-on-Trent, uk
Posted: 28th Sep 2014 11:25
Hi

I'm having a problem with SetSpritePhysicsImpulse. What i'm trying to do is, move a space ship round the screen using percentage system.
The ship is moved via SetSpritePhysicsImpulse command and this works fine, but the problem i'm having is that I want to wrap the ship round the screen. So if it goes off the top it will appear at the bottom, or if it goes off the right it will appear on the left and vice versa.
The problem is when I reset the ship position the impulse power is lost and I have no way to find out how much power was left as the ship left the screen.
Wow this sounds long winded lol.
Basic = asteroids(atari 2600) type game where using SetSpritePhysicsImpulse to power ship.


Many thanks

Scotty
Daniel TGC
Retired Moderator
17
Years of Service
User Offline
Joined: 19th Feb 2007
Location: TGC
Posted: 28th Sep 2014 11:40
Just use the commands GetSpritePhysicsVelocityX and GetSpritePhysicsVelocityY store them in a couple of tmp Identifiers and then use the command SetSpritePhysicsVelocity after you use the SetSpritePosition command to restore the velocity.
Scotty1973
AGK Backer
12
Years of Service
User Offline
Joined: 2nd Jun 2011
Location: Burton-on-Trent, uk
Posted: 28th Sep 2014 12:09 Edited at: 28th Sep 2014 12:23
Cheers Daniel

Missed your live broadcast yesterday and watched on you tube. Great stuff and can't wait for next one. Did think velocity but was trying to put it into the impulse command and getting super fast ship lol.

Thanks

Scotty
Kenjar
18
Years of Service
User Offline
Joined: 17th Jun 2005
Location: TGC
Posted: 29th Sep 2014 10:28
Yes Physics can get out of control, I usually just do a simple hardline limiter. I.e. if velocity > x then limit to x I also do the same thing on angular velocity.

Another thing you can do is adjust the mass of the object, objects with higher mass are less affected by collisions.
Scotty1973
AGK Backer
12
Years of Service
User Offline
Joined: 2nd Jun 2011
Location: Burton-on-Trent, uk
Posted: 29th Sep 2014 21:13
You are right Kenjar I did limit the angular velocity may do the same with normal velocity. Thanks for you help.

Scotty

Login to post a reply

Server time is: 2024-04-26 06:54:17
Your offset time is: 2024-04-26 06:54:17