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
# Game Project Assignment comment in progress by Julia Luu | |
import math | |
import simplegui | |
# constants | |
#-------------------------# | |
CANVAS_WIDTH = 1000 | |
CANVAS_HEIGHT = 550 |
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
class BoundedFloat(object): | |
def __init__(self, value, minimum, maximum): | |
assert minimum <= maximum | |
self._val = value | |
self.minimum = minimum | |
self.maximum = maximum | |
@property | |
def val(self): | |
return self._val |
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
import pygame as pg | |
class Square(object): | |
def __init__(self, center_point, size): | |
self.image = pg.Surface(size) | |
self.image.fill(pg.Color("dodgerblue")) | |
self.rect = self.image.get_rect(center=center_point) | |
self.pos = self.rect.center | |
self.x_velocity = 0 |
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
import pygame | |
import sys | |
from pygame.locals import * | |
def move(x, y, direction, matrix): | |
steps = [0, 0] | |
vx = directs[direction][0] | |
vy = directs[direction][1] | |
try: |
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
import pygame | |
import sys | |
from pygame.locals import * | |
data = [] | |
matrix = [] | |
with open("data.txt") as file: | |
for line in file: | |
data.append(line) |
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
import sys | |
from random import choice, randint | |
import pygame as pg | |
COLORS = ["springgreen", "goldenrod"] | |
class Square(pg.sprite.DirtySprite): | |
""" |
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
from itertools import cycle | |
import string | |
import pygame as pg | |
import prepare, tools | |
#To avoid instantiating unnecessary Font objects, | |
#Fonts are stored in this dict. When creating a Label or | |
#Button object, this dict is checked first to see if the | |
#font already exists in LOADED_FONTS. |
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
#This code is licensed as CC0 1.0 (https://creativecommons.org/publicdomain/zero/1.0/legalcode). | |
import sys | |
import pygame as pg | |
class Game(object): | |
""" | |
A single instance of this class is responsible for | |
managing which individual game state is active |
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
import sys | |
import random | |
import pygame as pg | |
# Importing prepare initializes the display. | |
import prepare | |
import actors | |
class App(object): |
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
import pygame as pg | |
def color_swap(source_image, swap_map): | |
""" | |
Creates a new Surface from the source_image with some or all colors | |
swapped for new colors. Colors are swapped according to the | |
color pairs in the swap_map dict. The keys and values in swap_map | |
can be RGB tuples or pygame color-names. For each key in swap_map, | |
all pixels of that color will be replaced by the color that key maps to. |
NewerOlder