-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from Schulich-Ignite/richard/game_s2
Uploaded game after Session 2
- Loading branch information
Showing
4 changed files
with
96 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
.DS_STORE | ||
.vscode | ||
.vscode | ||
*.pyo | ||
*.pyc | ||
bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Schulich Ignite Flare - Game | ||
This game is created over the course of 8 weeks with the help of students learning OOP. It is a collaborative effort between the Ignite team and students and serves as a template for anyone interested in picking up OOP through Pygame. | ||
|
||
## Usage | ||
Anyone is encouraged to copy or fork this project for personal use. Commercial usage is prohibited, except when given written consent by Schulich Ignite. While not strictly necessary, we would appreciate if you left the comments in `main.py` crediting the Schulich Ignite team. | ||
|
||
## Contributing | ||
You are welcome to create a pull request and add any changes you are interested in. Schulich Ignite reserves the right to make any changes to any contributions without consent from the original author. Schulich Ignite will not claim sole ownership for any contributions. | ||
|
||
## Session 1 | ||
N/A | ||
|
||
## Session 2 - Platforms | ||
Basic platforms have been added in. A fundamental for any platformer game. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# Created by Schulich Ignite Flare and students of Schulich Ignite | ||
|
||
import sys | ||
import os | ||
import pygame | ||
from platform import Platform | ||
|
||
""" | ||
SETUP section - preparing everything before the main loop runs | ||
""" | ||
pygame.init() | ||
|
||
# Global constants | ||
SCREEN_WIDTH = 1000 | ||
SCREEN_HEIGHT = 800 | ||
FRAME_RATE = 60 | ||
|
||
# Useful colors | ||
BLACK = (0, 0, 0) | ||
WHITE = (255, 255, 255) | ||
|
||
# Creating the screen and the clock | ||
screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT)) | ||
screen.set_alpha(0) # Make alpha bits transparent | ||
clock = pygame.time.Clock() | ||
|
||
# List of platforms | ||
platforms = [] | ||
|
||
# Add a platform to the platforms list | ||
def add_platform(x, y, width, height, color): | ||
p = Platform(x, y, width, height, color) | ||
platforms.append(p) | ||
|
||
add_platform(300, 600, 350, 50, (100, 255, 100)) | ||
add_platform(100, 500, 200, 50, (50, 100, 255)) | ||
add_platform(650, 450, 200, 50, (50, 100, 255)) | ||
|
||
|
||
while True: | ||
""" | ||
EVENTS section - how the code reacts when users do things | ||
""" | ||
for event in pygame.event.get(): | ||
if event.type == pygame.QUIT: # When user clicks the 'x' on the window, close our game | ||
pygame.quit() | ||
sys.exit() | ||
|
||
|
||
|
||
""" | ||
UPDATE section - manipulate everything on the screen | ||
""" | ||
|
||
|
||
|
||
""" | ||
DRAW section - make everything show up on screen | ||
""" | ||
screen.fill(BLACK) # Fill the screen with one colour | ||
|
||
for platform in platforms: | ||
pygame.draw.rect(screen, platform.color, platform.rect) | ||
|
||
pygame.display.flip() # Pygame uses a double-buffer, without this we see half-completed frames | ||
clock.tick(FRAME_RATE) # Pause the clock to always maintain FRAME_RATE frames per second | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import pygame | ||
|
||
class Platform: | ||
def __init__(self, x, y, width, height, color): | ||
# self.x = x | ||
# self.y = y | ||
# self.width = width | ||
# self.height = height | ||
|
||
self.rect = pygame.Rect(x, y, width, height) | ||
self.color = color |