Internal API

GameZero.ActorMethod

Actor(image::String)

Creates an Actor with the image given, which must be located in the images subdirectory.

GameZero.ContingentScheduledType

A contingent schdule. This type of schedule checks the return value of the action. If the action method returns nothing, no further action is scheduled. Otherwise, the return value is considered to be the interval, in seconds, to the next invocation of the action.

Since action methods are written by end users, the return value of those methods are not considered significant for ease of use. Hence ContingentScheduled is a separate type that should not be end user visible.

GameZero.LineType

Line(x1::Int, y1::Int, x2::Int, y2::Int) Line(x::Tuple, y::Tuple)

Creates an actor representing a line.

GameZero.OnceScheduledType

A scheduled action that is run once. The action is a zero-argument function that is wrapped as a WeakRef object. This ensures that schedules do not inadvertantly store references to game objects. This does however mean that anynymous functions should not be used as scheduled actions.

The time stored in the schedule is in absolute nanoseconds since epoch (Note the epoch for nanoseconds can be arbitrary). User facing times should always be in seconds, or fractions of a second, and usually specifed as interval from current time. Hence the time should be converted before being stored in a Sheduled object.

GameZero.RectType

Rect(x::Int,y::Int,w::Int,h::Int) Rect(x::Tuple, y::Tuple)

Creates an actor representing a rectangle.

GameZero.RepeatScheduledType

A scheduled action that is repeated indefinitely. The time of next invocation is stored as time, while the interval between each invocation is stored in interval. Both of these are stored in units of nanoseconds.

GameZero.SchedulerType

The schedule type stores an array of Sheduled objects, and a WallTimer object that is used to keep time. The scheduler object keeps its own timer, and does not reuse the timer in the game main loop, since the game timer can be reset every frame, while the scheduler timer needs to keep absolute time.

Base.angleMethod

angle(a1::Actor, a2::Actor)

Angle between the horizontal and the line between two actors. Value returned is in degrees.

Base.angleMethod

angle(a::Actor, x::Number, y::Number)

Angle between the horizontal of the line between an actor and a point in space. Value returned is in degrees.

Base.angleMethod

angle(a::Actor, xy::Tuple{Number, Number})

Angle between the horizontal of the line between an actor and a point in space. Value returned is in degrees.

GameZero.TextActorMethod
TextActor(text::String, font_name::String; font_size=24, color=Int[255,255,0,255])

Creates an actor with text rendered using font font_name. Font should be located in fonts directory.

GameZero.collideMethod

collide(a, b)

Checks if a and b (both game objects) are colliding.

GameZero.collideMethod
collide(a, x::Integer, y::Integer)
collide(a, xy::Tuple{Integer, Integer})

Checks if a (a game object) is colliding with a point.

GameZero.distanceMethod

distance(a1::Actor, a2::Actor)

Distance in pixels between two actors.

GameZero.distanceMethod

distance(a::Actor, x::Number, y::Number)

Distance in pixels between an actor and a point in space

GameZero.drawMethod

draw(a::Actor)

Draws the Actor on-screen at its current position.

GameZero.elapsedMethod

Return nanoseconds since timer was started or 0 if not yet started.

GameZero.play_musicFunction

play_music(name::String, loops::Integer)

Plays music from the sounds subdirectory. It will play the file the specified number of times. If not specified, it will default to infinitely.

GameZero.play_soundFunction

play_sound(filename::String, loops::Integer)

Plays a sound effect from the sounds subdirctory. It will play the specified number of times. If not specified, it will default to once.

GameZero.rungameFunction
`rungame(game_file::String)`
`rungame()`

The entry point to GameZero. This is the user-facing function that is used to start a game. 
The single argument method should be used from the REPL or main script. It takes the game source
file as it's only argument. 

The zero argument method should be used from the game source file itself when is being executed directly
GameZero.schedule_intervalFunction
schedule_interval(f::Function, interval, first_interval=interval)

Takes a function handle and time in seconds, and sets the function to run after that interval. Optional third argument first_interval can be passed to wait for that amount of time before first execution.

GameZero.schedule_onceMethod
schedule_once(f::Function, interval)

Takes a function and an interval in seconds, and sets the function to run after that interval.

GameZero.schedule_uniqueMethod
schedule_unique(f::Function, interval)

Takes a function and an interval in seconds, and sets the function to run after that interval only if the same function handle was not previously set.

GameZero.tickFunction

Run a contingent schduled action if due. If run, and not stopped, add a new scheduled action to the scheduler

GameZero.tickFunction

Run a repeated scheduled action if due. If run, this method will add a new scheduled action to the scheduler

GameZero.tick!Method

Run all actions in the global scheduler that are due