class Tsh::PlayThing

Overview

The generic class for anything in the engine

Defined in:

plaything.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new #

def self.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 Detail

def angle : Float32 #

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


def angle=(angle : Float32) #

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


def collision_flags : CollisionFlags #

The flags to use for collision detection


def collision_flags=(collision_flags : CollisionFlags) #

The flags to use for collision detection


def destroy #

Destroys a plaything (No more displaying or collision calls)


def flags : Flags #

The flags for the plaything


def flags=(flags : Flags) #

The flags for the plaything


def flipbook : Flipbook #

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


def flipbook=(flipbook : Flipbook) #

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


def move(x : Int, y : Int) #

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


def on_collide : Proc(PlayThing, PlayThing, Nil) #

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


def on_collide=(on_collide : Proc(PlayThing, PlayThing, Nil)) #

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


def on_collide_end : Proc(PlayThing, PlayThing, Nil) #

Called once when an overlap stops


def on_collide_end=(on_collide_end : Proc(PlayThing, PlayThing, Nil)) #

Called once when an overlap stops


def on_collide_start : Proc(PlayThing, PlayThing, Nil) #

Called once when an overlap starts


def on_collide_start=(on_collide_start : Proc(PlayThing, PlayThing, Nil)) #

Called once when an overlap starts


def right_vector : Raylib::Vector2 #

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


def rotate(rot : Float32) #

Rotates in rot direction, going clockwise


def sprite : Int32 #

The sprite to display from sprites


def sprite=(sprite : Int32) #

Sets the current sprite number in sprites to display


def sprites : Array(Sprite) #

An array of all sprites for the PlayThing to display


def unmove #

Sets the position to the previous x and y values


def up_vector : Raylib::Vector2 #

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


def x : UInt32 #

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


def x=(x : Int) #

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


def y : UInt32 #

def y=(y : Int) #

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