class

Tsh::PlayThing

Inherits Reference < Object

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

Source

Instance methods

angle

The PlayThing's angle in degrees. 0 points up. All ways to set will keep the value between 0 and 360

Source
angle=(angle : Float32 | Float64)

Sets the angle and removes all 360's from the number to ensure it is between 0 and 359

Source
collision_flags

The flags to use for collision detection

Source
collision_flags=(collision_flags : CollisionFlags)

The flags to use for collision detection

Source
destroy

Destroys a plaything (No more displaying or collision calls)

Source
flags

The flags for the plaything

Source
flags=(flags : Flags)

The flags for the plaything

Source
flipbook

The flipbook to animate the sprites. Will always overwrite sprite if active

Source
flipbook=(flipbook : Flipbook)

The flipbook to animate the sprites. Will always overwrite sprite if active

Source
move(x : Int, y : Int)

Moves in x, y direction. X and Y are speeds. Clamps between 0 and screen width/height

Source
on_collide

Called when an overlap between this plaything (pt) and another plaything (other) occurs

Source
on_collide=(on_collide : Proc(PlayThing, PlayThing, Nil))

Called when an overlap between this plaything (pt) and another plaything (other) occurs

Source
on_collide_end

Called once when an overlap stops

Source
on_collide_end=(on_collide_end : Proc(PlayThing, PlayThing, Nil))

Called once when an overlap stops

Source
on_collide_start

Called once when an overlap starts

Source
on_collide_start=(on_collide_start : Proc(PlayThing, PlayThing, Nil))

Called once when an overlap starts

Source
right_vector

The right direction of the PlayThing. A PlayThing with 0 angle will have right_vector {1, 0}

Source
rotate(rot : Float32)

Rotates in rot direction, going clockwise

Source
sprite

The sprite to display from sprites

Source
sprite=(sprite : Int32)

Sets the current sprite number in sprites to display

Source
sprites

An array of all sprites for the PlayThing to display

Source
unmove

Sets the position to the previous x and y values

Source
up_vector

The upwards direction of the PlayThing. A PlayThing with 0 angle will have up_vector {0, 1}

Source
x

The PlayThing's location. Bottom left centered. All ways to set clamp between 0 and Tsh.res_x/Tsh.res_y

Source
x=(x : Int)

Sets the x position and clamps it between 0 and the screen's width

Source
y=(y : Int)

Sets the y position and clamps it between 0 and the screen's height

Source

Nested types