Skip to content

main: Fixed Bird Class Variables #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 38 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
"""
Module providing pygame

"""


import pygame
import os
import random
Expand Down Expand Up @@ -30,6 +36,12 @@


class Dinosaur:

"""
This class provides Dinosaur

"""

X_POS = 80
Y_POS = 310
Y_POS_DUCK = 340
Expand Down Expand Up @@ -103,6 +115,11 @@ def draw(self, SCREEN):


class Cloud:

"""
This class provides Cloud.
"""

def __init__(self):
self.x = SCREEN_WIDTH + random.randint(800, 1000)
self.y = random.randint(50, 100)
Expand All @@ -120,6 +137,11 @@ def draw(self, SCREEN):


class Obstacle:

"""
This class provides Obstacle
"""

def __init__(self, image, type):
self.image = image
self.type = type
Expand All @@ -136,6 +158,11 @@ def draw(self, SCREEN):


class SmallCactus(Obstacle):

"""
This class provides Small Cactus
"""

def __init__(self, image):
self.type = random.randint(0, 2)
super().__init__(image, self.type)
Expand All @@ -150,6 +177,11 @@ def __init__(self, image):


class Bird(Obstacle):

"""
This class provides Birds.
"""

def __init__(self, image):
self.type = 0
super().__init__(image, self.type)
Expand Down Expand Up @@ -210,11 +242,14 @@ def background():
player.update(userInput)

if len(obstacles) == 0:
if random.randint(0, 2) == 0:

random_variable = random.randint(0,2)

if random_variable == 0:
obstacles.append(SmallCactus(SMALL_CACTUS))
elif random.randint(0, 2) == 1:
elif random_variable == 1:
obstacles.append(LargeCactus(LARGE_CACTUS))
elif random.randint(0, 2) == 2:
else:
obstacles.append(Bird(BIRD))

for obstacle in obstacles:
Expand Down