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 DBPro Corner / 2d pics moving down the screen

Author
Message
programmer ML
19
Years of Service
User Offline
Joined: 1st Jun 2005
Location:
Posted: 9th Feb 2006 02:02
i want to have some kind of 2d image falling down the screen in random places but i cant figure out how to do it. Please help me.
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 9th Feb 2006 10:50
The easiest way is to use sprites. You can load 1 image (LOAD IMAGE) and apply it to many sprites. Use the SPRITE command both to create the sprite and also to change it's position.

Fox Dark Master
20
Years of Service
User Offline
Joined: 20th Jul 2004
Location: Portugal
Posted: 9th Feb 2006 17:11
do like this:

Global
PosY = -10 //Off the screen

//This will take a random number of the screen width
PosX = rnd (screen width())
//The you just need to create a sprite and position it
Position sprite Spritenum,PosY,PosX
//After this just make the sprite move down



KiTsUnE wOrKsHoP
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 9th Feb 2006 22:24
I hate to tell you this since you're in the Pro-Noob Anti-Boob Justice League... but most of what you told him won't work.

If he's using classic "global" won't work. "//" works in C++ but doesn't work as a rem statement in Darkbasic. There is no "position sprite" command (just "sprite") and you've flipped the x and y coordinates on the sprite command.


Fox Dark Master
20
Years of Service
User Offline
Joined: 20th Jul 2004
Location: Portugal
Posted: 9th Feb 2006 23:50 Edited at: 9th Feb 2006 23:57
ok... I was in a hurry and I don't know C++ so well but if I could make comments on DB just like that would be bether, won't you agreed?



Basicly it works like this: The repeat structure have an conter named PosY that will increase every loop. When it will stop? after it's value reaches a number equal or bigger that screen height

I don't know if classic have this commands but if not sorry but with this you can get a clue of what y need to do. I didn't test the code proprelly so... if something goes wrong Will be the disonor of the Pro nood justice league.... buts this is just code to show how to do, notto compile!!! with this code you problably have an Idea of what to do.

Sorry sorry sorry



KiTsUnE wOrKsHoP
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 10th Feb 2006 02:50
It's ok. When you post code that's meant to not really be code type "pseudo code".




Fox Dark Master
20
Years of Service
User Offline
Joined: 20th Jul 2004
Location: Portugal
Posted: 10th Feb 2006 09:05
isn't the delete sprite required? hum... I've to see that on my program...



KiTsUnE wOrKsHoP
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 12th Feb 2006 23:18
Not really. You only want to delete the sprite if you want to get rid of it totally. Using the same sprite over and over again just repositions that sprite.


Login to post a reply

Server time is: 2024-11-27 06:39:07
Your offset time is: 2024-11-27 06:39:07