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.

2D All the way! / Sprite Collision Disappearing Reappearing Help...

Author
Message
Erusuwasu
20
Years of Service
User Offline
Joined: 21st Sep 2003
Location: Where am I? I think I\'m lost...
Posted: 22nd Sep 2003 00:31
Hello everybody, I'm a new guy with a hopefully intellegent question. I'm having difficulty with making my sprite disappear. I not only need it to dissappear but to be literaly gone so that it cannot be collided with. Here is some pseudocode of the collision I'm working with:

IF SPRITE COLLISION(cube,ball)
ballyspeed# = ballyspeed# * -1
ballxspeed# = ballxspeed# * -1
score = score + 10
hide sprite cube
ENDIF

The problem is the cube isn't gone so the ball still hits it even after it disappears. I hope that makes sense. The sprite needs to reappear if the user chooses to play again.

Thankyou in advance for any help you can give.

I've got DB Classic and PS Skillz and I'm not afraid to use um!
TheAbomb12
20
Years of Service
User Offline
Joined: 14th Aug 2003
Location: Amist the blue skies...
Posted: 22nd Sep 2003 03:43 Edited at: 22nd Sep 2003 03:44
Well,
When you hide a sprite your not really making it disappear, just making it so you cant see it. The sprite collision command will still function even though you cant see it.

here this might help



Notice its exactly the same except for the sprite visible part. This will check if the user can see the cube, if not then it will skip the collision as if it was not even there.

Those who Fight with swords get killed by those who don't
Erusuwasu
20
Years of Service
User Offline
Joined: 21st Sep 2003
Location: Where am I? I think I\'m lost...
Posted: 22nd Sep 2003 04:02
Thanks TheAbomb12. That makes a lot of sense (I didn't think of that). However, "visible" isn't a command in DBC. Is it a preset variable? If so, what and how would I set it? OR is there a COMMAND that checks if a SPRITE is visible or hidden?

I've got DB Classic and PS Skillz and I'm not afraid to use um!
Erusuwasu
20
Years of Service
User Offline
Joined: 21st Sep 2003
Location: Where am I? I think I\'m lost...
Posted: 22nd Sep 2003 09:21 Edited at: 22nd Sep 2003 09:42
I FIGURED IT OUT !!!! i think...

I used your idea only I created a variable "cubehit" at the beginning of the loop and set it to zero. Which would change to one when the cube and ball collided the first time. Here is the code:


IF cubehit = 1
ELSE
IF SPRITE COLLISION(cube,ball)
ballyspeed# = ballyspeed# * -1
ballxspeed# = ballxspeed# * -1
score = score + 10
cubehit = 1
hide sprite cube
ENDIF
ENDIF

I'm sure that is what you meant with the "visible".

I've got DB Classic and PS Skillz and I'm not afraid to use um!
Erusuwasu
20
Years of Service
User Offline
Joined: 21st Sep 2003
Location: Where am I? I think I\'m lost...
Posted: 22nd Sep 2003 09:24
Thank you so much for your help TheAbomb12. I'll post here agian if I have a related problem. If anyone else has a different idea or a better one than mine please let me know ^_^

I've got DB Classic and PS Skillz and I'm not afraid to use um!
TheAbomb12
20
Years of Service
User Offline
Joined: 14th Aug 2003
Location: Amist the blue skies...
Posted: 22nd Sep 2003 21:14
Sorry i didnt know you were running DBC. Thats why "sprite visible" didnt work. But you figured it out anyways

Those who Fight with swords get killed by those who don't
Erusuwasu
20
Years of Service
User Offline
Joined: 21st Sep 2003
Location: Where am I? I think I\'m lost...
Posted: 22nd Sep 2003 23:10
It's cool, you helped me see something I didn't see myself which led to the solution so you still gave me the answer. Thank you agian ^_^

I did have another question? If I wanted to create say 50 cube sprites and have each run this collision test, what would be the best way (no slow down) to declare the sprites and do the collision for all 50 everytime the game looped?

The only thing I can think of is to use the SET SPRITE to turn off background restore when declareing the SPRITES and a FOR/NEXT loop for the collision? Does that sound right? Any other ideas?

I've got DB Classic and PS Skillz and I'm not afraid to use um!

Login to post a reply

Server time is: 2024-05-05 10:16:23
Your offset time is: 2024-05-05 10:16:23