mirror of
https://github.com/zoriya/Bomberman.git
synced 2026-05-26 15:58:12 +00:00
player
This commit is contained in:
+29
-18
@@ -23,7 +23,7 @@
|
||||
#include "TraceLog.hpp"
|
||||
|
||||
const std::vector<std::string>textures = {
|
||||
"black", "blue", "pink", "red", "white", "yellow"
|
||||
"blue", "cyan", "green", "orange", "purple", "red", "yellow"
|
||||
};
|
||||
|
||||
std::string get_full_path(const std::string &color)
|
||||
@@ -42,27 +42,25 @@ int main()
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 450;
|
||||
std::vector<std::string>::const_iterator iterator = textures.begin();
|
||||
const std::string modelPath = "assets/player/HugoSohm.iqm";
|
||||
const std::string texturePath = "assets/player/HugoSohm.png";
|
||||
const std::string animationPath = "assets/player/HugoSohm.iqm";
|
||||
const std::string modelPath = "assets/player/player.iqm";
|
||||
RAY::TraceLog::setLevel(LOG_WARNING);
|
||||
RAY::Window &window = RAY::Window::getInstance(screenWidth, screenHeight, "Bidibidibop", FLAG_WINDOW_RESIZABLE);
|
||||
RAY::Image icon("assets/icon.png");
|
||||
window.setIcon(icon);
|
||||
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::Texture texture(texturePath);
|
||||
RAY::ModelAnimations animations(animationPath);
|
||||
RAY::Texture texture(get_full_path(*iterator));
|
||||
RAY::ModelAnimations animations(modelPath);
|
||||
RAY::Drawables::Drawables3D::Grid grid(10, 1.0f);
|
||||
RAY::Drawables::Drawables2D::Text instructionText("PRESS SPACE to PLAY MODEL ANIMATION", 10, {10, 20} , MAROON);
|
||||
model.setTextureToMaterial(MAP_DIFFUSE, texture);
|
||||
|
||||
size_t animationIndex = 0;
|
||||
RAY::Vector3 position(0.0f, 0.0f, 0.0f); // Set model position
|
||||
|
||||
model.setTextureToMaterial(MAP_DIFFUSE, texture);
|
||||
window.setIcon(icon);
|
||||
camera.setMode(CAMERA_FREE); // Set free camera mode
|
||||
|
||||
float y_rotation = 0;
|
||||
@@ -79,14 +77,27 @@ int main()
|
||||
// Play animation when spacebar is held down
|
||||
if (RAY::Controller::Keyboard::isDown(KEY_SPACE))
|
||||
{
|
||||
//++iterator;
|
||||
//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]);
|
||||
animations[animationIndex].incrementFrameCounter();
|
||||
model.setAnimation(animations[animationIndex]);
|
||||
}
|
||||
if (RAY::Controller::Keyboard::isReleased(KEY_UP))
|
||||
{
|
||||
++iterator;
|
||||
if (iterator == textures.end())
|
||||
iterator = textures.begin();
|
||||
texture.unload();
|
||||
texture.load(get_full_path(*iterator));
|
||||
model.setTextureToMaterial(MAP_DIFFUSE, texture);
|
||||
}
|
||||
if (RAY::Controller::Keyboard::isReleased(KEY_LEFT))
|
||||
{
|
||||
animationIndex = --animationIndex % animations.getAnimationsCount();
|
||||
model.setAnimation(animations[animationIndex]);
|
||||
}
|
||||
if (RAY::Controller::Keyboard::isReleased(KEY_RIGHT))
|
||||
{
|
||||
animationIndex = ++animationIndex % animations.getAnimationsCount();
|
||||
model.setAnimation(animations[animationIndex]);
|
||||
}
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
@@ -98,7 +109,7 @@ int main()
|
||||
|
||||
window.useCamera(camera);
|
||||
|
||||
window.draw(model, position, RAY::Vector3(1.0f, 20, 0.0f), -180.0f, RAY::Vector3( 1.0f, 1.0f, 1.0f ));
|
||||
window.draw(model, position, RAY::Vector3(1.0f, 20, 0.0f), -180.0f, RAY::Vector3( 3.0f, 3.0f, 3.0f ));
|
||||
|
||||
window.draw(grid);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user