def up_list(): global fields, cars, max_x, cur_x fields = [] cars = [] for i in range(1, 9): cars.append(objects.Car(i * 100 - 100)) for i in [-200, 0, 200, 400, 600, 800]: for j in [-200, 0, 200, 400, 600, 800]: fields.append(objects.Field(i, j))
import pygame, sys import pygame.locals as GAME_GLOBALS import pygame.event as GAME_EVENTS import objects windowHeight = 500 windowWidth = 500 #dirChangeDelay = 30 myGrid = objects.Field(windowWidth, windowHeight) ''' WIDTH = 10 # square width HEIGHT = 10 # square height MARGIN = 0 # distance between squares ''' pygame.init() pygame.font.init() surface = pygame.display.set_mode((myGrid.windowWidth, myGrid.windowHeight)) pygame.display.set_caption('Snake!') #Mouse Variables mousePosition = (0, 0) mouseStates = None mouseDown = False BLACK = (0, 0, 0) WHITE = (255, 255, 255) GREEN = (0, 255, 0) RED = (255, 0, 0)
glShadeModel(GL_SMOOTH) glEnable(GL_CULL_FACE) glEnable(GL_LIGHT0) glEnable(GL_DEPTH_TEST) glEnable(GL_NORMALIZE) glEnable(GL_LIGHTING) #create the game world object gameWorld = GameWorld() #add ball to game world ball = Ball(gameWorld) gameWorld.addObject(ball) #add bounds to game world gameWorld.addObject(objects.BoundingBox(gameWorld, 20, 20)) gameWorld.addObject(objects.Field()) #add players to game world player = HumanPlayer(gameWorld, (-5.0, 1.1, 5.0)) player.camera = gameWorld.camera gameWorld.addObject(player) gameWorld.addObject(AiPlayer(gameWorld, ball.body, (-5.0, 1.1, -5.0))) gameWorld.addObject(AiPlayer(gameWorld, ball.body, (5.0, 1.1, -5.0))) gameWorld.addObject(AiPlayer(gameWorld, ball.body, (5.0, 1.1, 5.0))) glClearColor(0.5, 0.7, 0.9, 1.0) #create game menu object gameMenu = GameMenu() #add the background objects to menu gameMenu.addObject(objects.Field())
import pygame import random import objects WIDTH = 600 HEIGHT = 600 pygame.display.set_caption("Slime") screen = pygame.display.set_mode((WIDTH, HEIGHT)) clock = pygame.time.Clock() list_f = [] for i in range(0, 10): for j in range(0, 10): list_f.append(objects.Field(i * 60, j * 60)) slime = objects.Slime() done = False get = False col = None pos = 100, 100 while not done: screen.fill((0, 0, 0)) clock.tick(60) for i in pygame.event.get(): if i.type == pygame.QUIT: done = True if pygame.mouse.get_pressed()[0] == 1 and get == False: if pygame.mouse.get_pos()[0] in range( 0, 601) and pygame.mouse.get_pos()[1] in range(0, 601):
def reset(): global list_of_f list_of_f = {} for i in range(0, HM): for j in range(0, HM): list_of_f[i, j] = objects.Field(i * WI, j * WI, WI)