class Glint::Game
- Glint::Game
- Reference
- Object
Overview
The main game class.
Extend Game
with #draw
and #update(delta : Float)
methods to create
simple games, or use the Scene
class to create more complex games.
Defined in:
glint/game.crConstructors
-
.new(width = 1920.pixels, height = 1080.pixels, title = "<untitled>", target_framerate : Int32 = 60)
Creates a new game with optional size, title and framerate.
Class Method Summary
-
.clear_background(color : Color | Nil)
Clears the background to the specified color.
-
.frame_time
Returns the duration (in seconds) since the last frame.
-
.framerate
Returns the current (real) framerate.
Instance Method Summary
-
#display_fps_text
Display the current FPS.
-
#draw
Performs custom drawing.
-
#fps_position : Glint::Vector2
Returns the FPS label's position.
-
#fps_position=(position : Position)
Sets the FPS label's position.
-
#frame_time
Returns the duration (in seconds) since the last frame.
-
#framerate
Returns the current (real) framerate.
-
#log_level : Glint::LogLevel
Returns the trace log level.
-
#log_level=(log_level : LogLevel)
Sets the trace log level.
-
#pause!
Pause the game.
-
#paused=(paused : Bool)
Sets whether the game is paused.
-
#paused? : Bool
Returns whether the game is paused.
-
#position : Glint::Vector2
Returns the game's absolute position.
-
#quit
Quits the game.
-
#run
Runs the game's mainloop: handle inputs, update game state, output.
-
#scene : Scene
The current
Scene
. -
#scene=(scene : Entity::Scene)
Sets the scene.
-
#should_quit?
Returns whether the game should quit.
-
#target_framerate : Int32
The target (maximum ideal) framerate.
-
#target_framerate=(target_framerate : Int32)
The target (maximum ideal) framerate.
-
#unpause!
Unpause the game.
-
#update(delta : Float)
Performs custom updates.
-
#window : Window
The game
Window
.
Constructor Detail
Creates a new game with optional size, title and framerate.
Class Method Detail
Clears the background to the specified color.
Returns the current (real) framerate.
This may differ from the #target_framerate
.
Instance Method Detail
Performs custom drawing.
Overload this method to draw directly, bypassing the automatic drawing of Scene
s
(Scene
s are still drawn, if they have anything to draw...).
By default, it shows a simple label displaying the name and version of the Glint library.
If you don't want to see this, simple override the Game#draw
method, even if it's
empty:
class MyGame < Game
def draw; end
end
# or even this, if you're feeling feisty:
class Game
def draw; end
end