aboutsummaryrefslogtreecommitdiff
path: root/plugins/monster
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/monster')
-rw-r--r--plugins/monster/Makefile2
-rw-r--r--plugins/monster/dependencies.txt2
-rw-r--r--plugins/monster/monster.c49
3 files changed, 28 insertions, 25 deletions
diff --git a/plugins/monster/Makefile b/plugins/monster/Makefile
index 28edde8..5cffca3 100644
--- a/plugins/monster/Makefile
+++ b/plugins/monster/Makefile
@@ -1,4 +1,4 @@
-plugins/monster/monster.so: plugins/monster/monster.c plugins/game/game.h
+plugins/monster/monster.so: plugins/monster/monster.c plugins/game/game.h plugins/score/score.h
cc -g -shared -fpic -o plugins/monster/monster.so plugins/monster/monster.c
PLUGINS := ${PLUGINS} plugins/monster/monster.so
diff --git a/plugins/monster/dependencies.txt b/plugins/monster/dependencies.txt
new file mode 100644
index 0000000..3914551
--- /dev/null
+++ b/plugins/monster/dependencies.txt
@@ -0,0 +1,2 @@
+game
+score
diff --git a/plugins/monster/monster.c b/plugins/monster/monster.c
index 59fa380..02957da 100644
--- a/plugins/monster/monster.c
+++ b/plugins/monster/monster.c
@@ -1,8 +1,7 @@
#include <stdlib.h>
#include <stddef.h>
#include "../game/game.h"
-
-static struct entity monster;
+#include "../score/score.h"
struct monster_data
{
@@ -40,34 +39,36 @@ static void monster_death(struct entity *self)
self->remove = true;
}
+static struct entity monster_entity = {
+ .name = "monster",
+ .x = 0,
+ .y = 0,
+ .color = {0},
+ .use_color = false,
+ .texture = "👾",
+ .remove = false,
+ .meta = NULL,
+ .health = 5,
+ .max_health = 5,
+ .collide_with_entities = true,
+
+ .on_step = &monster_step,
+ .on_collide = NULL,
+ .on_collide_with_entity = &monster_collide_with_entity,
+ .on_spawn = &monster_spawn,
+ .on_remove = NULL,
+ .on_death = &monster_death,
+ .on_damage = NULL,
+};
+
+
static void spawn_monster(int x, int y)
{
- spawn(monster, x, y, NULL);
+ spawn(monster_entity, x, y, NULL);
}
__attribute__((constructor)) static void init()
{
- monster = (struct entity) {
- .name = "monster",
- .x = 0,
- .y = 0,
- .color = get_color("#FF00F6"),
- .texture = "👾",
- .remove = false,
- .meta = NULL,
- .health = 5,
- .max_health = 5,
- .collide_with_entities = true,
-
- .on_step = &monster_step,
- .on_collide = NULL,
- .on_collide_with_entity = &monster_collide_with_entity,
- .on_spawn = &monster_spawn,
- .on_remove = NULL,
- .on_death = &monster_death,
- .on_damage = NULL,
- };
-
register_air_function((struct generator_function) {
.chance = 50,
.callback = &spawn_monster,