Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Create constants.py #25

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions spaceshooter/__init.py__
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
## initialize pygame and create window
pygame.init()
pygame.mixer.init() ## For sound
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Space Shooter")
clock = pygame.time.Clock() ## For syncing the FPS
Comment on lines +1 to +6

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If someone runs python <path to>/spaceShooter.py what result will be? It looks like this code is not required because it does nothing in this case.

Plus: where do you have constants WIDTH and HEIGHT from? Where is pygame import?

Looks like total nonsense and should be removed.

14 changes: 14 additions & 0 deletions spaceshooter/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
WIDTH = 480
HEIGHT = 600
FPS = 60
POWERUP_TIME = 5000
BAR_LENGTH = 100
BAR_HEIGHT = 10

# Define Colors
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
RED = (255, 0, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)
YELLOW = (255, 255, 0)
22 changes: 1 addition & 21 deletions spaceshooter/spaceShooter.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,8 @@
import pygame
import random
from os import path
from constans import *

## assets folder
img_dir = path.join(path.dirname(__file__), 'assets')
sound_folder = path.join(path.dirname(__file__), 'sounds')
Comment on lines -24 to -25

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have removed this two completely, why?

img_dir is a used constant.


###############################
## to be placed in "constant.py" later
WIDTH = 480
HEIGHT = 600
FPS = 60
POWERUP_TIME = 5000
BAR_LENGTH = 100
BAR_HEIGHT = 10

# Define Colors
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
RED = (255, 0, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)
YELLOW = (255, 255, 0)
###############################

###############################
## to placed in "__init__.py" later
Expand Down