Added water mesh, jumping animation, skybox and diving.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
/*
|
||||
# ______ ____ ___
|
||||
# | \/ ____| |___|
|
||||
# | | | \ | |
|
||||
#-----------------------------------------------------------------------
|
||||
# Copyright 2020, tyra - https://github.com/h4570/tyra
|
||||
# Licenced under Apache License 2.0
|
||||
# Michał Mostowik <mostek3pl@gmail.com>
|
||||
*/
|
||||
|
||||
#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);
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
# ______ ____ ___
|
||||
# | \/ ____| |___|
|
||||
# | | | \ | |
|
||||
#-----------------------------------------------------------------------
|
||||
# Copyright 2020, tyra - https://github.com/h4570/tyra
|
||||
# Licenced under Apache License 2.0
|
||||
# Michał Mostowik <mostek3pl@gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef _DRIVER_
|
||||
#define _DRIVER_
|
||||
|
||||
#include <tamtypes.h>
|
||||
#include <audsrv.h>
|
||||
#include <game.hpp>
|
||||
#include <engine.hpp>
|
||||
#include <models/light_bulb.hpp>
|
||||
#include <modules/texture_repository.hpp>
|
||||
#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
|
||||
@@ -8,14 +8,13 @@
|
||||
# Michał Mostowik <mostek3pl@gmail.com>
|
||||
*/
|
||||
|
||||
#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;
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -11,6 +11,8 @@
|
||||
#ifndef _PLAYER_
|
||||
#define _PLAYER_
|
||||
|
||||
#define WATER_LEVEL -5.0F
|
||||
|
||||
#include "../camera.hpp"
|
||||
#include <modules/pad.hpp>
|
||||
#include <tamtypes.h>
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user