taisei/src/enemy.h
laochailan bdc0db9957 merged Slave and Fairy to Enemy
To create a slave, pass ENEMY_IMMUNE for hp in create_enemy(). tip: create_enemyg(...) is an abbreviation for create_enemy(&global.enemies, ...).
There is something like a super fancy event system for Enemies' logic rules now: logic_rule will be called with t = negative special values like EVENT_BIRTH or EVENT_DEATH on corresponding events. cool, isn't it? well those values have to be filtered out (like if(t < 0) return;) if you don't use them so they don't do strange things with your locus.
2011-04-26 12:04:45 +02:00

54 lines
No EOL
1.1 KiB
C

/*
* This software is licensed under the terms of the MIT-License
* See COPYING for further information.
* ---
* Copyright (C) 2011, Lukas Weber <laochailan@web.de>
*/
#ifndef SLAVE_H
#define SLAVE_H
#include "animation.h"
#include <complex.h>
#include <stdarg.h>
struct Enemy;
typedef void (*EnemyLogicRule)(struct Enemy*, int t);
typedef EnemyLogicRule EnemyDrawRule;
enum {
ENEMY_IMMUNE = -9000,
};
typedef struct Enemy {
struct Enemy *next;
struct Enemy *prev;
long birthtime;
complex pos;
complex pos0;
int dir; // TODO: deprecate those
int moving;
EnemyLogicRule logic_rule;
EnemyDrawRule draw_rule;
int hp;
void *parent;
complex args[4];
} Enemy;
#define create_enemyg(drule, lrule, pos, hp, par, args) (create_enemy(&global.enemies, drule, lrule, pos, hp, par, args))
void create_enemy(Enemy **enemies, EnemyDrawRule draw_rule, EnemyLogicRule logic_rule,
complex pos, int hp, void *parent, complex args, ...);
void delete_enemy(Enemy **enemies, Enemy* enemy);
void draw_enemies(Enemy *enemies);
void free_enemies(Enemy **enemies);
void process_enemies(Enemy **enemies);
void Fairy(Enemy*, int t);
#endif