aboutsummaryrefslogtreecommitdiff
path: root/src/entities/soldato.c
blob: f19faa73cf715fe77ffda74fe68f94e91fd14793 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "soldato.h"
#include "game.h"

void initSoldato(Entity * entity, Game * game) {
	entity->model = &game->assets.models[SOLDATO_ASSET];
}

void closeSoldato(Entity * entity) {
}

void updateSoldato(Game * game, Entity * entity) {
	Entity * player = getEntityFromWorld(game->world, 0);

	// Get direction.
	Vector3 direction = Vector3Subtract(entity->position, player->position);
	direction = Vector3Normalize(direction);

	// Get look at and rotation.
	Matrix matrix = MatrixLookAt(Vector3Zero(), direction, (Vector3){0, 1, 0});
	Quaternion rotation = QuaternionFromMatrix(matrix);
	rotation = QuaternionInvert(rotation);

	entity->rotation = rotation;

	entity->velocity.velocity = Vector3Scale(direction, -10.0);
	entityUpdatePosition(entity);
}

void drawSoldato(Game * game, Entity * entity) {
	entityDraw(entity);
}