stickman_main.py
stickman_main.py — Python Source, 1 KB (2020 bytes)
Dateiinhalt
from stickman_network import * from stickman_fails import * #scene.stereo = "redcyan" players = [] def leave(nummer): players[nummer].visible = False class Spieler: def __init__(self, pos = (10,0,0)): self.pos = pos self.inited = 0 self.nummer = -1 self.verbinder = udpClientPlus(self, pos, 55152) def setPos(self, pos): self.pos = pos def empfangen(self, nachricht): try: exec (nachricht) #print nachricht if nachricht[:11]=="self.nummer": self.inited +=1 #print "nummer" if len(players) == self.nummer+1 and self.inited == 1: self.inited +=1 #print "len", len(players) except: print ("Fehler beim Ausfuehren (exec) der Nachricht:") print ("'"+nachricht+"'") print sys.exc_info()[0] if self.inited == 2: self.man = players[0] self.inited += 1 #print self.inited def senden(self,nachricht): self.verbinder.senden(nachricht) def beenden(self): self.senden("!ende") def leave(self): self.senden("leave(%d)" % self.nummer) def update(self): self.man.update() #self.pos = self.man.pos player = Spieler() while True: rate(30) if player.inited > 2: player.update() player.senden("players[%d].pos = (%f,%f,%f)"%(player.nummer, player.man.pos.x,player.man.pos.y,player.man.pos.z)) player.senden("players[%d].muni = %d" % (player.nummer, player.man.muni)) for pfeil in Eliste: player.senden("Eliste[%d].pos = (%f,%f,%f)"%(Eliste.index(pfeil), pfeil.pos.x,pfeil.pos.y,pfeil.pos.z)) player.senden("Eliste[%d].geschossen = %r"%(Eliste.index(pfeil), pfeil.geschossen)) if scene.kb.keys: zeichen = scene.kb.getkey() if zeichen == "escape": break player.leave()