ippa-chingu 0.5.1 → 0.5.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest.txt +0 -52
- data/chingu.gemspec +4 -4
- data/examples/example1.rb +1 -1
- data/lib/chingu.rb +1 -1
- data/lib/chingu/window.rb +3 -3
- metadata +2 -55
- data/games/triangle_wars/NOT_DONE_YET.txt +0 -1
- data/games/triangle_wars/media/1up.png +0 -0
- data/games/triangle_wars/media/33487__CosmicD__006.wav +0 -0
- data/games/triangle_wars/media/Thumbs.db +0 -0
- data/games/triangle_wars/media/autofire.png +0 -0
- data/games/triangle_wars/media/backgrounds/GPN-2000-000933.jpg +0 -0
- data/games/triangle_wars/media/backgrounds/Thumbs.db +0 -0
- data/games/triangle_wars/media/backgrounds/background10.png +0 -0
- data/games/triangle_wars/media/backgrounds/background10.svg +0 -94
- data/games/triangle_wars/media/backgrounds/background2.jpg +0 -0
- data/games/triangle_wars/media/backgrounds/background2.png +0 -0
- data/games/triangle_wars/media/backgrounds/hubble_deep_field.jpg +0 -0
- data/games/triangle_wars/media/backgrounds/hubble_deep_field.png +0 -0
- data/games/triangle_wars/media/backgrounds/intro_bg.png +0 -0
- data/games/triangle_wars/media/backgrounds/star_4.jpg +0 -0
- data/games/triangle_wars/media/backgrounds/star_5.jpg +0 -0
- data/games/triangle_wars/media/backgrounds/star_6.jpg +0 -0
- data/games/triangle_wars/media/backgrounds/supernova_1.jpg +0 -0
- data/games/triangle_wars/media/bigbomb.png +0 -0
- data/games/triangle_wars/media/bullets.svg +0 -223
- data/games/triangle_wars/media/enemy.png +0 -0
- data/games/triangle_wars/media/enemy.svg +0 -194
- data/games/triangle_wars/media/enemy_dying.png +0 -0
- data/games/triangle_wars/media/enemy_small.svg +0 -195
- data/games/triangle_wars/media/explosion.wav +0 -0
- data/games/triangle_wars/media/hit.wav +0 -0
- data/games/triangle_wars/media/hit2.wav +0 -0
- data/games/triangle_wars/media/hit3.wav +0 -0
- data/games/triangle_wars/media/laser.png +0 -0
- data/games/triangle_wars/media/laser.svg +0 -166
- data/games/triangle_wars/media/laser_up.png +0 -0
- data/games/triangle_wars/media/plasma.png +0 -0
- data/games/triangle_wars/media/plasma.wav +0 -0
- data/games/triangle_wars/media/plasma_up.png +0 -0
- data/games/triangle_wars/media/powerup_bg.png +0 -0
- data/games/triangle_wars/media/powerups.svg +0 -885
- data/games/triangle_wars/media/rocket_up.png +0 -0
- data/games/triangle_wars/media/spaceship.png +0 -0
- data/games/triangle_wars/media/spaceship.svg +0 -318
- data/games/triangle_wars/media/triangle_logo.svg +0 -335
- data/games/triangle_wars/media/triangle_wars.png +0 -0
- data/games/triangle_wars/media/triangle_wars_intro.mp3 +0 -0
- data/games/triangle_wars/media/triangle_wars_intro.ogg +0 -0
- data/games/triangle_wars/src/enemy.rb +0 -117
- data/games/triangle_wars/src/game_over_state.rb +0 -18
- data/games/triangle_wars/src/level_state.rb +0 -114
- data/games/triangle_wars/src/menu_state.rb +0 -67
- data/games/triangle_wars/src/my_game_object.rb +0 -46
- data/games/triangle_wars/src/pause_state.rb +0 -16
- data/games/triangle_wars/src/player.rb +0 -136
- data/games/triangle_wars/src/power_up.rb +0 -67
- data/games/triangle_wars/triangle_wars.rb +0 -69
Binary file
|
Binary file
|
Binary file
|
@@ -1,117 +0,0 @@
|
|
1
|
-
class EnemyTemplate < MyGameObject
|
2
|
-
attr_reader :speed_x, :speed_y
|
3
|
-
#attr_accessor :prev_x, :prev_y, :aim_x, :aim_y
|
4
|
-
|
5
|
-
def initialize(options = {})
|
6
|
-
super
|
7
|
-
@image = Image["enemy.png"]
|
8
|
-
|
9
|
-
@type = options[:type] || 0
|
10
|
-
@reaction = options[:reaction] || 0.1
|
11
|
-
|
12
|
-
@prev_x, @prev_y = @x, @y
|
13
|
-
@speed_x = @speed_y = 0.0
|
14
|
-
@acceleration_x = @acceleration_y = 0.0
|
15
|
-
|
16
|
-
@keep_color_for = 0
|
17
|
-
@rad_to_deg = 180 / Math::PI
|
18
|
-
end
|
19
|
-
|
20
|
-
def setup
|
21
|
-
@factor_x = @width.to_f / @image.width.to_f
|
22
|
-
@factor_y = @height.to_f / @image.height.to_f
|
23
|
-
self.factor = (@factor_x < @factor_y) ? @factor_x : @factor_y
|
24
|
-
|
25
|
-
@radius = (@width + @height) / 2 * 0.50
|
26
|
-
@original_color = @color
|
27
|
-
end
|
28
|
-
|
29
|
-
def aim_at(x, y)
|
30
|
-
if @status != :dying
|
31
|
-
@aim_x, @aim_y = x, y
|
32
|
-
@angle = Math.atan2(@aim_y - @y, @aim_x - @x).to_f * @rad_to_deg
|
33
|
-
@angle = 90 + @angle
|
34
|
-
|
35
|
-
@acceleration_y = (@y - @aim_y < 0) ? @reaction : -@reaction
|
36
|
-
@acceleration_x = (@x - @aim_x < 0) ? @reaction : -@reaction
|
37
|
-
end
|
38
|
-
self
|
39
|
-
end
|
40
|
-
|
41
|
-
def damage(punch)
|
42
|
-
super
|
43
|
-
if @status != :dying
|
44
|
-
Sound["hit3.wav"].play(0.1, 0.3 + rand(10)/20.to_f)
|
45
|
-
@color = Gosu::Color.new(255,255,255,255)
|
46
|
-
@keep_color_for = $window.ticks + 5
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def die!
|
51
|
-
Sound["explosion.wav"].play(0.1, 1.0 + rand(0.5))
|
52
|
-
@image = Image["enemy_dying.png"]
|
53
|
-
@status = :dying
|
54
|
-
@color = @original_color
|
55
|
-
@color.alpha = 100
|
56
|
-
end
|
57
|
-
|
58
|
-
def update
|
59
|
-
if @status == :dying
|
60
|
-
@factor_x += 0.4
|
61
|
-
@factor_y -= 0.2 if @factor_y > 0.2
|
62
|
-
@color.alpha -= 10 if @color.alpha > 10
|
63
|
-
else
|
64
|
-
@speed_y += @acceleration_y if (@speed_y + @acceleration_y).abs < @max_speed
|
65
|
-
@acceleration_y = 0 if @speed_y == 0
|
66
|
-
|
67
|
-
@speed_x += @acceleration_x if (@speed_x + @acceleration_x).abs < @max_speed
|
68
|
-
@acceleration_x = 0 if @speed_x == 0
|
69
|
-
move
|
70
|
-
end
|
71
|
-
|
72
|
-
if @factor_x > 3
|
73
|
-
@status = :dead
|
74
|
-
$window.remove_game_object(self)
|
75
|
-
end
|
76
|
-
|
77
|
-
@color = @original_color if @color != @original_color && $window.ticks > @keep_color_for
|
78
|
-
|
79
|
-
self
|
80
|
-
end
|
81
|
-
|
82
|
-
def move
|
83
|
-
base = $window.dt/100.0
|
84
|
-
@prev_x, @prev_y = @x, @y
|
85
|
-
@x += @speed_x * base
|
86
|
-
@y += @speed_y * base
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
|
91
|
-
class Enemy < EnemyTemplate
|
92
|
-
def initialize(options)
|
93
|
-
super
|
94
|
-
|
95
|
-
@type = options[:type] || 0
|
96
|
-
case @type
|
97
|
-
when 0
|
98
|
-
@width = 40
|
99
|
-
@height = 30
|
100
|
-
@reaction = 0.01
|
101
|
-
@punch = 40
|
102
|
-
@health = 40
|
103
|
-
@max_speed = 4
|
104
|
-
@color = Gosu::Color.new(255,0,255,0)
|
105
|
-
when 1
|
106
|
-
@width = 80
|
107
|
-
@height = 60
|
108
|
-
@reaction = 0.02
|
109
|
-
@punch = 80
|
110
|
-
@health = 80
|
111
|
-
@max_speed = 10
|
112
|
-
@color = Gosu::Color.new(255,255,255,0)
|
113
|
-
end
|
114
|
-
|
115
|
-
setup
|
116
|
-
end
|
117
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
class GameOver < Chingu::GameState
|
2
|
-
def initialize(options)
|
3
|
-
super
|
4
|
-
@title = Chingu::Text.new(:text=>"Game Over! Hit Space to continue.", :x=>150, :y=>200, :size=>40, :color => Color.new(0xFFFFFF00))
|
5
|
-
self.input = { :space => :restart }
|
6
|
-
end
|
7
|
-
|
8
|
-
def back_to_menu
|
9
|
-
clear_game_states
|
10
|
-
push_game_state(Menu)
|
11
|
-
end
|
12
|
-
|
13
|
-
def draw
|
14
|
-
previous_game_state.update # Draw prev game state onto screen (in this case our level)
|
15
|
-
previous_game_state.draw # Draw prev game state onto screen (in this case our level)
|
16
|
-
super # Draw game objects in current game state, this includes Chingu::Texts
|
17
|
-
end
|
18
|
-
end
|
@@ -1,114 +0,0 @@
|
|
1
|
-
class Level < Chingu::GameState
|
2
|
-
def initialize(options)
|
3
|
-
super
|
4
|
-
@player = Player.new({})
|
5
|
-
@level = options[:level] || 1
|
6
|
-
self.input = { :p => Pause, :f1 => :power_up }
|
7
|
-
|
8
|
-
@score = Text.new(:text => "Score: #{@player.score} Lives: #{@player.lives}", :x => 10, :y => 4, :size => 30)
|
9
|
-
end
|
10
|
-
|
11
|
-
def setup
|
12
|
-
# If we're starting from the beginning, initialize playerstuffz
|
13
|
-
if options[:level] == 1
|
14
|
-
@player.setup
|
15
|
-
end
|
16
|
-
|
17
|
-
@player.x = $window.width/2
|
18
|
-
@player.y = $window.height/2
|
19
|
-
end
|
20
|
-
|
21
|
-
def power_up
|
22
|
-
#PowerUp.new(:type=>"plasma_up", :x=>50, :y=>50, :speed_x=>3, :speed_y=>3)
|
23
|
-
@player.laser += 1
|
24
|
-
end
|
25
|
-
|
26
|
-
def random_entry_point
|
27
|
-
x, y = 0
|
28
|
-
if rand(2)==0
|
29
|
-
x = rand(2)==0 ? 1 : $window.width
|
30
|
-
y = rand($window.height)
|
31
|
-
else
|
32
|
-
x = rand($window.width)
|
33
|
-
y = rand(2)==0 ? 1 : $window.height
|
34
|
-
end
|
35
|
-
return [x,y]
|
36
|
-
end
|
37
|
-
|
38
|
-
def update
|
39
|
-
super
|
40
|
-
|
41
|
-
push_game_state(GameOver) if @player.lives == 0
|
42
|
-
|
43
|
-
@score.text = "Score: #{@player.score} Lives: #{@player.lives}"
|
44
|
-
|
45
|
-
if $window.ticks % 30 == 0
|
46
|
-
x, y = random_entry_point
|
47
|
-
Enemy.new(:x => x, :y => y, :level => options[:level], :type => rand(2))
|
48
|
-
end
|
49
|
-
|
50
|
-
@bullets = game_objects_of_class(Bullet)
|
51
|
-
|
52
|
-
PowerUp.all.each do |power_up|
|
53
|
-
if power_up.alive? && @player.collides_with?(power_up)
|
54
|
-
@player.take(power_up)
|
55
|
-
power_up.die!
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
|
60
|
-
#
|
61
|
-
# Loop thru all enemies, aim them at player and do collidestuff
|
62
|
-
#
|
63
|
-
Enemy.all.select { |enemy| enemy.alive? }.each do |enemy|
|
64
|
-
# Aim all enemies at player
|
65
|
-
enemy.aim_at(@player.x, @player.y)
|
66
|
-
|
67
|
-
# Collide enemies with our bullets, damage enemies and kill bullets
|
68
|
-
[enemy].collide_by_radius(@bullets) do |enemy, bullet|
|
69
|
-
enemy.damage(bullet.health)
|
70
|
-
bullet.die!
|
71
|
-
|
72
|
-
#power_up_from(enemy) if enemy.dying?
|
73
|
-
PowerUp.new_from(enemy) if enemy.dying?
|
74
|
-
end
|
75
|
-
|
76
|
-
# Collide all enemies with player, damage player and kill enemy
|
77
|
-
[enemy].collide_by_radius([@player]) do |enemy, player|
|
78
|
-
player.damage(enemy.health)
|
79
|
-
enemy.die!
|
80
|
-
end
|
81
|
-
|
82
|
-
end
|
83
|
-
|
84
|
-
#
|
85
|
-
# Do some garbagecollection every 10 click, remove all dead objects and objcts outside screen.
|
86
|
-
#
|
87
|
-
#if $window.ticks % 10 == 0
|
88
|
-
@game_objects.reject! { |object| (object.respond_to?(:status) && object.dead?) || object.outside_window? }
|
89
|
-
#end
|
90
|
-
#@game_objects.reject! { |object| object.outside_window? }
|
91
|
-
end
|
92
|
-
|
93
|
-
def draw
|
94
|
-
#Image["background#{options[:level]}.png"].draw(0, 0, 0)
|
95
|
-
super
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
#
|
103
|
-
# # Collide all enemies with eachother (they "bump" into eachother and get stuck)
|
104
|
-
# @enemies.collide_by_radius(@enemies) do |enemy, enemy2|
|
105
|
-
# # Ensure that it's 2 different enemies
|
106
|
-
# if enemy.object_id != enemy2.object_id
|
107
|
-
#
|
108
|
-
# # Revert the last X/Y move for the enemy that's farthest from player
|
109
|
-
# # This makes him stop while the closes enemy keeps moving towards player
|
110
|
-
# farthest_enemy = @player.distance_to(enemy) > @player.distance_to(enemy2) ? enemy : enemy2
|
111
|
-
# farthest_enemy.x = farthest_enemy.prev_x
|
112
|
-
# farthest_enemy.y = farthest_enemy.prev_y
|
113
|
-
# end
|
114
|
-
# end
|
@@ -1,67 +0,0 @@
|
|
1
|
-
class Menu < Chingu::GameState
|
2
|
-
def initialize(options)
|
3
|
-
super
|
4
|
-
Text.size = 60
|
5
|
-
x = 220
|
6
|
-
@menu_items = []
|
7
|
-
@menu_items << Text.new(:text => "START GAME", :x => x, :y => 200, :id => :start)
|
8
|
-
@menu_items << Text.new(:text => "HELP", :x => x, :y => 300, :id => :help)
|
9
|
-
@menu_items << Text.new(:text => "QUIT", :x => x, :y => 400, :id => :quit)
|
10
|
-
|
11
|
-
@red = Color.new(200,255,255,255)
|
12
|
-
@red2 = Color.new(255,255,0,0)
|
13
|
-
@white = Color.new(255,255,255)
|
14
|
-
|
15
|
-
@logo = GameObject.new(:x => $window.width/2, :y => 70, :image => "triangle_wars.png", :zorder => 10)
|
16
|
-
@background = GameObject.new(:image => "hubble_deep_field.png", :zorder => 0, :x => $window.width/2, :y => $window.height/2)
|
17
|
-
@background.color = Color.new(150,255,255,255)
|
18
|
-
|
19
|
-
@zoom_seed = Math::PI
|
20
|
-
@zoom_seed_x = 0
|
21
|
-
@zoom_seed_y = Math::PI
|
22
|
-
self.input = { :up => :up, :down => :down, :return => :chose, :space => :chose}
|
23
|
-
|
24
|
-
end
|
25
|
-
|
26
|
-
def setup
|
27
|
-
@menu_index = 0
|
28
|
-
#Gosu::Song.new($window, "media/triangle_wars_intro.ogg").play
|
29
|
-
Song["triangle_wars_intro.ogg"].play(true)
|
30
|
-
end
|
31
|
-
|
32
|
-
def up
|
33
|
-
@menu_index -= 1 if @menu_index > 0
|
34
|
-
end
|
35
|
-
|
36
|
-
def down
|
37
|
-
@menu_index += 1 if @menu_index < @menu_items.size-1
|
38
|
-
end
|
39
|
-
|
40
|
-
def update
|
41
|
-
@background.angle += 0.05
|
42
|
-
@background.factor = 1.5 + Math::sin(@zoom_seed += 0.001)
|
43
|
-
|
44
|
-
@menu_items.each_with_index do |menu_item, index|
|
45
|
-
if @menu_index == index
|
46
|
-
menu_item.color = ($window.ticks % 2 == 0) ? @red : @red2
|
47
|
-
else
|
48
|
-
menu_item.color = @white
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
super # let chingu update all GameOjject based objects (Text is)
|
53
|
-
end
|
54
|
-
|
55
|
-
def finalize
|
56
|
-
Song["triangle_wars_intro.ogg"].stop
|
57
|
-
end
|
58
|
-
|
59
|
-
def chose
|
60
|
-
puts "chose!"
|
61
|
-
case @menu_items[@menu_index].options[:id]
|
62
|
-
when :start then push_game_state(Level.new(:level => 1))
|
63
|
-
when :help then push_game_state(Help)
|
64
|
-
when :quit then close
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
@@ -1,46 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Our basic class that every ingame object inherits from
|
3
|
-
#
|
4
|
-
class MyGameObject < Chingu::GameObject
|
5
|
-
attr_accessor :lives, :health, :speed_x, :speed_y
|
6
|
-
attr_reader :status, :radius, :punch
|
7
|
-
|
8
|
-
def initialize(options)
|
9
|
-
super
|
10
|
-
@status = :default
|
11
|
-
end
|
12
|
-
def damage(punch)
|
13
|
-
@health = 0 if @health.nil? ## ugly fix for something :/
|
14
|
-
|
15
|
-
@health -= punch
|
16
|
-
if @health <= 0
|
17
|
-
@health = 0
|
18
|
-
die!
|
19
|
-
end
|
20
|
-
self
|
21
|
-
end
|
22
|
-
|
23
|
-
def collides_with?(object)
|
24
|
-
distance(self.x, self.y, object.x, object.y) < self.radius
|
25
|
-
end
|
26
|
-
|
27
|
-
def die!
|
28
|
-
@lives -= 1 if defined?(@lives)
|
29
|
-
@status = :dead
|
30
|
-
self
|
31
|
-
end
|
32
|
-
|
33
|
-
def alive?
|
34
|
-
@status == :default
|
35
|
-
end
|
36
|
-
|
37
|
-
def dead?
|
38
|
-
@status == :dead
|
39
|
-
end
|
40
|
-
|
41
|
-
def dying?
|
42
|
-
@status == :dying
|
43
|
-
end
|
44
|
-
|
45
|
-
end
|
46
|
-
|
@@ -1,16 +0,0 @@
|
|
1
|
-
class Pause < Chingu::GameState
|
2
|
-
def initialize(options)
|
3
|
-
super
|
4
|
-
@title = Chingu::Text.new(:text=>"PAUSED ('P' to un-pause)", :x=>150, :y=>200, :size=>40, :color => Color.new(0xFFFFFF00))
|
5
|
-
self.input = { :p => :un_pause }
|
6
|
-
end
|
7
|
-
|
8
|
-
def un_pause
|
9
|
-
pop_game_state(:setup => false) # Return the previous game state, dont call setup()
|
10
|
-
end
|
11
|
-
|
12
|
-
def draw
|
13
|
-
previous_game_state.draw # Draw prev game state onto screen (in this case our level)
|
14
|
-
super # Draw game objects in current game state, this includes Chingu::Texts
|
15
|
-
end
|
16
|
-
end
|
@@ -1,136 +0,0 @@
|
|
1
|
-
class Player < MyGameObject
|
2
|
-
add_component :input
|
3
|
-
attr_accessor :speed, :score, :lives, :plasma
|
4
|
-
|
5
|
-
def initialize(options)
|
6
|
-
super
|
7
|
-
@image = Image["spaceship.png"]
|
8
|
-
@radius = (@image.height + @image.width) / 2 * 0.80
|
9
|
-
setup
|
10
|
-
end
|
11
|
-
|
12
|
-
def setup
|
13
|
-
self.input = { :holding_left => :turn_left, :holding_right => :turn_right, :space => :fire }
|
14
|
-
|
15
|
-
@engine_power = 7
|
16
|
-
@health = 100
|
17
|
-
@lives = 3
|
18
|
-
@score = 0
|
19
|
-
@angle_step = 3
|
20
|
-
|
21
|
-
# weapons
|
22
|
-
@plasma = 1
|
23
|
-
@rocket = 0
|
24
|
-
@laser = 1
|
25
|
-
@autofire = 0
|
26
|
-
@current_weapon = :plasma
|
27
|
-
end
|
28
|
-
|
29
|
-
def turn_left
|
30
|
-
@angle -= @angle_step
|
31
|
-
end
|
32
|
-
def turn_right
|
33
|
-
@angle += @angle_step
|
34
|
-
end
|
35
|
-
|
36
|
-
def bigbomb
|
37
|
-
#game_objects_of_class(Enemy).each do |enemy|
|
38
|
-
#end
|
39
|
-
end
|
40
|
-
|
41
|
-
def take(power_up)
|
42
|
-
case power_up.type
|
43
|
-
when "1up"
|
44
|
-
@lives += 1
|
45
|
-
when "autofire"
|
46
|
-
self.input[:holding_space] = :fire
|
47
|
-
when "bigbomb"
|
48
|
-
puts "bigbomb"
|
49
|
-
bigbomb
|
50
|
-
when "plasma_up"
|
51
|
-
puts "plasma"
|
52
|
-
@plasma += 1 if @plasma < 10
|
53
|
-
@current_weapon = :plasma
|
54
|
-
when "laser_up"
|
55
|
-
puts "laser"
|
56
|
-
@laser += 1 if @laser < 10
|
57
|
-
@current_weapon = :laser
|
58
|
-
when "rocket_up"
|
59
|
-
puts "rocket"
|
60
|
-
@rocket += 1 if @rocket < 5
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
def fire
|
65
|
-
# @plasma:
|
66
|
-
# 2: start_offset: 5
|
67
|
-
# 3: start_offset: 10
|
68
|
-
# 4: start_offset: 15 -15, -5, 5, 15
|
69
|
-
#
|
70
|
-
if @current_weapon == :plasma
|
71
|
-
start_offset = (@plasma-1) * 5
|
72
|
-
@plasma.times do |nr|
|
73
|
-
Bullet.new(:x => @x, :y => @y, :angle => @angle - start_offset + (nr*10), :type => :plasma)
|
74
|
-
end
|
75
|
-
elsif @current_weapon == :laser
|
76
|
-
@plasma.times do |nr|
|
77
|
-
Bullet.new(:x => @x, :y => @y, :angle => @angle, :type => :laser)
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
|
82
|
-
end
|
83
|
-
|
84
|
-
def distance_to(object)
|
85
|
-
distance(self.x, self.y, object.x, object.y)
|
86
|
-
end
|
87
|
-
|
88
|
-
def update
|
89
|
-
@x += offset_x(@angle, 2)
|
90
|
-
@y += offset_y(@angle, 2)
|
91
|
-
self
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
class Weapon
|
96
|
-
def initialize(weapon_class, power = 1)
|
97
|
-
@weapon_class = weapon_class
|
98
|
-
@power = power
|
99
|
-
end
|
100
|
-
|
101
|
-
def fire
|
102
|
-
#@weapon_class.new
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
class Bullet < MyGameObject
|
107
|
-
def initialize(options)
|
108
|
-
super
|
109
|
-
@range = options[:range] || 40
|
110
|
-
@type = options[:type] || :plasma
|
111
|
-
@image = Image["#{@type.to_s}.png"]
|
112
|
-
@health = 10
|
113
|
-
@speed = 8
|
114
|
-
@color = Color.new(255,255,255,255)
|
115
|
-
@mode = :additive
|
116
|
-
|
117
|
-
Sample["plasma.wav"].play(0.1)
|
118
|
-
end
|
119
|
-
|
120
|
-
def move
|
121
|
-
@x += @speed_x
|
122
|
-
@y += @speed_y
|
123
|
-
end
|
124
|
-
|
125
|
-
def update(time = 1)
|
126
|
-
#base = time/100.0
|
127
|
-
|
128
|
-
if @type == :laser
|
129
|
-
@color.alpha = ($window.ticks%2 == 0) ? 255 : 0
|
130
|
-
end
|
131
|
-
|
132
|
-
@speed_x = offset_x(@angle, @speed)
|
133
|
-
@speed_y = offset_y(@angle, @speed)
|
134
|
-
move
|
135
|
-
end
|
136
|
-
end
|