def update_info(self): try: numero_datos = unpack("i", recvpackage(self.s, 4))[0] if (numero_datos < 0): #hp if numero_datos == -1: player.set_hp(unpack("f", recvpackage(self.s, 4))[0]) #energy elif numero_datos == -2: player.set_energy(unpack("f", recvpackage(self.s, 4))[0]) #hp y energy elif numero_datos == -3: player.set_hp(unpack("f", recvpackage(self.s, 4))[0]) player.set_energy(unpack("f", recvpackage(self.s, 4))[0]) return True else: var = -10 tmp = dict() player_pos = player.get_position() for taa in range(int(numero_datos)): tmp2 = unpack("iifff", recvpackage(self.s, 20)) if(math.hypot(player_pos[0] - tmp2[2], player_pos[1] - tmp2[3])<20): if tmp2[0] == -2: ids = var var -= 1 else: ids = tmp2[0] tmp[tmp2[0]] = [ids, tmp2[1], tmp2[2], tmp2[3], tmp2[4]] return tmp except: print "error network" print "len", numero_datos return True
def update_info(self): try: numero_datos = unpack("i", recvpackage(self.s, 4))[0] if numero_datos < 0: # hp if numero_datos == -1: player.set_hp(unpack("f", recvpackage(self.s, 4))[0]) # energy elif numero_datos == -2: player.set_energy(unpack("f", recvpackage(self.s, 4))[0]) # hp y energy elif numero_datos == -3: player.set_hp(unpack("f", recvpackage(self.s, 4))[0]) player.set_energy(unpack("f", recvpackage(self.s, 4))[0]) return True else: var = -10 tmp = dict() player_pos = player.get_position() for taa in range(int(numero_datos)): tmp2 = unpack("iifff", recvpackage(self.s, 20)) if math.hypot(player_pos[0] - tmp2[2], player_pos[1] - tmp2[3]) < 20: if tmp2[0] == -2: ids = var var -= 1 else: ids = tmp2[0] tmp[tmp2[0]] = [ids, tmp2[1], tmp2[2], tmp2[3], tmp2[4]] return tmp except: print "error network" print "len", numero_datos return True
def create_camera(zoom_lock): glLoadIdentity() glMatrixMode(GL_PROJECTION) glLoadIdentity() if(zoom_lock): zoom_tmp = 3.0 else: zoom_tmp = zoom if (aspect >= 1.0): glOrtho(-zoom_tmp * aspect, zoom_tmp * aspect, -zoom_tmp, zoom_tmp, -zoom_tmp, zoom_tmp) else: print "wtf" glOrtho(-zoom_tmp, zoom_tmp, -zoom_tmp / aspect, zoom_tmp / aspect, -zoom_tmp, zoom_tmp) glMatrixMode(GL_MODELVIEW) if (zoom_lock == False): glRotate(0, 0, 0, 0) glRotate(0, 1, 0, 0) glRotate(0, 0, 0, 1) camera = player.get_position() glTranslate( -camera[0] , -camera[1], 0)
def create_camera(zoom_lock): glLoadIdentity() glMatrixMode(GL_PROJECTION) glLoadIdentity() if zoom_lock: zoom_tmp = 3.0 else: zoom_tmp = zoom if aspect >= 1.0: glOrtho(-zoom_tmp * aspect, zoom_tmp * aspect, -zoom_tmp, zoom_tmp, -zoom_tmp, zoom_tmp) else: print "wtf" glOrtho(-zoom_tmp, zoom_tmp, -zoom_tmp / aspect, zoom_tmp / aspect, -zoom_tmp, zoom_tmp) glMatrixMode(GL_MODELVIEW) if zoom_lock == False: glRotate(0, 0, 0, 0) glRotate(0, 1, 0, 0) glRotate(0, 0, 0, 1) camera = player.get_position() glTranslate(-camera[0], -camera[1], 0)
def create_camera(): glRotate(0, 0, 0, 0) glRotate(0, 1, 0, 0) glRotate(0, 0, 0, 1) camera = player.get_position()[0] glTranslate(-camera[0], -camera[1], 0)
def RenderGLFun(): global status_global if status_global == 0 or status_global == 3: updateFPS() getDelta() glClearColor(0.0, 0.0, 0.0, 0.0) glClear(GL_COLOR_BUFFER_BIT) glLoadIdentity() glPushMatrix() glLoadIdentity() if status_global == 0: draw_pantallazo(6) if (wasd[0] == True): status_global = 1 else: draw_pantallazo(7) glPopMatrix() glutSwapBuffers() #pepito elif status_global == 1: #updateFPS() #getDelta() update() #---- Init Experimental zone ---- global animate animate += float(t_delta) / 60.0 if animate > 16: animate = 0.0 #---- End Experimental zone ---- #Init Frame glClearColor(0.0, 0.0, 0.0, 0.0) glClear(GL_COLOR_BUFFER_BIT) glLoadIdentity() create_camera() #draw time (optional) setupTexture(0) Lchunk[0].draw_static() setupTexture(3) Lchunk[0].draw_decoration() new_frame(True) Lchunk[0].draw_items(player.get_position()) new_frame(False) Lchunk[0].draw_dynamics(player.get_position()) setupTexture(1) draw_civils() player.draw(radians, animate, wasd) #components.py:31 opengl setupTexture(2) for taa in list(bullet): if (taa.draw()): world.DestroyBody(taa.get_body()) bullet.remove(taa) setupTexture(5) trenecito.draw(t_delta) #GUI glPushMatrix() glLoadIdentity() setupTexture(1) draw_caretos() setupTexture(4) draw_kills() setupTexture(3) draw_heals() draw_frases() glPopMatrix() #FIN GUI #draw_select() #go to gpu glutSwapBuffers()
def object_select(): v_object_select[0] = int((player.get_position()[0][0] + 0.16) * 3.125) v_object_select[1] = int((player.get_position()[0][1] + 0.16) * 3.125)
def create_camera(): glRotate(0, 0, 0, 0) glRotate(0, 1, 0, 0) glRotate(0, 0, 0, 1) camera = player.get_position()[0] glTranslate( -camera[0] , -camera[1], 0)
def RenderGLFun(): global status_global if status_global == 0 or status_global == 3: updateFPS() getDelta() glClearColor(0.0,0.0,0.0,0.0) glClear(GL_COLOR_BUFFER_BIT) glLoadIdentity() glPushMatrix() glLoadIdentity() if status_global == 0: draw_pantallazo(6) if (wasd[0] == True): status_global = 1 else: draw_pantallazo(7) glPopMatrix() glutSwapBuffers() #pepito elif status_global == 1: #updateFPS() #getDelta() update() #---- Init Experimental zone ---- global animate animate +=float(t_delta)/60.0 if animate > 16: animate = 0.0 #---- End Experimental zone ---- #Init Frame glClearColor(0.0,0.0,0.0,0.0) glClear(GL_COLOR_BUFFER_BIT) glLoadIdentity() create_camera() #draw time (optional) setupTexture(0) Lchunk[0].draw_static() setupTexture(3) Lchunk[0].draw_decoration() new_frame(True) Lchunk[0].draw_items(player.get_position()) new_frame(False) Lchunk[0].draw_dynamics(player.get_position()) setupTexture(1) draw_civils() player.draw(radians, animate, wasd) #components.py:31 opengl setupTexture(2) for taa in list(bullet): if(taa.draw()): world.DestroyBody(taa.get_body()) bullet.remove(taa) setupTexture(5) trenecito.draw(t_delta) #GUI glPushMatrix() glLoadIdentity() setupTexture(1) draw_caretos() setupTexture(4) draw_kills() setupTexture(3) draw_heals() draw_frases() glPopMatrix() #FIN GUI #draw_select() #go to gpu glutSwapBuffers()