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 / Problem with sprites colliding

Author
Message
DMM
16
Years of Service
User Offline
Joined: 11th Sep 2008
Location:
Posted: 3rd Oct 2008 05:32
Hi guys,

I'm trying to make a little 2d top down tank game to practice what I'm reading in J. Harbour's dbpro book.

I can't figure out why these bullet sprites wont collide with the tank sprites. If I paste the bullets stationary to the screen then they will collide with the tanks without a problem (when I drive over them with the tanks), but when I try to test for the collision between moving bullets shot from a tank, it doesn't work. I also tried using the sprite command instead of the paste sprite command in the shoot() functions I wrote, but when I do that, the sprites don't show up on the screen at all.

If you want, you can get my image files from me website derekmims.com on the sidebar link labeled tank fight. The "whole thing in a zip" and "source" links arent working right now, but you can (of course) copy and paste from here.

I also left the stationary bullets on the screen so you can run over them and see "hit" print on the top left of the screen. You can also shoot and see how nothing happens with the right ctrl button for the first tank and spacebar for the second tank. wasd and dpad for movement.

Any advice would be sincerely appreciated.



Thanks
DMM
16
Years of Service
User Offline
Joined: 11th Sep 2008
Location:
Posted: 4th Oct 2008 01:22
ok so that was so easy to fix it was kind of disappointing. I just added the sprite command after each paste sprite command and it works. That was a huge fundamental misunderstanding about the paste sprite and sprite commands that I somehow missed from the text and help menus. Thanks for the help windowskiller.
DMM
16
Years of Service
User Offline
Joined: 11th Sep 2008
Location:
Posted: 6th Oct 2008 03:51
Why do you sometimes have to use paste sprite for the sprite to show on the screen but other times you can just use the sprite command?
Stefan p
15
Years of Service
User Offline
Joined: 2nd Nov 2008
Location: Online
Posted: 11th Dec 2008 02:30
Thank you DMM i was doing exact same thing and had simmarlar problem thank you so much.

As for your question they both always work for me.

I was here.
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 12th Dec 2008 13:47
...and sprite priority MIGHT be your issue here... cuz he's right - the Sprite Command is typically all you need.. I thought paste was a way of rubber stamping the sprite.. but its not truly "there".. just drawn if that makes sense (not sure I'm right either) but thats how I thoght it worked.

--Jason

Cronius Draks
15
Years of Service
User Offline
Joined: 8th Dec 2008
Location:
Posted: 17th Dec 2008 04:11
strange, I couldnt get my collision detection to work until i used paste sprite.

i had setup a menu using sprites and the text i had on the buttons disappeared behind the sprites, with paste sprite i could see the text and collision started working.

not sure why it did what it did but it works now. heh.

basically I used sprite and hide sprite before the main loop starts. then I use paste sprite anywhere i needed them to show up in the main loop.

Wandering the digital world in search of knowledge for 22 years... you would think I might have found something useful by now.

Login to post a reply

Server time is: 2024-09-27 22:30:29
Your offset time is: 2024-09-27 22:30:29