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.

Dark GDK / Help with Randomly generated platforms

Author
Message
TokenFlyer
7
Years of Service
User Offline
Joined: 22nd Apr 2012
Location:
Posted: 22nd Apr 2012 08:23
I am trying to get a platform to randomly generate somewhere on the right side of the screen, move to the left, and lastly disappear once it hits the left edge and start over from some other random spot on the right side of the display. I feel like this should be really easy but whenever I load my code the platform just randomly shoots around in the y-axis of the far right of the display.

here is the code snippet of code giving me trouble
[dbSprite(2, 500, dbRnd(500), 4);

while (LoopGDK( ))
{
dbRotateSprite(2, 90);
dbMoveSprite(2, -5);
dbRotateSprite(2, 0);
if (dbSpriteX(2) > -500)
{
dbSprite(2, 500, dbRnd(500), 4);
}
]

4 is just the image used for the platform.

adsfffffdscsdd
JTK
10
Years of Service
User Offline
Joined: 10th Feb 2010
Location:
Posted: 22nd Apr 2012 21:46
If (dbSpriteX(2)<-dbSpriteWidth(2))
{
dbSprite(2,500,dbRnd(500),4);
}

You're currently checking for > -500 which will always be true.

JTK
TokenFlyer
7
Years of Service
User Offline
Joined: 22nd Apr 2012
Location:
Posted: 22nd Apr 2012 22:11
[You're currently checking for > -500 which will always be true.]

ah man I feel dumb now. thanks for your help, I was really tired when writing this code and just couldn't put up with it any longer.

adsfffffdscsdd

Login to post a reply

Server time is: 2020-02-20 07:12:35
Your offset time is: 2020-02-20 07:12:35