예제 #1
0
 def update(self):
     if not self.alive and self.alive_locally:
         jukebox.play_sound('missile_boom')
         entity_container.append(
                 LOCAL,
                 Explosion((self.x, self.y),
                     spritemaps['missile_explosion'], 4))
         self.alive_locally = False
예제 #2
0
    def update(self):
        if not self.alive and self.alive_locally:
            jukebox.play_sound('missile_boom')
            entity_container.append(
                    LOCAL,
                    Explosion((self.x, self.y),
                        spritemaps['missile_explosion'], 4))
            self.alive_locally = False

        self.x += self.vel * sin(radians(self.rot))
        self.y += self.vel * cos(radians(self.rot))
        self.sprite.set_direction(self.rot)
예제 #3
0
    def get_server_state(self):

        """Get state from server and update accordingly."""

        state_list = self.connection.get_state()
        #self.logger.debug("State List: %s" % state_list)

        for state in state_list:
            for entity in state:
                #self.logger.debug("State: %s" % state)
                name = entity['name']
                dict = entity['dict']
                serial = dict['serial']

                entity = self.entities.get_with_serial(serial, layer=SERVER)

                # Create objects that doesn't exist yet
                if not entity:
                    if name == 'Vehicle':
                        self.entities.append(SERVER,
                                Vehicle(dict, spritemaps['vehicle']))

                    if name in ('Rocket', 'HomingMissile'):
                        self.entities.append(SERVER,
                                Missile(dict, spritemaps['missile']))
                        jukebox.play_sound('rocket')

                    if name == 'MgBullet':
                        self.entities.append(SERVER,
                                Machinegun(dict))

                    if name == 'LandMine':
                        self.entities.append(SERVER,
                                LandMine(dict))

                    if name == 'Block':
                        pass
                        #print "Block"
                   #     self.mapHandler.change_color_at(

                # If the object exists, update it with the new data
                else:
                    entity.__dict__.update(dict)

        self.entities.update()

        jukebox.update()

        self.entities.clean_dead()
예제 #4
0
    def update(self):
        if not self.alive and self.alive_locally:
            jukebox.play_sound('vehicle_boom')
            self.logger.info("%s died!" % self.player)
            self.health = 0
            entity_container.append(LOCAL,
                    Explosion((self.x, self.y),
                              spritemaps['vehicle_explosion'], 10))
            self.alive_locally = False

        #self.rot += self.torque / 4.0

        while self.rot < 0.0:
            self.rot += 360.0
        while self.rot >= 360.0:
            self.rot -= 360.0

#        self.x += (self.vel * sin(radians(self.rot))) / 2.0
#        self.y += (self.vel * cos(radians(self.rot))) / 2.0
#        self.x += (self.strafe_vel * sin(radians(self.rot + 90.0))) / 2.0
#        self.y += (self.strafe_vel * cos(radians(self.rot + 90.0))) / 2.0

        self.turret.update()
        self.sprite.set_direction(self.rot)