Mirai's Miscellaneous Misadventures

M41 / include / mimimi / sprites.h

// copyright 2023 zamfofex
// license: AGPLv3 or later

#ifndef MIMIMI_SPRITES_H
#define MIMIMI_SPRITES_H

struct mimimi_behavior;
struct mimimi_allocator;
struct mimimi_ground;
struct mimimi_position;

struct mimimi_physics
{
	int dx, dy;
	unsigned char airborne;
	int width, height;
	int gravity;
};

struct mimimi_life
{
	int knocked_time;
	int immunity_time;
	int pristinity;
	int max_pristinity;
	int recovery_time;
};

struct mimimi_fall
{
	int max_speed;
	int knocked_time;
};

struct mimimi_walk
{
	int ground_speed;
	int airborne_speed;
	int direction;
};

struct mimimi_jump
{
	int strength;
};

struct mimimi_dash
{
	int x_strength;
	int y_strength;
};

struct mimimi_path_finding
{
	struct mimimi_ground *ground;
	struct mimimi_position *target;
	struct mimimi_sprite *sprite;
	struct mimimi_jump *jump;
	struct mimimi_behavior *jump_behavior;
	int radius;
};

struct mimimi_sprite
{
	struct mimimi_position *position;
	struct mimimi_physics *physics;
	struct mimimi_life *life;
	struct mimimi_fall *fall;
	struct mimimi_walk *walk;
	struct mimimi_behavior *behavior;
	unsigned char awake;
};

struct mimimi_behavior *mimimi_physics(struct mimimi_physics *physics, struct mimimi_position *position, struct mimimi_ground *ground, struct mimimi_allocator *allocator);
struct mimimi_behavior *mimimi_collision_physics(struct mimimi_physics *physics, struct mimimi_position *position, struct mimimi_ground *ground, struct mimimi_allocator *allocator);
struct mimimi_behavior *mimimi_dynamics(struct mimimi_physics *physics, struct mimimi_position *position, struct mimimi_allocator *allocator);

struct mimimi_behavior *mimimi_life(struct mimimi_life *life, struct mimimi_allocator *allocator);
struct mimimi_behavior *mimimi_fall(struct mimimi_fall *fall, struct mimimi_physics *physics, struct mimimi_life *life, struct mimimi_allocator *allocator);
struct mimimi_behavior *mimimi_walk(struct mimimi_walk *walk, struct mimimi_physics *physics, struct mimimi_allocator *allocator);

struct mimimi_behavior *mimimi_positioned_physics(struct mimimi_physics *physics, struct mimimi_position *position, struct mimimi_ground *ground, struct mimimi_position *transform, struct mimimi_allocator *allocator);

struct mimimi_behavior *mimimi_jump(struct mimimi_jump *jump, struct mimimi_physics *physics, struct mimimi_allocator *allocator);
struct mimimi_behavior *mimimi_dash(struct mimimi_dash *dash, struct mimimi_physics *physics, struct mimimi_walk *walk, struct mimimi_allocator *allocator);

struct mimimi_behavior *mimimi_find_path(struct mimimi_path_finding *path_finding, struct mimimi_ground *ground, struct mimimi_position *target, struct mimimi_sprite *sprite, struct mimimi_allocator *allocator);

struct mimimi_behavior *mimimi_conveyor(struct mimimi_sprite *sprite, struct mimimi_ground *ground, unsigned char which, int speed, struct mimimi_allocator *allocator);
struct mimimi_behavior *mimimi_trampoline(struct mimimi_sprite *sprite, struct mimimi_ground *ground, unsigned char which, int restitution, struct mimimi_allocator *allocator);

#endif