Skip to content

Instantly share code, notes, and snippets.

@amyghotra
amyghotra / runner_game.py
Last active August 8, 2016 19:11
note* this code does not include the score/lives
import pygame
import random
from city_scroller import Scroller
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
GREEN = (0, 255, 0)
RED = (255, 0, 0)
BLUE = (0, 0, 255)
GREY = (129, 129, 129)
@amyghotra
amyghotra / pygame_snow2.py
Last active December 20, 2018 17:19
Using python, create continuously falling snow.
import pygame
import random
# Define some colors
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
GREEN = (0, 255, 0)
RED = (255, 0, 0)
BLUE = (0, 0, 255)
@amyghotra
amyghotra / pythonshapes2.py
Last active August 8, 2016 19:13
Create a simple figure.
from turtle import *
def polygon(number_of_sides, side_length, color):
penup()
forward(2)
pencolor(color)
pendown()
for i in range (6):
forward(2)
right(360/ number_of_sides)
@amyghotra
amyghotra / pygame22.py
Last active August 8, 2016 19:11
Create two flashing, bouncing balls.
import pygame
import random
# Define some colors
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
GREEN = (0, 255, 0)
RED = (255, 0, 0)
BLUE = (0, 0, 255)
@amyghotra
amyghotra / obamicon2.py
Last active August 8, 2016 19:10
Change any JPEG picture into one that looks like the typical President Obama poster.
from PIL import Image
userInputImage = input("Choose an image to alter .jpg.")
im = Image.open(userInputImage)
data = list(im.getdata()) #gets the the RGB values of each pixel
def addTuples(tuple):
return tuple[0] + tuple[1] + tuple[2]
red = (140, 35, 24)