Kill all Aliens!
Hello. Just added my space shooter game if any of you are interested in testing it.
It's far from completed but it has a boss now
Things in need of improvement and bugs
- Boss only moves when beeing hit ( wanted it to move all the time
- Enemy lasers do not always need to hit the ship ( if they are really close it considered a hit)
- Distance to Boss needs to reset when boss is killed so distance to next boss is displayed)
- Alot more but these are the things im working on now
Please leave feedback for improvments Im only doing this because it's fun and I want to learn
I have created a gist and updated the game now there are powerups that when the player collect will make it shoot green twin lasers
Still haven't fixed so they shoot for a period of time, so for now they only fire once
If anybody has any idea for how to make them better please let me know
Here is the url: link text
- Power-up works fine now (They do not work on bosses)
- Added second boss
- Fixed some issues with enemy lasers and boss lasers
- Added score (Just for fun)
- Add new enemies
- Add final boss or more bosses
- more power-ups
- Start up screen/ end screen
I have a problem with a function and Im wondering if anybody can help me with it
I have create "Bombs" that explode if you shot them, however my issue is that I would like the ship to die if it touches the explosion and I thought that it should look something like this for it to work:
def bomb_gone(self, bomb): explode = SpriteNode('shp:Explosion00', parent=self) explode.scale = 0.5 explode.position = bomb.position if self.ship.position == explode.frame: exit() explode.run_action(A.move_by(10, 10, 1.6, TIMING_EASE_OUT)) explode.run_action(A.sequence(A.wait(1), A.remove())) bomb.remove_from_parent()
as you can see if the ships and explode occupies the same frame the game is over, but it does not work, it works if the "bomb" has not exploded and I fly right into it but not if they explode, any suggestions?
if self.ship.position == explode.frame:
- Position is a point
- Frame is a rect
- I would have written:
- if self.ship.position in explode.frame:
@ccc thanks for the help, but I stll don't get it to work maybe I have forgotten something else. Anyhow thank you for your help will look through it all again
Your code only checks the first time, not while the explosion moves. Is that what you wanted?
Also, really what you want is if the two frames intersect --@ccc's code only checks the position, which might be the center, or corner, so probably isnt what you want
rect offers an intersect method:
which would check if the bounding boxes intersect. note that this might be "unfair", since if you have a round explosion, and round ship, this test would pass when the corners touch, not the circles. I forget if shapenodes or textures have an intersect method...
It might be better to use a circular distance check, which would let the explostion intersect slightly.
abs(self.ship.position-explode) < (explode.width + self.ship.width)/2.
you could play with a scale factor multilier on the right, to get something that looks/feels right.
@JonB yes, I want the ship to "die" if it touches the explosion, gonna try your solution when I get home, thank you