コード例 #1
0
ファイル: main.py プロジェクト: chozabu/Neinjarz
 def __init__(self):
     terrain.loadimg("testlevel")
     #terrain.loadimg("clev")
     self.name = "damnidontcare"
     display.init()
     self.gamestate = gameStateClass()
     self.walkers = self.gamestate.walkers
     self.clients = self. walkers
     simplenet.clients = self.clients
     terrain.walkers = self.walkers
     display.lookat(0, 0)
     self.mx = 100
     self.my = 100
     self.mywalker = self.walkers[0]
     self.menu = menu.Menu()
コード例 #2
0
ファイル: menu.py プロジェクト: chozabu/Neinjarz
 def handleEvent(self, event):
     if event.type == 2:#keypress
         if event.key == pgl.K_r:
             terrain.loadimg("clev")
         if event.key == pgl.K_w:
             simplenet.isServer = 0
             simplenet.isClient = 0
             return True
         if event.key == pgl.K_s:
             simplenet.isServer = 1
             simplenet.isClient = 0
             simplenet.initNet()
             return True
         if event.key == pgl.K_c:
             simplenet.isServer = 0
             simplenet.isClient = 1
             self.name = "nameless"+str(random()*1000)[0:3]
             simplenet.sendserv("join", self.name)
             return True
         if event.key == pgl.K_h:
             self.menu.currentMenu = self.menu.helpMenu
コード例 #3
0
ファイル: main.py プロジェクト: chozabu/Neinjarz
 def mainloop(self):
     #bind(self.walkers[4], self.walkers[5], 50)
     for b in self.walkers:
         b.update()
         if b.kills > 9:
           terrain.loadimg("clev")
           b.kills = 0
     remlist = []
     for i in range(0, len(self.walkers)-1):
         for r in range(i+1, len(self.walkers)):#FIXME
             dist = 25
             a=self.walkers[i]
             b=self.walkers[r]
             xd = a.x-b.x
             yd = a.y-b.y
             td = hypot(xd, yd)#+0.000000001
             if (0<td< dist):
                 diffd = (dist-td)*0.49
                 xd /=td
                 yd /=td
                 a.xvel +=xd*diffd
                 a.yvel +=yd*diffd
                 b.xvel -=xd*diffd
                 b.yvel -=yd*diffd
                 a.movev(xd *diffd, yd *diffd)
                 b.movev(-xd *diffd, -yd *diffd)
                 if a.y < b.y:
                   a.canjump = 1
                 else:
                   b.canjump = 1
                 #particles.addParticle(a.x, b.y, 5, 3, "smoke.png")
                 #a.x+=xd*diffd
                 #a.y+=yd*diffd
                 #b.x-=xd*diffd
                 #b.y-=yd*diffd
     for i in remlist:
         self.walkers.remove(i)