This file contains hidden or 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
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
# Main.py | |
import os | |
import sys | |
import random | |
import pygame as pg |
This file contains hidden or 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
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
# Main.py | |
import os | |
import random | |
import pygame as pg |
This file contains hidden or 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 | |
SCREEN_SIZE = 500, 500 | |
BACKGROUND = pg.Color("darkslategrey") | |
FPS = 60 | |
class Ball(pg.sprite.Sprite): |
This file contains hidden or 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 __future__ import division | |
class BoundedFloat(float): | |
def __new__(self, value, minimum, maximum): | |
return float.__new__(self, value) | |
def __init__(self, value, minimum, maximum): | |
if not (minimum <= value <= maximum): | |
raise ValueError("Minimum must be less than or equal to value which" |
This file contains hidden or 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 __future__ import division | |
class BoundedFloat(float): | |
def __new__(self, value, minimum, maximum): | |
return float.__new__(self, value) | |
def __init__(self, value, minimum, maximum): | |
if not (minimum <= value <= maximum): | |
raise ValueError("Minimum must be less than or equal to value which" |
This file contains hidden or 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 | |
from math import degrees, atan2, pi | |
def get_angle(origin, destination): | |
"""Returns angle in radians from origin to destination. | |
This is the angle that you would get if the points were | |
on a cartesian grid. Arguments of (0,0), (1, -1) | |
return pi/4 (45 deg) rather than 7/4. | |
""" | |
x_dist = destination[0] - origin[0] |
This file contains hidden or 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 pygame as pg | |
BACKGROUND = pg.Color("darkslategray") | |
SCREEN_SIZE = (500, 500) | |
FPS = 60 | |
class App(object): |
This file contains hidden or 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 pygame as pg | |
BACKGROUND = pg.Color("darkslategray") | |
SCREEN_SIZE = (500, 500) | |
FPS = 60 | |
class App(object): |
This file contains hidden or 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 pygame as pg | |
TRANSPARENT = (0,0,0,0) | |
BACKGROUND_COLOR = pg.Color("slategray") | |
class Player(pg.sprite.Sprite): | |
def __init__(self,pos,*groups): |
This file contains hidden or 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 | |
SCREEN_SIZE = (500, 500) | |
BACKGROUND = pg.Color("slategray") | |
TEXT_COLOR = pg.Color("tomato") | |
POST_DELAY = 300 | |
FPS = 60 |