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 Studio Chat / Giving sprites variables in an array

Author
Message
Bluepixel
4
Years of Service
User Offline
Joined: 8th Apr 2019
Location:
Posted: 16th May 2019 09:54 Edited at: 16th May 2019 14:25


I am trying to give each individual sprite a random direction, and then have them keep going into that direction. but right now the sprites will go crazy. is there a way to make this work properly? for instance giving each sprite its individual variable in an array. please explain to me what everything does so I can understand how it works since im quite new to AGK
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 16th May 2019 15:10 Edited at: 16th May 2019 16:02
If you have a look at this code it takes a sprite image and shatters it sending pieces in every direction


the code taken from this thread of mine https://forum.thegamecreators.com/thread/222027?page=3
fubarpk
fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 18th May 2019 01:06 Edited at: 18th May 2019 01:15
you've got the idea, bluepixel. assign a random direction to each sprite via an array.

note the SpriteData Type which contains the SpriteID and its specific Direction of travel so you can maintain their relationship.

Sprite would be your Array which contains each Sprite's "Data" above:



i tend to use "temp" variables such as ThisSprite in the code above so i don't have to type, in this case, Sprite[x].ID (over and over) so, don't let that throw you off; it's just my way. it's easier for me to "read"

Login to post a reply

Server time is: 2024-03-28 10:26:35
Your offset time is: 2024-03-28 10:26:35