Otter
0.9.8.91
2d Game Development Framework based on SFML.Net
|
ᶜ(ᵔᴥᵔ)ᵓ Core class Otter. Create a Game, and then use Game.Start(); to run it. More...
Public Member Functions | |
Game (string title="Game", int width=640, int height=480, int targetFramerate=60, bool fullscreen=false) | |
Creates a new game to run in the program. More... | |
void | SetWindow (int width, int height=0, bool fullscreen=false, bool vsync=false) |
Creates a new window for the game to be shown in. More... | |
void | SetWindowAutoFullscreen (bool vsync=false) |
Creates a new window that is the resolution of the screen and in fullscreen mode. More... | |
void | ForceDebugger () |
Force the creation of a Debugger object (even in Release mode!) More... | |
void | CenterWindow () |
Center the window on the monitor that the window was initialized on. More... | |
void | AddSurface (Surface surface) |
Add a surface to the list of surfaces to be rendered to the window. More... | |
void | RemoveSurface (Surface surface) |
Remove a surface from the list of surfaces to be rendered to the window. More... | |
void | SetWindowScale (float scale=1) |
Create a new window using a scale value instead of pixels. More... | |
void | SetIcon (string source) |
Set the icon of the current window. More... | |
void | Stop () |
Stop the game from running completely. More... | |
void | Pause () |
Pause the game. More... | |
void | Resume () |
Resume the game after pausing. More... | |
void | PauseToggle () |
Toggle the pause state on and off. More... | |
void | Sleep (int milliseconds) |
Pauses the game for a certain time. Only works with fixed framerate currently. More... | |
void | Start (Scene firstScene) |
Start the game using a specific Scene. Shortcut for setting the FirstScene then using Start. More... | |
void | Start () |
Start the game. This will begin the game loop and no other code past Start() in your entry point will run. Make sure to set the first scene before executing this. More... | |
void | Close () |
Close the current game window. More... | |
void | SwitchScene (Scene scene) |
Switch to a new scene. This removes the scene stack! More... | |
void | AddScene (Scene scene) |
Add a scene to the top of the stack. You do not have to use Game.FirstScene if you use this before Game.Start(). More... | |
void | AddScene (params Scene[] scenes) |
Add multiple scenes to the top of the stack. The last scene added will be on top. More... | |
void | RemoveScene () |
Remove the scene from the top of the scene stack. More... | |
T | GetScene< T > () |
Get the current scene cast to a specific type. Useful for when you extend Scene to your own class. More... | |
Session | AddSession (string name) |
Adds a new Session to the game. More... | |
Session | AddSession (Enum name) |
Adds a new Session to the game. More... | |
Session | Session (string name) |
Get a session by the name. More... | |
Session | Session (Enum name) |
Get a Session by the name. More... | |
Session | Session (int id) |
Get a session by id. More... | |
Public Attributes | |
int | TargetFramerate |
The desired framerate that the game should update at. More... | |
bool | FixedFramerate = true |
Render and update the game at a fixed framerate. The game will never exceed the target framerate, and will slow down if performance decreases. More... | |
string | Title |
The title of the game displayed in the window. More... | |
bool | Active = false |
If the game is currently being run. More... | |
bool | Paused = false |
If the game is paused (no longer updating.) More... | |
Action | OnInit = delegate { } |
An action called when the game initializes. More... | |
Action | OnUpdate = delegate { } |
An action called when the game updates (happens after all Scene and Entity updates.) More... | |
Action | OnSceneBegin = delegate { } |
An action called when any Scene begins. More... | |
Action | OnSceneEnd = delegate { } |
An action called when any Scene ends. More... | |
Action | OnEnd = delegate { } |
An Action called when the game ends. The last code that executes when closing the game. More... | |
Action | OnFocusLost = delegate { } |
An action that is called when the window loses focus. More... | |
Action | OnFocusGained = delegate { } |
An action that is called when the window gains focus. More... | |
Action | OnEndOfUpdate = delegate { } |
An action that is called at the very end of the update (the very last thing before Render()) After this is called it will be cleared! More... | |
Action | OnStartOfNextUpdate = delegate { } |
An action that is called at the very start of the next update (the very first thing before UpdateFirst()) After this is called it will be cleared! More... | |
bool | DrawInactiveScenes = true |
If the game should draw all scenes on the stack including inactive scenes. More... | |
Color | Color = Color.Black |
The default background color of the game. More... | |
Color | LetterBoxColor = Color.Black |
The default color to draw in the letterboxed areas of the window. More... | |
float | Timer |
How long the game has been active. Measured in units of delta time. More... | |
Scene | FirstScene |
The first scene that the game should load when Start() is called. More... | |
int | GameFrames |
The number of frames that have passed since the game started. If you're not using fixed framerate then this number will vary wildly. More... | |
bool | MeasureTimeInFrames = true |
If the game should measure time in frames when using a fixed framerate. If true delta time will increase by 1 on each update, if false it will increase by 1 / TargetFramerate. More... | |
bool | LockMouse |
If the game should attempt to lock the mouse inside the window. This is not 100% accurate. More... | |
int | LockMousePadding = 10 |
The distance from the edge of the window in which the mouse cant escape when locked. More... | |
bool | LockMouseCenter |
If the mouse should be locked to the center of the window. The Input class should still report the mouse position accurately if this is true. This is currently the best way to lock the mouse inside of the window region. More... | |
bool | AlwaysUpdate = true |
If the game should keep updating even when it has lost focus. More... | |
Atlas | Atlas = new Atlas() |
The default Atlas to search for image assets in. More... | |
bool | LockAspectRatio = true |
Maintain the original aspect ratio of the game when scaling the window. More... | |
Button | QuitButton = new Button() |
Button that closes the game when pressed. Defaults to the Escape key. More... | |
Button | ScreenshotButton = new Button() |
Button that will save the game's surface out to a timestamp named .png file after the next render. More... | |
bool | EnableQuitButton = true |
Determines if the QuitButton can close the game. More... | |
bool | EnableAltF4 = true |
Determines if Alt+F4 will close the game immediately. More... | |
bool | InvertAngleY = true |
Determines if Y values determined by angles in the Util class will invert the Y axis. This is mostly for backwards compatibility. Turn it back to false if you don't want to change all of your math. More... | |
bool | ReleaseModeDebugger = false |
Determines if the debug console will be available when building in release mode. Must be set before Game.Start() is called. More... | |
bool | WindowResize = true |
Determines if the game window can be resized. Must be set before calling Game.SetWindow() or Game.Start(). More... | |
bool | WindowClose = true |
Determines if the game window has a close button or Alt+F4. Must be set before calling Game.SetWindow() or Game.Start(). More... | |
bool | WindowBorder = true |
Determines if the game window has a border. If the window has no border it cannot be resized or closed with the close button or Alt+F4. Must be set before calling Game.SetWindow() or Game.Start() More... | |
Static Public Attributes | |
static Game | Instance |
A reference to the active Game instance. More... | |
Properties | |
int | WindowX [get, set] |
Set the X position of the Window. More... | |
int | WindowY [get, set] |
Set the Y position of the Window. More... | |
Debugger | Debugger [get, set] |
The debugger. Only accessable in Debug mode, otherwise null. More... | |
Coroutine | Coroutine [get, set] |
The Coroutine manager. More... | |
Tweener | Tweener [get, set] |
The tween manager. More... | |
bool | ShowDebugger [get, set] |
True if the debugger is currently open. More... | |
float | Framerate [get, set] |
The current framerate of the game. More... | |
float | AverageFramerate [get, set] |
The average framerate of the game over the past few seconds. More... | |
float | DeltaTime [get, set] |
How much time has passed since the last update. Will only make sense if FixedFramerate is false. More... | |
int | Width [get, set] |
The internal width of the game. More... | |
int | Height [get, set] |
The internal height of the game. More... | |
int | WindowWidth [get, set] |
The window width of the game. More... | |
int | WindowHeight [get, set] |
The window height of the game. More... | |
bool | WindowFullscreen [get, set] |
If the game window is currently fullscreen. More... | |
Stack< Scene > | Scenes [get, set] |
The stack of scenes currently in the game. More... | |
List< Session > | Sessions [get, set] |
The list of player sessions currently in the game. More... | |
Input | Input [get, set] |
The input used by the game. More... | |
DebugInput | DebugInput [get, set] |
The debug input used by the game. More... | |
Surface | Surface [get, set] |
The main surface that the game renders to. More... | |
bool | IsDebugMode [get, set] |
If the game is currently being run in a Debug Mode build. More... | |
int | MouseDeltaX [get, set] |
The change in the mouse's x position before it's relocked to the center. Only reports when LockMouseCenter is set to true. More... | |
int | MouseDeltaY [get, set] |
The change in the mouse's y position before it's relocked to the center. Only reports when LockMouseCenter is set to true. More... | |
bool | HasFocus [get, set] |
If the window currently has focus. More... | |
DataSaver | OptionsData [get, set] |
The stored data for game options. The options file is not externally modifiable. More... | |
DataSaver | SaveData [get, set] |
The stored data for the general game data. The file is not externally modifiable. More... | |
DataSaver | ConfigData [get, set] |
The stored data for the game config file. The config file is externally modifiable. More... | |
string | GameFolder [get, set] |
The default folder to use for storing data files for the game. This will be a folder created in the current user's My Documents folder. The default is 'ottergame' so it will create a folder 'ottergame' in My Documents. More... | |
string | Filepath [get] |
The main filepath for saving and loading files for the game. More... | |
float | AspectRatio [get, set] |
The aspect ratio of the window that the game is rendering to. More... | |
int | Second [get] |
A second in terms of frames for fixed frame rate games. More... | |
List< Surface > | Surfaces [get, set] |
The surfaces that should be rendered to the final game window. Useful for games that need to render to multiple surfaces. More... | |
float | CameraAngle [get, set] |
The camera angle for the game's main view. More... | |
float | CameraZoom [get, set] |
The camera zoom for the game's main view. More... | |
float | RealDeltaTime [get, set] |
The real delta time for each update. More... | |
bool | MouseVisible [get, set] |
Set the visibilty of the mouse. More... | |
int | RenderTime [get] |
The amount of time in milliseconds for the render pass to complete. More... | |
int | UpdateTime [get] |
The amount of time in milliseconds for the update time to complete. More... | |
int | RenderCount [get, set] |
The number of draw calls in the last update. More... | |
int | UpdateCount [get, set] |
The number of objects that were updated in the last update. More... | |
int | HalfWidth [get, set] |
Half of the game's internal width. More... | |
int | HalfHeight [get, set] |
Half of the game's internal height. More... | |
Scene | Scene [get, set] |
A reference to the current scene being updated by the game. More... | |
ᶜ(ᵔᴥᵔ)ᵓ Core class Otter. Create a Game, and then use Game.Start(); to run it.
Otter.Game.Game | ( | string | title = "Game" , |
int | width = 640 , |
||
int | height = 480 , |
||
int | targetFramerate = 60 , |
||
bool | fullscreen = false |
||
) |
Creates a new game to run in the program.
title | The title of the window. |
width | The width of the internal game resolution. |
height | The height of the internal game resolution. |
targetFramerate | The target framerate (for fixed framerate.) |
fullscreen | Run the game in fullscreen. |
void Otter.Game.AddScene | ( | Scene | scene | ) |
Add a scene to the top of the stack. You do not have to use Game.FirstScene if you use this before Game.Start().
scene | The scene to add. |
void Otter.Game.AddScene | ( | params Scene[] | scenes | ) |
Add multiple scenes to the top of the stack. The last scene added will be on top.
scenes | The scenes to add. |
Session Otter.Game.AddSession | ( | string | name | ) |
Session Otter.Game.AddSession | ( | Enum | name | ) |
void Otter.Game.AddSurface | ( | Surface | surface | ) |
Add a surface to the list of surfaces to be rendered to the window.
surface | The surface to add. |
void Otter.Game.CenterWindow | ( | ) |
Center the window on the monitor that the window was initialized on.
void Otter.Game.Close | ( | ) |
Close the current game window.
void Otter.Game.ForceDebugger | ( | ) |
Force the creation of a Debugger object (even in Release mode!)
T Otter.Game.GetScene< T > | ( | ) |
Get the current scene cast to a specific type. Useful for when you extend Scene to your own class.
T | The class to return the scene as. |
T | : | Scene |
void Otter.Game.Pause | ( | ) |
Pause the game.
void Otter.Game.PauseToggle | ( | ) |
Toggle the pause state on and off.
void Otter.Game.RemoveScene | ( | ) |
Remove the scene from the top of the scene stack.
void Otter.Game.RemoveSurface | ( | Surface | surface | ) |
Remove a surface from the list of surfaces to be rendered to the window.
surface | The surface to remove. |
void Otter.Game.Resume | ( | ) |
Resume the game after pausing.
Session Otter.Game.Session | ( | string | name | ) |
Get a session by the name.
name | The name of the session. |
Session Otter.Game.Session | ( | Enum | name | ) |
Session Otter.Game.Session | ( | int | id | ) |
void Otter.Game.SetIcon | ( | string | source | ) |
Set the icon of the current window.
width | The width of the icon. |
height | The height of the icon. |
source | The source path to the icon image. |
void Otter.Game.SetWindow | ( | int | width, |
int | height = 0 , |
||
bool | fullscreen = false , |
||
bool | vsync = false |
||
) |
Creates a new window for the game to be shown in.
width | The width of the window. |
height | The height of the window. |
fullscreen | Run the window in fullscreen mode. |
vsync | Enable vertical sync. |
void Otter.Game.SetWindowAutoFullscreen | ( | bool | vsync = false | ) |
Creates a new window that is the resolution of the screen and in fullscreen mode.
vsync | Enable vertical sync. |
void Otter.Game.SetWindowScale | ( | float | scale = 1 | ) |
Create a new window using a scale value instead of pixels.
scale | The scale compared to the game's internal resolution. |
void Otter.Game.Sleep | ( | int | milliseconds | ) |
Pauses the game for a certain time. Only works with fixed framerate currently.
milliseconds | The time to freeze for in milliseconds. |
void Otter.Game.Start | ( | Scene | firstScene | ) |
void Otter.Game.Start | ( | ) |
Start the game. This will begin the game loop and no other code past Start() in your entry point will run. Make sure to set the first scene before executing this.
void Otter.Game.Stop | ( | ) |
Stop the game from running completely.
void Otter.Game.SwitchScene | ( | Scene | scene | ) |
Switch to a new scene. This removes the scene stack!
scene | The scene to switch to. |
bool Otter.Game.Active = false |
If the game is currently being run.
bool Otter.Game.AlwaysUpdate = true |
If the game should keep updating even when it has lost focus.
Color Otter.Game.Color = Color.Black |
The default background color of the game.
bool Otter.Game.DrawInactiveScenes = true |
If the game should draw all scenes on the stack including inactive scenes.
bool Otter.Game.EnableAltF4 = true |
Determines if Alt+F4 will close the game immediately.
bool Otter.Game.EnableQuitButton = true |
Determines if the QuitButton can close the game.
bool Otter.Game.FixedFramerate = true |
Render and update the game at a fixed framerate. The game will never exceed the target framerate, and will slow down if performance decreases.
int Otter.Game.GameFrames |
The number of frames that have passed since the game started. If you're not using fixed framerate then this number will vary wildly.
bool Otter.Game.InvertAngleY = true |
Determines if Y values determined by angles in the Util class will invert the Y axis. This is mostly for backwards compatibility. Turn it back to false if you don't want to change all of your math.
Color Otter.Game.LetterBoxColor = Color.Black |
The default color to draw in the letterboxed areas of the window.
bool Otter.Game.LockAspectRatio = true |
Maintain the original aspect ratio of the game when scaling the window.
bool Otter.Game.LockMouse |
If the game should attempt to lock the mouse inside the window. This is not 100% accurate.
bool Otter.Game.LockMouseCenter |
If the mouse should be locked to the center of the window. The Input class should still report the mouse position accurately if this is true. This is currently the best way to lock the mouse inside of the window region.
int Otter.Game.LockMousePadding = 10 |
The distance from the edge of the window in which the mouse cant escape when locked.
bool Otter.Game.MeasureTimeInFrames = true |
If the game should measure time in frames when using a fixed framerate. If true delta time will increase by 1 on each update, if false it will increase by 1 / TargetFramerate.
Action Otter.Game.OnEnd = delegate { } |
An Action called when the game ends. The last code that executes when closing the game.
Action Otter.Game.OnEndOfUpdate = delegate { } |
An action that is called at the very end of the update (the very last thing before Render()) After this is called it will be cleared!
Action Otter.Game.OnFocusGained = delegate { } |
An action that is called when the window gains focus.
Action Otter.Game.OnFocusLost = delegate { } |
An action that is called when the window loses focus.
Action Otter.Game.OnInit = delegate { } |
An action called when the game initializes.
Action Otter.Game.OnSceneBegin = delegate { } |
An action called when any Scene begins.
Action Otter.Game.OnSceneEnd = delegate { } |
An action called when any Scene ends.
Action Otter.Game.OnStartOfNextUpdate = delegate { } |
An action that is called at the very start of the next update (the very first thing before UpdateFirst()) After this is called it will be cleared!
Action Otter.Game.OnUpdate = delegate { } |
bool Otter.Game.Paused = false |
If the game is paused (no longer updating.)
Button that closes the game when pressed. Defaults to the Escape key.
bool Otter.Game.ReleaseModeDebugger = false |
Determines if the debug console will be available when building in release mode. Must be set before Game.Start() is called.
Button that will save the game's surface out to a timestamp named .png file after the next render.
int Otter.Game.TargetFramerate |
The desired framerate that the game should update at.
float Otter.Game.Timer |
How long the game has been active. Measured in units of delta time.
string Otter.Game.Title |
The title of the game displayed in the window.
bool Otter.Game.WindowBorder = true |
Determines if the game window has a border. If the window has no border it cannot be resized or closed with the close button or Alt+F4. Must be set before calling Game.SetWindow() or Game.Start()
bool Otter.Game.WindowClose = true |
Determines if the game window has a close button or Alt+F4. Must be set before calling Game.SetWindow() or Game.Start().
bool Otter.Game.WindowResize = true |
Determines if the game window can be resized. Must be set before calling Game.SetWindow() or Game.Start().
|
getset |
The aspect ratio of the window that the game is rendering to.
|
getset |
The average framerate of the game over the past few seconds.
|
getset |
The camera angle for the game's main view.
|
getset |
The camera zoom for the game's main view.
|
getset |
The stored data for the game config file. The config file is externally modifiable.
|
getset |
The debugger. Only accessable in Debug mode, otherwise null.
|
getset |
The debug input used by the game.
|
getset |
How much time has passed since the last update. Will only make sense if FixedFramerate is false.
|
get |
The main filepath for saving and loading files for the game.
|
getset |
The current framerate of the game.
|
getset |
The default folder to use for storing data files for the game. This will be a folder created in the current user's My Documents folder. The default is 'ottergame' so it will create a folder 'ottergame' in My Documents.
|
getset |
Half of the game's internal height.
|
getset |
Half of the game's internal width.
|
getset |
If the window currently has focus.
|
getset |
The internal height of the game.
|
getset |
The input used by the game.
|
getset |
If the game is currently being run in a Debug Mode build.
|
getset |
The change in the mouse's x position before it's relocked to the center. Only reports when LockMouseCenter is set to true.
|
getset |
The change in the mouse's y position before it's relocked to the center. Only reports when LockMouseCenter is set to true.
|
getset |
Set the visibilty of the mouse.
|
getset |
The stored data for game options. The options file is not externally modifiable.
|
getset |
The real delta time for each update.
|
getset |
The number of draw calls in the last update.
|
get |
The amount of time in milliseconds for the render pass to complete.
|
getset |
The stored data for the general game data. The file is not externally modifiable.
|
getset |
A reference to the current scene being updated by the game.
|
getset |
The stack of scenes currently in the game.
|
get |
A second in terms of frames for fixed frame rate games.
|
getset |
The list of player sessions currently in the game.
|
getset |
True if the debugger is currently open.
|
getset |
The main surface that the game renders to.
|
getset |
The surfaces that should be rendered to the final game window. Useful for games that need to render to multiple surfaces.
|
getset |
The tween manager.
|
getset |
The number of objects that were updated in the last update.
|
get |
The amount of time in milliseconds for the update time to complete.
|
getset |
The internal width of the game.
|
getset |
If the game window is currently fullscreen.
|
getset |
The window height of the game.
|
getset |
The window width of the game.
|
getset |
Set the X position of the Window.
|
getset |
Set the Y position of the Window.