Class: Introduction
- Inherits:
-
Chingu::GameState
- Object
- Chingu::GameState
- Introduction
- Defined in:
- lib/games_and_rpg_paradise/gui/gosu/chinguroids/beginning.rb
Overview
INTRODUCTION GAMESTATE
Instance Method Summary collapse
- #draw ⇒ Object
-
#initialize ⇒ Introduction
constructor
initialize.
-
#next ⇒ Object
next.
- #setup ⇒ Object
- #update ⇒ Object
Constructor Details
#initialize ⇒ Introduction
initialize
129 130 131 132 |
# File 'lib/games_and_rpg_paradise/gui/gosu/chinguroids/beginning.rb', line 129 def initialize super self.input = { [:enter, :return] => :next, :p => Pause, :r => lambda{current_game_state.setup} } end |
Instance Method Details
#draw ⇒ Object
245 246 247 248 |
# File 'lib/games_and_rpg_paradise/gui/gosu/chinguroids/beginning.rb', line 245 def draw Image["../media/assets/background.png"].draw(0, 0, 0) # Background Image: Raw Gosu Image.draw(x,y,zorder)-call super end |
#next ⇒ Object
next
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
# File 'lib/games_and_rpg_paradise/gui/gosu/chinguroids/beginning.rb', line 170 def next if @nxt == true # if you've already pressed 'enter' once, pressing it again skips ahead @nxt = false push_game_state(Level_1) else @nxt = true # transition to Level 1 - Knight enters and speaks; push Level_1 gamestate @click.play after(200) { if @text2 != nil; @text2.destroy; end # only destroy @text2 if it exists after(200) { if @text != nil; @text.destroy; end after(200) { @count = 0 @knight.movement # Knight methods are defined in characters.rb after (1400) { @knight.speak after(10) { @text3 = Chingu::Text.create("Hello", :y => 220, :font => "GeosansLight", :size => 35, :color => Colors::White, :zorder => 300) @text3.x = 400 - @text3.width/2 # center text after (880) { @text4 = Chingu::Text.create("Use the arrows to move", :y => 350, :font => "GeosansLight", :size => 35, :color => Colors::White, :zorder => 300) @text4.x = 400 - @text4.width/2 after (1390) { @text5 = Chingu::Text.create("and the spacebar to shoot.", :y => 390, :font => "GeosansLight", :size => 35, :color => Colors::White, :zorder => 300) @text5.x = 400 - @text5.width/2 after(1400) { @knight.enter_ship after(10) { @song_fade = true after(800) {@text3.destroy} after(1300) {@text4.destroy} after(1600) {@text5.destroy} after(2300) { $music.stop push_game_state(Level_1) } } } } } } } } } } end end |
#setup ⇒ Object
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/games_and_rpg_paradise/gui/gosu/chinguroids/beginning.rb', line 134 def setup Chingu::Text.destroy_all # destroy any previously existing Text, Player, EndPlayer, and Meteors Player.destroy_all EndPlayer.destroy_all Meteor.destroy_all $window. = "ChinguRoids" @counter = 0 # used for automated Meteor creation @count = 1 # used for automated Meteor creation @nxt = false # used for :next method ('enter') @song_fade = false @fade_count = 0 @knight = Knight.create(:x=>900,:y=>300,:zorder=>100) # creates Knight offscreen; Knight is defined in characters.rb @click = Sound["media/audio/pickup_chime.ogg"] if $intro == false $music = Song["media/audio/music/intro_song.ogg"] $music.volume = 0.8 $music.play(true) else $intro = false end after(300) { @text = Chingu::Text.create("Welcome to ChinguRoids", :y => 60, :font => "GeosansLight", :size => 45, :color => Colors::Dark_Orange, :zorder => Zorder::GUI) @text.x = 800/2 - @text.width/2 # center text after(300) { @text2 = Chingu::Text.create("Press ENTER to play", :y => 510, :font => "GeosansLight", :size => 45, :color => Colors::Dark_Orange, :zorder => Zorder::GUI) @text2.x =800/2 - @text2.width/2 # center text after(300) { @player = EndPlayer.create(:x => 400, :y => 450, :zorder => Zorder::Main_Character) } } } end |
#update ⇒ Object
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 |
# File 'lib/games_and_rpg_paradise/gui/gosu/chinguroids/beginning.rb', line 209 def update super @counter += @count # used for Meteor creation if @song_fade == true # fade song if @song_fade is true @fade_count += 1 if @fade_count == 20 @fade_count = 0 $music.volume -= 0.1 end end if(@counter >= 80) # automated Meteor creation when @counter is 80 @random = rand(4)+1 case @random when 1 Meteor.create(x: rand(800)+1, y: 0, velocity_y: rand(5)+1, velocity_x: rand(-5..5), :scale => rand(0.5)+0.4, :zorder => Zorder::Object) when 2 Meteor.create(x: rand(800)+1, y: 600, velocity_y: rand(1..5)*-1, velocity_x: rand(-5..5), :scale => rand(0.5)+0.4, :zorder => Zorder::Object) when 3 Meteor.create(x: 0, y: rand(600)+1, velocity_x: rand(1..5), velocity_y: rand(-5..5), :scale => rand(0.5)+0.4, :zorder => Zorder::Object) when 4 Meteor.create(x: 800, y: rand(600)+1, velocity_x: rand(1..5)*-1, velocity_y: rand(-5..5), :scale => rand(0.5)+0.4, :zorder => Zorder::Object) end @counter = 60 # resets @counter to 60 end Meteor.destroy_if {|meteor| meteor.outside_window?} # self-explanatory end |