mirror of
https://github.com/zoriya/Bomberman.git
synced 2026-05-27 08:13:18 +00:00
model is now a 3D drawable
This commit is contained in:
+49
-29
@@ -6,21 +6,31 @@
|
||||
*/
|
||||
|
||||
|
||||
#include "Wal.hpp"
|
||||
#include <iostream>
|
||||
#include "Runner/Runner.hpp"
|
||||
|
||||
// Dependencies of the demo
|
||||
#include "Camera/Camera3D.hpp"
|
||||
#include "Controllers/Keyboard.hpp"
|
||||
#include "Drawables/2D/Text.hpp"
|
||||
#include "Drawables/Image.hpp"
|
||||
#include "Drawables/3D/Grid.hpp"
|
||||
#include "Drawables/Texture.hpp"
|
||||
#include "Drawables/3D/Circle.hpp"
|
||||
#include "Drawables/2D/Circle.hpp"
|
||||
#include "Drawables/3D/Cube.hpp"
|
||||
#include "Drawables/3D/Sphere.hpp"
|
||||
#include "Model/Model.hpp"
|
||||
#include "Model/ModelAnimations.hpp"
|
||||
#include "System/Renderer/Renderer3DSystem.hpp"
|
||||
#include "System/Renderer/Renderer2DSystem.hpp"
|
||||
#include "Component/Drawable/Drawable3DComponent.hpp"
|
||||
#include "Component/Drawable/Drawable2DComponent.hpp"
|
||||
#include "System/Renderer/RenderScreenSystem.hpp"
|
||||
#include "Vector/Vector3.hpp"
|
||||
#include "Window.hpp"
|
||||
#include "TraceLog.hpp"
|
||||
#include "Wal.hpp"
|
||||
|
||||
const std::vector<std::string>textures = {
|
||||
"blue", "cyan", "green", "orange", "purple", "red", "yellow"
|
||||
@@ -35,10 +45,9 @@ std::string get_full_path(const std::string &color)
|
||||
return path;
|
||||
}
|
||||
|
||||
int main()
|
||||
int demo()
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
WAL::Wal wal;
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 450;
|
||||
std::vector<std::string>::const_iterator iterator = textures.begin();
|
||||
@@ -48,10 +57,19 @@ int main()
|
||||
RAY::Image icon("assets/icon.png");
|
||||
RAY::Model model(modelPath);
|
||||
RAY::Camera::Camera3D camera(RAY::Vector3(10.0f, 10.0f, 10.0f),
|
||||
RAY::Vector3(0.0f, 0.0f, 0.0f),
|
||||
RAY::Vector3(0.0f, 1.0f, 0.0f),
|
||||
45.0f, CAMERA_PERSPECTIVE
|
||||
);
|
||||
RAY::Vector3(0.0f, 0.0f, 0.0f),
|
||||
RAY::Vector3(0.0f, 1.0f, 0.0f),
|
||||
45.0f, CAMERA_PERSPECTIVE
|
||||
);
|
||||
WAL::Entity entityPlayer("roger");
|
||||
RAY::Drawables::Drawables3D::Circle circle({0, 0, 0}, 5, MAROON, {0, 0, 0}, 0);
|
||||
BBM::Drawable3DComponent<RAY::Drawables::Drawables3D::Circle> circleComponent(entityPlayer, circle);
|
||||
|
||||
BBM::Renderer3DSystem<RAY::Drawables::Drawables3D::Circle> circleSystem(window);
|
||||
|
||||
wal.addSystem(circleSystem);
|
||||
entityPlayer.addComponent(circleComponent);
|
||||
|
||||
RAY::Texture texture(get_full_path(*iterator));
|
||||
RAY::ModelAnimations animations(modelPath);
|
||||
RAY::Drawables::Drawables3D::Grid grid(10, 1.0f);
|
||||
@@ -64,14 +82,10 @@ int main()
|
||||
camera.setMode(CAMERA_FREE); // Set free camera mode
|
||||
|
||||
float y_rotation = 0;
|
||||
window.setFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
window.setFPS(60);
|
||||
|
||||
// Main game loop
|
||||
while (!window.shouldClose()) // Detect window close button or ESC key
|
||||
while (!window.shouldClose())
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
camera.update();
|
||||
|
||||
// Play animation when spacebar is held down
|
||||
@@ -99,33 +113,39 @@ int main()
|
||||
animationIndex = ++animationIndex % animations.getAnimationsCount();
|
||||
model.setAnimation(animations[animationIndex]);
|
||||
}
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
window.setDrawingState(RAY::Window::DRAWING);
|
||||
|
||||
window.clear();
|
||||
|
||||
window.useCamera(camera);
|
||||
|
||||
window.draw(model, position, RAY::Vector3(1.0f, 20, 0.0f), -180.0f, RAY::Vector3( 3.0f, 3.0f, 3.0f ));
|
||||
|
||||
window.draw(grid);
|
||||
|
||||
window.draw(circle);
|
||||
window.unuseCamera();
|
||||
|
||||
window.draw(instructionText);
|
||||
|
||||
window.setDrawingState(RAY::Window::IDLE);
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
window.close();
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
window.close(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void usage(const std::string &bin)
|
||||
{
|
||||
std::cout << "Bomberman." << std::endl
|
||||
<< "\tUsage: " << bin << " [options]" << std::endl
|
||||
<< "Options:" << std::endl
|
||||
<< "\t-h:\tPrint this help message" << std::endl;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
if (argc == 2 && std::string(argv[1]) == "-h") {
|
||||
usage(argv[0]);
|
||||
return 1;
|
||||
}
|
||||
return demo();
|
||||
return BBM::run();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user