-
Notifications
You must be signed in to change notification settings - Fork 0
/
intro_state.rb
81 lines (59 loc) · 2.24 KB
/
intro_state.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
class ScamState < Chingu::GameState
def initialize(options = {})
super
Chingu::Text.create(:text => "This game is free!", :x => 100, :y => 250, :size => 40, :font => default_font_name())
Chingu::Text.create(:text => "If you paid for this game, you have been scammed!", :x => 100, :y => 300, :size => 20, :font => default_font_name())
@close_state = 5000
self.input = { :space => :continue, :enter => :continue, :return => :continue}
end
def continue
pop_game_state
push_game_state MainMenuState
end
def setup
$window.speak("coins detected in pocket")
end
def update
$window.update_speech
end
end
class IntroState < Chingu::GameState
#has_trait :timer, :effect
def initialize(options = {})
super
self.input = { :space => :continue, :enter => :continue, :return => :continue}
@skull = GameObject.create(:image => "skull.png", :rotation_center => :top_left, :color => 0x00FFFFFF, :zorder => 2)
@gradient = GameObject.create(:image => "gradient.png", :rotation_center => :top_left, :color => 0x00FFFFFF, :zorder => 1)
# remove when new chingu comes out
#@skull.rotation_center(:top_left)
#@gradient.rotation_center(:top_left)
@sweep = Song["intro.ogg"]
@sweep.play
Text.size = 120
Text.font = media_path("game_over.ttf")
@drop_text = Array.new
@drop_text << Text.create("IPPA", :y => -600*4, :color => 0xFFFF0000, :stop_at => 100, :sound => "intro_1.wav", :falling => true)
@drop_text << Text.create("& DEPS", :y => -700*4, :color => 0xFF00FF00, :stop_at => 200, :sound => "intro_2.wav", :falling => true)
@drop_text << Text.create("GAMING", :y => -800*4, :color => 0xFF0000FF, :stop_at => 300, :sound => "intro_3.wav", :falling => true)
end
def finalize
@sweep.stop if @sweep
end
def continue
pop_game_state
push_game_state ScamState
end
def update
@skull.alpha += 1
@gradient.alpha += 1
@drop_text.select { |text| text.options[:falling] }.each do |text|
if text.y > text.options[:stop_at]
Sound[text.options[:sound]].play(0.4)
text.options[:falling] = false
@sweep.stop if @sweep
else
text.y += 10
end
end
end
end