Added muzzle light and mesh to enemies

dev
Shariq Shah 5 years ago
parent 9b431e5d6c
commit 5ea0d73d3d
  1. 75
      assets/entities/turret.symtres
  2. BIN
      assets/models/quad.symbres
  3. BIN
      assets/textures/gui_skin.tga
  4. 3
      src/common/limits.h
  5. 2
      src/common/version.h
  6. 13
      src/game/editor.c
  7. 79
      src/game/enemy.c
  8. 1
      src/game/enemy.h
  9. 7
      src/game/entity.h
  10. 34
      src/game/gui_game.c
  11. 19
      src/game/gui_game.h
  12. 25
      src/game/player.c
  13. 1
      todo.txt

@ -5,26 +5,71 @@ Entity
pulsate_height : 1.5000
vision_range : 15.0000
pulsate_speed_scale : 0.1000
rotation : 0.000 0.000 0.000 1.000
rotation : 0.000 0.001 0.000 1.001
health : 116
alert_cooldown : 1.0000
color_alert : 1.000 1.000 0.000 1.000
active : true
muzzle_light_intensity_min : 1
turn_speed_when_targetting : 50.0000
max_yaw : 60.0000
position : 0.000 3.000 0.000
bounding_box_min : -0.500 -0.500 -0.500
flags : 1
enemy_type : 0
muzzle_light_intensity_max : 5
turn_speed_default : 50.0000
turn_direction_positive : true
attack_cooldown : 0.0500
name : Turret
bounding_box_max : 0.500 0.500 0.500
bounding_box_min : -1.000 -0.500 -1.000
muzzle_light_intensity_decay : 30
color_default : 0.000 1.000 1.000 1.000
hit_chance : 4
color_attack : 1.000 0.000 0.000 1.000
bounding_box_max : 1.000 1.000 1.000
damage : 10
}
Entity
{
type : 5
scale : 1.000 1.000 1.000
inner_angle : 50.0000
falloff : 1.5000
light_type : 0
depth_bias : 0.0005
rotation : 0.000 0.000 0.000 1.000
cast_shadow : false
intensity : 0.0000
color : 0.900 0.400 0.000
radius : 25.0000
position : 0.000 0.000 -1.000
flags : 1
outer_angle : 80.0000
name : Enemy_Muzzle_Light
bounding_box_min : -0.500 -0.500 -0.500
pcf_enabled : false
valid : true
bounding_box_max : 0.500 0.500 0.500
}
Entity
{
type : 6
scale : 0.000 0.000 0.000
material : 0
rotation : 0.707 0.000 0.000 0.707
diffuse_color : 0.900 0.400 0.000 1.000
geometry : muzzle_flash.symbres
specular : 1.0000
diffuse_texture : white.tga
diffuse : 6.0000
position : 0.000 -0.500 -1.000
flags : 1
specular_strength : 50.0000
name : Enemy_Muzzle_Light_Mesh
uv_scale : 1.000 1.000
}
Entity
{
type : 7
@ -34,16 +79,16 @@ Entity
rotation : 0.000 0.000 0.000 1.000
loop : false
sound_min_distance : 0.0000
active : true
paused : true
position : 0.000 0.000 0.000
bounding_box_min : -0.500 -0.500 -0.500
flags : 9
source_filename : sounds/bullet_1.wav
sound_type : 1
sound_max_distance : 30.0000
name : Turret_Weapon_Sound
bounding_box_max : 0.500 0.500 0.500
bounding_box_min : -0.500 -0.500 -0.500
sound_attenuation_type : 2
paused : true
bounding_box_max : 0.500 0.500 0.500
}
Entity
@ -55,16 +100,16 @@ Entity
rotation : 0.000 0.000 0.000 1.000
loop : true
sound_min_distance : 0.0000
active : true
paused : false
position : 0.000 0.000 0.000
bounding_box_min : -0.500 -0.500 -0.500
flags : 9
source_filename : sounds/windy_ambience.ogg
sound_type : 2
sound_max_distance : 30.0000
name : Turret_Ambient_Sound
bounding_box_max : 0.500 0.500 0.500
bounding_box_min : -0.500 -0.500 -0.500
sound_attenuation_type : 2
paused : true
bounding_box_max : 0.500 0.500 0.500
}
Entity
@ -73,13 +118,13 @@ Entity
scale : 1.000 1.000 1.000
material : 0
rotation : 0.000 0.000 0.000 1.000
diffuse_color : 0.055 0.863 0.839 1.000
diffuse_color : 0.000 1.000 1.000 1.000
geometry : suzanne.symbres
specular : 0.4000
active : true
diffuse_texture : default.tga
diffuse : 1.0000
position : 0.000 0.000 0.000
position : 0.000 0.242 0.000
flags : 9
specular_strength : 62.0000
name : Turret_Mesh
uv_scale : 0.300 0.200

