-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: add CuboSurfers models and plugins
- Loading branch information
Showing
46 changed files
with
461 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"actions": { | ||
"left": { | ||
"keys": [ | ||
"A", | ||
"Left" | ||
] | ||
}, | ||
"right": { | ||
"keys": [ | ||
"D", | ||
"Right" | ||
] | ||
}, | ||
"restart": { | ||
"keys": [ | ||
"R" | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"id": "b20900a4-20ee-4caa-8830-14585050bead" | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"id": "101da567-3d23-46ae-a391-c10ec00e8718" | ||
} |
108 changes: 108 additions & 0 deletions
108
engine/samples/games/cubosurfers/assets/scenes/main.cubos
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
{ | ||
"entities": { | ||
"render-target": { | ||
"cubos::engine::RenderTargetDefaults": {} | ||
}, | ||
"player": { | ||
"cubos::engine::RenderVoxelGrid": { | ||
"asset": "57d1b886-8543-4b8b-8f78-d911e9c4f896", | ||
"offset": { | ||
"x": -4, | ||
"y": 0, | ||
"z": -4 | ||
} | ||
}, | ||
"cubos::engine::Position": { | ||
"x": 0, | ||
"y": 0, | ||
"z": 0 | ||
}, | ||
"cubos::engine::BoxCollisionShape": { | ||
"x": 3.0, | ||
"y": 7.0, | ||
"z": 2.0 | ||
}, | ||
"cubos::engine::Collider": {}, | ||
"Player": { | ||
"speed": 5, | ||
"laneWidth": 9 | ||
} | ||
}, | ||
"track1": { | ||
"cubos::engine::RenderVoxelGrid": { | ||
"asset": "746088e3-84ec-4483-b4b2-216ae690c3b7", | ||
"offset": { | ||
"x": -16, | ||
"y": -1, | ||
"z": 0 | ||
} | ||
}, | ||
"cubos::engine::Position": { | ||
"x": 0, | ||
"y": 0, | ||
"z": -48 | ||
}, | ||
"cubos::engine::Scale": 2 | ||
}, | ||
"track2": { | ||
"cubos::engine::RenderVoxelGrid": { | ||
"asset": "746088e3-84ec-4483-b4b2-216ae690c3b7", | ||
"offset": { | ||
"x": -16, | ||
"y": -1, | ||
"z": 0 | ||
} | ||
}, | ||
"cubos::engine::Position": { | ||
"x": 0, | ||
"y": 0, | ||
"z": 208 | ||
}, | ||
"cubos::engine::Scale": 2 | ||
}, | ||
"obstacle-spawner": { | ||
"cubos::engine::Position": { | ||
"x": 0, | ||
"y": 0, | ||
"z": 300 | ||
}, | ||
"Spawner": { | ||
"scene": "b15272c5-08c9-47f5-9b24-1192332580a8", | ||
"sceneRoot": "base", | ||
"period": 1.0, | ||
"laneWidth": 9 | ||
} | ||
}, | ||
"sun": { | ||
"cubos::engine::DirectionalLight": { | ||
"color": { | ||
"x": 1.0, | ||
"y": 1.0, | ||
"z": 1.0 | ||
}, | ||
"intensity": 1.0 | ||
}, | ||
"cubos::engine::Rotation": { | ||
"w": 0.783, | ||
"x": 0.488, | ||
"y": 0.327, | ||
"z": 0.204 | ||
} | ||
}, | ||
"camera": { | ||
"cubos::engine::PerspectiveCamera": {}, | ||
"cubos::engine::DrawsTo@render-target": {}, | ||
"cubos::engine::Position": { | ||
"x": 0, | ||
"y": 12.5, | ||
"z": -25 | ||
}, | ||
"cubos::engine::Rotation": { | ||
"x": 0, | ||
"y": 1, | ||
"z": 0, | ||
"w": 0 | ||
} | ||
} | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
engine/samples/games/cubosurfers/assets/scenes/main.cubos.meta
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"id": "ee5bb451-05b7-430f-a641-a746f7009eef" | ||
} |
34 changes: 34 additions & 0 deletions
34
engine/samples/games/cubosurfers/assets/scenes/obstacle.cubos
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"entities": { | ||
"base": { | ||
"cubos::engine::RenderVoxelGrid": { | ||
"asset": "fe862296-fab7-4bf9-b62e-3cc28448dff1", | ||
"offset": { | ||
"x": -4, | ||
"y": 0, | ||
"z": -4 | ||
} | ||
}, | ||
"cubos::engine::Rotation": { | ||
"x": 0, | ||
"y": 1, | ||
"z": 0, | ||
"w": 0 | ||
}, | ||
"cubos::engine::BoxCollisionShape": { | ||
"x": 3.0, | ||
"y": 7.0, | ||
"z": 2.0 | ||
}, | ||
"cubos::engine::Collider": {}, | ||
"Obstacle": { | ||
"velocity": { | ||
"x": 0, | ||
"y": 0, | ||
"z": -100 | ||
}, | ||
"killZ": -10 | ||
} | ||
} | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
engine/samples/games/cubosurfers/assets/scenes/obstacle.cubos.meta
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"id": "b15272c5-08c9-47f5-9b24-1192332580a8" | ||
} |
Binary file not shown.
3 changes: 3 additions & 0 deletions
3
engine/samples/games/cubosurfers/assets/voxels/enemy/base.grd.meta
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"id": "fe862296-fab7-4bf9-b62e-3cc28448dff1" | ||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
3 changes: 3 additions & 0 deletions
3
engine/samples/games/cubosurfers/assets/voxels/player/base.grd.meta
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"id": "57d1b886-8543-4b8b-8f78-d911e9c4f896" | ||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
3 changes: 3 additions & 0 deletions
3
engine/samples/games/cubosurfers/assets/voxels/player/jetpack.grd.meta
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"id": "c7263b46-be18-47c2-b3ef-05592b2e9dec" | ||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
3 changes: 3 additions & 0 deletions
3
engine/samples/games/cubosurfers/assets/voxels/player/shield.grd.meta
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"id": "4892c2f3-10b3-4ca7-9de3-822b77a0ba7e" | ||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
3 changes: 3 additions & 0 deletions
3
engine/samples/games/cubosurfers/assets/voxels/power_up/jetpack.grd.meta
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"id": "732498a6-7675-4efa-86ef-8f35d3bec485" | ||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
3 changes: 3 additions & 0 deletions
3
engine/samples/games/cubosurfers/assets/voxels/power_up/shield.grd.meta
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"id": "fd89da0f-72d2-4ef9-9297-f73ff2ca5c63" | ||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
3 changes: 3 additions & 0 deletions
3
engine/samples/games/cubosurfers/assets/voxels/track/track.grd.meta
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"id": "746088e3-84ec-4483-b4b2-216ae690c3b7" | ||
} |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#include <cubos/engine/assets/plugin.hpp> | ||
#include <cubos/engine/collisions/colliding_with.hpp> | ||
#include <cubos/engine/defaults/plugin.hpp> | ||
#include <cubos/engine/input/plugin.hpp> | ||
#include <cubos/engine/render/lights/environment.hpp> | ||
#include <cubos/engine/render/voxels/palette.hpp> | ||
#include <cubos/engine/scene/plugin.hpp> | ||
#include <cubos/engine/settings/plugin.hpp> | ||
#include <cubos/engine/voxels/plugin.hpp> | ||
|
||
#include "obstacle.hpp" | ||
#include "player.hpp" | ||
#include "spawner.hpp" | ||
|
||
using namespace cubos::engine; | ||
|
||
static const Asset<Scene> SceneAsset = AnyAsset("ee5bb451-05b7-430f-a641-a746f7009eef"); | ||
static const Asset<VoxelPalette> PaletteAsset = AnyAsset("101da567-3d23-46ae-a391-c10ec00e8718"); | ||
static const Asset<InputBindings> InputBindingsAsset = AnyAsset("b20900a4-20ee-4caa-8830-14585050bead"); | ||
|
||
int main() | ||
{ | ||
Cubos cubos{}; | ||
|
||
cubos.plugin(defaultsPlugin); | ||
cubos.plugin(spawnerPlugin); | ||
cubos.plugin(obstaclePlugin); | ||
cubos.plugin(playerPlugin); | ||
|
||
cubos.startupSystem("configure settings").tagged(settingsTag).call([](Settings& settings) { | ||
settings.setString("assets.io.path", SAMPLE_ASSETS_FOLDER); | ||
}); | ||
|
||
cubos.startupSystem("set the palette, environment, input bindings and spawn the scene") | ||
.tagged(assetsTag) | ||
.call([](Commands commands, const Assets& assets, RenderPalette& palette, Input& input, | ||
RenderEnvironment& environment) { | ||
palette.asset = PaletteAsset; | ||
environment.ambient = {0.1F, 0.1F, 0.1F}; | ||
environment.skyGradient[0] = {0.2F, 0.4F, 0.8F}; | ||
environment.skyGradient[1] = {0.6F, 0.6F, 0.8F}; | ||
input.bind(*assets.read(InputBindingsAsset)); | ||
commands.spawn(assets.read(SceneAsset)->blueprint); | ||
}); | ||
|
||
cubos.system("restart the game on input") | ||
.call([](Commands cmds, const Assets& assets, const Input& input, Query<Entity> all) { | ||
if (input.justPressed("restart")) | ||
{ | ||
for (auto [ent] : all) | ||
{ | ||
cmds.destroy(ent); | ||
} | ||
|
||
cmds.spawn(assets.read(SceneAsset)->blueprint); | ||
} | ||
}); | ||
|
||
cubos.system("detect player vs obstacle collisions") | ||
.call([](Query<const Player&, const CollidingWith&, const Obstacle&> collisions) { | ||
for (auto [player, collidingWith, obstacle] : collisions) | ||
{ | ||
CUBOS_INFO("Player collided with an obstacle!"); | ||
(void)player; // here to shut up 'unused variable warning', you can remove it | ||
} | ||
}); | ||
|
||
cubos.run(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#include "obstacle.hpp" | ||
|
||
#include <cubos/core/ecs/reflection.hpp> | ||
#include <cubos/core/reflection/external/glm.hpp> | ||
#include <cubos/core/reflection/external/primitives.hpp> | ||
#include <cubos/core/reflection/external/string.hpp> | ||
|
||
#include <cubos/engine/assets/plugin.hpp> | ||
#include <cubos/engine/transform/plugin.hpp> | ||
|
||
using namespace cubos::engine; | ||
|
||
CUBOS_REFLECT_IMPL(Obstacle) | ||
{ | ||
return cubos::core::ecs::TypeBuilder<Obstacle>("Obstacle") | ||
.withField("velocity", &Obstacle::velocity) | ||
.withField("killZ", &Obstacle::killZ) | ||
.build(); | ||
} | ||
|
||
void obstaclePlugin(cubos::engine::Cubos& cubos) | ||
{ | ||
cubos.depends(assetsPlugin); | ||
cubos.depends(transformPlugin); | ||
|
||
cubos.component<Obstacle>(); | ||
|
||
cubos.system("move obstacles") | ||
.call([](Commands cmds, const DeltaTime& dt, Query<Entity, const Obstacle&, Position&> obstacles) { | ||
for (auto [ent, obstacle, position] : obstacles) | ||
{ | ||
position.vec += obstacle.velocity * dt.value(); | ||
position.vec.y = glm::abs(glm::sin(position.vec.z * 0.15F)) * 1.5F; | ||
|
||
if (position.vec.z < obstacle.killZ) | ||
{ | ||
cmds.destroy(ent); | ||
} | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#pragma once | ||
|
||
#include <glm/vec3.hpp> | ||
|
||
#include <cubos/engine/prelude.hpp> | ||
|
||
struct Obstacle | ||
{ | ||
CUBOS_REFLECT; | ||
|
||
glm::vec3 velocity{0.0F, 0.0F, -1.0F}; | ||
float killZ{0.0F}; | ||
}; | ||
|
||
void obstaclePlugin(cubos::engine::Cubos& cubos); |
Oops, something went wrong.