10 enemies in demo

This commit is contained in:
h4570
2022-08-12 23:40:26 +02:00
parent 2054dba4ec
commit 8829bf3035
23 changed files with 596 additions and 224 deletions
+19 -1
View File
@@ -12,12 +12,18 @@
#include <renderer/3d/mesh/dynamic/dynamic_mesh.hpp>
#include <renderer/3d/pipeline/dynamic/dynpip_options.hpp>
#include <renderer/3d/mesh/dynamic/animation_sequence_callback.hpp>
#include "states/game/renderer/renderer_dynamic_pair.hpp"
#include "states/game/terrain/heightmap.hpp"
#include <renderer/renderer.hpp>
#include <engine.hpp>
#include "./enemy_info.hpp"
using Tyra::AnimationSequenceCallback;
using Tyra::Audio;
using Tyra::DynamicMesh;
using Tyra::DynPipOptions;
using Tyra::Engine;
using Tyra::Renderer;
using Tyra::TextureRepository;
using Tyra::Vec4;
@@ -26,7 +32,7 @@ namespace Demo {
class Enemy {
public:
Enemy(TextureRepository* repo);
Enemy(Engine* engine, const EnemyInfo& info);
~Enemy();
DynamicMesh* mesh;
@@ -36,7 +42,19 @@ class Enemy {
void update(const Heightmap& heightmap, const Vec4& playerPosition);
private:
std::vector<u32> walkSequence;
std::vector<u32> fightSequence;
void allocateOptions();
void walk(const Heightmap& heightmap, const Vec4& positionDiff);
void animationCallback(const AnimationSequenceCallback& callback);
void fight();
bool isWalking = true;
bool isFighting = false;
Audio* audio;
EnemyInfo info;
};
} // namespace Demo
+31
View File
@@ -0,0 +1,31 @@
/*
# _____ ____ ___
# | \/ ____| |___|
# | | | \ | |
#-----------------------------------------------------------------------
# Copyright 2022, tyra - https://github.com/h4570/tyra
# Licensed under Apache License 2.0
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
*/
#pragma once
#include <tyra>
#include <audsrv.h>
using Tyra::DynamicMesh;
using Tyra::Texture;
using Tyra::Vec4;
namespace Demo {
struct EnemyInfo {
u8 adpcmChannel;
audsrv_adpcm_t* adpcmSample;
DynamicMesh* motherMesh;
Texture* bodyTexture;
Texture* clothTexture;
Vec4 spawnPoint;
};
} // namespace Demo
@@ -0,0 +1,43 @@
/*
# _____ ____ ___
# | \/ ____| |___|
# | | | \ | |
#-----------------------------------------------------------------------
# Copyright 2022, tyra - https://github.com/h4570/tyra
# Licensed under Apache License 2.0
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
*/
#pragma once
#include "states/game/terrain/heightmap.hpp"
#include "./enemy.hpp"
#include <tyra>
#include <vector>
using Tyra::DynamicMesh;
using Tyra::Engine;
using Tyra::Texture;
using Tyra::TextureRepository;
using Tyra::Vec4;
namespace Demo {
class EnemyManager {
public:
EnemyManager(Engine* engine, const Heightmap& heightmap);
~EnemyManager();
void update(const Heightmap& heightmap, const Vec4& playerPosition);
std::vector<RendererDynamicPair*> getPairs() const;
private:
TextureRepository* textureRepo;
std::vector<Enemy*> enemies;
DynamicMesh* motherMesh;
Texture* bodyTexture;
Texture* clothTexture;
};
} // namespace Demo
+2 -2
View File
@@ -17,7 +17,7 @@
#include "./terrain/terrain.hpp"
#include "./skybox/skybox.hpp"
#include "./debug_object.hpp"
#include "./enemy/enemy.hpp"
#include "./enemy/enemy_manager.hpp"
namespace Demo {
@@ -45,7 +45,7 @@ class GameState : public State<GlobalStateType> {
GameRenderer renderer;
Player* player;
Enemy* enemy;
EnemyManager* enemyManager;
Terrain* terrain;
Skybox* skybox;
DebugObject* dbgObj;