Big big update

This commit is contained in:
2026-03-07 17:25:11 +03:00
parent 95daf12fc5
commit 79898c42d6
22 changed files with 423 additions and 47 deletions

View File

@@ -4,7 +4,8 @@ local BLUE_COLOR = { 0.0, 0.0, 1.0, 1.0 }
local BLACK_COLOR = { 0.0, 0.0, 0.0, 1.0 }
local WHITE_COLOR = { 1.0, 1.0, 1.0, 1.0 }
local draw_test_hud = false
local draw_test_hud = true
local draw_example_test_hud = true
local draw_debug_string = false
local debug_string_text = ""
local debug_string_time = 0.0
@@ -15,14 +16,16 @@ function game_hud_draw( )
return
end
-- example of color
local color = { 0.5, 0.5, 0.1, 1.0 }
if draw_example_test_hud then
-- example of color
local color = { 0.5, 0.5, 0.1, 1.0 }
-- example of drawing
ui.draw_rect(100.0, 100.0, 400.0, 400.0, BLUE_COLOR)
ui.draw_image("data/textures/koshka1.jpg", 110.0, 110.0, 390.0, 390.0, WHITE_COLOR)
ui.draw_text("Hello, world!", 200.0, 200.0, GREEN_COLOR)
end
-- example of drawing
ui.draw_rect(150.0, 150.0, 350.0, 350.0, BLUE_COLOR)
ui.draw_image("data/textures/koshka1.jpg", 160.0, 160.0, 340.0, 340.0, WHITE_COLOR)
ui.draw_text("Hello, world!", 200.0, 200.0, GREEN_COLOR)
if g_player then
game_player_hud_draw()
end

View File

@@ -7,13 +7,13 @@ load_script("game_object.lua")
load_script("test_object.lua")
load_script("weapons/weapon_base.lua")
load_script("weapons/weapon_ump.lua")
load_script("actors/actor_base.lua")
load_script("actors/actor_player.lua")
load_script("triggers/trigger_deleter.lua")
-- глобальные переменные
g_player = nil
@@ -22,18 +22,24 @@ g_entity_table = {
-- Lua class -- CPP class -- Description
-- Actors
{ "actor_player", "ActorBase", "Player entity" },
{ "actor_player", "ActorBase", "Player entity" },
-- Weapons
{ "weapon_ump", "WeaponBase", "Weapon UMP" },
{ "weapon_ump", "WeaponBase", "Weapon UMP" },
-- Triggers
{ "trigger_deleter", "TriggerBase", "Example trigger" },
-- Simple entity
{ "test_object", "Entity", "Test entity" },
{ "test_object", "Entity", "Test entity" },
}
function sv_game_init( )
console.print("--- Game initialization ---")
end
function sv_on_game_start( )
console.print("Welcome to our Engine")
end

View File

@@ -0,0 +1,24 @@
-- тестовый класс
trigger_deleter = inherit_table(game_object)
function trigger_deleter:on_init()
game_object.on_init(self)
self:create_box_body(1.0, 1.0, 1.0, 0.0, 0.0, 0.0, true, false)
end
function trigger_deleter:on_shutdown()
game_object.on_shutdown(self)
end
function trigger_deleter:on_update(dt)
game_object.on_shutdown(self, dt)
end
function trigger_deleter:on_collide(other)
console.print(string.format("trigger_deleter:on_collide: %s", other:get_classname()))
put_debug_string_to_screen(string.format("trigger_deleter:on_collide: %s", other:get_classname()), 4)
-- FOR TEST
other:mark_for_delete()
end

View File

@@ -45,7 +45,8 @@ function weapon_base:on_fsm_state_update(dt)
-- проверка на стрельбу
if (self.m_state == WEAPON_FSM_STATE_ATTACK or
self.m_state == WEAPON_FSM_STATE_ATTACK2) and
self.m_state == WEAPON_FSM_STATE_ATTACK2 or
self.m_state == WEAPON_FSM_STATE_RELOAD) and
self.m_state_time >= self.m_end_state_time then
-- переходим в ожидание
@@ -113,6 +114,10 @@ function weapon_base:on_state_switch(state)
local anim_id = self:find_animation(fsm_state.anim)
self:play_animation(anim_id, fsm_state.anim_playback)
if fsm_state.anim_sound then
engine.play_sound(fsm_state.anim_sound)
end
end
function weapon_base:set_relative_position_to_camera( ent )

View File

@@ -17,14 +17,16 @@ weapon_ump.m_fsm[WEAPON_FSM_STATE_IDLE] = {
weapon_ump.m_fsm[WEAPON_FSM_STATE_ATTACK] = {
anim = "shoot1", -- имя анимации
anim_playback = ANIM_PLAYBACK_NONE,
anim_speed = 1.0 -- обычная скорость анимации
anim_speed = 1.0, -- обычная скорость анимации
anim_sound = "data/sounds/weapons/ump45_shoot.wav"
}
-- перезарядка
weapon_ump.m_fsm[WEAPON_FSM_STATE_RELOAD] = {
anim = "reload", -- имя анимации
anim_playback = ANIM_PLAYBACK_NONE,
anim_speed = 1.0 -- обычная скорость анимации
anim_speed = 1.0, -- обычная скорость анимации
anim_sound = "data/sounds/weapons/ump45_reload.wav"
}
function weapon_ump:on_init()