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 / Making something go towards a certain point and then detect collision

Author
Message
tiffit
9
Years of Service
User Offline
Joined: 1st Feb 2015
Location:
Posted: 1st Feb 2015 07:02
So lets say I want a sprite to go to (100, 1000) and then when it reaches that point, it detects if there is anything there. If there is, then
randomvariable = randomvariable + 1
happens. How exactly would I do this? I like to look at code, and learn what the person did, so it would be nice if someone could write the code, since I am new. Sorry if my english is bad.
easter bunny
12
Years of Service
User Offline
Joined: 20th Nov 2012
Playing: Dota 2
Posted: 1st Feb 2015 23:04 Edited at: 1st Feb 2015 23:09
Do you means something like this?



Note: This code is completely untested, and it won't even work properly, see the last couple of lines for why.
Bascially this is what it theoretically should do though:
1. Create 9 enemy sprites
2. Create player (Hero)
3. in loop, if user clicks, move hero to that position via function
4. function will return 1 if the sprite has reached target location
5. if it has, then scan through all 9 enemies for collision

the only part that definitely doesn't work, is the function checking if you've reached the target location. I also don't know if the function will even work, it's meant to calculate the length of the vector, normalise it and multiply it by the speed, but I don't know if it'll work properly. I don't have time to check it at the moment, but if nobody's got it sorted out my this afternoon, I'll fix it for you


Audacia Games - Latest WIP - AUTOMAYTE 2.1, AppGameKit one click deploy to Android
"When you've finished 90% of your game, you only have 90% left"
tiffit
9
Years of Service
User Offline
Joined: 1st Feb 2015
Location:
Posted: 2nd Feb 2015 03:02
ok thanks, thats exactly what I wanted!
easter bunny
12
Years of Service
User Offline
Joined: 20th Nov 2012
Playing: Dota 2
Posted: 3rd Feb 2015 01:19
Cool let me know if you have any problems


Audacia Games - Latest WIP - AUTOMAYTE 2.1, AppGameKit one click deploy to Android
"When you've finished 90% of your game, you only have 90% left"

Login to post a reply

Server time is: 2024-11-21 12:52:04
Your offset time is: 2024-11-21 12:52:04