Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/python
# -*- coding: utf-8 -*-
# Main.py
import os
import sys
import random
import pygame as pg
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Main.py
import os
import random
import pygame as pg
import sys
import random
import pygame as pg
SCREEN_SIZE = 500, 500
BACKGROUND = pg.Color("darkslategrey")
FPS = 60
class Ball(pg.sprite.Sprite):
@Mekire
Mekire / bound2.py
Last active December 29, 2016 04:15
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"
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"
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]
import sys
import pygame as pg
BACKGROUND = pg.Color("darkslategray")
SCREEN_SIZE = (500, 500)
FPS = 60
class App(object):
import sys
import pygame as pg
BACKGROUND = pg.Color("darkslategray")
SCREEN_SIZE = (500, 500)
FPS = 60
class App(object):
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):
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