def fixpos(self, xm=0, ym=0): 'called when the player is inside some land while moving' #self.x-=self.xn #self.y-=self.yn tn = terrain.getnormal(int(self.x)+xm, int(self.y)+ym) self.landcolour = terrain.getcolour(self.x,self.y) self.tnx = tn[0] self.tny = tn[1] impx = tn[0]*self.xvel impy = tn[1]*self.yvel impd = impx*impx+impy*impy if impd>(23*23): #print impd/100 brad = int(impd/100) if brad > 30: brad = 30 terrain.explode(self.x,self.y,brad) self.damage(impd/100,self) particles.addParticle(self.x, self.y, 0.4, "blood.png", 1.5, 3) #print self.tnx,self.tny if self.tny < 0.1: self.onground = 1 self.canjump = 1 self.x += self.tnx/2 self.y += self.tny/2 dp = self.xn*(-self.tny)+self.yn*self.tnx self.xn = -self.tny*dp self.yn = self.tnx*dp #else: self.xvel = self.xn*self.vel self.yvel = self.yn*self.vel if self.crouchkey == 1: self.xvel += -self.tnx#*self.vel wtf? FIXME whossis do self.yvel += -self.tny#*self.vel if self.digkey and self.lastdig+20 < timer.totaltime: terrain.explode(int(self.x), int(self.y), 30, 20) self.dugg = 1 self.lastdig = timer.totaltime
def move(self): self.yvel +=self.grav self.yvel *=self.drag self.xvel *=self.drag self.vel = hypot(self.xvel, self.yvel) self.xn = self.xvel /self.vel self.yn = self.yvel /self.vel xs = self.x -self.xn*4 ys = self.y -self.yn*4 maxmoves = self.vel/5 if maxmoves > 15: maxmoves = 15 while maxmoves > 0: maxmoves -= 1 self.x += self.xn*5 self.y += self.yn*5 #if self.x > terrain.x2 - 10: # self.x-=terrain.x2-20 # #self.x = terrain.x2 - 10 # #self.finalHitLand() # break if self.y > terrain.y2*3: self.dead = 1 break #if self.y > terrain.y2 - 10: # self.y-=terrain.y2-20 # #self.y = terrain.y2 - 10 # #self.finalHitLand() # break #if self.x < 10: # self.x+=terrain.x2-20 # #self.x = 10 # #self.finalHitLand() # break #if self.y < 10: # self.y+=terrain.y2-20 # #self.y = 10 # #self.finalHitLand() # break if terrain.getalpha(int(self.x), int(self.y)) > 128: self.x -= self.xn*4 self.y -= self.yn*4 while terrain.getalpha(int(self.x), int(self.y)) < 128: self.x += self.xn self.y += self.yn self.bouncecount +=1 if self.bouncecount > self.maxbounces: self.finalHitLand() break self.hitLand() if self.bouncing: tn = terrain.getnormal(int(self.x), int(self.y)) self.x += tn[0]#*3 self.y += tn[1]#*3 nv = self.reflect(self.xn, self.yn, tn[0], tn[1]) self.xn = nv[0] self.yn = nv[1] self.xvel *= 0.7 self.yvel *= 0.7 self.xvel = self.xn * self.vel self.yvel = self.yn * self.vel #self.movPix() self.totalmoves -= 1 if self.totalmoves < 0: self.timeUp() self.dead = 1 for c in self.owner.gamestate.clients: if c is self.owner: continue xd = c.cx - self.x yd = c.cy - self.y td = xd * xd + yd * yd if td < 250: self.hitPlayer(c) self.movDone(xs, ys, self.x - self.xn * 4, self.y - self.yn * 4) return 0