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.

DarkBASIC Discussion / Deleting all sprites when it should only delete one...

Author
Message
Zeus
18
Years of Service
User Offline
Joined: 8th Jul 2006
Location: Atop Mount Olympus
Posted: 19th Feb 2008 00:17
I am working on this fun little game and when I press one key to delete one sprite it delete every other sprite. What is wrong here?




Formerely Cool Guy Jordan
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 19th Feb 2008 00:25
Quote: "when I press one key to delete one sprite it delete every other sprite"


Your code snippet doesn't even have a Delete Sprite command!

TDK_Man

Zeus
18
Years of Service
User Offline
Joined: 8th Jul 2006
Location: Atop Mount Olympus
Posted: 19th Feb 2008 01:31
Hide sprite. My bad. But I still have the problem.


Formerely Cool Guy Jordan
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 19th Feb 2008 02:17 Edited at: 19th Feb 2008 02:20
The problem is with your if inkey$()= lines. The bit after the Or looks like it's returning true for all of them.

Check the logic and use parenthesis if required - normally they are always required if you have multiple And's and Or's on the same line. Only you can do this because only you know the exact circumstances you want the sprites to be hidden.

And don't forget to indent your code. It's not too bad with a small code snippet like this, but with a bigger one I don't know about anyone else, but I wouldn't have bothered looking at it.

TDK_Man

Zeus
18
Years of Service
User Offline
Joined: 8th Jul 2006
Location: Atop Mount Olympus
Posted: 19th Feb 2008 13:37
Thanks TDK you're the best.


Formerely Cool Guy Jordan
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 19th Feb 2008 20:27 Edited at: 19th Feb 2008 20:32
TDK is right

When you typed

DB thought you meant

so if any one of those conditions were true it would return a 1 (True).

What I think you want is


You could actually write it better as you have a simple range

No need for brackets for that one as they are all ANDs

Login to post a reply

Server time is: 2025-06-04 01:55:59
Your offset time is: 2025-06-04 01:55:59