Internal API
GameZero.Actor
GameZero.ContingentScheduled
GameZero.Line
GameZero.OnceScheduled
GameZero.Rect
GameZero.RepeatScheduled
GameZero.Scheduler
Base.angle
Base.angle
Base.angle
GameZero.TextActor
GameZero.collide
GameZero.collide
GameZero.distance
GameZero.distance
GameZero.draw
GameZero.edit_distance
GameZero.elapsed
GameZero.play_music
GameZero.play_sound
GameZero.rungame
GameZero.schedule_interval
GameZero.schedule_once
GameZero.schedule_unique
GameZero.tick
GameZero.tick
GameZero.tick
GameZero.tick!
GameZero.unschedule
GameZero.Actor
— MethodActor(image::String)
Creates an Actor with the image given, which must be located in the images
subdirectory.
GameZero.ContingentScheduled
— TypeA 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.Line
— TypeLine(x1::Int, y1::Int, x2::Int, y2::Int)
Line(x::Tuple, y::Tuple)
Creates an actor representing a line.
GameZero.OnceScheduled
— TypeA 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.Rect
— TypeRect(x::Int,y::Int,w::Int,h::Int)
Rect(x::Tuple, y::Tuple)
Creates an actor representing a rectangle.
GameZero.RepeatScheduled
— TypeA 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.Scheduler
— TypeThe 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.angle
— Methodangle(a1::Actor, a2::Actor)
Angle between the horizontal and the line between two actors. Value returned is in degrees.
Base.angle
— Methodangle(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.angle
— Methodangle(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.TextActor
— MethodTextActor(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.collide
— Methodcollide(a, b)
Checks if a and b (both game objects) are colliding.
GameZero.collide
— Methodcollide(a, x::Integer, y::Integer)
collide(a, xy::Tuple{Integer, Integer})
Checks if a (a game object) is colliding with a point.
GameZero.distance
— Methoddistance(a1::Actor, a2::Actor)
Distance in pixels between two actors.
GameZero.distance
— Methoddistance(a::Actor, x::Number, y::Number)
Distance in pixels between an actor and a point in space
GameZero.draw
— Methoddraw(a::Actor)
Draws the Actor on-screen at its current position.
GameZero.edit_distance
— MethodSimplistic string edit distance method
GameZero.elapsed
— MethodReturn nanoseconds since timer was started or 0 if not yet started.
GameZero.play_music
— Functionplay_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_sound
— Functionplay_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.rungame
— Function`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_interval
— Functionschedule_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_once
— Methodschedule_once(f::Function, interval)
Takes a function and an interval in seconds, and sets the function to run after that interval.
GameZero.schedule_unique
— Methodschedule_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.tick
— FunctionRun a single scheduled action if due
GameZero.tick
— FunctionRun a contingent schduled action if due. If run, and not stopped, add a new scheduled action to the scheduler
GameZero.tick
— FunctionRun a repeated scheduled action if due. If run, this method will add a new scheduled action to the scheduler
GameZero.tick!
— MethodRun all actions in the global scheduler that are due
GameZero.unschedule
— Methodunschedule(f::Function)
Removes a function from the schedule.