From 51702d5ef72f78cde0e6d542576fecc78749217c Mon Sep 17 00:00:00 2001 From: Foxar Date: Tue, 1 Dec 2020 17:21:07 +0100 Subject: [PATCH 1/4] Switched audio filenames to available binaries --- src/samples/ari/ari.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/samples/ari/ari.cpp b/src/samples/ari/ari.cpp index bfdf545..e43adc4 100644 --- a/src/samples/ari/ari.cpp +++ b/src/samples/ari/ari.cpp @@ -34,8 +34,8 @@ void Ari::onInit() { engine->renderer->setCameraDefinitions(&camera.worldView, &camera.position, camera.planes); engine->audio.setSongVolume(40); - // engine->audio.loadSong("MOV-CIRC.WAV"); - engine->audio.loadSong("nob-else.wav"); + engine->audio.loadSong("MOV-CIRC.WAV"); + //engine->audio.loadSong("nob-else.wav"); adpcm1 = engine->audio.loadADPCM("ziobro1.adpcm"); adpcm2 = engine->audio.loadADPCM("ziobro2.adpcm"); From 7e676916a020e8991ec38ec85bce2da2caf7f787 Mon Sep 17 00:00:00 2001 From: Foxar Date: Wed, 2 Dec 2020 20:54:19 +0100 Subject: [PATCH 2/4] Added new sample dolphin. --- src/samples/dolphin/Makefile | 65 +++++++++++++++++++++++++ src/samples/dolphin/camera.cpp | 67 ++++++++++++++++++++++++++ src/samples/dolphin/camera.hpp | 41 ++++++++++++++++ src/samples/dolphin/driver.cpp | 48 ++++++++++++++++++ src/samples/dolphin/driver.hpp | 45 +++++++++++++++++ src/samples/dolphin/main.cpp | 21 ++++++++ src/samples/dolphin/objects/player.cpp | 52 ++++++++++++++++++++ src/samples/dolphin/objects/player.hpp | 32 ++++++++++++ 8 files changed, 371 insertions(+) create mode 100755 src/samples/dolphin/Makefile create mode 100755 src/samples/dolphin/camera.cpp create mode 100755 src/samples/dolphin/camera.hpp create mode 100755 src/samples/dolphin/driver.cpp create mode 100755 src/samples/dolphin/driver.hpp create mode 100755 src/samples/dolphin/main.cpp create mode 100755 src/samples/dolphin/objects/player.cpp create mode 100755 src/samples/dolphin/objects/player.hpp diff --git a/src/samples/dolphin/Makefile b/src/samples/dolphin/Makefile new file mode 100755 index 0000000..d59fe5e --- /dev/null +++ b/src/samples/dolphin/Makefile @@ -0,0 +1,65 @@ +EE_BIN = driver.elf + +EE_OBJS = \ + ../../engine/models/math/matrix.o \ + ../../engine/models/math/plane.o \ + ../../engine/models/math/point.o \ + ../../engine/models/math/vector3.o \ + ../../engine/models/mesh_frame.o \ + ../../engine/models/mesh_material.o \ + ../../engine/models/mesh.o \ + ../../engine/models/mesh_texture.o \ + ../../engine/modules/audio.o \ + ../../engine/modules/camera_base.o \ + ../../engine/modules/file_service.o \ + ../../engine/modules/gif_sender.o \ + ../../engine/modules/light.o \ + ../../engine/modules/pad.o \ + ../../engine/modules/renderer.o \ + ../../engine/modules/texture_repository.o \ + ../../engine/modules/timer.o \ + ../../engine/modules/vif_sender.o \ + ../../engine/utils/math.o \ + ../../engine/utils/string.o \ + ../../engine/loaders/bmp_loader.o \ + ../../engine/loaders/dff_loader.o \ + ../../engine/loaders/md2_loader.o \ + ../../engine/loaders/obj_loader.o \ + ../../engine/vu1_progs/draw3D.o \ + ../../engine/engine.o \ + camera.o \ + objects/player.o \ + driver.o \ + main.o + +EE_LIBS = -ldraw -lgraph -lmath3d -lpacket -ldma -lpacket2 -lpad -laudsrv -lc -lstdc++ +EE_INCS := -I./../../engine/include $(EE_INCS) +EE_DVP = dvp-as +EE_VCL = vcl + +all: $(EE_BIN) + $(EE_STRIP) --strip-all $(EE_BIN) + mv $(EE_BIN) bin/$(EE_BIN) + rm $(EE_OBJS) + +# https://github.com/microsoft/wsl/issues/2468#issuecomment-374904520 +#%.vsm: %.vcl # sudo service binfmt-support start +# $(EE_VCL) $< >> $@ + +%.o: %.vsm + $(EE_DVP) $< -o $@ + +clean: + rm -f $(EE_OBJS) + +run: $(EE_BIN) + killall -v ps2client || true + ps2client reset + ps2client reset + $(EE_STRIP) --strip-all $(EE_BIN) + mv $(EE_BIN) bin/$(EE_BIN) + rm $(EE_OBJS) + cd bin/ && ps2client execee host:$(EE_BIN) + +include $(PS2SDK)/samples/Makefile.pref +include $(PS2SDK)/samples/Makefile.eeglobal diff --git a/src/samples/dolphin/camera.cpp b/src/samples/dolphin/camera.cpp new file mode 100755 index 0000000..8ab5c12 --- /dev/null +++ b/src/samples/dolphin/camera.cpp @@ -0,0 +1,67 @@ +/* +# ______ ____ ___ +# | \/ ____| |___| +# | | | \ | | +#----------------------------------------------------------------------- +# Copyright 2020, tyra - https://github.com/h4570/tyra +# Licenced under Apache License 2.0 +# Michał Mostowik +*/ + +#include "camera.hpp" + +#include + +const float CAMERA_Y = 15.0F; + + +Camera::Camera(ScreenSettings *t_screen) : CameraBase(t_screen, &position, &up) +{ + verticalLevel = 80.0F; + up.x = 0.0F; + up.y = 1.0F; + up.z = 0.0F; +} + +Camera::~Camera() {} + +void Camera::update(Pad &t_pad, Mesh &t_mesh) +{ + rotate(t_pad); + followBy(t_mesh); + Vector3 lookPos = Vector3(t_mesh.position.x, t_mesh.position.y + 10.0F, t_mesh.position.z); + lookAt(lookPos); +} + +void Camera::rotate(Pad &t_pad) +{ + if (t_pad.rJoyH <= 50) + horizontalLevel -= 0.08; + else if (t_pad.rJoyH >= 200) + horizontalLevel += 0.04; + if (t_pad.rJoyV <= 50 && verticalLevel > 25.0F) + verticalLevel -= 0.9F; + else if (t_pad.rJoyV >= 200 && verticalLevel < 80.0F) + verticalLevel += 0.9F; + unitCirclePosition.x = (Math::sin(horizontalLevel) * verticalLevel); + unitCirclePosition.y = CAMERA_Y; + unitCirclePosition.z = (Math::cos(horizontalLevel) * verticalLevel); +} + +void Camera::followBy(Mesh &t_mesh) +{ + position.x = unitCirclePosition.x + t_mesh.position.x; + position.y = unitCirclePosition.y + t_mesh.position.y; + position.z = unitCirclePosition.z + t_mesh.position.z; + + if (position.x > (-0.04F * verticalLevel) && + position.x < 0.0F && + position.z > (0.998F * verticalLevel)) + { + // TODO + // position.x = 0.0F; + // position.y = 0.0F; + // position.z = 0.0F; + // horizontalLevel = 0.0F; + } +} \ No newline at end of file diff --git a/src/samples/dolphin/camera.hpp b/src/samples/dolphin/camera.hpp new file mode 100755 index 0000000..7bcbde3 --- /dev/null +++ b/src/samples/dolphin/camera.hpp @@ -0,0 +1,41 @@ +/* +# ______ ____ ___ +# | \/ ____| |___| +# | | | \ | | +#----------------------------------------------------------------------- +# Copyright 2020, tyra - https://github.com/h4570/tyra +# Licenced under Apache License 2.0 +# Michał Mostowik +*/ + +#ifndef _CAMERA_ +#define _CAMERA_ + +#include +#include +#include +#include +#include +#include + +class Camera : public CameraBase +{ + +public: + Vector3 position,up, unitCirclePosition; + float horizontalLevel, verticalLevel; + + Camera(ScreenSettings *t_screen); + ~Camera(); + + void update(Pad &t_pad, Mesh &t_mesh); + void rotate(Pad &t_pad); + void followBy(Mesh &t_mesh); + +protected: + Vector3 *getPosition() { return &position; }; + Vector3 *getUp() { return &up; }; + ScreenSettings screen; +}; + +#endif diff --git a/src/samples/dolphin/driver.cpp b/src/samples/dolphin/driver.cpp new file mode 100755 index 0000000..262f811 --- /dev/null +++ b/src/samples/dolphin/driver.cpp @@ -0,0 +1,48 @@ +/* +# ______ ____ ___ +# | \/ ____| |___| +# | | | \ | | +#----------------------------------------------------------------------- +# Copyright 2020, tyra - https://github.com/h4570/tyra +# Licenced under Apache License 2.0 +# Michał Mostowik +*/ + +#include "driver.hpp" +#include "utils/math.hpp" + +Driver::Driver(Engine *t_engine) : engine(t_engine), camera(&engine->screen) +{ + +} + +Driver::~Driver() {} + +void Driver::onInit() +{ + engine->renderer->setCameraDefinitions(&camera.worldView, &camera.position, camera.planes); + + texRepo = engine->renderer->getTextureRepository(); + + engine->renderer->disableVSync(); + + island.loadDff("sunnyisl/", "sunnyisl", 1.0F, false); + island.rotation.x = -1.6F; + island.position.set(0.0F, 10.0F, 20.0F); + island.shouldBeBackfaceCulled = true; + island.shouldBeFrustumCulled = false; + + texRepo->addByMesh("dolphin/",player.mesh); + texRepo->addByMesh("sunnyisl/",island); + + bulb.intensity=55; + bulb.position.set(5.0F,10.0F,10.0f); +} + +void Driver::onUpdate() +{ + player.update(engine->pad); + camera.update(engine->pad,player.mesh); + engine->renderer->draw(island); + engine->renderer->draw(player.mesh); +} diff --git a/src/samples/dolphin/driver.hpp b/src/samples/dolphin/driver.hpp new file mode 100755 index 0000000..ce25589 --- /dev/null +++ b/src/samples/dolphin/driver.hpp @@ -0,0 +1,45 @@ +/* +# ______ ____ ___ +# | \/ ____| |___| +# | | | \ | | +#----------------------------------------------------------------------- +# Copyright 2020, tyra - https://github.com/h4570/tyra +# Licenced under Apache License 2.0 +# Michał Mostowik +*/ + +#ifndef _DRIVER_ +#define _DRIVER_ + +#include +#include +#include +#include +#include +#include +#include "./camera.hpp" +#include "./objects/player.hpp" + + +class Driver : public Game +{ + +public: + Driver(Engine* t_engine); + ~Driver(); + + void onInit(); + void onUpdate(); + + Engine *engine; +private: + LightBulb bulb; + Player player; + Camera camera; + Mesh island; + TextureRepository *texRepo; + + +}; + +#endif diff --git a/src/samples/dolphin/main.cpp b/src/samples/dolphin/main.cpp new file mode 100755 index 0000000..4090b93 --- /dev/null +++ b/src/samples/dolphin/main.cpp @@ -0,0 +1,21 @@ +/* +# ______ ____ ___ +# | \/ ____| |___| +# | | | \ | | +#----------------------------------------------------------------------- +# Copyright 2020, tyra - https://github.com/h4570/tyra +# Licenced under Apache License 2.0 +# Michał Mostowik +*/ + +#include "driver.hpp" + +int main() +{ + Engine engine = Engine(); + Driver game = Driver(&engine); + game.engine->init(&game,128); + SleepThread(); + return 0; + +} \ No newline at end of file diff --git a/src/samples/dolphin/objects/player.cpp b/src/samples/dolphin/objects/player.cpp new file mode 100755 index 0000000..851f372 --- /dev/null +++ b/src/samples/dolphin/objects/player.cpp @@ -0,0 +1,52 @@ +/* +# ______ ____ ___ +# | \/ ____| |___| +# | | | \ | | +#----------------------------------------------------------------------- +# Copyright 2020, tyra - https://github.com/h4570/tyra +# Licenced under Apache License 2.0 +# Michał Mostowik +*/ + +#include "player.hpp" + +#include +#include +#include +#include +#include + +Player::Player() +{ + mesh.loadMD2("dolphin/","dolphin",0.05F,true); + mesh.shouldBeFrustumCulled = false; + mesh.position.set(0.0F,20.0F,-10.0f); + mesh.rotation.x = -1.6F; + mesh.setAnimSpeed(0.05F); +} + +Player::~Player() +{ + +} + +void Player::update(Pad& t_pad) +{ + velocity=0; + if(t_pad.lJoyV <= 100) + velocity=1; + else if(t_pad.lJoyV >= 200) + velocity=-1; + + if(t_pad.lJoyH >= 200) + mesh.rotation.z-=0.1; + else if(t_pad.lJoyH <= 100) + mesh.rotation.z+=0.1; + + if(velocity>0 && mesh.getCurrentAnimationFrame()==0) + mesh.playAnimation(0, 14); + + mesh.position.z+=Math::cos(mesh.rotation.z)*velocity; + mesh.position.x+=Math::sin(mesh.rotation.z)*velocity; + +} \ No newline at end of file diff --git a/src/samples/dolphin/objects/player.hpp b/src/samples/dolphin/objects/player.hpp new file mode 100755 index 0000000..b996c1c --- /dev/null +++ b/src/samples/dolphin/objects/player.hpp @@ -0,0 +1,32 @@ +/* +# ______ ____ ___ +# | \/ ____| |___| +# | | | \ | | +#----------------------------------------------------------------------- +# Copyright 2020, tyra - https://github.com/h4570/tyra +# Licenced under Apache License 2.0 +# Michał Mostowik +*/ + +#ifndef _PLAYER_ +#define _PLAYER_ + +#include "../camera.hpp" +#include +#include + +class Player +{ + +public: + float gravity, velocity; + Mesh mesh; + Player(); + ~Player(); + void update(Pad &t_pad); +private: + Vector3 playerNextPosition; + +}; + +#endif From bae834e5991b5fe429f9657ec587964c27be69a8 Mon Sep 17 00:00:00 2001 From: Foxar Date: Thu, 3 Dec 2020 18:33:20 +0100 Subject: [PATCH 3/4] Added water mesh, jumping animation, skybox and diving. --- src/samples/dolphin/Makefile | 48 +++--------------- src/samples/dolphin/camera.cpp | 4 +- src/samples/dolphin/driver.cpp | 48 ------------------ src/samples/dolphin/driver.hpp | 45 ----------------- src/samples/dolphin/main.cpp | 7 ++- src/samples/dolphin/objects/player.cpp | 70 +++++++++++++++++++------- src/samples/dolphin/objects/player.hpp | 9 ++-- 7 files changed, 73 insertions(+), 158 deletions(-) delete mode 100755 src/samples/dolphin/driver.cpp delete mode 100755 src/samples/dolphin/driver.hpp diff --git a/src/samples/dolphin/Makefile b/src/samples/dolphin/Makefile index d59fe5e..c4e5f83 100755 --- a/src/samples/dolphin/Makefile +++ b/src/samples/dolphin/Makefile @@ -1,53 +1,22 @@ -EE_BIN = driver.elf +EE_BIN = dolphin.elf + +TYRA_DIR = ./../../engine EE_OBJS = \ - ../../engine/models/math/matrix.o \ - ../../engine/models/math/plane.o \ - ../../engine/models/math/point.o \ - ../../engine/models/math/vector3.o \ - ../../engine/models/mesh_frame.o \ - ../../engine/models/mesh_material.o \ - ../../engine/models/mesh.o \ - ../../engine/models/mesh_texture.o \ - ../../engine/modules/audio.o \ - ../../engine/modules/camera_base.o \ - ../../engine/modules/file_service.o \ - ../../engine/modules/gif_sender.o \ - ../../engine/modules/light.o \ - ../../engine/modules/pad.o \ - ../../engine/modules/renderer.o \ - ../../engine/modules/texture_repository.o \ - ../../engine/modules/timer.o \ - ../../engine/modules/vif_sender.o \ - ../../engine/utils/math.o \ - ../../engine/utils/string.o \ - ../../engine/loaders/bmp_loader.o \ - ../../engine/loaders/dff_loader.o \ - ../../engine/loaders/md2_loader.o \ - ../../engine/loaders/obj_loader.o \ - ../../engine/vu1_progs/draw3D.o \ - ../../engine/engine.o \ camera.o \ objects/player.o \ - driver.o \ + dolphin.o \ main.o -EE_LIBS = -ldraw -lgraph -lmath3d -lpacket -ldma -lpacket2 -lpad -laudsrv -lc -lstdc++ -EE_INCS := -I./../../engine/include $(EE_INCS) -EE_DVP = dvp-as -EE_VCL = vcl +EE_LIBS = -ltyra all: $(EE_BIN) $(EE_STRIP) --strip-all $(EE_BIN) mv $(EE_BIN) bin/$(EE_BIN) rm $(EE_OBJS) -# https://github.com/microsoft/wsl/issues/2468#issuecomment-374904520 -#%.vsm: %.vcl # sudo service binfmt-support start -# $(EE_VCL) $< >> $@ - -%.o: %.vsm - $(EE_DVP) $< -o $@ +rebuild-engine: + cd $(TYRA_DIR) && make clean && make clean: rm -f $(EE_OBJS) @@ -61,5 +30,4 @@ run: $(EE_BIN) rm $(EE_OBJS) cd bin/ && ps2client execee host:$(EE_BIN) -include $(PS2SDK)/samples/Makefile.pref -include $(PS2SDK)/samples/Makefile.eeglobal +include $(TYRA_DIR)/Makefile.pref diff --git a/src/samples/dolphin/camera.cpp b/src/samples/dolphin/camera.cpp index 8ab5c12..0fb871f 100755 --- a/src/samples/dolphin/camera.cpp +++ b/src/samples/dolphin/camera.cpp @@ -14,7 +14,6 @@ const float CAMERA_Y = 15.0F; - Camera::Camera(ScreenSettings *t_screen) : CameraBase(t_screen, &position, &up) { verticalLevel = 80.0F; @@ -35,14 +34,17 @@ void Camera::update(Pad &t_pad, Mesh &t_mesh) void Camera::rotate(Pad &t_pad) { + if (t_pad.rJoyH <= 50) horizontalLevel -= 0.08; else if (t_pad.rJoyH >= 200) horizontalLevel += 0.04; + /* if (t_pad.rJoyV <= 50 && verticalLevel > 25.0F) verticalLevel -= 0.9F; else if (t_pad.rJoyV >= 200 && verticalLevel < 80.0F) verticalLevel += 0.9F; + */ unitCirclePosition.x = (Math::sin(horizontalLevel) * verticalLevel); unitCirclePosition.y = CAMERA_Y; unitCirclePosition.z = (Math::cos(horizontalLevel) * verticalLevel); diff --git a/src/samples/dolphin/driver.cpp b/src/samples/dolphin/driver.cpp deleted file mode 100755 index 262f811..0000000 --- a/src/samples/dolphin/driver.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/* -# ______ ____ ___ -# | \/ ____| |___| -# | | | \ | | -#----------------------------------------------------------------------- -# Copyright 2020, tyra - https://github.com/h4570/tyra -# Licenced under Apache License 2.0 -# Michał Mostowik -*/ - -#include "driver.hpp" -#include "utils/math.hpp" - -Driver::Driver(Engine *t_engine) : engine(t_engine), camera(&engine->screen) -{ - -} - -Driver::~Driver() {} - -void Driver::onInit() -{ - engine->renderer->setCameraDefinitions(&camera.worldView, &camera.position, camera.planes); - - texRepo = engine->renderer->getTextureRepository(); - - engine->renderer->disableVSync(); - - island.loadDff("sunnyisl/", "sunnyisl", 1.0F, false); - island.rotation.x = -1.6F; - island.position.set(0.0F, 10.0F, 20.0F); - island.shouldBeBackfaceCulled = true; - island.shouldBeFrustumCulled = false; - - texRepo->addByMesh("dolphin/",player.mesh); - texRepo->addByMesh("sunnyisl/",island); - - bulb.intensity=55; - bulb.position.set(5.0F,10.0F,10.0f); -} - -void Driver::onUpdate() -{ - player.update(engine->pad); - camera.update(engine->pad,player.mesh); - engine->renderer->draw(island); - engine->renderer->draw(player.mesh); -} diff --git a/src/samples/dolphin/driver.hpp b/src/samples/dolphin/driver.hpp deleted file mode 100755 index ce25589..0000000 --- a/src/samples/dolphin/driver.hpp +++ /dev/null @@ -1,45 +0,0 @@ -/* -# ______ ____ ___ -# | \/ ____| |___| -# | | | \ | | -#----------------------------------------------------------------------- -# Copyright 2020, tyra - https://github.com/h4570/tyra -# Licenced under Apache License 2.0 -# Michał Mostowik -*/ - -#ifndef _DRIVER_ -#define _DRIVER_ - -#include -#include -#include -#include -#include -#include -#include "./camera.hpp" -#include "./objects/player.hpp" - - -class Driver : public Game -{ - -public: - Driver(Engine* t_engine); - ~Driver(); - - void onInit(); - void onUpdate(); - - Engine *engine; -private: - LightBulb bulb; - Player player; - Camera camera; - Mesh island; - TextureRepository *texRepo; - - -}; - -#endif diff --git a/src/samples/dolphin/main.cpp b/src/samples/dolphin/main.cpp index 4090b93..9c5f37e 100755 --- a/src/samples/dolphin/main.cpp +++ b/src/samples/dolphin/main.cpp @@ -8,14 +8,13 @@ # Michał Mostowik */ -#include "driver.hpp" +#include "dolphin.hpp" int main() { Engine engine = Engine(); - Driver game = Driver(&engine); - game.engine->init(&game,128); + Dolphin game = Dolphin(&engine); + game.engine->init(&game, 128); SleepThread(); return 0; - } \ No newline at end of file diff --git a/src/samples/dolphin/objects/player.cpp b/src/samples/dolphin/objects/player.cpp index 851f372..207dfdc 100755 --- a/src/samples/dolphin/objects/player.cpp +++ b/src/samples/dolphin/objects/player.cpp @@ -18,35 +18,71 @@ Player::Player() { - mesh.loadMD2("dolphin/","dolphin",0.05F,true); + mesh.loadMD2("dolphin/", "dolphin", 0.025F, true); mesh.shouldBeFrustumCulled = false; - mesh.position.set(0.0F,20.0F,-10.0f); + mesh.position.set(0.0F, 0.0F, 10.0f); mesh.rotation.x = -1.6F; mesh.setAnimSpeed(0.05F); + isJumping = false; } Player::~Player() { - } -void Player::update(Pad& t_pad) +void Player::update(Pad &t_pad) { - velocity=0; - if(t_pad.lJoyV <= 100) - velocity=1; - else if(t_pad.lJoyV >= 200) - velocity=-1; + if (lift > 0.0F) + lift -= 0.05F; + if (lift < 0.0F) + lift += 0.05F; + if (lift < 0.1F && lift > -0.1F) + lift = 0; + velocity = 0; + if (t_pad.lJoyV <= 100) + velocity = 1; + else if (t_pad.lJoyV >= 200) + velocity = -1; - if(t_pad.lJoyH >= 200) - mesh.rotation.z-=0.1; - else if(t_pad.lJoyH <= 100) - mesh.rotation.z+=0.1; + if (t_pad.lJoyH >= 200) + mesh.rotation.z -= 0.1; + else if (t_pad.lJoyH <= 100) + mesh.rotation.z += 0.1; - if(velocity>0 && mesh.getCurrentAnimationFrame()==0) - mesh.playAnimation(0, 14); + if (t_pad.rJoyV >= 200 && lift <= 1) + lift += 0.2F; + else if (t_pad.rJoyV <= 100 && lift >= -1) + lift -= 0.2F; - mesh.position.z+=Math::cos(mesh.rotation.z)*velocity; - mesh.position.x+=Math::sin(mesh.rotation.z)*velocity; + if (t_pad.isCrossClicked && mesh.getCurrentAnimationFrame() <= 14 && WATER_LEVEL - 15 < mesh.position.y) + { + printf("Cross\n"); + mesh.setAnimSpeed(0.8F); + mesh.playAnimation(14, 58, 0); + } + if (mesh.getCurrentAnimationFrame() > 25 && mesh.getCurrentAnimationFrame() < 47) + isJumping = true; + else + isJumping = false; + + if (lift < 0) + mesh.rotation.y = 1; + else if (lift > 0) + mesh.rotation.y = -1; + else + mesh.rotation.y = 0; + + if (velocity > 0 && mesh.getCurrentAnimationFrame() == 0) + { + mesh.setAnimSpeed(0.05F); + printf("Swim animation\n"); + mesh.playAnimation(1, 14, 0); + } + + mesh.position.z += + Math::cos(mesh.rotation.z) * velocity * (isJumping + 1); + mesh.position.x += + Math::sin(mesh.rotation.z) * velocity * (isJumping + 1); + mesh.position.y += lift; } \ No newline at end of file diff --git a/src/samples/dolphin/objects/player.hpp b/src/samples/dolphin/objects/player.hpp index b996c1c..bd990be 100755 --- a/src/samples/dolphin/objects/player.hpp +++ b/src/samples/dolphin/objects/player.hpp @@ -11,6 +11,8 @@ #ifndef _PLAYER_ #define _PLAYER_ +#define WATER_LEVEL -5.0F + #include "../camera.hpp" #include #include @@ -19,14 +21,15 @@ class Player { public: - float gravity, velocity; + float gravity, velocity, lift; Mesh mesh; Player(); ~Player(); void update(Pad &t_pad); -private: - Vector3 playerNextPosition; +private: + u8 isJumping; + Vector3 playerNextPosition; }; #endif From 17ef6b9fbc8196ad4fc8a0d47158373119d45140 Mon Sep 17 00:00:00 2001 From: Foxar Date: Thu, 3 Dec 2020 20:25:13 +0100 Subject: [PATCH 4/4] Revert "Switched audio filenames to available binaries" This reverts commit 51702d5ef72f78cde0e6d542576fecc78749217c. --- src/samples/ari/ari.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/samples/ari/ari.cpp b/src/samples/ari/ari.cpp index 52a00b4..3c33919 100644 --- a/src/samples/ari/ari.cpp +++ b/src/samples/ari/ari.cpp @@ -34,8 +34,8 @@ void Ari::onInit() { engine->renderer->setCameraDefinitions(&camera.worldView, &camera.position, camera.planes); engine->audio.setSongVolume(40); - engine->audio.loadSong("MOV-CIRC.WAV"); - //engine->audio.loadSong("nob-else.wav"); + // engine->audio.loadSong("MOV-CIRC.WAV"); + engine->audio.loadSong("nob-else.wav"); adpcm1 = engine->audio.loadADPCM("ziobro1.adpcm"); adpcm2 = engine->audio.loadADPCM("ziobro2.adpcm");