lunar_lander 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,33 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
module LunarLander
|
3
|
+
class Leveldone < Chingu::GameState
|
4
|
+
|
5
|
+
def initialize(options = {})
|
6
|
+
super
|
7
|
+
|
8
|
+
@white = Gosu::Color.new(255,255,255,255)
|
9
|
+
@color = Gosu::Color.new(200,0,0,0)
|
10
|
+
@font = Gosu::Font[35]
|
11
|
+
@text = ["Parabéns! Pouso perfeito!","Pressione 'n' para tentar novamente."]
|
12
|
+
|
13
|
+
self.input = { :n => :new_game }
|
14
|
+
end
|
15
|
+
|
16
|
+
def new_game
|
17
|
+
switch_game_state LunarLander::Play
|
18
|
+
end
|
19
|
+
|
20
|
+
def draw
|
21
|
+
previous_game_state.draw # Draw prev game state onto screen (in this case our level)
|
22
|
+
$window.draw_quad( 0,0,@color,
|
23
|
+
$window.width,0,@color,
|
24
|
+
$window.width,$window.height,@color,
|
25
|
+
0,$window.height,@color, Chingu::DEBUG_ZORDER)
|
26
|
+
|
27
|
+
@text.each_with_index do |text, index|
|
28
|
+
@font.draw(text, ($window.width/2 - @font.text_width(text)/2), $window.height/2 - (@font.height - (index * @font.height)), Chingu::DEBUG_ZORDER + 1)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
module LunarLander
|
2
3
|
class Play < Chingu::GameState
|
3
4
|
def setup
|
@@ -35,18 +36,24 @@ module LunarLander
|
|
35
36
|
|
36
37
|
def update_hud
|
37
38
|
if @player
|
38
|
-
@velocity_x_text
|
39
|
-
@velocity_y_text
|
40
|
-
@angle_text
|
41
|
-
@fuel_text
|
39
|
+
update_text_if_needed(@velocity_x_text, "Velocidade Lateral: #{(@player.velocity_x * 10).ceil.abs}")
|
40
|
+
update_text_if_needed(@velocity_y_text, "Velocidade Vertical: #{(@player.velocity_y * 10).ceil * -1}")
|
41
|
+
update_text_if_needed(@angle_text, "Ângulo: #{@player.angle}")
|
42
|
+
update_text_if_needed(@fuel_text, "Combustível: #{@player.fuel.ceil}")
|
42
43
|
end
|
43
44
|
end
|
44
45
|
|
46
|
+
def update_text_if_needed(text_instance, text)
|
47
|
+
text_instance.text = text unless text_instance.text == text
|
48
|
+
end
|
49
|
+
|
45
50
|
def test_colision
|
46
51
|
if @player.bounding_box.collide_rect?(@surface)
|
47
52
|
if @player.should_die?
|
48
53
|
@player.die
|
49
54
|
switch_game_state LunarLander::Gameover
|
55
|
+
else
|
56
|
+
switch_game_state LunarLander::Leveldone
|
50
57
|
end
|
51
58
|
@player.stop
|
52
59
|
end
|
@@ -59,4 +66,4 @@ module LunarLander
|
|
59
66
|
|
60
67
|
end
|
61
68
|
end
|
62
|
-
end
|
69
|
+
end
|
data/lib/lunar_lander/version.rb
CHANGED
data/lib/lunar_lander.rb
CHANGED
@@ -3,4 +3,5 @@ require 'lunar_lander/game'
|
|
3
3
|
require 'lunar_lander/game_states/play'
|
4
4
|
require 'lunar_lander/game_states/pause'
|
5
5
|
require 'lunar_lander/game_states/gameover'
|
6
|
-
require 'lunar_lander/
|
6
|
+
require 'lunar_lander/game_states/leveldone'
|
7
|
+
require 'lunar_lander/game_objects/player'
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lunar_lander
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Lucas Roxo Mundim
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-03-
|
19
|
+
date: 2011-03-05 00:00:00 -03:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -56,6 +56,7 @@ files:
|
|
56
56
|
- lib/lunar_lander/game.rb
|
57
57
|
- lib/lunar_lander/game_objects/player.rb
|
58
58
|
- lib/lunar_lander/game_states/gameover.rb
|
59
|
+
- lib/lunar_lander/game_states/leveldone.rb
|
59
60
|
- lib/lunar_lander/game_states/pause.rb
|
60
61
|
- lib/lunar_lander/game_states/play.rb
|
61
62
|
- lib/lunar_lander/version.rb
|