Skip to content

Instantly share code, notes, and snippets.

import sys
import random
import pygame as pg
CAPTION = "Collisions"
SCREEN_SIZE = (500, 500)
BACKGROUND_COLOR = (30, 20, 30)
import sys
import math
import pygame as pg
class Block(pg.sprite.Sprite):
def __init__(self, pos, speed, next_move):
super(Block, self).__init__()
self.image = pg.Surface((50,50)).convert()
self.image.fill(pg.Color("red"))
@Mekire
Mekire / tiles.py
Last active September 10, 2015 02:20
import sys
import random
import pygame as pg
from string import ascii_uppercase
SCREEN_SIZE = (500, 500)
CAPTION = "Letter Tiles"
BACKGROUND_COLOR = pg.Color("darkslategray")
@Mekire
Mekire / resizable_relative.py
Last active January 20, 2016 11:11
Accurate relative mouse movement in a resizable display.
#! /usr/bin/env python
"""
A very simple example showing how to drag an item with the mouse.
Dragging in this example uses relative mouse movement.
-Written by Sean J. McKiernan 'Mekire'
"""
from __future__ import division
import pygame
import time
from player import *
from constant import *
from spritesheet_functions import SpriteSheet
import sys
import math
pygame.init()
pygame.mixer.init()
@Mekire
Mekire / movement.py
Created February 25, 2016 09:00
Store dt*velocity only changing the rect when above 1
#! /usr/bin/env python
import os
import sys
import math
import pygame as pg
CAPTION = "Move me with the Arrow Keys"
import pygame, sys, random
from pygame.locals import *
#set up pygame
pygame.init()
mainClock = pygame.time.Clock()
#set up the window
WINDOWIDTH = 600
height = 600
#! /usr/bin/env python
import os
import sys
import pygame as pg
CAPTION = "Flashing Screen"
SCREEN_SIZE = (500, 500)
#! /usr/bin/env python
import os
import sys
import pygame as pg
CAPTION = "Flashing Screen"
SCREEN_SIZE = (500, 500)
import sys
import random
import pygame as pg
MAP_SIZE = 20, 10
TILE_SIZE = 50, 50
CHANCE_OF_SAME = 0.75
TEXTURES = ["water", "dirt", "grass", "coal"]