-->

Welcome to our Coding with python Page!!! hier you find various code with PHP, Python, AI, Cyber, etc ... Electricity, Energy, Nuclear Power

Tuesday 3 July 2018

Python | Flappy Bird Style Game in Space Setting

Simple game where you control space shuttle with mouse click and try to avoid meteors moving in random speed toward you. There are some things I am still developing like rotation and menus, but wanted to get some tips/recommendations on what I have so far.

Thank you in advance!
# Import pygame and random
import pygame
import random

# Initialize the game engine 
pygame.init()

#Define colors
WHITE = (255, 255, 255)

# Define done 
done = False

# Define function to create new meteor
def create_meteor():
    meteor = Meteor(WHITE, width, height)
    meteor_sprites_list.add(meteor)

# Define player class
class Player(pygame.sprite.Sprite):
     def __init__(self, filename, color, HW, HH):
        super().__init__()

        # Set height, width
        self.image = pygame.image.load("player.png").convert_alpha()
        # Set background color to transparent
        self.image.set_colorkey(color)


        # Make top-left corner the passed in locatin 
        self.rect = pygame.rect.Rect((HW, HH), self.image.get_size())

        # Gravity
        self.dy = 0 

No comments:

Post a Comment

Thanks for your comments

Rank

seo