Class: Bestguigui::App
- Inherits:
-
Gosu::Window
- Object
- Gosu::Window
- Bestguigui::App
- Defined in:
- lib/bestguigui/app.rb
Overview
Sous-classe pour ton jeu, appelle switch_state pour changer d'écran.
Instance Method Summary collapse
- #button_down(id) ⇒ Object
- #button_up(id) ⇒ Object
- #draw ⇒ Object
-
#initialize(width: 800, height: 600, title: "Game") ⇒ App
constructor
A new instance of App.
- #switch_state(state) ⇒ Object
- #update ⇒ Object
Constructor Details
#initialize(width: 800, height: 600, title: "Game") ⇒ App
Returns a new instance of App.
4 5 6 7 8 |
# File 'lib/bestguigui/app.rb', line 4 def initialize(width: 800, height: 600, title: "Game") super(width, height) self.caption = title @last_update_time = Gosu.milliseconds end |
Instance Method Details
#button_down(id) ⇒ Object
29 30 31 |
# File 'lib/bestguigui/app.rb', line 29 def (id) @state&.(id) end |
#button_up(id) ⇒ Object
33 34 35 |
# File 'lib/bestguigui/app.rb', line 33 def (id) @state&.(id) end |
#draw ⇒ Object
25 26 27 |
# File 'lib/bestguigui/app.rb', line 25 def draw @state&.draw end |
#switch_state(state) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/bestguigui/app.rb', line 10 def switch_state(state) @state&.exit @state = state @state.app = self @state.enter end |
#update ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/bestguigui/app.rb', line 17 def update now = Gosu.milliseconds dt = (now - @last_update_time) / 1000.0 @last_update_time = now @state&.update(dt) end |