beginning...
This commit is contained in:
40
src/game/ecs/entity/play/entity_player.c
Normal file
40
src/game/ecs/entity/play/entity_player.c
Normal file
@ -0,0 +1,40 @@
|
||||
#include "entity_player.h"
|
||||
|
||||
/* Initializes a player entity. */
|
||||
void
|
||||
entity_player_init(ECS* ecs, u32 id, vec3 position)
|
||||
{
|
||||
ComponentGameObject* gameObject;
|
||||
ComponentControlMove* controlMove;
|
||||
ComponentShoot* shoot;
|
||||
|
||||
gameObject = ecs_component_add(ecs, ECS_COMPONENT_GAME_OBJECT, id);
|
||||
controlMove = ecs_component_add(ecs, ECS_COMPONENT_CONTROL_MOVE, id);
|
||||
shoot = ecs_component_add(ecs, ECS_COMPONENT_SHOOT, id);
|
||||
|
||||
ecs_component_add(ecs, ECS_COMPONENT_CONTROL_SHOOT, id);
|
||||
|
||||
component_game_object_init
|
||||
(
|
||||
gameObject,
|
||||
ecs,
|
||||
ecs->game->resources.textures[TEXTURE_PLAYER],
|
||||
SHADER_TEXTURE_QUAD,
|
||||
ORIGIN_CENTER,
|
||||
(f32*)PLAYER_SIZE,
|
||||
position,
|
||||
(f32*)COLOR_OPAQUE,
|
||||
PLAYER_FRICTION,
|
||||
PLAYER_VELOCITY_MAX
|
||||
);
|
||||
|
||||
component_control_move_init(controlMove, PLAYER_SPEED);
|
||||
|
||||
component_shoot_init
|
||||
(
|
||||
shoot,
|
||||
(EntityGameObjectInit)entity_snake_init,
|
||||
PLAYER_SHOOT_SPEED,
|
||||
PLAYER_SHOOT_OFFSET
|
||||
);
|
||||
}
|
19
src/game/ecs/entity/play/entity_player.h
Normal file
19
src/game/ecs/entity/play/entity_player.h
Normal file
@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
#include "../../ecs_component.h"
|
||||
#include "../../component/component_game_object.h"
|
||||
#include "../../component/component_control_move.h"
|
||||
#include "../../component/component_control_shoot.h"
|
||||
#include "../../component/component_shoot.h"
|
||||
#include "../../component/component_lifetime.h"
|
||||
|
||||
#include "entity_snake.h"
|
||||
|
||||
#define PLAYER_SPEED 0.85
|
||||
#define PLAYER_FRICTION 0.9
|
||||
#define PLAYER_VELOCITY_MAX 6
|
||||
#define PLAYER_SHOOT_SPEED 5
|
||||
#define PLAYER_SHOOT_OFFSET 32
|
||||
static const vec2 PLAYER_SIZE = {50.0f, 100.0f};
|
||||
|
||||
void entity_player_init(ECS* ecs, u32 id, vec3 position);
|
24
src/game/ecs/entity/play/entity_snake.c
Normal file
24
src/game/ecs/entity/play/entity_snake.c
Normal file
@ -0,0 +1,24 @@
|
||||
#include "entity_snake.h"
|
||||
|
||||
/* Initializes a snake entity. */
|
||||
void
|
||||
entity_snake_init(ECS* ecs, u32 id, vec3 position)
|
||||
{
|
||||
ComponentGameObject* gameObject;
|
||||
|
||||
gameObject = ecs_component_add(ecs, ECS_COMPONENT_GAME_OBJECT, id);
|
||||
|
||||
component_game_object_init
|
||||
(
|
||||
gameObject,
|
||||
ecs,
|
||||
ecs->game->resources.textures[TEXTURE_SNAKE],
|
||||
SHADER_TEXTURE_QUAD,
|
||||
ORIGIN_CENTER,
|
||||
(f32*)SNAKE_SIZE,
|
||||
position,
|
||||
(f32*)COLOR_OPAQUE,
|
||||
SNAKE_FRICTION,
|
||||
SNAKE_VELOCITY_MAX
|
||||
);
|
||||
}
|
11
src/game/ecs/entity/play/entity_snake.h
Normal file
11
src/game/ecs/entity/play/entity_snake.h
Normal file
@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "../../ecs_component.h"
|
||||
#include "../../component/component_game_object.h"
|
||||
|
||||
#define SNAKE_SPEED 1
|
||||
#define SNAKE_FRICTION 1
|
||||
#define SNAKE_VELOCITY_MAX 50
|
||||
static const vec2 SNAKE_SIZE = {25.0f, 25.0f};
|
||||
|
||||
void entity_snake_init(ECS* ecs, u32 id, vec3 position);
|
Reference in New Issue
Block a user