“political invasion!” alien invasion rip-off

While making the game alien invasion, I decided it would be funny to test different pictures with the games sprites for fun.

So, in this version, I add joe Biden and Donald trump to the game. making this small game and testing out images and other functions in the game has taught me a lot about how to use sprites and images in my code along with learning various other useful functions in my games and code to become a better programmer.

he is what the game looks like if you were to play it, despite not having a background, it still works like regular alien invasion.

displayed here is the code used for the ship(trump):

import pygame

class ship:
    """A class to manage the ship"""
    def __init__(self, ai_game):
        """initializie the ship and set it's starting position"""
        self.screen = ai_game.screen
        self.settings = ai_game.settings
        self.screen_rect = ai_game.screen.get_rect()

        #load the image
        self.image = pygame.image.load("images/dump truck god.png")
        self.rect = self.image.get_rect()

        #start the ship in the bottom middle of the screen
        self.rect.midbottom = self.screen_rect.midbottom

        #store a decimal value for the ship's horizontal position.
        self.x = float(self.rect.x)

and here is the code used to make the aliens(Biden):

import pygame
from pygame.sprite import Sprite

from PIL import Image

class Alien(Sprite):

    def __init__(self, ai_game):
        """Initialize the alien and set its starting position"""
        super().__init__()
        self.screen = ai_game.screen
        self.settings = ai_game.settings

        #load the alien image and set its rect attribute.
        self.image = pygame.image.load('images/bie joden god.png')
        self.rect = self.image.get_rect()
        

        

        #start each new alien near the top left of the screen.
        self.rect.x = self.rect.width
        self.rect.y = self.rect.height

        #Store the alien's exact horizontal position.
        self.x = float(self.rect.x)


    def check_edges(self):
        """return True of alien is at the edge of screen."""
        screen_rect = self.screen.get_rect()
        if self.rect.right >= screen_rect.right or self.rect.left <= 0:
            return True


    def update(self):
        """Move the alien left or right"""
        self.x += (self.settings.alien_speed * self.settings.fleet_direction)
        self.rect.x = self.x

overall, had a lot of fun doing this random doodle of fun and “silliness” to pass time.


Leave a Reply

Your email address will not be published. Required fields are marked *