Rearrangements; Audio support
This commit is contained in:
5
src/gamedata/CMakeLists.txt
Normal file
5
src/gamedata/CMakeLists.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
project(gamedata)
|
||||
find_package(OGRE REQUIRED COMPONENTS Bites Bullet Paging Terrain CONFIG)
|
||||
add_library(GameData STATIC GameData.cpp)
|
||||
target_link_libraries(GameData PUBLIC OgreMain OgreBullet flecs::flecs_static)
|
||||
target_include_directories(GameData PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
29
src/gamedata/GameData.cpp
Normal file
29
src/gamedata/GameData.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
#include <Ogre.h>
|
||||
#include "GameData.h"
|
||||
|
||||
namespace ECS
|
||||
{
|
||||
static flecs::world ecs;
|
||||
CharacterModule::CharacterModule(flecs::world &ecs)
|
||||
{
|
||||
ecs.component<Input>();
|
||||
ecs.add<Input>();
|
||||
ecs.system("HandleInput").kind(flecs::OnUpdate).run([](flecs::iter &it) {
|
||||
/* handle input */
|
||||
});
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
ecs.add<GameData>();
|
||||
ecs.import <CharacterModule>();
|
||||
}
|
||||
void update(float delta)
|
||||
{
|
||||
ecs.progress(delta);
|
||||
}
|
||||
flecs::world &get()
|
||||
{
|
||||
return ecs;
|
||||
}
|
||||
}
|
||||
36
src/gamedata/GameData.h
Normal file
36
src/gamedata/GameData.h
Normal file
@@ -0,0 +1,36 @@
|
||||
#ifndef GAMEDATA_H
|
||||
#define GAMEDATA_H
|
||||
#include <OgreBullet.h>
|
||||
#include <flecs.h>
|
||||
namespace ECS
|
||||
{
|
||||
struct GameData {
|
||||
flecs::entity player;
|
||||
};
|
||||
struct Vector3 {
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
};
|
||||
struct Input {
|
||||
Vector3 motion;
|
||||
bool fast;
|
||||
Input()
|
||||
: motion({ 0, 0, 0 })
|
||||
, fast(false)
|
||||
{
|
||||
}
|
||||
};
|
||||
struct CharacterBody {
|
||||
btPairCachingGhostObject *mGhostObject;
|
||||
btCompoundShape *mCollisionShape;
|
||||
Ogre::Bullet::DynamicsWorld *mWorld;
|
||||
};
|
||||
struct CharacterModule {
|
||||
CharacterModule(flecs::world &ecs);
|
||||
};
|
||||
void setup();
|
||||
void update(float delta);
|
||||
flecs::world &get();
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user