Executable
+33
@@ -0,0 +1,33 @@
|
||||
EE_BIN = dolphin.elf
|
||||
|
||||
TYRA_DIR = ./../../engine
|
||||
|
||||
EE_OBJS = \
|
||||
camera.o \
|
||||
objects/player.o \
|
||||
dolphin.o \
|
||||
main.o
|
||||
|
||||
EE_LIBS = -ltyra
|
||||
|
||||
all: $(EE_BIN)
|
||||
$(EE_STRIP) --strip-all $(EE_BIN)
|
||||
mv $(EE_BIN) bin/$(EE_BIN)
|
||||
rm $(EE_OBJS)
|
||||
|
||||
rebuild-engine:
|
||||
cd $(TYRA_DIR) && make clean && make
|
||||
|
||||
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 $(TYRA_DIR)/Makefile.pref
|
||||
Executable
+69
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
# ______ ____ ___
|
||||
# | \/ ____| |___|
|
||||
# | | | \ | |
|
||||
#-----------------------------------------------------------------------
|
||||
# Copyright 2020, tyra - https://github.com/h4570/tyra
|
||||
# Licenced under Apache License 2.0
|
||||
# Michał Mostowik <mostek3pl@gmail.com>
|
||||
*/
|
||||
|
||||
#include "camera.hpp"
|
||||
|
||||
#include <utils/math.hpp>
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
Executable
+41
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
# ______ ____ ___
|
||||
# | \/ ____| |___|
|
||||
# | | | \ | |
|
||||
#-----------------------------------------------------------------------
|
||||
# Copyright 2020, tyra - https://github.com/h4570/tyra
|
||||
# Licenced under Apache License 2.0
|
||||
# Michał Mostowik <mostek3pl@gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef _CAMERA_
|
||||
#define _CAMERA_
|
||||
|
||||
#include <modules/pad.hpp>
|
||||
#include <models/mesh.hpp>
|
||||
#include <models/math/vector3.hpp>
|
||||
#include <models/screen_settings.hpp>
|
||||
#include <modules/camera_base.hpp>
|
||||
#include <tamtypes.h>
|
||||
|
||||
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
|
||||
Executable
+20
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
# ______ ____ ___
|
||||
# | \/ ____| |___|
|
||||
# | | | \ | |
|
||||
#-----------------------------------------------------------------------
|
||||
# Copyright 2020, tyra - https://github.com/h4570/tyra
|
||||
# Licenced under Apache License 2.0
|
||||
# Michał Mostowik <mostek3pl@gmail.com>
|
||||
*/
|
||||
|
||||
#include "dolphin.hpp"
|
||||
|
||||
int main()
|
||||
{
|
||||
Engine engine = Engine();
|
||||
Dolphin game = Dolphin(&engine);
|
||||
game.engine->init(&game, 128);
|
||||
SleepThread();
|
||||
return 0;
|
||||
}
|
||||
Executable
+88
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
# ______ ____ ___
|
||||
# | \/ ____| |___|
|
||||
# | | | \ | |
|
||||
#-----------------------------------------------------------------------
|
||||
# Copyright 2020, tyra - https://github.com/h4570/tyra
|
||||
# Licenced under Apache License 2.0
|
||||
# Michał Mostowik <mostek3pl@gmail.com>
|
||||
*/
|
||||
|
||||
#include "player.hpp"
|
||||
|
||||
#include <loaders/obj_loader.hpp>
|
||||
#include <loaders/bmp_loader.hpp>
|
||||
#include <modules/gif_sender.hpp>
|
||||
#include <utils/debug.hpp>
|
||||
#include <utils/math.hpp>
|
||||
|
||||
Player::Player()
|
||||
{
|
||||
mesh.loadMD2("dolphin/", "dolphin", 0.025F, true);
|
||||
mesh.shouldBeFrustumCulled = false;
|
||||
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)
|
||||
{
|
||||
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.rJoyV >= 200 && lift <= 1)
|
||||
lift += 0.2F;
|
||||
else if (t_pad.rJoyV <= 100 && lift >= -1)
|
||||
lift -= 0.2F;
|
||||
|
||||
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;
|
||||
}
|
||||
Executable
+35
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
# ______ ____ ___
|
||||
# | \/ ____| |___|
|
||||
# | | | \ | |
|
||||
#-----------------------------------------------------------------------
|
||||
# Copyright 2020, tyra - https://github.com/h4570/tyra
|
||||
# Licenced under Apache License 2.0
|
||||
# Michał Mostowik <mostek3pl@gmail.com>
|
||||
*/
|
||||
|
||||
#ifndef _PLAYER_
|
||||
#define _PLAYER_
|
||||
|
||||
#define WATER_LEVEL -5.0F
|
||||
|
||||
#include "../camera.hpp"
|
||||
#include <modules/pad.hpp>
|
||||
#include <tamtypes.h>
|
||||
|
||||
class Player
|
||||
{
|
||||
|
||||
public:
|
||||
float gravity, velocity, lift;
|
||||
Mesh mesh;
|
||||
Player();
|
||||
~Player();
|
||||
void update(Pad &t_pad);
|
||||
|
||||
private:
|
||||
u8 isJumping;
|
||||
Vector3 playerNextPosition;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user