game

package
v0.0.0-...-d1ed616 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 2, 2016 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package game provides an example of a usual Kaori game skeleton. Everything that are specific to the game should and only be in this class only.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChangeScene

func ChangeScene(s scene.Scene)

ChangeScene changes the scene and runs the proper functions ( Run Exit on Old Scene, and Enter on New Scene )

func Clean

func Clean()

Clean is used for cleaning the game's resources such as Freeing the Textures, Clean the used resources, etc.

func HandleEvents

func HandleEvents()

HandleEvents is used for receiving and handling SDL Events such as Update the mouse location, Check if the user is requesting to close the game, etc.

func Init

func Init(title string, x, y, width, height int, fullscreen bool)

Init is used for a starting procedure of the game which will do things such as creating the SDL Window, creating the SDL Renderer, Start the Scene, etc.

func Render

func Render()

Render is used for drawing something to the renderer. Which will show up on the screen.

func Renderer

func Renderer() *sdl.Renderer

Renderer returns the SDL Renderer that's being used for the Window.

func Running

func Running() bool

Running returns the game's 'running' status.

func Stop

func Stop()

Stop literally stops the game

func Update

func Update()

Update is used to update and tick the game's component such as Moving the enemy, Update the score, Do physics, etc.

func Window

func Window() *sdl.Window

Window returns the SDL Window that's being used.

Types

type DemoScene

type DemoScene struct {
	// contains filtered or unexported fields
}

DemoScene is an example use of a Scene in this case drawing the logo

func (*DemoScene) Draw

func (s *DemoScene) Draw(r *sdl.Renderer)

Draw executes when a game render is being executed

func (*DemoScene) Enter

func (s *DemoScene) Enter()

Enter executes when the scene is starting

func (*DemoScene) Exit

func (s *DemoScene) Exit()

Exit executes when the scene is being changed or the game is closing

func (*DemoScene) HandleEvents

func (s *DemoScene) HandleEvents(e sdl.Event)

HandleEvents executes when there's an SDL Event from the Event Poll

func (*DemoScene) Update

func (s *DemoScene) Update()

Update executes when a game update is being executed

type EmptyScene

type EmptyScene struct {
}

EmptyScene is a skeleton for a Scene

func (*EmptyScene) Draw

func (s *EmptyScene) Draw(r *sdl.Renderer)

Draw is used when a game render event happens usually this function is used for drawing the objects

func (*EmptyScene) Enter

func (s *EmptyScene) Enter()

Enter is used when the Scene is going to be used usually this function is used for loading assets, transitions, etc

func (*EmptyScene) Exit

func (s *EmptyScene) Exit()

Exit is used when the Scene is going to change or the game is going to close ( You can check what's going on with the running variable ) usually this function is used for freeing resources, cleaning objects, transitions, etc

func (*EmptyScene) HandleEvents

func (s *EmptyScene) HandleEvents(e sdl.Event)

HandleEvents is used when a certain SDL Event is received

func (*EmptyScene) Update

func (s *EmptyScene) Update()

Update is used when a game update event happens usually this function is used for moving the objects, check the input devices, etc

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL