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 / I need help with sprites

Author
Message
Robsam
16
Years of Service
User Offline
Joined: 4th Feb 2008
Location: scotland
Posted: 12th Feb 2008 18:29
I have a program with 8 sprites moving horizontally back and forth on the screen. I have one sprite dropping vertically like a depth charge which I am able to detect a collision with the other 8 sprites, however when I use delete sprite after the collision the sound of the explosion is heard bur the sprite is not deleted. I changed from delete sprite to hide sprite but I still hear explosions when a collision is made with the hidden sprites, why are the sprited not deleted or are being redrawn?. I initially placed the sprites on screen within my do loop is this the problem? I would appreciate any help
Ed222
17
Years of Service
User Offline
Joined: 3rd Nov 2007
Location: Calgary
Posted: 12th Feb 2008 20:22 Edited at: 12th Feb 2008 20:24
Would you mind posting your code? this would really help us understand more. also hide sprite hides your sprite so it still exist but it can't be seen meaning that the sprite will still be detected.

Windows Is better than everything
Robsam
16
Years of Service
User Offline
Joined: 4th Feb 2008
Location: scotland
Posted: 12th Feb 2008 21:26

Attachments

Login to view attachments
Robsam
16
Years of Service
User Offline
Joined: 4th Feb 2008
Location: scotland
Posted: 12th Feb 2008 21:27
Hi Ed222 I dont know if you got my code, let me know as Im not sure about how to get the code to you


Thanks for your help
Ed222
17
Years of Service
User Offline
Joined: 3rd Nov 2007
Location: Calgary
Posted: 12th Feb 2008 23:26 Edited at: 12th Feb 2008 23:36
ok I got your code so what your saying is that your trying to make it so if a sprite collides with another sprite the sound stops playing and remove the sprite?[edit]ok never mind I found out what you ment and when you delete the sprite it's being redrawen again oh and one more thing to post a code press the code button on top and paste in your code than press code again to end it also try lable it next time it's kind of hard to work with out lables.
P.S. i'll post the code when I'm done

Windows Is better than everything
Ed222
17
Years of Service
User Offline
Joined: 3rd Nov 2007
Location: Calgary
Posted: 12th Feb 2008 23:48
Ok done heres you code


Windows Is better than everything
Robsam
16
Years of Service
User Offline
Joined: 4th Feb 2008
Location: scotland
Posted: 13th Feb 2008 19:02
Hello Ed222, I received your code and the program runs exactly as I had hoped for thanks a lot for your time it is much apreciated. I must apologise for the lack of labels especially after the last code you sent me, (lesson learned) there is another point you may be able to help me with and that is when my vertically dropping sprite representing the depth charge falls, it drops too fast, I tried "inc ver 0.5" but this created an error. can you tell, me how to slow the sprite down a bit.

Attachments

Login to view attachments
Ed222
17
Years of Service
User Offline
Joined: 3rd Nov 2007
Location: Calgary
Posted: 13th Feb 2008 20:19
sure ok instead of inc use some thing like this
Replace the so with your varibles for dec do the same thing but use - instead of +

Windows Is better than everything
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 14th Feb 2008 04:22 Edited at: 14th Feb 2008 04:25
Quote: "so=so+0.5

Replace the so with your varibles for dec do the same thing but use - instead of +"


There's no difference between using Inc/Dec and what you are already doing so unfortunately that's a waste of time. Neither will work if 'so' is an integer. It will never increase from it's starting value.

Make it a float variable... or better still, use a timer to move it.

TDK_Man

Ed222
17
Years of Service
User Offline
Joined: 3rd Nov 2007
Location: Calgary
Posted: 14th Feb 2008 16:20 Edited at: 14th Feb 2008 16:26
oppss I guessed I messed up...
[edit] I just compiled a code and tried that it didn't work I guess I better test it next time....and yes inc and dec is the same but the something=something+1 metiod is much faster to type..

Tip Of The Day!: DBC is an interperter programming language while DBP is true machine code and uses 9x so it'll always run faster.
Robsam
16
Years of Service
User Offline
Joined: 4th Feb 2008
Location: scotland
Posted: 14th Feb 2008 17:51
thanks for the advice TDK I will try the float variable: I do not know how to use the timer in conjunction with the moving sprite
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 14th Feb 2008 21:17 Edited at: 14th Feb 2008 21:19
My timer tutorial:

http://forum.thegamecreators.com/?m=forum_view&t=59347&b=7

In it's simplest form:



Alter the values 100 and 200 to change the speed things move.

The advantage of using this method is that a depth charge will take the same time to drop down the screen on everybody's machine whereas at the moment, if mine is a lot faster than yours it might run too fast to be playable for me.

TDK_Man

Robsam
16
Years of Service
User Offline
Joined: 4th Feb 2008
Location: scotland
Posted: 14th Feb 2008 22:08
Thanks for the code TDK_man much appreciated its great to have people like yourself for us new programers to get help and advice when we need it.
Robsam
16
Years of Service
User Offline
Joined: 4th Feb 2008
Location: scotland
Posted: 18th Feb 2008 19:06
can yo help with this sprite problem: I have a scenario where I want to use downkey to start dropping my depthcharge from the point where my surface ship is at that time, however when the depthcharge drops and I move my ship the depthcharge also moves to the left or right, how can I overcome this problem

I have included my code

Attachments

Login to view attachments
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 18th Feb 2008 23:40 Edited at: 18th Feb 2008 23:44
Check out my shooting tutorial number 11 (same link as last time).

A depth charge is basically shooting a bullet down the screen and your problem is specifically covered in the second code snippet.

You might want to check all of the tutorials that are available there when your next problem pops up!

TDK_Man

Login to post a reply

Server time is: 2024-11-25 07:26:17
Your offset time is: 2024-11-25 07:26:17