def setupObjects(): """Setup global objects for drawing""" #globs.StarBackground = StarBackground.StarBackground(0, 0, .1, .1) globs.MapBackground = tilemap.Map() globs.Player = Player.Player(globs.startPosX, globs.startPosY, globs.playerWidth, globs.playerHeight) globs.Background = Background.Background()
def main(): window = Window(WIDTH, HEIGHT, "Python Invaders") renderer = window.renderer # Load sprites player_sprite = renderer.LoadSprite("Sprites/player.png") parrot_sprite = renderer.LoadSprite("Sprites/parrot.png") # Load objects player = Player(player_sprite, WIDTH, HEIGHT) parrots = ParrotHandler(parrot_sprite, WIDTH, HEIGHT) window.AddObject(player) window.AddObject(parrots) bullets = [] while window.IsRunning(): if player.ShouldFire(): bullets.append([player.pos[0], player.pos[1]]) bullets_hit = [] for bullet in bullets: bullet[1] -= 10 if parrots.TestCollision(bullet[0], bullet[1]) or bullet[1] <= 0: bullets_hit.append(bullet) else: renderer.SetPixel(int(bullet[0]), int(bullet[1]), 0, 255, 0) for bullet in bullets_hit: bullets.remove(bullet) window.Update()
def __init__(self, *args, **kwargs): self.winer = '' self.GS = GameSettings() self.reservedEC = kwargs.get('reservedEC', set()) self.P = kwargs.get('p', Player('N')) pv = copy.deepcopy(self.P.playerVars) # self.P.nofRoundPausing = kwargs.get('nofpr',0) #event card pd = kwargs.get('playingdeck', list()) self.EC = EventCards(pv, self.reservedEC, pd) #worm card wcdeck = kwargs.get('wcdeck', list()) self.WC = WormCards(pv, wcdeck) #--- self.playerDesicion = False self.myDesicion = desicion() self.stepNr = kwargs.get('currentStep', 0) self.roundNr = kwargs.get('currentRound', 0) self.sampleNr = kwargs.get('samplecounter', 0) return
from random import randrange from GameObjects.Player import * from GameObjects.Game import * from GameObjects.Cards import * #import GameObjects.Cards import * from copy import deepcopy import mssql tempply = Player('') GS = GameSettings() sampleCounter = 0 previousStep = Step() #initial print("Hello From Game Simulation! Data Generation is begining") gsID = mssql.insertGameSettings(GS) while sampleCounter <= GS.sampleQuantity: mygame = Game(sampleCounter, previousStep) mygame.gameSettingsID = gsID mygame.gameID = mssql.insertGame(mygame) firstdeck = mygame.thisStep.EC.playingdeck #play print("---Game : " + str(sampleCounter) + "---") condition = True while condition: mygame.currentRound = mygame.currentRound + 1 mygame = copy.deepcopy(mygame.playOneRound())
def add_player(self, posx, posy, imgindex): self.player = Player(posx, posy, imgindex) self.player_sprites.add(self.player)
def setupObjects(): """Setup global objects for drawing""" globs.StarBackground = StarBackground.StarBackground(0, 0) globs.MapBackground = tilemap.Map() globs.objectsToDraw.append(Player.Player(0, 0, .25))
def setupObjects(): """Setup global objects for drawing""" globs.Player = Player.Player(globs.startPosX, globs.startPosY, globs.startPosZ, globs.playerWidth, globs.playerHeight, globs.playerDepth) globs.MeshObjects.append(Map.MapRoom(math3d.vec3(0,0,0), "dungeon"))