Commits

LorenzBreu committed b96aab8

Guns kill stuff now

  • Participants
  • Parent commits 49e4486

Comments (0)

Files changed (1)

test/tutorial_game.py

                 FOV_ALGO)
         self.draw_map()
         
+        
         for obj in self.killed:
             self.draw_obj(obj)
-        
+
         #Gunshot grapics
         for obj in self.objects:
             if obj.time_left == 0:
         self.wait = 0
         self.world = world
         
-        #special attibute for timed removal
+        #Special attribute for timed removal
         self.time_left = 10
+        
+        #Special attribute for gun killing
+        self.kill_coords = []
     
     def move_to(self, x, y):
         #move to the given coordinates
 class PlayerObject(Mob):
     def take_turn(self):
         pass
+    
+    def kill(self):
+        self.blocking = False
+        self.color = COLOR_DEAD
+        self.alive = False
+        message(self.name + ' has died.', libtcod.red)
 
     def fire_gun(self, tarx, tary):
         # LORENZ: WRITE A THING THAT READS IN MAP FILES IF I HAVEN'T DONE IT
         # ALREADY -- Devin
+        self.kill_coords = []
         message(self.name + ' shoots his gun.', libtcod.orange)
         libtcod.line_init(self.x, self.y, tarx, tary)
         self.draw_line()
-        
- 
-        #for obj in objects:  #damage every fighter in range, including the player
-            #if obj.distance_from(tarx, tary) <= GUN_RANGE:
-                #obj.kill()
-                
+        return [
+            i for i, obj in enumerate(self.world.objects)
+            if  obj.alive and (obj.x, obj.y) in self.kill_coords and obj.name != 'pew' and obj != self]
+
     def draw_line(self):
         (x, y) = libtcod.line_step()
         if (x, y) != (None, None):
             pew = Pew(x, y, '*', 'pew', libtcod.silver, blocking=False, alive=False)
             self.world.place_object(pew)
-            #add special code for pew so that it kills everything it touches.
+            self.kill_coords.append((x, y))
             self.draw_line()
         
     def cast_blastwave(self, tarx, tary):
         #Gun
         if (mouse.lbutton_pressed and libtcod.map_is_in_fov(self.world.fov_map, tarx, tary) and
             player_obj.distance_from(tarx, tary) <= GUN_RANGE):
-            player_obj.fire_gun(tarx, tary)
+            self.callRemote(Kill, kill_ids=player_obj.fire_gun(tarx, tary))
         #Blastwave
         if mouse.rbutton_pressed:
             self.callRemote(Kill, kill_ids=player_obj.cast_blastwave(tarx, tary))