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.

Newcomers AppGameKit Corner / How to make a sprite go in circle?

Author
Message
NeedHalp
8
Years of Service
User Offline
Joined: 20th May 2016
Location:
Posted: 23rd Jul 2016 05:13
This may seem trivial but I just can't figure out how to make a sprite go in circle. I thought about doing SetSpritePositionByOffset(spriteID,Sin(t),Cos(t)) but because of different aspect ratio, I think it's going in oval. Is there a way to get around this problem? Thank you in advance.
JLMoondog
Moderator
15
Years of Service
User Offline
Joined: 18th Jan 2009
Location: Paradox
Posted: 23rd Jul 2016 06:37
Multiply the y position variable by the aspect ratio to get the correct position of the sprite, when using the percentage system. I love the percentage system, so whenever working with trig-math or similar, make sure you do something like this:



Tip #2: Always use floats for positioning and aspect ratio, otherwise you'll run into very jerky and polygon shaped circles.

Good luck!
My workstation was destroyed in a fire, help me out and get free media for AppGameKit and Game Guru: https://www.gofundme.com/bfpm0g
NeedHalp
8
Years of Service
User Offline
Joined: 20th May 2016
Location:
Posted: 23rd Jul 2016 20:28
Thank you! It seems to be working fairly well.
NeedHalp
8
Years of Service
User Offline
Joined: 20th May 2016
Location:
Posted: 24th Jul 2016 21:12 Edited at: 24th Jul 2016 22:15
Urgh... I thought it was working but it's still not a perfect circle. I just think SetSpriteGetPositionByOffset is a bad idea to send the sprite rotating in circle. Is there a better way to do this? Maybe using physics?

Edit: Never mind. Tried using GetDeviceHeight()/GetDeviceWidth() instead of using GetDisplayAspect()... OOOoooopppss :p
JLMoondog
Moderator
15
Years of Service
User Offline
Joined: 18th Jan 2009
Location: Paradox
Posted: 25th Jul 2016 09:03 Edited at: 25th Jul 2016 09:06
Yah, setting the position manually is way easier than any other way. Also, here's a quick example how I go about setting up my projects with the percentage system(hope it helps you):

main.agc file:


settings.agc file:


functions.agc file:


settings.ini file, place in the media folder in your project directory:


You can use this as a template for your game, or just pick and choose what to grab from it. Hope it helps! Let me know if anything needs explaining, tried to put in as much detailed comments as possible. Good luck!
Qugurun
Valued Member
9
Years of Service
User Offline
Joined: 8th Dec 2014
Playing: AppGameKit
Posted: 28th Jul 2016 00:04 Edited at: 28th Jul 2016 00:05

Login to post a reply

Server time is: 2024-11-21 20:38:21
Your offset time is: 2024-11-21 20:38:21