示例#1
0
__author__ = 'Gregorio Manabat III'

import sys

import pygame

import Game_Stuff.utilities.grid as grid_class
import Game_Stuff.utilities.colors as colors
import Game_Stuff.utilities.doodles as doodles

pygame.init()

# set up the window

bitmap = grid_class.Grid(width=100,
                         height=100,
                         scale=4,
                         fill_function=(lambda x, y: colors.WHITE))
pygame.display.set_caption('drawing grid')

clock = pygame.time.Clock()

# run the game loop

bitmap.redraw()

while True:
    pygame.display.update()
    clock.tick(60)
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit()
__author__ = 'Gregorio Manabat III'

import sys
import random

import pygame

import Game_Stuff.utilities.colors as colors
import Game_Stuff.utilities.grid as grid_class

pygame.init()

# set up the window
grid = grid_class.Grid(
    width=100,
    height=100,
    scale=1,
    fill_function=(lambda x, y: [colors.random_color(), 0, 0]))
pygame.display.set_caption('Sifting Colors')
pixels = pygame.PixelArray(grid.DISPLAY_SURFACE)

width = grid.width
height = grid.height
array = grid.grid


def generate_values(up, right):
    for x in range(width):
        for y in range(height):
            pixel = array[x][y]
            pixel[1] = sum(pixel[0][c] * up[c] for c in range(3))
示例#3
0
from Game_Stuff.utilities import colors

__author__ = 'Gregorio Manabat III'

import sys
import copy

import pygame

import Game_Stuff.utilities.colors as colors
import Game_Stuff.utilities.grid as the_grid

pygame.init()

# set up the window
grid = the_grid.Grid(width=100, height=80, scale=7, fill_function=(lambda x, y: colors.random_color()))
pygame.display.set_caption('Blur')

bitmap_newframe = [[[] for x in range(grid.height)] for x in range(grid.width)]

def update():
    blur()

def blur():
    for x in range(grid.width):
        for y in range(grid.height):
            color = [0, 0, 0]
            for a in [-1, 0, 1]:
                for b in [-1, 0, 1]:
                    square = grid.grid[(x+a) % grid.width][(y+b) % grid.height]
                    for c in [0,1,2]:
__author__ = 'Gregorio Manabat III'

import sys
import random

import pygame

import Game_Stuff.utilities.grid as grid_class

pygame.init()

# initialize fonts
myfont = pygame.font.SysFont("consolas", 24)
grid = grid_class.Grid(width=512,
                       height=256,
                       scale=3,
                       fill_function=(lambda x, y: 0))
random_init = True


def init():
    if random_init:
        for u in range(grid.width):
            grid.grid[u][0] = round(random.random())
    else:
        for u in range(grid.width):
            grid.grid[u][0] = 0
        grid.grid[int(grid.width / 2)][0] = 1


pygame.display.set_caption('Elementary Cellular Automaton')
示例#5
0
import Game_Stuff.utilities.doodles as doodles

pygame.init()


def fill(x, y):
    if (x * y % 2 == 0 or x + y & 4 == 2) and round(random.random()) == 0:
        return random.choice(['Wall'])
    else:
        return "Empty"


# set up the window
info_Object = pygame.display.Info()
the_grid = grid_python.Grid(width=int(info_Object.current_w / 8),
                            height=int(info_Object.current_h / 8),
                            scale=5,
                            fill_function=fill)
pygame.display.set_caption('Maze Solver')

show_directions = True
ship_list = []

for i in range(100):
    the_grid.grid[random.randrange(the_grid.width)][random.randrange(
        the_grid.height)] = 'End'

the_grid.grid[int(the_grid.width / 2)][int(the_grid.height / 2)] = 'End'

# run the game loop
clock = pygame.time.Clock()
示例#6
0
import pygame

import Game_Stuff.utilities.colors as colors
import Game_Stuff.utilities.grid as array_grid

pygame.init()

COLORS = [colors.random_color() for i in range(4)]


def function(x, y):
    return random.choice(COLORS)


the_grid = array_grid.Grid(width=100,
                           height=100,
                           scale=6,
                           fill_function=function)
# set up the window

pygame.display.set_caption('Flood it')  # set up the colors

the_grid.redraw()


def colour_checker(x, y, colour):
    value_to_fill = the_grid.grid[x][y]
    if not value_to_fill == colour:
        need_check = set()
        need_check.add((x, y))
        while len(need_check) > 0:
            new_check = []
示例#7
0
from Game_Stuff.utilities import colors

__author__ = 'Gregorio Manabat III'

import sys
import random

import pygame

import Game_Stuff.utilities.colors as colors
import Game_Stuff.utilities.grid as the_grid

pygame.init()

grid = the_grid.Grid(width=50, height=40, scale=10)

pygame.display.set_caption('Traffic Simulator')

cargen = set()
traffic = []
density = 0.3

for i in range(int(grid.width * grid.height * density)):
    cargen.add((random.randrange(grid.width), random.randrange(grid.height)))
for blank_car in cargen:
    traffic.append([blank_car[0], blank_car[1], round(random.random())])


def update():
    for car in traffic:
        if car[2] == 0: