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)) pixel[2] = sum(pixel[0][c] * right[c] for c in range(3))
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]:
ship_cap = 1 while True: pygame.display.update() # clock.tick(30) for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() sys.exit() pressed = pygame.key.get_pressed() if pressed[pygame.K_SPACE]: while len(ship_list) < ship_cap: ship_list.append( Nav.Navigator( (the_grid.width, the_grid.height), the_grid.grid, start=(50, 50), style=[colors.random_color(), colors.random_color()], ship_list=ship_list)) draw_walls() for ship in ship_list: ship.update() for coordinate in ship.active_coordinates: update_draw(coordinate[0], coordinate[1], ship, ship.style) get_drawings()
def init_clusters(): return colors.random_color(), random.randrange(width), random.randrange( height)
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 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()