The generic class for anything in the engine
Constructors
new(*, x :
Int = 0, y :
Int = 0, collision_flags :
CollisionFlags =
CollisionFlags::None, on_collide :
Proc(
PlayThing,
PlayThing,
Nil) = ->(pt :
PlayThing, other :
PlayThing) do
end, on_collide_start :
Proc(
PlayThing,
PlayThing,
Nil) = ->(pt :
PlayThing, other :
PlayThing) do
end, on_collide_end :
Proc(
PlayThing,
PlayThing,
Nil) = ->(pt :
PlayThing, other :
PlayThing) do
end, sprites :
Array(
Sprite) = [] of
Sprite, flags :
Flags =
Flags::None)
Creates the PlayThing and sets sprite to 0 if any sprites were given
SourceInstance methods
angle
The PlayThing's angle in degrees.
0 points up.
All ways to set will keep the value between 0 and 360
SourceSets the angle and removes all 360's from the number to ensure it is between 0 and 359
Sourcecollision_flags
The flags to use for collision detection
Sourcecollision_flags=(collision_flags : CollisionFlags)
The flags to use for collision detection
Sourcedestroy
Destroys a plaything (No more displaying or collision calls)
Sourceflags
The flags for the plaything
SourceThe flags for the plaything
Sourceflipbook
The flipbook to animate the sprites. Will always overwrite sprite if active
Sourceflipbook=(flipbook : Flipbook)
The flipbook to animate the sprites. Will always overwrite sprite if active
SourceMoves in x, y direction. X and Y are speeds.
Clamps between 0 and screen width/height
Sourceon_collide
Called when an overlap between this plaything (pt) and another plaything (other) occurs
Sourceon_collide=(on_collide :
Proc(
PlayThing,
PlayThing,
Nil))
Called when an overlap between this plaything (pt) and another plaything (other) occurs
Sourceon_collide_end
Called once when an overlap stops
Sourceon_collide_end=(on_collide_end :
Proc(
PlayThing,
PlayThing,
Nil))
Called once when an overlap stops
Sourceon_collide_start
Called once when an overlap starts
Sourceon_collide_start=(on_collide_start :
Proc(
PlayThing,
PlayThing,
Nil))
Called once when an overlap starts
Sourceright_vector
The right direction of the PlayThing.
A PlayThing with 0 angle will have right_vector {1, 0}
SourceRotates in rot direction, going clockwise
Sourcesprite
The sprite to display from sprites
SourceSets the current sprite number in sprites to display
Sourcesprites
An array of all sprites for the PlayThing to display
Sourceunmove
Sets the position to the previous x and y values
Sourceup_vector
The upwards direction of the PlayThing.
A PlayThing with 0 angle will have up_vector {0, 1}
Sourcex
The PlayThing's location. Bottom left centered.
All ways to set clamp between 0 and Tsh.res_x/Tsh.res_y
SourceSets the x position and clamps it between 0 and the screen's width
SourceSets the y position and clamps it between 0 and the screen's height
Source