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 Professional Discussion / Applying Upgrades to a Ship Sprite

Author
Message
Game Warden
16
Years of Service
User Offline
Joined: 12th May 2010
Location: Union, MO
Posted: 8th Jun 2011 19:32
Hello, I have been working on a 2d space shooter for a little while now and everything has been going great. However, I cannot seem to get sprite collision working correctly to apply a permanent change to a sprite. Anytime I try and apply a transparent shield sprite to my ship after it collides with the shield pickup sprite I get the shield showing temporarily and only upon collision. I have tried several different combinations all with the same effect including changing a variable upon collision but each time it will only apply temporarily.

One thing I have yet to try is writing the status of the ship to memory so that maybe the change is permanent and then just access that memory whenever the shields are depleted. Will this strategy work or is there another approach I can take?

Thank you for your time
Hodgey
16
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 8th Jun 2011 23:13
Hi, you could try using a boolean to determine when the shield is on or off.

psuedocode, kind of:


Hope that makes sense

A clever person solves a problem, a wise person avoids it - Albert Einstein
Game Warden
16
Years of Service
User Offline
Joined: 12th May 2010
Location: Union, MO
Posted: 8th Jun 2011 23:19 Edited at: 9th Jun 2011 00:08
Ah that was my problem when I tried that before. I forgot to declare the variable as a boolean and also made the pickup equal to 0 at the beginning of my function rendering everything else I had inside it useless because it kept resetting itself. Wow well I'm glad it wasn't anything too tough lol. Thanks for your help Hodgey your response makes perfect sense I guess sometimes I just need to write down what is happening and talk with someone about it to better realize what the problem is.
DVader
22
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 9th Jun 2011 01:46
Declaring the variable as boolean would not make a difference, just the setting of the flag. I use flags all the time with no need to set as boolean. I can only assume it saves memory, as I can be a bit lazy with declaring variables.

http://s6.bitefight.org/c.php?uid=103081
Hodgey
16
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 9th Jun 2011 13:31
Quote: "Thanks for your help Hodgey your response makes perfect sense "

You're welcome, glad it made sense

A clever person solves a problem, a wise person avoids it - Albert Einstein

Login to post a reply

Server time is: 2026-07-10 22:55:02
Your offset time is: 2026-07-10 22:55:02