assets for player

This commit is contained in:
arthur.jamet
2021-05-25 14:06:57 +02:00
parent efa6d4b154
commit 5c78a4bd07
13 changed files with 31478 additions and 14 deletions

BIN
assets/bomberman.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 373 KiB

31422
assets/player.obj Normal file

File diff suppressed because it is too large Load Diff

BIN
assets/player_black.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

BIN
assets/player_blue.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

BIN
assets/player_pink.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

BIN
assets/player_red.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
assets/player_white.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

BIN
assets/player_yellow.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

@@ -10,7 +10,7 @@
namespace RAY { namespace RAY {
namespace Drawables { namespace Drawables {
class IDrawable; class ADrawable2D;
} }
//! @brief Interface for any drawable surface //! @brief Interface for any drawable surface
class Canvas { class Canvas {
@@ -19,7 +19,7 @@ namespace RAY {
virtual ~Canvas() = default; virtual ~Canvas() = default;
//! @brief draw drawable //! @brief draw drawable
virtual void draw(Drawables::IDrawable &) = 0; virtual void draw(Drawables::ADrawable2D &) = 0;
protected: protected:
private: private:

View File

@@ -6,6 +6,7 @@
*/ */
#include "Drawables/Image.hpp" #include "Drawables/Image.hpp"
#include "Drawables/IDrawable.hpp"
RAY::Image::Image(const std::string &filename): RAY::Image::Image(const std::string &filename):
_image(LoadImage(filename.c_str())) _image(LoadImage(filename.c_str()))

View File

@@ -9,6 +9,8 @@
#include <utility> #include <utility>
#include "Controllers/Mouse.hpp" #include "Controllers/Mouse.hpp"
#include "Drawables/ADrawable2D.hpp"
#include "Drawables/ADrawable3D.hpp"
RAY::Window &RAY::Window::getInstance(int width, int height, const std::string &title, unsigned flags, bool openNow) RAY::Window &RAY::Window::getInstance(int width, int height, const std::string &title, unsigned flags, bool openNow)
{ {
@@ -145,7 +147,12 @@ void RAY::Window::setTitle(const std::string &title)
this->_title = title; this->_title = title;
} }
void RAY::Window::draw(RAY::Drawables::IDrawable &drawable) void RAY::Window::draw(RAY::Drawables::ADrawable2D &drawable)
{
drawable.drawOn(*this);
}
void RAY::Window::draw(RAY::Drawables::ADrawable3D &drawable)
{ {
drawable.drawOn(*this); drawable.drawOn(*this);
} }

View File

@@ -17,13 +17,17 @@
#include "Camera/Camera3D.hpp" #include "Camera/Camera3D.hpp"
#include "Color.hpp" #include "Color.hpp"
#include "Canvas.hpp" #include "Canvas.hpp"
#include "Drawables/IDrawable.hpp" #include "Drawables/ADrawable3D.hpp"
#include "Drawables/ADrawable2D.hpp"
#include "Drawables/Texture.hpp" #include "Drawables/Texture.hpp"
#include "Model/Model.hpp" #include "Model/Model.hpp"
namespace RAY { namespace RAY {
class Model; class Model;
//! @brief Window manager //! @brief Window manager
namespace Drawables {
class ADrawable3D;
}
class Window: public Canvas { class Window: public Canvas {
public: public:
//! @return A widow insta,ce. Only one window can be open at a time //! @return A widow insta,ce. Only one window can be open at a time
@@ -111,9 +115,13 @@ namespace RAY {
void setTitle(const std::string &title); void setTitle(const std::string &title);
//! @brief draw rectangle //! @brief draw drawable
//! @param drawable The drawable to render on screen //! @param drawable The drawable to render on screen
void draw(Drawables::IDrawable &drawable) override; void draw(RAY::Drawables::ADrawable2D &drawable) override;
//! @brief draw drawable
//! @param drawable The drawable to render on screen
void draw(RAY::Drawables::ADrawable3D &drawable);
//! @brief draw texture at position //! @brief draw texture at position
//! @param texture The object to render //! @param texture The object to render

View File

@@ -10,6 +10,7 @@
#include "Camera/Camera3D.hpp" #include "Camera/Camera3D.hpp"
#include "Controllers/Keyboard.hpp" #include "Controllers/Keyboard.hpp"
#include "Drawables/2D/Text.hpp" #include "Drawables/2D/Text.hpp"
#include "Drawables/Image.hpp"
#include "Drawables/3D/Grid.hpp" #include "Drawables/3D/Grid.hpp"
#include "Drawables/Texture.hpp" #include "Drawables/Texture.hpp"
#include "Model/Model.hpp" #include "Model/Model.hpp"
@@ -18,13 +19,29 @@
#include "Window.hpp" #include "Window.hpp"
#include "TraceLog.hpp" #include "TraceLog.hpp"
const std::vector<std::string>textures = {
"black", "blue", "pink", "red", "white", "yellow"
};
std::string get_full_path(const std::string &color)
{
std::string path = "assets/player_";
path += color;
path += ".png";
return path;
}
int main() int main()
{ {
SetTraceLogLevel(LOG_WARNING);
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
const int screenWidth = 800; const int screenWidth = 800;
const int screenHeight = 450; const int screenHeight = 450;
std::vector<std::string>::const_iterator iterator = textures.begin();
const std::string modelPath = "assets/player.obj";
const std::string texturePath = "assets/player_blue.png";
//const std::string animationPath = "assets/guy.iqm";
RAY::TraceLog::setLevel(LOG_WARNING); RAY::TraceLog::setLevel(LOG_WARNING);
RAY::Window &window = RAY::Window::getInstance(screenWidth, screenHeight, "Bidibidibop", FLAG_WINDOW_RESIZABLE); RAY::Window &window = RAY::Window::getInstance(screenWidth, screenHeight, "Bidibidibop", FLAG_WINDOW_RESIZABLE);
RAY::Camera::Camera3D camera(RAY::Vector3(10.0f, 10.0f, 10.0f), RAY::Camera::Camera3D camera(RAY::Vector3(10.0f, 10.0f, 10.0f),
@@ -32,9 +49,11 @@ int main()
RAY::Vector3(0.0f, 1.0f, 0.0f), RAY::Vector3(0.0f, 1.0f, 0.0f),
45.0f, CAMERA_PERSPECTIVE 45.0f, CAMERA_PERSPECTIVE
); );
RAY::Model model("assets/guy.iqm"); RAY::Model model(modelPath);
RAY::Texture texture("assets/guytex.png"); RAY::Image icon("assets/bomberman.ico");
RAY::ModelAnimations animations("assets/guy.iqm"); RAY::Texture texture(get_full_path(*iterator));
window.setIcon(icon);
//RAY::ModelAnimations animations(animationPath);
RAY::Drawables::Drawables3D::Grid grid(10, 1.0f); RAY::Drawables::Drawables3D::Grid grid(10, 1.0f);
RAY::Drawables::Drawables2D::Text instructionText("PRESS SPACE to PLAY MODEL ANIMATION", 10, {10, 20} , MAROON); RAY::Drawables::Drawables2D::Text instructionText("PRESS SPACE to PLAY MODEL ANIMATION", 10, {10, 20} , MAROON);
model.setTextureToMaterial(MAP_DIFFUSE, texture); model.setTextureToMaterial(MAP_DIFFUSE, texture);
@@ -43,6 +62,7 @@ int main()
camera.setMode(CAMERA_FREE); // Set free camera mode 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); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@@ -54,10 +74,16 @@ int main()
camera.update(); camera.update();
// Play animation when spacebar is held down // Play animation when spacebar is held down
if (RAY::Controller::Keyboard::isDown(KEY_SPACE)) if (RAY::Controller::Keyboard::isReleased(KEY_SPACE))
{ {
animations[0].incrementFrameCounter(); ++iterator;
model.setAnimation(animations[0]); if (iterator == textures.end())
iterator = textures.begin();
texture.unload();
texture.load(get_full_path(*iterator));
model.setTextureToMaterial(MAP_DIFFUSE, texture);
//animations[0].incrementFrameCounter();
//model.setAnimation(animations[0]);
} }
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
@@ -69,7 +95,7 @@ int main()
window.useCamera(camera); window.useCamera(camera);
window.draw(model, position, RAY::Vector3(1.0f, 0.0f, 0.0f), -90.0f, RAY::Vector3( 1.0f, 1.0f, 1.0f )); window.draw(model, position, RAY::Vector3(1.0f, 20, 0.0f), -180.0f, RAY::Vector3( 5.0f, 5.0f, 5.0f ));
window.draw(grid); window.draw(grid);