[PyGame] Space Invaders in PyGame - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Game Development (https://python-forum.io/forum-11.html) +--- Thread: [PyGame] Space Invaders in PyGame (/thread-30662.html) |
Space Invaders in PyGame - Russ_CW - Oct-30-2020 Hi Folks, This is my clone of space invaders with an explanation of how I coded it. Code RE: Space Invaders in PyGame - michael1789 - Nov-08-2020 I watch your videos. Is this something you plan on doing in an ongoing way? Do Bubble Bobble! :) RE: Space Invaders in PyGame - joe_momma - Nov-10-2020 great start- I like the art work. some suggestions: if the aliens reach the width of the screen they drop down and speed up. If you shoot the left side the remaining aliens kept travelling until they reach the width. more levels. replay option. RE: Space Invaders in PyGame - Russ_CW - Nov-15-2020 Thanks! Those are good suggestions, I'll definitely polish it up with those kinds of features now that the basic mechanic of the game is done. I'll add Bubble Bobble to the list :). I've actually been working on a little platformer but there's still a lot to do. RE: Space Invaders in PyGame - luke83 - Nov-22-2020 Trying to work through this wonderful tutorial series and having issues getting my spaceship to move...Is there someway to show what keys are being pressed so i can determine if the Key press is not being registered or if my update is just wrong... Its pretty sad when you cant copy the code from the video and still make mistakes, i even raided the Github and copied and pasted in his movement commands to try to fix my issue as i could not see the fault. Since the game did not throw an error i am unsure how to determine where the issue is. Quote:import pygame RE: Space Invaders in PyGame - Russ_CW - Nov-22-2020 I ran the code that you've pasted above and it works fine here, but I'm wondering if you have got the "update" method indented correctly within the spaceship class. it should be: #create spaceship class class Spaceship(pygame.sprite.Sprite): def __init__(self, x, y): pygame.sprite.Sprite.__init__(self) self.image = pygame.image.load("img/spaceship.png") # load image self.rect = self.image.get_rect() # force image to rectangle self.rect.center = [x, y] def update(self): # set movement speed speed = 8 # get key press key = pygame.key.get_pressed() if key[pygame.K_LEFT] and self.rect.left > 0: print('Move Left') self.rect.x -= speed if key[pygame.K_RIGHT] and self.rect.right < screen_width: self.rect.x += speedThis ensures the update method is part of that class rather than a method on its own. Also, if you want to troubleshoot and check whether something is working as it should, you can print it. In the code above I've put a print statement which will say 'Move Left' when the conditions are met. It's a quick way to see what's going on and where the problems might be. Of course you'll want to remove that once you get it working :) |