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 / Sprites.(how can I make them disapear?) DBpro.

Author
Message
Jonesy
19
Years of Service
User Offline
Joined: 9th Nov 2004
Location: England
Posted: 15th Nov 2004 22:55
hello! I'm havin some trouble with sprites. I want it that when I press the space bar one sprite disapears and another one appears(firing a gun) but I just cant see what i'm doing wrong! can anyone help me please?

oh well
2D Analyst
AGK Developer
20
Years of Service
User Offline
Joined: 2nd May 2004
Location:
Posted: 16th Nov 2004 03:40
Yeah I'll write a code out now, not sure will it work since I don't have DarkBasic on me now. Here is what I think should work:

load image "pic1.bmp",1
load image "pic2.bmp",2
load image "pic3.bmp",3

on=0

Do
sprite 1,400,400,1
sprite 2,500,500,2
hide sprite 2
if spacebar()=1 and on=0
hide sprite 1
show sprite 2
on=1
endif
if spacebar()=1 and on=1
show sprite 1
hide sprite 2
on=0
endif
sync
Loop

It depends do you have any animation for your character firing or will you create firing manually? The code can vary depending on what media your using and what exactly do you want to do. Hope this helps man. Again, not sure if this works or not since I did not use this code on DarkBasic yet.

eatfishy
VietDao
19
Years of Service
User Offline
Joined: 30th Oct 2004
Location: Earth, Lovely Earth
Posted: 17th Nov 2004 00:03
Hi,
There's no Spacebar() command, the correct command is spacekey() Change it to the following code:

If there's no Wait 250, the programme will continue running, it means when the 1st sprite disappears, the 2nd sprite appears, the 1st sprite will appear immediately, and the 2nd sprite will disapear, and so on... as the loop is so fast, when the spacebar is pressed 0.1 seconds, the programme may complete 100 loops (as my computer can do arround 1000 simple loops/sec).
That's it,
Hope it help,
Bye bye,
2D Analyst
AGK Developer
20
Years of Service
User Offline
Joined: 2nd May 2004
Location:
Posted: 17th Nov 2004 04:26
O yeah, I almost forgot the correct syntax for spacebar function. I haven't used the spacekey() in a while. Lolz Thanks for pointing it out. I'm sure I can think of a shorter way to make a sprite disappear. I normally post message up during work, where I don't have access to DarkBasic. Viet Dao, what kinda games have you created so far?

eatfishy
VietDao
19
Years of Service
User Offline
Joined: 30th Oct 2004
Location: Earth, Lovely Earth
Posted: 21st Nov 2004 20:59
Hi,
Me?! I've created no games, but so far some applicants like Files Management, and stuff like that,... stupid ones!
Bye bye,

Login to post a reply

Server time is: 2024-09-23 05:30:23
Your offset time is: 2024-09-23 05:30:23