line-em-up 0.3.4 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/line-em-up/models/bomb.rb +40 -0
- data/line-em-up/models/bomb_pack.rb +17 -0
- data/line-em-up/models/building.rb +60 -0
- data/line-em-up/models/bullet.rb +43 -0
- data/line-em-up/models/cursor.rb +25 -0
- data/line-em-up/models/enemy_bomb.rb +40 -0
- data/line-em-up/models/enemy_bullet.rb +43 -0
- data/line-em-up/models/enemy_homing_missile.rb +103 -0
- data/line-em-up/models/enemy_player.rb +105 -0
- data/line-em-up/models/footer_bar.rb +164 -0
- data/line-em-up/models/general_object.rb +104 -0
- data/line-em-up/models/gl_background.rb +93 -0
- data/line-em-up/models/grappling_hook.rb +242 -0
- data/line-em-up/models/guidable_torpedo.rb +117 -0
- data/line-em-up/models/health_pack.rb +47 -0
- data/line-em-up/models/menu.rb +31 -0
- data/line-em-up/models/menu_item.rb +74 -0
- data/line-em-up/models/missile.rb +66 -0
- data/line-em-up/models/missile_boat.rb +101 -0
- data/line-em-up/models/missile_pack.rb +17 -0
- data/line-em-up/models/mothership.rb +136 -0
- data/line-em-up/models/pickup.rb +40 -0
- data/line-em-up/models/player.rb +241 -0
- data/line-em-up/models/projectile.rb +244 -0
- data/line-em-up/models/small_explosion.rb +48 -0
- data/line-em-up/models/star.rb +62 -0
- metadata +27 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d9421cc61562776406fdb6434aefa629abe793a3
|
4
|
+
data.tar.gz: 4958a21d527c866522676a7f346b6735fc33ae2e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea9e7e14ff9596ed5000a2c1a0ed08c5a4b1c152a74f7c6c63ce408db376252f2289459a203265215de674ce6f807a919073f6910f7afefd0f100d3a8177fc2e
|
7
|
+
data.tar.gz: 708c5fd5be3f031830ec85d22bfc28761144b4228112313d9e9a8af6da39c347b99672e384ebc4251d5430aa60902c01f870ca99fb54c77a744947cc59ac2c00
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'ostruct'
|
2
|
+
require_relative 'projectile.rb'
|
3
|
+
|
4
|
+
class Bomb < Projectile
|
5
|
+
COOLDOWN_DELAY = 50
|
6
|
+
MAX_SPEED = 5
|
7
|
+
STARTING_SPEED = 3.0
|
8
|
+
INITIAL_DELAY = 0
|
9
|
+
SPEED_INCREASE_FACTOR = 0.0
|
10
|
+
DAMAGE = 100
|
11
|
+
AOE = 150
|
12
|
+
|
13
|
+
MAX_CURSOR_FOLLOW = 4
|
14
|
+
|
15
|
+
def get_image
|
16
|
+
Gosu::Image.new("#{MEDIA_DIRECTORY}/bomb.png")
|
17
|
+
end
|
18
|
+
|
19
|
+
def draw
|
20
|
+
# @image.draw(@x, @y, ZOrder::Projectile, scale_x = 1, scale_y = 1, color = 0xff_ffffff, mode = :default)
|
21
|
+
# @image.draw(@x, @y, ZOrder::Projectile, scale_x = 1, scale_y = 1, color = 0xff_ffffff, mode = :default)
|
22
|
+
# draw_rot(x, y, z, angle, center_x = 0.5, center_y = 0.5, scale_x = 1, scale_y = 1, color = 0xff_ffffff, mode = :default) ⇒ void
|
23
|
+
# @image.draw_rot(@x, @y, ZOrder::Projectile, @y, 0.5, 0.5, scale, scale)
|
24
|
+
return draw_rot()
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
def update width, height, mouse_x = nil, mouse_y = nil, player = nil
|
29
|
+
vx = (self.class.get_starting_speed * @scale) * Math.cos(@angle * Math::PI / 180)
|
30
|
+
|
31
|
+
vy = (self.class.get_starting_speed * @scale) * Math.sin(@angle * Math::PI / 180)
|
32
|
+
# Because our y is inverted
|
33
|
+
vy = vy * -1
|
34
|
+
|
35
|
+
@x = @x + vx
|
36
|
+
@y = @y + vy
|
37
|
+
|
38
|
+
super(width, height, mouse_x, mouse_y)
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require_relative 'pickup.rb'
|
2
|
+
|
3
|
+
class BombPack < Pickup
|
4
|
+
def get_image
|
5
|
+
Gosu::Image.new("#{MEDIA_DIRECTORY}/bomb_pack.png", :tileable => true)
|
6
|
+
end
|
7
|
+
|
8
|
+
def draw
|
9
|
+
# @image.draw_rot(@x, @y, ZOrder::Pickups, @y, 0.5, 0.5, 1, 1)
|
10
|
+
draw_rot()
|
11
|
+
end
|
12
|
+
|
13
|
+
def collected_by_player player
|
14
|
+
player.bombs += 3
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require_relative 'general_object.rb'
|
2
|
+
|
3
|
+
class Building < GeneralObject
|
4
|
+
POINT_VALUE_BASE = 1
|
5
|
+
attr_accessor :health, :armor, :x, :y
|
6
|
+
|
7
|
+
def initialize(scale, x = nil, y = nil)
|
8
|
+
@scale = scale
|
9
|
+
# image = Magick::Image::read("#{MEDIA_DIRECTORY}/building.png").first.resize(0.3)
|
10
|
+
# @image = Gosu::Image.new(image, :tileable => true)
|
11
|
+
@image = Gosu::Image.new("#{MEDIA_DIRECTORY}/building.png")
|
12
|
+
@image_width = @image.width * @scale
|
13
|
+
@image_height = @image.height * @scale
|
14
|
+
@image_size = @image_width * @image_height / 2
|
15
|
+
@image_radius = (@image_width + @image_height) / 4
|
16
|
+
@x = rand * 800
|
17
|
+
@y = 0 - get_height
|
18
|
+
# puts "NEW BUILDING: #{@x} and #{@y}"
|
19
|
+
@health = 15
|
20
|
+
@armor = 0
|
21
|
+
@current_speed = (GLBackground::SCROLLING_SPEED * @scale)
|
22
|
+
end
|
23
|
+
|
24
|
+
def get_points
|
25
|
+
return POINT_VALUE_BASE
|
26
|
+
end
|
27
|
+
|
28
|
+
def is_alive
|
29
|
+
@health > 0
|
30
|
+
end
|
31
|
+
|
32
|
+
def take_damage damage
|
33
|
+
@health -= damage
|
34
|
+
end
|
35
|
+
|
36
|
+
def drops
|
37
|
+
rand_num = rand(10)
|
38
|
+
if rand(10) == 9
|
39
|
+
[HealthPack.new(@scale, @x, @y)]
|
40
|
+
elsif rand(10) == 8
|
41
|
+
[BombPack.new(@scale, @x, @y)]
|
42
|
+
else
|
43
|
+
[MissilePack.new(@scale, @x, @y)]
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def get_draw_ordering
|
48
|
+
ZOrder::Building
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
def update width, height, mouse_x = nil, mouse_y = nil, player = nil
|
53
|
+
if is_alive
|
54
|
+
@y += @current_speed
|
55
|
+
@y < height + get_height
|
56
|
+
else
|
57
|
+
false
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require_relative 'projectile.rb'
|
2
|
+
|
3
|
+
class Bullet < Projectile
|
4
|
+
DAMAGE = 5
|
5
|
+
COOLDOWN_DELAY = 30
|
6
|
+
MAX_SPEED = 5
|
7
|
+
|
8
|
+
def get_image
|
9
|
+
Gosu::Image.new("#{MEDIA_DIRECTORY}/bullet-mini.png")
|
10
|
+
end
|
11
|
+
|
12
|
+
def initialize(scale, width, height, object, mouse_x = nil, mouse_y = nil, options = {})
|
13
|
+
@scale = scale
|
14
|
+
@time_alive = 0
|
15
|
+
@image = get_image
|
16
|
+
# @color = Gosu::Color.new(0xff_000000)
|
17
|
+
# @color.red = rand(255 - 40) + 40
|
18
|
+
# @color.green = rand(255 - 40) + 40
|
19
|
+
# @color.blue = rand(255 - 40) + 40
|
20
|
+
if LEFT == options[:side]
|
21
|
+
@x = object.x - (object.get_width / 2)
|
22
|
+
@y = object.y# - player.get_height
|
23
|
+
elsif RIGHT == options[:side]
|
24
|
+
@x = (object.x + object.get_width / 2) - 4
|
25
|
+
@y = object.y# - player.get_height
|
26
|
+
else
|
27
|
+
@x = object.x
|
28
|
+
@y = object.y
|
29
|
+
end
|
30
|
+
@image_width = @image.width * @scale
|
31
|
+
@image_height = @image.height * @scale
|
32
|
+
@image_size = @image_width * @image_height / 2
|
33
|
+
@image_radius = (@image_width + @image_height) / 4
|
34
|
+
@current_speed = self.class.get_max_speed * @scale
|
35
|
+
end
|
36
|
+
|
37
|
+
def update width, height, mouse_x = nil, mouse_y = nil, player = nil
|
38
|
+
@y -= @current_speed
|
39
|
+
# Return false when out of screen (gets deleted then)
|
40
|
+
@y > 0 && @y < height
|
41
|
+
# super(mouse_x, mouse_y)
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require_relative 'general_object.rb'
|
2
|
+
class Cursor < GeneralObject
|
3
|
+
# attr_reader :img, :visible, :imgObj
|
4
|
+
|
5
|
+
|
6
|
+
def get_image
|
7
|
+
Gosu::Image.new("#{MEDIA_DIRECTORY}/crosshair.png")
|
8
|
+
end
|
9
|
+
|
10
|
+
|
11
|
+
def initialize scale
|
12
|
+
@scale = scale
|
13
|
+
@image = get_image
|
14
|
+
@image_width = @image.width * @scale
|
15
|
+
@image_height = @image.height * @scale
|
16
|
+
@image_size = @image_width * @image_height / 2
|
17
|
+
@image_radius = (@image_width + @image_height) / 4
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
def draw mouse_x, mouse_y
|
22
|
+
@image.draw(mouse_x - get_width / 2, mouse_y - get_height / 2, ZOrder::Cursor, @scale, @scale)
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'ostruct'
|
2
|
+
require_relative 'projectile.rb'
|
3
|
+
|
4
|
+
class EnemyBomb < Projectile
|
5
|
+
COOLDOWN_DELAY = 50
|
6
|
+
MAX_SPEED = 5
|
7
|
+
STARTING_SPEED = 3.0
|
8
|
+
INITIAL_DELAY = 0
|
9
|
+
SPEED_INCREASE_FACTOR = 0.0
|
10
|
+
DAMAGE = 20
|
11
|
+
AOE = 0
|
12
|
+
|
13
|
+
MAX_CURSOR_FOLLOW = 4
|
14
|
+
|
15
|
+
def get_image
|
16
|
+
Gosu::Image.new("#{MEDIA_DIRECTORY}/bomb.png")
|
17
|
+
end
|
18
|
+
|
19
|
+
def draw
|
20
|
+
# @image.draw(@x, @y, ZOrder::Projectile, scale_x = 1, scale_y = 1, color = 0xff_ffffff, mode = :default)
|
21
|
+
# @image.draw(@x, @y, ZOrder::Projectile, scale_x = 1, scale_y = 1, color = 0xff_ffffff, mode = :default)
|
22
|
+
# draw_rot(x, y, z, angle, center_x = 0.5, center_y = 0.5, scale_x = 1, scale_y = 1, color = 0xff_ffffff, mode = :default) ⇒ void
|
23
|
+
# @image.draw_rot(@x, @y, ZOrder::Projectile, @y, 0.5, 0.5, scale, scale)
|
24
|
+
return draw_rot()
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
def update width, height, mouse_x = nil, mouse_y = nil, player = nil
|
29
|
+
vx = (self.class.get_starting_speed * @scale) * Math.cos(@angle * Math::PI / 180)
|
30
|
+
|
31
|
+
vy = (self.class.get_starting_speed * @scale) * Math.sin(@angle * Math::PI / 180)
|
32
|
+
# Because our y is inverted
|
33
|
+
vy = vy * -1
|
34
|
+
|
35
|
+
@x = @x + vx
|
36
|
+
@y = @y + vy
|
37
|
+
|
38
|
+
super(width, height, mouse_x, mouse_y)
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require_relative 'projectile.rb'
|
2
|
+
|
3
|
+
class EnemyBullet < Projectile
|
4
|
+
DAMAGE = 5
|
5
|
+
COOLDOWN_DELAY = 30
|
6
|
+
MAX_SPEED = 5
|
7
|
+
|
8
|
+
def get_image
|
9
|
+
Gosu::Image.new("#{MEDIA_DIRECTORY}/bullet-mini-reverse.png")
|
10
|
+
end
|
11
|
+
|
12
|
+
def initialize(scale, width, height, object, mouse_x = nil, mouse_y = nil, options = {})
|
13
|
+
@scale = scale
|
14
|
+
@time_alive = 0
|
15
|
+
@image = get_image
|
16
|
+
# @color = Gosu::Color.new(0xff_000000)
|
17
|
+
# @color.red = rand(255 - 40) + 40
|
18
|
+
# @color.green = rand(255 - 40) + 40
|
19
|
+
# @color.blue = rand(255 - 40) + 40
|
20
|
+
if LEFT == options[:side]
|
21
|
+
@x = object.x - (object.get_width / 2)
|
22
|
+
@y = object.y# - player.get_height
|
23
|
+
elsif RIGHT == options[:side]
|
24
|
+
@x = (object.x + object.get_width / 2) - 4
|
25
|
+
@y = object.y# - player.get_height
|
26
|
+
else
|
27
|
+
@x = object.x
|
28
|
+
@y = object.y
|
29
|
+
end
|
30
|
+
@image_width = @image.width * @scale
|
31
|
+
@image_height = @image.height * @scale
|
32
|
+
@image_size = @image_width * @image_height / 2
|
33
|
+
@image_radius = (@image_width + @image_height) / 4
|
34
|
+
@current_speed = self.class.get_max_speed * @scale
|
35
|
+
end
|
36
|
+
|
37
|
+
def update width, height, mouse_x = nil, mouse_y = nil, player = nil
|
38
|
+
@y += @current_speed
|
39
|
+
# Return false when out of screen (gets deleted then)
|
40
|
+
@y > 0 && @y < height
|
41
|
+
# super(mouse_x, mouse_y)
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
require_relative 'projectile.rb'
|
2
|
+
class EnemyHomingMissile < Projectile
|
3
|
+
attr_reader :x, :y, :time_alive, :mouse_start_x, :mouse_start_y, :health
|
4
|
+
COOLDOWN_DELAY = 75
|
5
|
+
MAX_SPEED = 18
|
6
|
+
STARTING_SPEED = 0.0
|
7
|
+
INITIAL_DELAY = 2
|
8
|
+
SPEED_INCREASE_FACTOR = 0.5
|
9
|
+
DAMAGE = 15
|
10
|
+
AOE = 0
|
11
|
+
|
12
|
+
MAX_CURSOR_FOLLOW = 4
|
13
|
+
# ADVANCED_HIT_BOX_DETECTION = true
|
14
|
+
ADVANCED_HIT_BOX_DETECTION = false
|
15
|
+
|
16
|
+
def initialize(scale, width, height, object, mouse_x = nil, mouse_y = nil, homing_object = nil, options = {})
|
17
|
+
@scale = scale
|
18
|
+
@image = get_image
|
19
|
+
@time_alive = 0
|
20
|
+
@health = 5
|
21
|
+
# @mouse_start_x = mouse_x
|
22
|
+
# @mouse_start_y = mouse_y
|
23
|
+
|
24
|
+
if LEFT == options[:side]
|
25
|
+
@x = object.x - (object.get_width / 2)
|
26
|
+
@y = object.y
|
27
|
+
elsif RIGHT == options[:side]
|
28
|
+
@x = (object.x + object.get_width / 2) - 4
|
29
|
+
@y = object.y
|
30
|
+
else
|
31
|
+
@x = object.x
|
32
|
+
@y = object.y
|
33
|
+
end
|
34
|
+
|
35
|
+
if homing_object && homing_object.is_alive
|
36
|
+
|
37
|
+
start_point = OpenStruct.new(:x => @x - width / 2, :y => @y - height / 2)
|
38
|
+
# start_point = GeoPoint.new(@x - WIDTH / 2, @y - HEIGHT / 2)
|
39
|
+
# end_point = OpenStruct.new(:x => @mouse_start_x, :y => @mouse_start_y)
|
40
|
+
end_point = OpenStruct.new(:x => homing_object.x - width / 2, :y => homing_object.y - height / 2)
|
41
|
+
# end_point = GeoPoint.new(@mouse_start_x - WIDTH / 2, @mouse_start_y - HEIGHT / 2)
|
42
|
+
@angle = calc_angle(start_point, end_point)
|
43
|
+
@radian = calc_radian(start_point, end_point)
|
44
|
+
|
45
|
+
|
46
|
+
if @angle < 0
|
47
|
+
@angle = 360 - @angle.abs
|
48
|
+
end
|
49
|
+
else
|
50
|
+
@angle = 280.0
|
51
|
+
end
|
52
|
+
@image_width = @image.width * @scale
|
53
|
+
@image_height = @image.height * @scale
|
54
|
+
@image_size = @image_width * @image_height / 2
|
55
|
+
@image_radius = (@image_width + @image_height) / 4
|
56
|
+
end
|
57
|
+
|
58
|
+
def destructable?
|
59
|
+
true
|
60
|
+
end
|
61
|
+
|
62
|
+
def is_alive
|
63
|
+
@health > 0
|
64
|
+
end
|
65
|
+
|
66
|
+
|
67
|
+
def take_damage damage
|
68
|
+
@health -= damage
|
69
|
+
end
|
70
|
+
|
71
|
+
def get_image
|
72
|
+
Gosu::Image.new("#{MEDIA_DIRECTORY}/mini_missile_reverse.png")
|
73
|
+
end
|
74
|
+
|
75
|
+
def update width, height, mouse_x = nil, mouse_y = nil, player = nil
|
76
|
+
if is_alive
|
77
|
+
new_speed = 0
|
78
|
+
if @time_alive > self.class.get_initial_delay
|
79
|
+
new_speed = self.class.get_starting_speed + (self.class.get_speed_increase_factor > 0 ? @time_alive * self.class.get_speed_increase_factor : 0)
|
80
|
+
new_speed = self.class.get_max_speed if new_speed > self.class.get_max_speed
|
81
|
+
new_speed = new_speed * @scale
|
82
|
+
end
|
83
|
+
|
84
|
+
vx = 0
|
85
|
+
vy = 0
|
86
|
+
if new_speed > 0
|
87
|
+
vx = ((new_speed / 3)) * Math.cos(@angle * Math::PI / 180)
|
88
|
+
|
89
|
+
vy = ((new_speed / 3)) * Math.sin(@angle * Math::PI / 180)
|
90
|
+
vy = vy * -1
|
91
|
+
# Because our y is inverted
|
92
|
+
vy = vy - ((new_speed / 3) * 2)
|
93
|
+
end
|
94
|
+
|
95
|
+
@x = @x + vx
|
96
|
+
@y = @y - vy
|
97
|
+
|
98
|
+
super(width, height, mouse_x, mouse_y)
|
99
|
+
else
|
100
|
+
false
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
require_relative 'player.rb'
|
2
|
+
require_relative 'enemy_bullet.rb'
|
3
|
+
require_relative 'small_explosion.rb'
|
4
|
+
require_relative 'star.rb'
|
5
|
+
|
6
|
+
class EnemyPlayer < GeneralObject
|
7
|
+
Speed = 3
|
8
|
+
MAX_ATTACK_SPEED = 3.0
|
9
|
+
POINT_VALUE_BASE = 10
|
10
|
+
attr_accessor :cooldown_wait, :attack_speed, :health, :armor, :x, :y
|
11
|
+
|
12
|
+
def initialize(scale, width, height, x = nil, y = nil)
|
13
|
+
@scale = scale
|
14
|
+
# image = Magick::Image::read("#{MEDIA_DIRECTORY}/starfighterv4.png").first
|
15
|
+
# @image = Gosu::Image.new(image, :tileable => true)
|
16
|
+
# @image = Gosu::Image.new("#{MEDIA_DIRECTORY}/starfighterv4.png")
|
17
|
+
@image = Gosu::Image.new("#{MEDIA_DIRECTORY}/airship1_color1_reverse.png")
|
18
|
+
# @beep = Gosu::Sample.new("#{MEDIA_DIRECTORY}/beep.wav")
|
19
|
+
@x = x || rand(width)
|
20
|
+
@y = y || 0
|
21
|
+
@cooldown_wait = 0
|
22
|
+
@attack_speed = 0.5
|
23
|
+
@health = 15
|
24
|
+
@armor = 0
|
25
|
+
@image_width = @image.width * @scale
|
26
|
+
@image_height = @image.height * @scale
|
27
|
+
@image_size = @image_width * @image_height / 2
|
28
|
+
@image_radius = (@image_width + @image_height) / 4
|
29
|
+
@current_speed = (rand(5) * @scale).round + 1
|
30
|
+
end
|
31
|
+
|
32
|
+
def get_points
|
33
|
+
return POINT_VALUE_BASE
|
34
|
+
end
|
35
|
+
|
36
|
+
def is_alive
|
37
|
+
@health > 0
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
def take_damage damage
|
42
|
+
@health -= damage
|
43
|
+
end
|
44
|
+
|
45
|
+
def attack width, height, player
|
46
|
+
return {
|
47
|
+
projectiles: [EnemyBullet.new(@scale, width, height, self)],
|
48
|
+
cooldown: EnemyBullet::COOLDOWN_DELAY
|
49
|
+
}
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
def drops
|
54
|
+
[
|
55
|
+
SmallExplosion.new(@scale, @x, @y, @image),
|
56
|
+
Star.new(@scale, @x, @y)
|
57
|
+
]
|
58
|
+
end
|
59
|
+
|
60
|
+
def get_draw_ordering
|
61
|
+
ZOrder::Enemy
|
62
|
+
end
|
63
|
+
|
64
|
+
# def draw
|
65
|
+
# @image.draw(@x - get_width / 2, @y - get_height / 2, ZOrder::Enemy)
|
66
|
+
# end
|
67
|
+
|
68
|
+
# SPEED = 1
|
69
|
+
def get_speed
|
70
|
+
@current_speed
|
71
|
+
end
|
72
|
+
|
73
|
+
def update width, height, mouse_x = nil, mouse_y = nil, player = nil
|
74
|
+
@cooldown_wait -= 1 if @cooldown_wait > 0
|
75
|
+
if is_alive
|
76
|
+
# Stay above the player
|
77
|
+
if player.y < @y
|
78
|
+
@y -= get_speed
|
79
|
+
else
|
80
|
+
if rand(2).even?
|
81
|
+
@y += get_speed
|
82
|
+
|
83
|
+
@y = height / 2 if @y > height / 2
|
84
|
+
else
|
85
|
+
@y -= get_speed
|
86
|
+
|
87
|
+
@y = 0 + (get_height / 2) if @y < 0 + (get_height / 2)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
if rand(2).even?
|
91
|
+
@x += get_speed
|
92
|
+
@x = width if @x > width
|
93
|
+
else
|
94
|
+
@x -= get_speed
|
95
|
+
@x = 0 + (get_width / 2) if @x < 0 + (get_width / 2)
|
96
|
+
end
|
97
|
+
|
98
|
+
|
99
|
+
@y < height + (get_height / 2)
|
100
|
+
else
|
101
|
+
false
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
@@ -0,0 +1,164 @@
|
|
1
|
+
require_relative 'general_object.rb'
|
2
|
+
|
3
|
+
class FooterBar < GeneralObject
|
4
|
+
attr_reader :x, :y, :living_time
|
5
|
+
|
6
|
+
def initialize(scale, screen_width = nil, screen_height = nil, image = nil)
|
7
|
+
@scale = scale * 0.7
|
8
|
+
padding = 10 * @scale
|
9
|
+
@health_100 = Gosu::Image.new("#{MEDIA_DIRECTORY}/health_bar_0.png")
|
10
|
+
@health_90 = Gosu::Image.new("#{MEDIA_DIRECTORY}/health_bar_1.png")
|
11
|
+
@health_80 = Gosu::Image.new("#{MEDIA_DIRECTORY}/health_bar_2.png")
|
12
|
+
@health_70 = Gosu::Image.new("#{MEDIA_DIRECTORY}/health_bar_3.png")
|
13
|
+
@health_60 = Gosu::Image.new("#{MEDIA_DIRECTORY}/health_bar_4.png")
|
14
|
+
@health_50 = Gosu::Image.new("#{MEDIA_DIRECTORY}/health_bar_5.png")
|
15
|
+
@health_40 = Gosu::Image.new("#{MEDIA_DIRECTORY}/health_bar_6.png")
|
16
|
+
@health_30 = Gosu::Image.new("#{MEDIA_DIRECTORY}/health_bar_7.png")
|
17
|
+
@health_20 = Gosu::Image.new("#{MEDIA_DIRECTORY}/health_bar_8.png")
|
18
|
+
@health_10 = Gosu::Image.new("#{MEDIA_DIRECTORY}/health_bar_9.png")
|
19
|
+
@health_00 = Gosu::Image.new("#{MEDIA_DIRECTORY}/health_bar_10.png")
|
20
|
+
|
21
|
+
|
22
|
+
@green_health_100 = Gosu::Image.new("#{MEDIA_DIRECTORY}/green_health_bar_0.png")
|
23
|
+
@green_health_90 = Gosu::Image.new("#{MEDIA_DIRECTORY}/green_health_bar_1.png")
|
24
|
+
@green_health_80 = Gosu::Image.new("#{MEDIA_DIRECTORY}/green_health_bar_2.png")
|
25
|
+
@green_health_70 = Gosu::Image.new("#{MEDIA_DIRECTORY}/green_health_bar_3.png")
|
26
|
+
@green_health_60 = Gosu::Image.new("#{MEDIA_DIRECTORY}/green_health_bar_4.png")
|
27
|
+
@green_health_50 = Gosu::Image.new("#{MEDIA_DIRECTORY}/green_health_bar_5.png")
|
28
|
+
@green_health_40 = Gosu::Image.new("#{MEDIA_DIRECTORY}/green_health_bar_6.png")
|
29
|
+
@green_health_30 = Gosu::Image.new("#{MEDIA_DIRECTORY}/green_health_bar_7.png")
|
30
|
+
@green_health_20 = Gosu::Image.new("#{MEDIA_DIRECTORY}/green_health_bar_8.png")
|
31
|
+
@green_health_10 = Gosu::Image.new("#{MEDIA_DIRECTORY}/green_health_bar_9.png")
|
32
|
+
|
33
|
+
@bomb_hud = Gosu::Image.new("#{MEDIA_DIRECTORY}/bomb_pack_hud.png")
|
34
|
+
@missile_hud = Gosu::Image.new("#{MEDIA_DIRECTORY}/missile_pack_hud.png")
|
35
|
+
|
36
|
+
|
37
|
+
# @time_alive = 0
|
38
|
+
# @image_width = @image.width * @scale
|
39
|
+
# @image_height = @image.height * @scale
|
40
|
+
# @image_size = @image_width * @image_height / 2
|
41
|
+
# @image_radius = (@image_width + @image_height) / 4
|
42
|
+
# @current_speed = (SCROLLING_SPEED - 1) * @scale
|
43
|
+
@health = 0
|
44
|
+
|
45
|
+
@health_bar_width = (@health_100.width * @scale)
|
46
|
+
@health_bar_height = (@health_100.height * @scale)
|
47
|
+
|
48
|
+
|
49
|
+
# @image_width_half =
|
50
|
+
# @image_height_half =
|
51
|
+
@health_bar_x = screen_width - @health_bar_width - padding
|
52
|
+
@health_bar_y = screen_height- @health_bar_height - padding
|
53
|
+
|
54
|
+
@bomb_hud_width = (@bomb_hud.width * @scale)
|
55
|
+
@bomb_hud_height = (@bomb_hud.height * @scale)
|
56
|
+
@bomb_hud_width_half = @bomb_hud_width / 2
|
57
|
+
@bomb_hud_height_half = @bomb_hud_height /2
|
58
|
+
|
59
|
+
@bomb_hud_x = screen_width - @health_bar_width - padding - @bomb_hud_width - padding
|
60
|
+
@bomb_hud_y = screen_height - @bomb_hud_height - padding
|
61
|
+
|
62
|
+
@missile_hud_width = (@missile_hud.width * @scale)
|
63
|
+
@missile_hud_height = (@missile_hud.height * @scale)
|
64
|
+
@missile_hud_width_half = @missile_hud_width / 2
|
65
|
+
@missile_hud_height_half = @missile_hud_height /2
|
66
|
+
|
67
|
+
@missile_hud_x = screen_width - @health_bar_width - padding - @bomb_hud_width - padding - @missile_hud_width - padding
|
68
|
+
@missile_hud_y = screen_height - @missile_hud_height - padding
|
69
|
+
|
70
|
+
@font = Gosu::Font.new(20)
|
71
|
+
@red_color = Gosu::Color.new(0xff_000000)
|
72
|
+
@red_color.red = 255
|
73
|
+
@black_color = Gosu::Color.new(0xff_000000)
|
74
|
+
@black_color.red = 0
|
75
|
+
@black_color.green = 0
|
76
|
+
@black_color.blue = 0
|
77
|
+
@current_color = Gosu::Color.new(0xff_000000)
|
78
|
+
@current_color.red = 51
|
79
|
+
@current_color.green = 204
|
80
|
+
@current_color.blue = 51
|
81
|
+
# rgb(51, 204, 51)
|
82
|
+
end
|
83
|
+
|
84
|
+
def get_draw_ordering
|
85
|
+
ZOrder::UI
|
86
|
+
end
|
87
|
+
|
88
|
+
def draw player
|
89
|
+
health_level = player.health
|
90
|
+
if health_level >= 200
|
91
|
+
health_image = @green_health_100
|
92
|
+
elsif health_level >= 190
|
93
|
+
health_image = @green_health_90
|
94
|
+
elsif health_level >= 180
|
95
|
+
health_image = @green_health_80
|
96
|
+
elsif health_level >= 170
|
97
|
+
health_image = @green_health_70
|
98
|
+
elsif health_level >= 160
|
99
|
+
health_image = @green_health_60
|
100
|
+
elsif health_level >= 150
|
101
|
+
health_image = @green_health_50
|
102
|
+
elsif health_level >= 140
|
103
|
+
health_image = @green_health_40
|
104
|
+
elsif health_level >= 130
|
105
|
+
health_image = @green_health_30
|
106
|
+
elsif health_level >= 120
|
107
|
+
health_image = @green_health_20
|
108
|
+
elsif health_level >= 110
|
109
|
+
health_image = @green_health_10
|
110
|
+
elsif health_level >= 100
|
111
|
+
health_image = @health_100
|
112
|
+
elsif health_level >= 90
|
113
|
+
health_image = @health_90
|
114
|
+
elsif health_level >= 80
|
115
|
+
health_image = @health_80
|
116
|
+
elsif health_level >= 70
|
117
|
+
health_image = @health_70
|
118
|
+
elsif health_level >= 60
|
119
|
+
health_image = @health_60
|
120
|
+
elsif health_level >= 50
|
121
|
+
health_image = @health_50
|
122
|
+
elsif health_level >= 40
|
123
|
+
health_image = @health_40
|
124
|
+
elsif health_level >= 30
|
125
|
+
health_image = @health_30
|
126
|
+
elsif health_level >= 20
|
127
|
+
health_image = @health_20
|
128
|
+
elsif health_level >= 10
|
129
|
+
health_image = @health_10
|
130
|
+
else
|
131
|
+
health_image = @health_00
|
132
|
+
end
|
133
|
+
|
134
|
+
health_image.draw(@health_bar_x, @health_bar_y, get_draw_ordering, @scale, @scale)
|
135
|
+
|
136
|
+
@bomb_hud.draw(@bomb_hud_x, @bomb_hud_y, get_draw_ordering, @scale, @scale)
|
137
|
+
# @bomb_hud_width_half = @bomb_hud_width / 2
|
138
|
+
# @bomb_hud_height_half = @bomb_hud_height /2
|
139
|
+
if player.get_secondary_name == 'Bomb'
|
140
|
+
bomb_color = @current_color
|
141
|
+
else
|
142
|
+
bomb_color = @red_color
|
143
|
+
end
|
144
|
+
@font.draw("#{player.bombs}", @bomb_hud_x + @bomb_hud_width_half - (@font.text_width("#{player.bombs}")), @bomb_hud_y + @bomb_hud_height_half, ZOrder::UI, @scale, @scale, bomb_color)
|
145
|
+
# local_width = @font.text_width('>')
|
146
|
+
# local_height = @font.height
|
147
|
+
@missile_hud.draw(@missile_hud_x, @missile_hud_y, get_draw_ordering, @scale, @scale)
|
148
|
+
# draw(text, x, y, z, scale_x = 1, scale_y = 1, color = 0xff_ffffff, mode = :default) ⇒ void
|
149
|
+
if player.get_secondary_name == 'Rocket'
|
150
|
+
rocket_color = @current_color
|
151
|
+
else
|
152
|
+
rocket_color = @red_color
|
153
|
+
end
|
154
|
+
@font.draw("#{player.rockets}", @missile_hud_x + @missile_hud_width_half - (@font.text_width("#{player.rockets}")), @missile_hud_y - 5 + @missile_hud_height_half, ZOrder::UI, @scale, @scale, rocket_color)
|
155
|
+
|
156
|
+
end
|
157
|
+
|
158
|
+
|
159
|
+
def update
|
160
|
+
raise "Do not call update on this object"
|
161
|
+
end
|
162
|
+
|
163
|
+
|
164
|
+
end
|