Commits

LorenzBreu committed d73d45a

Implemented kill counter, ctrl+click to blast wave, and recharge bar for gun

Comments (0)

Files changed (1)

test/tutorial_game.py

 #Game vars
 DEFAULT_SPEED = 3
 PLAYER_SPEED = 1
-GUN_RANGE = 15
+GUN_RANGE = 20
+RECHARGE = 10
 BLASTWAVE_RADIUS = 10
 
 COLOR_LIGHT_WALL = libtcod.Color(130, 110, 50)
         
         self.objects = objects
         self.killed = set()
+        self.recharge = RECHARGE
+        self.num_npcs = 1
+        self.kill_count = 0
         
         self.pillars = []
         
     
     def place_map_objects(self):
         #choose random number of npcs
-        num_npcs = libtcod.random_get_int(self.rng, 10, MAX_MAP_NPC)
+        self.num_npcs = libtcod.random_get_int(self.rng, 20, MAX_MAP_NPC)
     
-        for i in range(num_npcs):
+        for i in range(self.num_npcs):
             #choose random spot for this npc
             x, y = self.find_random_pos()
             
             libtcod.console_print_left(self.panel, MSG_X, y, libtcod.BKGND_NONE, line)
             y += 1
  
-        #show the player's stats
-        #5 and 10 will be replaced by a recharge timer when implemented
-        render_bar(1, 1, BAR_WIDTH, 'Recharge', 5, 10,
+        #shows the player recharge time on gun
+        render_bar(1, 1, BAR_WIDTH, 'Recharge',self.recharge, RECHARGE,
             libtcod.light_orange, libtcod.darker_orange, self.panel)
+        render_bar(1, 3, BAR_WIDTH, 'Kills', self.kill_count, self.num_npcs,
+            libtcod.light_red, libtcod.darker_red, self.panel)
  
         #blit the contents of "panel" to the root console
         libtcod.console_blit(self.panel, 0, 0, SCREEN_WIDTH, PANEL_HEIGHT, 0, 0, PANEL_Y)
         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()
+        self.world.recharge = 0
         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 player_move(self, x, y):
+        if self.world.recharge < RECHARGE:
+            self.world.recharge += 1
         if self.wait > 0:
             self.wait -= 1
         else:
         mouse = libtcod.mouse_get_status()
         (tarx, tary) = (mouse.cx, mouse.cy)
         #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):
+        if (mouse.lbutton_pressed and libtcod.map_is_in_fov(self.world.fov_map, tarx, tary) and 
+            self.world.recharge >= RECHARGE and player_obj.distance_from(tarx, tary) <= GUN_RANGE):
             self.callRemote(Kill, kill_ids=player_obj.fire_gun(tarx, tary))
         #Blastwave
-        if mouse.rbutton_pressed:
+        if mouse.rbutton_pressed and libtcod.console_is_key_pressed(libtcod.KEY_CONTROL):
             self.callRemote(Kill, kill_ids=player_obj.cast_blastwave(tarx, tary))
         
         key = libtcod.console_check_for_keypress()
             if i in kill_ids:
                 obj.kill()
                 self.world.killed.add(obj)
+                self.world.kill_count += 1
             if i in move_ids:
                 x, y = move_ids[i]
                 if obj == self.world.player_obj: