Commit 2d10b0fb5fc23691c21b7ec772bd2d5a3ed15996

Authored by Marius Hanne
1 parent fb5f9fd600
Exists in master

max_power

Showing 3 changed files with 10 additions and 5 deletions Side-by-side Diff

... ... @@ -88,7 +88,7 @@
88 88 end
89 89  
90 90 if @player.power > 1
91   - surface = Surface.new([(@screen.size[0] / 100 * (@player.power / 5)) - 10, 20])
  91 + surface = Surface.new([(@screen.size[0] / 100 * @player.power) - 10, 20])
92 92 surface.fill :blue
93 93 surface.blit(@screen, [5, @screen.size[1] - 25])
94 94 end
... ... @@ -44,9 +44,7 @@
44 44 pos = [@pos[0] + size[0] / 2, @pos[1] + size[1] / 2]
45 45 Explosion.new(@game, pos, image: "explosion.png", zoom: 1.0).show
46 46 ship.take_damage(damage)
47   - @ship.power += damage / 2
48   - @ship.power = 500 if @ship.power > 500
49   - @ship.debug = nil
  47 + @ship.hit(ship, damage)
50 48 hide
51 49 end
52 50 end
... ... @@ -14,7 +14,8 @@
14 14 image = SHIPS[type][:image]
15 15 image[:rot] = is_a?(Enemy) ? 0.0 : 180.0
16 16 super(*a, SHIPS[type][:image])
17   - @power = SHIPS[type][:power]
  17 + @max_power = SHIPS[type][:power]
  18 + @power = @max_power
18 19 @speed = SHIPS[type][:speed]
19 20 @type = type
20 21 end
... ... @@ -34,6 +35,12 @@
34 35  
35 36 def size
36 37 [@surface.size[0] - 10, @surface.size[1] - 10]
  38 + end
  39 +
  40 + def hit other, damage
  41 + @power += damage / 2
  42 + @power = @max_power if @power > @max_power
  43 + @debug = nil
37 44 end
38 45  
39 46 def destroy