Binary file not shown.

Binary file not shown.

@ -26,7 +26,8 @@
#define MAX_FRAME_TIME 0.5f
#define MAX_ENEMY_SOUND_SOURCES 2
#define MAX_ENEMY_MESHES 1
#define MAX_ENEMY_MESHES 2
#define MAX_ENEMY_LIGHTS 1
#define MAX_CONSOLE_MESSAGE_LEN 256
#define MAX_CONSOLE_MESSAGES 1024

@ -4,7 +4,7 @@
/* Auto generated version file. DO NOT MODIFY */
#define SYMMETRY_VERSION_MAJOR 0
#define SYMMETRY_VERSION_MINOR 2
#define SYMMETRY_VERSION_REVISION 362
#define SYMMETRY_VERSION_REVISION 363
#define SYMMETRY_VERSION_BRANCH "dev"
#endif

@ -1833,12 +1833,13 @@ void editor_window_property_inspector(struct nk_context* context, struct Editor*
if(nk_tree_push(context, NK_TREE_NODE, "Flags", NK_MINIMIZED))
{
nk_layout_row_dynamic(context, row_height, 1);
nk_checkbox_flags_label(context, "Active", &entity->flags, EF_ACTIVE);
nk_checkbox_flags_label(context, "Transient", &entity->flags, EF_TRANSIENT);
nk_checkbox_flags_label(context, "Hide in Editor", &entity->flags, EF_HIDE_IN_EDITOR_SCENE_HIERARCHY);
nk_checkbox_flags_label(context, "Skip Render", &entity->flags, EF_SKIP_RENDER);
nk_checkbox_flags_label(context, "Ignore Raycast", &entity->flags, EF_IGNORE_RAYCAST);
nk_checkbox_flags_label(context, "Ignore Collision", &entity->flags, EF_IGNORE_COLLISION);
nk_checkbox_flags_label(context, "Active", &entity->flags, EF_ACTIVE);
nk_checkbox_flags_label(context, "Transient", &entity->flags, EF_TRANSIENT);
nk_checkbox_flags_label(context, "Hide in Editor", &entity->flags, EF_HIDE_IN_EDITOR_SCENE_HIERARCHY);
nk_checkbox_flags_label(context, "Skip Render", &entity->flags, EF_SKIP_RENDER);
nk_checkbox_flags_label(context, "Ignore Raycast", &entity->flags, EF_IGNORE_RAYCAST);
nk_checkbox_flags_label(context, "Ignore Collision", &entity->flags, EF_IGNORE_COLLISION);
nk_checkbox_flags_label(context, "Disable Backface Cull", &entity->flags, EF_DISABLE_BACKFACE_CULL);
nk_tree_pop(context);
}

@ -12,6 +12,7 @@
#include "debug_vars.h"
#include "im_render.h"
#include "player.h"
#include "texture.h"
#include <string.h>
#include <math.h>
@ -32,13 +33,35 @@ void enemy_init(struct Enemy* enemy, int type)
enemy->base.type = ET_ENEMY;
enemy->type = type;
////Muzzle
//enemy->muzzle_light_intensity_min = 1.f;
//enemy->muzzle_light_intensity_max = 5.f;
//enemy->muzzle_light_intensity_decay = 30.f;
//
//vec3 translation = { 0.f, 0.f, -1.f };
//enemy->muzzle_light = scene_light_create(scene, "Enemy_Muzzle_Light", enemy, LT_SPOT);
//transform_translate(enemy->muzzle_light, &translation, TS_LOCAL);
//enemy->muzzle_light->intensity = 0.f;
//enemy->muzzle_light->radius = 25.f;
//enemy->muzzle_light->outer_angle = 80.f;
//enemy->muzzle_light->inner_angle = 50.f;
//vec3_fill(&enemy->muzzle_light->color, 0.9f, 0.4f, 0.f);
//enemy->muzzle_light_mesh = scene_static_mesh_create(scene, "Enemy_Muzzle_Light_Mesh", enemy, "muzzle_flash.symbres", MAT_BLINN);
//transform_translate(enemy->muzzle_light_mesh, &(vec3) {0.f, 0.f, -1.f}, TS_LOCAL);
//transform_rotate(enemy->muzzle_light_mesh, &UNIT_X, 90.f, TS_LOCAL);
//transform_scale(enemy->muzzle_light_mesh, &(vec3){0.f});
//enemy->muzzle_light_mesh->model.material_params[MMP_DIFFUSE_TEX].val_int = texture_create_from_file("white.tga", TU_DIFFUSE);
//enemy->muzzle_light_mesh->model.material_params[MMP_DIFFUSE].val_float = 6.f;
//vec4_fill(&enemy->muzzle_light_mesh->model.material_params[MMP_DIFFUSE_COL].val_vec4, 0.9f, 0.4f, 0.f, 1.f);
/* Initialization specific to each enemy type */
switch(enemy->type)
{
case ENEMY_TURRET:
{
enemy->health = 100;
enemy->damage = 10;
enemy->damage = 20;
enemy->Turret.yaw_direction_positive = true;
enemy->Turret.scan = false;
enemy->Turret.turn_speed_default = 50.f;
@ -56,6 +79,7 @@ void enemy_init(struct Enemy* enemy, int type)
enemy->Turret.time_elapsed_since_alert = 0.f;
enemy->Turret.time_elapsed_since_attack = 0.f;
enemy->Turret.vision_range = 15.f;
enemy->hit_chance = 4;
}
break;
default:
@ -89,6 +113,22 @@ void enemy_static_mesh_set(struct Enemy* enemy, const char* geometry_filename, i
void enemy_update(struct Enemy* enemy, struct Scene* scene, float dt)
{
if(enemy->muzzle_light->intensity > 0.f)
{
enemy->muzzle_light->intensity -= enemy->muzzle_light_intensity_decay * dt;
if(enemy->muzzle_light->intensity < 0.f)
enemy->muzzle_light->intensity = 0.f;
}
if(enemy->muzzle_light_mesh->base.transform.scale.x > 0.f)
{
enemy->muzzle_light_mesh->base.transform.scale.x -= enemy->muzzle_light_intensity_decay * dt;
enemy->muzzle_light_mesh->base.transform.scale.y -= enemy->muzzle_light_intensity_decay * dt;
enemy->muzzle_light_mesh->base.transform.scale.z -= enemy->muzzle_light_intensity_decay * dt;
transform_update_transmat(enemy->muzzle_light_mesh);
}
// AI Update
static float enemy_update_interval = 1.f / 60.f;
static float time_elapsed_since_last_update = 0.f;
@ -139,8 +179,12 @@ struct Enemy* enemy_read(struct Parser_Object* object, const char* name, struct
new_enemy = scene_enemy_create(scene, name, parent_entity, enemy_type); // Create enemy with default values then read and update from file if necessary
if(!new_enemy)
return new_enemy;
if(hashmap_value_exists(object->data, "health")) new_enemy->health = hashmap_int_get(object->data, "health");
if(hashmap_value_exists(object->data, "damage")) new_enemy->damage = hashmap_int_get(object->data, "damage");
if(hashmap_value_exists(object->data, "health")) new_enemy->health = hashmap_int_get(object->data, "health");
if(hashmap_value_exists(object->data, "damage")) new_enemy->damage = hashmap_int_get(object->data, "damage");
if(hashmap_value_exists(object->data, "hit_chance")) new_enemy->hit_chance = hashmap_int_get(object->data, "hit_chance");
if(hashmap_value_exists(object->data, "muzzle_light_intensity_decay")) new_enemy->muzzle_light_intensity_decay = hashmap_float_get(object->data, "muzzle_light_intensity_decay");
if(hashmap_value_exists(object->data, "muzzle_light_intensity_min")) new_enemy->muzzle_light_intensity_min = hashmap_int_get(object->data, "muzzle_light_intensity_min");
if(hashmap_value_exists(object->data, "muzzle_light_intensity_max")) new_enemy->muzzle_light_intensity_max = hashmap_int_get(object->data, "muzzle_light_intensity_max");
switch(new_enemy->type)
{
@ -169,6 +213,10 @@ void enemy_write(struct Enemy* enemy, struct Hashmap* entity_data)
hashmap_int_set(entity_data, "enemy_type", enemy->type);
hashmap_int_set(entity_data, "health", enemy->health);
hashmap_int_set(entity_data, "damage", enemy->damage);
hashmap_int_set(entity_data, "hit_chance", enemy->hit_chance);
hashmap_int_set(entity_data, "muzzle_light_intensity_decay", enemy->muzzle_light_intensity_decay);
hashmap_int_set(entity_data, "muzzle_light_intensity_min", enemy->muzzle_light_intensity_min);
hashmap_int_set(entity_data, "muzzle_light_intensity_max", enemy->muzzle_light_intensity_max);
switch(enemy->type)
{
@ -198,9 +246,12 @@ void enemy_on_scene_loaded(struct Event* event, void* enemy_ptr)
// Assign pointers to static_mesh and sound_source child entities
struct Entity* enemy_mesh[MAX_ENEMY_MESHES] = { NULL };
struct Entity* enemy_sound_sources[MAX_ENEMY_SOUND_SOURCES] = { NULL };
struct Entity* enemy_lights[MAX_ENEMY_LIGHTS] = { NULL };
if(entity_get_num_children_of_type(enemy, ET_STATIC_MESH, &enemy_mesh, MAX_ENEMY_MESHES) == MAX_ENEMY_MESHES)
{
enemy->mesh = enemy_mesh[0];
enemy->muzzle_light_mesh = enemy_mesh[0];
enemy->mesh = enemy_mesh[1];
}
else
{
@ -217,6 +268,11 @@ void enemy_on_scene_loaded(struct Event* event, void* enemy_ptr)
log_error("enemy:on_scene_load", "Could not find %d child sound source entities for enemy %s", MAX_ENEMY_SOUND_SOURCES, enemy->base.name);
}
if(entity_get_num_children_of_type(enemy, ET_LIGHT, &enemy_lights, MAX_ENEMY_LIGHTS) == MAX_ENEMY_LIGHTS)
enemy->muzzle_light = enemy_lights[0];
else
log_error("enemy:on_scene_load", "Could not find %d child light entities for enemy %s", MAX_ENEMY_LIGHTS, enemy->base.name);
// Do other post-scene-load initialization stuff per enemy type here
switch(enemy->type)
{
@ -384,9 +440,12 @@ void enemy_update_ai_turret(struct Enemy* enemy, struct Game_State* game_state,
{
enemy->Turret.time_elapsed_since_attack = 0.f;
sound_source_play(game_state->sound, enemy->weapon_sound);
enemy->muzzle_light->intensity = enemy->muzzle_light_intensity_min + rand() % enemy->muzzle_light_intensity_max;
transform_scale(enemy->muzzle_light_mesh, &(vec3){1.f, 1.f, 1.f});
int hit_chance = 4;
int roll = rand() % 10;
if(roll <= hit_chance)
if(roll <= enemy->hit_chance)
{
player_apply_damage(&scene->player, enemy);
}
@ -458,3 +517,13 @@ void enemy_state_set_turret(struct Enemy* enemy, int state)
break;
}
}
void enemy_apply_damage(struct Enemy* enemy, int damage)
{
enemy->health -= damage;
vec4_fill(&enemy->mesh->model.material_params[MMP_DIFFUSE_COL].val_vec4, 0.7f, 0.3f, 0.1f, 1.f);
if(enemy->health <= 0)
{
scene_enemy_remove(game_state_get()->scene, enemy);
}
}

@ -24,5 +24,6 @@ struct Enemy* enemy_read(struct Parser_Object* object, const char* name, struct
void enemy_write(struct Enemy* enemy, struct Hashmap* entity_data);
void enemy_weapon_sound_set(struct Enemy* enemy, const char* sound_filename, int type);
void enemy_static_mesh_set(struct Enemy* enemy, const char* geometry_filename, int material_type);
void enemy_apply_damage(struct Enemy* enemy, int damage);
#endif

@ -219,6 +219,7 @@ struct Player
int weapon_light_intensity_max;
float weapon_light_intensity_decay;
int health;
int damage;
int key_mask;
float move_speed;
float move_speed_multiplier;
@ -237,7 +238,13 @@ struct Enemy
int type;
int health;
int damage;
int hit_chance;
int current_state;
float muzzle_light_intensity_decay;
int muzzle_light_intensity_min;
int muzzle_light_intensity_max;
struct Static_Mesh* muzzle_light_mesh;
struct Light* muzzle_light;
struct Static_Mesh* mesh;
struct Sound_Source* weapon_sound;
struct Sound_Source* ambient_sound;

@ -25,11 +25,12 @@ void gui_game_init(struct Game_Gui* game_gui)
game_gui->show_next_level_dialog = false;
game_gui->show_restart_level_dialog = false;
game_gui->skin.skin_texture = texture_create_from_file("gui_skin.tga", TU_DIFFUSE);
game_gui->skin.button = nk_subimage_id(game_gui->skin.skin_texture, SKIN_TEXTURE_WIDTH, SKIN_TEXTURE_HEIGHT, nk_recti(32, 32, 128, 48));
game_gui->skin.button_active = nk_subimage_id(game_gui->skin.skin_texture, SKIN_TEXTURE_WIDTH, SKIN_TEXTURE_HEIGHT, nk_recti(32, 32, 128, 48));
game_gui->skin.button_hover = nk_subimage_id(game_gui->skin.skin_texture, SKIN_TEXTURE_WIDTH, SKIN_TEXTURE_HEIGHT, nk_recti(32, 32, 128, 48));
game_gui->skin.hp = nk_subimage_id(game_gui->skin.skin_texture, SKIN_TEXTURE_WIDTH, SKIN_TEXTURE_HEIGHT, nk_recti(32, 0, 32, 32));
game_gui->skin.key = nk_subimage_id(game_gui->skin.skin_texture, SKIN_TEXTURE_WIDTH, SKIN_TEXTURE_HEIGHT, nk_recti(0, 32, 32, 32));
game_gui->skin.button = nk_subimage_id(game_gui->skin.skin_texture, SKIN_TEXTURE_WIDTH, SKIN_TEXTURE_HEIGHT, nk_recti(32, 32, 128, 48));
game_gui->skin.button_active = nk_subimage_id(game_gui->skin.skin_texture, SKIN_TEXTURE_WIDTH, SKIN_TEXTURE_HEIGHT, nk_recti(32, 32, 128, 48));
game_gui->skin.button_hover = nk_subimage_id(game_gui->skin.skin_texture, SKIN_TEXTURE_WIDTH, SKIN_TEXTURE_HEIGHT, nk_recti(32, 32, 128, 48));
game_gui->skin.hp = nk_subimage_id(game_gui->skin.skin_texture, SKIN_TEXTURE_WIDTH, SKIN_TEXTURE_HEIGHT, nk_recti(32, 0, 32, 32));
game_gui->skin.key = nk_subimage_id(game_gui->skin.skin_texture, SKIN_TEXTURE_WIDTH, SKIN_TEXTURE_HEIGHT, nk_recti(0, 32, 32, 32));
game_gui->skin.crosshair = nk_subimage_id(game_gui->skin.skin_texture, SKIN_TEXTURE_WIDTH, SKIN_TEXTURE_HEIGHT, nk_recti(112, 0, 32, 32));
struct nk_context* context = &game_gui->gui->context;
context->style.button.normal = nk_style_item_image(game_gui->skin.button);
@ -38,9 +39,8 @@ void gui_game_init(struct Game_Gui* game_gui)
context->style.window.border_color = nk_rgba_f(0.f, 0.f, 0.f, 1.f);
context->style.window.background = nk_rgba_f(0.f, 0.f, 0.f, 1.f);
context->style.window.fixed_background = nk_style_item_image(nk_subimage_id(game_gui->skin.skin_texture,
SKIN_TEXTURE_WIDTH, SKIN_TEXTURE_HEIGHT,
nk_recti(32, 32, 128, 48)));
game_gui->skin.hud_background = nk_style_item_image(nk_subimage_id(game_gui->skin.skin_texture, SKIN_TEXTURE_WIDTH, SKIN_TEXTURE_HEIGHT, nk_recti(32, 32, 128, 48)));
game_gui->skin.menu_background = nk_style_item_color(nk_rgba_f(0.2f, 0.2f, 0.2f, 0.6f));
//context->style.window.fixed_background = nk_style_item_color(nk_rgba_f(0.f, 0.f, 0.f, 0.05f));
gui_font_set(game_gui->gui, "6809_chargen.ttf", 30.f);
@ -69,6 +69,7 @@ void gui_game_update(struct Game_Gui* game_gui, float dt)
if(game_state->game_mode == GAME_MODE_GAME)
{
// HUD
context->style.window.fixed_background = game_gui->skin.hud_background;
const float key_opacity_full = 1.f;
const float key_opacity_reduced = 0.3f;
int hud_offset_x = 50;
@ -101,6 +102,18 @@ void gui_game_update(struct Game_Gui* game_gui, float dt)
nk_end(context);
}
int crosshair_width = 50;
int crosshair_height = 32;
int crosshair_x = (display_width / 2) - (crosshair_width / 2);
int crosshair_y = (display_height / 2) - (crosshair_height / 2);
context->style.window.fixed_background = nk_style_item_hide();
if(nk_begin(context, "Crosshair", nk_recti(crosshair_x, crosshair_y, crosshair_width, crosshair_height), NK_WINDOW_BACKGROUND | NK_WINDOW_NO_SCROLLBAR))
{
nk_layout_row_dynamic(context, crosshair_height, 1);
nk_image_color(context, game_gui->skin.crosshair, nk_rgba_f(1.f, 1.f, 1.f, 0.3f));
nk_end(context);
}
if(game_gui->show_next_level_dialog)
gui_game_next_level_dialog(context);
@ -161,6 +174,7 @@ void gui_game_show_door_locked_dialog(struct Game_Gui* game_gui, struct Door* do
if(nk_begin(context, "Key Needed Gui", nk_recti(key_needed_gui_x, key_needed_gui_y, key_needed_gui_width, key_needed_gui_height), NK_WINDOW_BACKGROUND | NK_WINDOW_NO_SCROLLBAR))
{
context->style.window.fixed_background = game_gui->skin.menu_background;
nk_layout_row_begin(context, NK_DYNAMIC, 40, keys_needed + 2);
nk_layout_row_push(context, starting_ratio);
nk_label(context, "YOU NEED THE", label_flags);
@ -193,6 +207,7 @@ void gui_game_show_door_locked_dialog(struct Game_Gui* game_gui, struct Door* do
void gui_game_pause_menu(struct nk_context* context)
{
struct Game_State* game_state = game_state_get();
struct Game_Gui* game_gui = game_state->gui_game;
int row_height = 30;
int popup_x = 0;
int popup_y = 0;
@ -208,6 +223,7 @@ void gui_game_pause_menu(struct nk_context* context)
int background_window_flags = NK_WINDOW_BACKGROUND;
if(nk_begin(context, "Pause Gui", nk_rect(0, 0, display_width, display_height), background_window_flags))
{
context->style.window.fixed_background = game_gui->skin.menu_background;
nk_window_set_focus(context, "Pause Gui");
if(nk_popup_begin(context, NK_POPUP_DYNAMIC, "Game Paused", popup_flags, nk_recti(popup_x, popup_y, popup_width, popup_height)))
{
@ -254,6 +270,7 @@ static void gui_game_next_level_dialog(struct nk_context* context)
int background_window_flags = NK_WINDOW_BACKGROUND;
if(nk_begin(context, "Scene Cleared", nk_rect(0, 0, display_width, display_height), background_window_flags))
{
context->style.window.fixed_background = game_gui->skin.menu_background;
nk_window_set_focus(context, "Scene Cleared");
if(nk_popup_begin(context, NK_POPUP_DYNAMIC, "Scene Cleared!", popup_flags, nk_recti(popup_x, popup_y, popup_width, popup_height)))
{
@ -314,6 +331,7 @@ static void gui_game_restart_level_dialog(struct nk_context* context)
int background_window_flags = NK_WINDOW_BACKGROUND;
if(nk_begin(context, "Player Died Gui", nk_rect(0, 0, display_width, display_height), background_window_flags))
{
context->style.window.fixed_background = game_gui->skin.menu_background;
nk_window_set_focus(context, "Player Died Gui");
if(nk_popup_begin(context, NK_POPUP_DYNAMIC, "You Died", popup_flags, nk_recti(popup_x, popup_y, popup_width, popup_height)))
{

@ -11,14 +11,17 @@ struct Game_Gui
struct
{
int skin_texture;
struct nk_image button;
struct nk_image button_hover;
struct nk_image button_active;
struct nk_image check;
struct nk_image check_cursor;
struct nk_image hp;
struct nk_image key;
int skin_texture;
struct nk_image button;
struct nk_image button_hover;
struct nk_image button_active;
struct nk_image check;
struct nk_image check_cursor;
struct nk_image hp;
struct nk_image key;
struct nk_image crosshair;
struct nk_style_item hud_background;
struct nk_style_item menu_background;
} skin;
};

@ -19,6 +19,7 @@
#include "entity.h"
#include "gui_game.h"
#include "texture.h"
#include "enemy.h"
#include <float.h>
#include <string.h>
@ -53,6 +54,7 @@ void player_init(struct Player* player, struct Scene* scene)
player->weapon_light_intensity_min = 1.f;
player->weapon_light_intensity_max = 5.f;
player->weapon_light_intensity_decay = 30.f;
player->damage = 25;
player->body_mesh = scene_static_mesh_create(scene, "Player_Body_Mesh", player, "sphere.symbres", MAT_BLINN);
@ -83,6 +85,7 @@ void player_init(struct Player* player, struct Scene* scene)
player->muzzle_flash_mesh = scene_static_mesh_create(scene, "Player_Muzzle_Flash_Mesh", player_camera, "muzzle_flash.symbres", MAT_BLINN);
transform_translate(player->muzzle_flash_mesh, &(vec3) {0.f, -0.3f, -2.75f}, TS_LOCAL);
transform_rotate(player->muzzle_flash_mesh, &UNIT_X, 90.f, TS_LOCAL);
transform_scale(player->muzzle_flash_mesh, &(vec3){0.f});
player->muzzle_flash_mesh->model.material_params[MMP_DIFFUSE_TEX].val_int = texture_create_from_file("white.tga", TU_DIFFUSE);
player->muzzle_flash_mesh->model.material_params[MMP_DIFFUSE].val_float = 6.f;
vec4_fill(&player->muzzle_flash_mesh->model.material_params[MMP_DIFFUSE_COL].val_vec4, 0.9f, 0.4f, 0.f, 1.f);
@ -257,9 +260,6 @@ void player_update_physics(struct Player* player, struct Scene* scene, float fix
vec3 norm_scaled = { 0.f };
vec3_scale(&normal, &normal, dot);
vec3_sub(&move_direction, &move_direction, &normal);
debug_vars_show_vec3("Normal", &normal);
debug_vars_show_vec3("Dir", &move_direction);
debug_vars_show_float("Dot", dot);
}
}
}
@ -376,7 +376,12 @@ void player_on_mousebutton_released(const struct Event* event)
half_height /= 2;
struct Ray bullet_ray = camera_screen_coord_to_ray(player->camera, half_width, half_height);
struct Entity* colliding_entity = scene_ray_intersect_closest(scene, &bullet_ray, ERM_STATIC_MESH);
struct Entity* colliding_entity = scene_ray_intersect_closest(scene, &bullet_ray, ERM_ENEMY);
int intensity = player->weapon_light_intensity_min + rand() % player->weapon_light_intensity_max;
player->weapon_light->intensity = intensity;
transform_scale(player->muzzle_flash_mesh, &(vec3){1.f, 1.f, 1.f});
sound_source_play(game_state->sound, player->weapon_sound);
if(!colliding_entity || colliding_entity == player->body_mesh)
return;
@ -384,18 +389,14 @@ void player_on_mousebutton_released(const struct Event* event)
float distance = bv_distance_ray_bounding_box(&bullet_ray, &colliding_entity->derived_bounding_box);
if(distance > 0.f)
{
vec3 collision_point = bullet_ray.direction;
vec3_scale(&collision_point, &collision_point, distance);
vec3_add(&collision_point, &collision_point, &bullet_ray.origin);
//vec3 collision_point = bullet_ray.direction;
//vec3_scale(&collision_point, &collision_point, distance);
//vec3_add(&collision_point, &collision_point, &bullet_ray.origin);
//struct Static_Mesh* bullet = scene_static_mesh_create(game_state_get()->scene, "bullet", NULL, "cube.symbres", MAT_UNSHADED);
//struct Light* bullet = entity_load("Spot", DIRT_INSTALL, true);
//if(bullet) transform_set_position(bullet, &collision_point);
enemy_apply_damage((struct Enemy*)colliding_entity, player->damage);
}
int intensity = player->weapon_light_intensity_min + rand() % player->weapon_light_intensity_max;
player->weapon_light->intensity = intensity;
transform_scale(player->muzzle_flash_mesh, &(vec3){1.f, 1.f, 1.f});
sound_source_play(game_state->sound, player->weapon_sound);
}
}

@ -3,6 +3,7 @@ Todo:
- Don't save parent entity's transform when saving entity archetype. Only save the transformation values for children
- Enemies getting hit by bullets
- Add weapon flash, muzzle mesh to turrets
- Add collision-only entities that can be used to manually approximate collision mesh for an entity
- Save case sensitive file names when scene entity entries
- Disbale all player actions when scene cleared dialog or scene restart dialog are active
- Memory utils that provide allocation tracking

Loading…
Cancel
Save