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 / Help with falling asteroids

Author
Message
Midget Blaster
AGK Developer
8
Years of Service
User Offline
Joined: 7th May 2016
Location:
Posted: 27th Dec 2017 01:51
I need to make asteroids that fall from the sky, hit the floor and come back up. This is what I have been currently working on but I don't see what is wrong.




I want to make it so that when the asteroid hits the ground, it shrinks and then gets placed back up, with a random x coordinate so every time it falls it falls again on a different x position.

If anyone can help me improve my code I would really appreciate it. Thank you.
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 27th Dec 2017 02:12
I don't think you need to use getspritecollision(), just check the y position of the asteroid
smallg
Valued Member
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location: steam
Posted: 27th Dec 2017 09:36
asteroidx and asteroidy are not being reset so the asteroid gets placed back but then immediately placed back at the floor... You need to make them equal to the same as randomx and randomy

Also look into arrays because currently you can only have 1 asteroid.
life's one big game
spec= 4ghz, 16gb ram, AMD R9 2700 gpu
Bengismo
7
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 27th Dec 2017 14:32
Surely you want to check that your "asteroidsize" variable is OVER 100 so it has shrunk to zero and then it resets (your using 100-asteroidsize)
should use >

You are also using integers for most of your variables where GetFrameTime() returns a float so you X,Y and size variables maybe could be float values too.

And you will need to reset your ateroidsize variable to zero after each loop too...I think.
Midget Blaster
AGK Developer
8
Years of Service
User Offline
Joined: 7th May 2016
Location:
Posted: 27th Dec 2017 22:27
Thanks guys I made it work, Much appreciated

Login to post a reply

Server time is: 2024-11-24 03:39:56
Your offset time is: 2024-11-24 03:39:56