module Sprite: sig endtype 'a t
type 'a set
type ('a, 'b) table
Sprites
|
val create : ?set:'a set -> 'a -> Video.t -> ?width:int -> int * int -> 'a tcreate ?set data frames ?width position Creates a sprite with frames
from the given surface.val move_to : 'a t -> int * int -> unitmove_to sprite (x, y) Sets the position of sprite to (x, y)val move : 'a t -> int * int -> unitmove sprite (dx, dy) moves sprite spr by (dx, dy)val get_pos : 'a t -> int * intget_pos spritespriteval set_data : 'a t -> 'a -> unitset_data sprite data sets the data of sprite to dataval get_data : 'a t -> 'aget_data sprite returns the data of spriteval get_size : 'a t -> int * intget_size sprite returns the size of spriteval delete : 'a t -> unitdelete sprite removes sprite from all sets it belong to
Sprite sets
|
module Set: sig end
Collision
|
val add_collision_fun : 'a set ->
'b set ->
?alpha_bias:int -> bool -> ('a t -> 'b t -> unit) -> unitadd_collison_fun set1 set2 per_pixel collision_fun
adds collision_fun to the list of functions called when a sprite from
set1 collides with any from set2Log.fatal when Sprite.Set.set_collision was not called for any of
any of the given sets.alpha_bias : see Sprite.collides_withper_pixel : if set to true per_pixel collision will be checkedval check_collisions : 'a t -> unitcheck_collisions sprite finds all objects that sprite collides with
all sets that were registered for collision with the sets sprite belongs
to. For every collision it calls the apropriate function registered by
Sprite.add_collision_funval collides_with : 'a t -> ?alpha_bias:int -> bool -> 'b set -> 'b t listcollides_with spr per_pixel set returns the list of all sprites from
set that collide with spralpha_bias : is an optional parameter, that for surfaces with alpha
channel means what sum of alpha values hast to be overcomed for collision
to be detected. The default is 255 (collision when sum is over 255),
while maximum for any surface is 255.
If per_pixel is true per pixel collision will be checked
World boundary
|
val in_bounds : 'a t -> boolin_bounds sprite checks if the sprite is ouside of world in any of the
sets it belongs toval move_in_bounds : 'a t -> ?chk:('a t -> bool) -> int * int -> int * intmove_in_bounds sprites (dx, dy) moves sprite as far as possible so that
it remains in bounds
Drawing
|
val draw : ?on:Video.t -> 'a t -> unitdraw cnt sprite draws sprite spr on context cnt. cnt is optionalval set_animation_frame : 'a t -> int -> unitset_animation_frame sprite frame_num Sets the frame displayed by sprite
to frame_num picture on the image. If wrong frame number is specified
an error message is shown on the console.val get_animation_frame : 'a t -> intget_animation_frame spritespriteval set_frames : 'a t -> ?width:int -> Video.t -> unitval get_frames : 'a t -> Video.tval mask_cut : 'a t -> 'b t -> int -> unitmask_cut from_where cut_what alpha_bias cuts all pixel's from
from_where where cut_what has alpha bigger than alpha_biasmodule Table: sig end