Skip to content

Commit

Permalink
Merge pull request #9 from Schulich-Ignite/richard/game_s2
Browse files Browse the repository at this point in the history
Uploaded game after Session 2
  • Loading branch information
AlphaRLee authored Feb 16, 2021
2 parents eaaca46 + cfc4168 commit 6d3141c
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 1 deletion.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
.DS_STORE
.vscode
.vscode
*.pyo
*.pyc
bin
14 changes: 14 additions & 0 deletions game/README.md
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.
67 changes: 67 additions & 0 deletions game/main.py
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

11 changes: 11 additions & 0 deletions game/platform.py
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

0 comments on commit 6d3141c

Please sign in to comment.