class Tsh::PlayThing
- Tsh::PlayThing
- Reference
- Object
Overview
The generic class for anything in the engine
Defined in:
plaything.crConstructors
- .new
-
.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
Instance Method Summary
-
#angle : Float32
The PlayThing's angle in degrees.
-
#angle=(angle : Float32)
Sets the angle and removes all 360's from the number to ensure it is between 0 and 359
-
#collision_flags : CollisionFlags
The flags to use for collision detection
-
#collision_flags=(collision_flags : CollisionFlags)
The flags to use for collision detection
-
#destroy
Destroys a plaything (No more displaying or collision calls)
-
#flags : Flags
The flags for the plaything
-
#flags=(flags : Flags)
The flags for the plaything
-
#flipbook : Flipbook
The flipbook to animate the sprites.
-
#flipbook=(flipbook : Flipbook)
The flipbook to animate the sprites.
-
#move(x : Int, y : Int)
Moves in x, y direction.
-
#on_collide : Proc(PlayThing, PlayThing, Nil)
Called when an overlap between this plaything (pt) and another plaything (other) occurs
-
#on_collide=(on_collide : Proc(PlayThing, PlayThing, Nil))
Called when an overlap between this plaything (pt) and another plaything (other) occurs
-
#on_collide_end : Proc(PlayThing, PlayThing, Nil)
Called once when an overlap stops
-
#on_collide_end=(on_collide_end : Proc(PlayThing, PlayThing, Nil))
Called once when an overlap stops
-
#on_collide_start : Proc(PlayThing, PlayThing, Nil)
Called once when an overlap starts
-
#on_collide_start=(on_collide_start : Proc(PlayThing, PlayThing, Nil))
Called once when an overlap starts
-
#right_vector : Raylib::Vector2
The right direction of the PlayThing.
-
#rotate(rot : Float32)
Rotates in rot direction, going clockwise
-
#sprite : Int32
The sprite to display from sprites
-
#sprite=(sprite : Int32)
Sets the current sprite number in sprites to display
-
#sprites : Array(Sprite)
An array of all sprites for the PlayThing to display
-
#unmove
Sets the position to the previous x and y values
-
#up_vector : Raylib::Vector2
The upwards direction of the PlayThing.
-
#x : UInt32
The PlayThing's location.
-
#x=(x : Int)
Sets the x position and clamps it between 0 and the screen's width
- #y : UInt32
-
#y=(y : Int)
Sets the y position and clamps it between 0 and the screen's height
Constructor Detail
Creates the PlayThing and sets sprite to 0 if any sprites were given
Instance Method Detail
The PlayThing's angle in degrees. 0 points up. All ways to set will keep the value between 0 and 360
Sets the angle and removes all 360's from the number to ensure it is between 0 and 359
The flipbook to animate the sprites. Will always overwrite sprite if active
The flipbook to animate the sprites. Will always overwrite sprite if active
Moves in x, y direction. X and Y are speeds. Clamps between 0 and screen width/height
Called when an overlap between this plaything (pt) and another plaything (other) occurs
Called when an overlap between this plaything (pt) and another plaything (other) occurs
Called once when an overlap stops
Called once when an overlap starts
The right direction of the PlayThing. A PlayThing with 0 angle will have right_vector {1, 0}
The upwards direction of the PlayThing. A PlayThing with 0 angle will have up_vector {0, 1}
The PlayThing's location. Bottom left centered. All ways to set clamp between 0 and Tsh.res_x/Tsh.res_y