Merge pull request #58 from Foxar/master
Missing commits and files from last PR
This commit is contained in:
@@ -99,7 +99,7 @@ This is an example of how to list things you need to use the software and how to
|
|||||||
|
|
||||||
1. Clone the repo
|
1. Clone the repo
|
||||||
```sh
|
```sh
|
||||||
git clone https://github.com/ps2-tyra/tyra.git
|
git clone https://github.com/h4570/tyra.git
|
||||||
```
|
```
|
||||||
2. Get into src folder and compile it!
|
2. Get into src folder and compile it!
|
||||||
```sh
|
```sh
|
||||||
@@ -114,7 +114,7 @@ make
|
|||||||
## Roadmap
|
## Roadmap
|
||||||
|
|
||||||
### Roadmap moved to github kanban:
|
### Roadmap moved to github kanban:
|
||||||
[https://github.com/h4570/tyra/projects/1](https://github.com/ps2-tyra/tyra/projects/1)
|
[https://github.com/h4570/tyra/projects/1](https://github.com/h4570/tyra/projects/1)
|
||||||
|
|
||||||
|
|
||||||
See the [open issues](https://github.com/h4570/tyra/issues) for a list of proposed features (and known issues).
|
See the [open issues](https://github.com/h4570/tyra/issues) for a list of proposed features (and known issues).
|
||||||
@@ -150,9 +150,9 @@ Without these guys, everything would be harder:
|
|||||||
|
|
||||||
Project Link: [https://github.com/h4570/tyra](https://github.com/h4570/tyra)
|
Project Link: [https://github.com/h4570/tyra](https://github.com/h4570/tyra)
|
||||||
|
|
||||||
[contributors-shield]: https://img.shields.io/github/contributors/ps2-tyra/tyra.svg?style=flat-square
|
[contributors-shield]: https://img.shields.io/github/contributors/h4570/tyra.svg?style=flat-square
|
||||||
[contributors-url]: https://github.com/ps2-tyra/tyra/graphs/contributors
|
[contributors-url]: https://github.com/h4570/tyra/graphs/contributors
|
||||||
[linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=flat-square&logo=linkedin&colorB=555
|
[linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=flat-square&logo=linkedin&colorB=555
|
||||||
[linkedin-url]: https://linkedin.com/in/sandro-sobczyński-28820b15a/
|
[linkedin-url]: https://linkedin.com/in/sandro-sobczyński-28820b15a/
|
||||||
[license-shield]: https://img.shields.io/github/license/ps2-tyra/tyra.svg?style=flat-square
|
[license-shield]: https://img.shields.io/github/license/h4570/tyra.svg?style=flat-square
|
||||||
[license-url]: https://github.com/ps2-tyra/tyra/blob/master/LICENSE
|
[license-url]: https://github.com/h4570/tyra/blob/master/LICENSE
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ EE_OBJS = \
|
|||||||
camera.o \
|
camera.o \
|
||||||
objects/player.o \
|
objects/player.o \
|
||||||
objects/collectible.o \
|
objects/collectible.o \
|
||||||
|
objects/mine.o \
|
||||||
dolphin.o \
|
dolphin.o \
|
||||||
main.o
|
main.o
|
||||||
|
|
||||||
|
|||||||
@@ -14,16 +14,22 @@
|
|||||||
const u8 WATER_TILE_SCALE = 5;
|
const u8 WATER_TILE_SCALE = 5;
|
||||||
const u8 WATER_SIZE = 100;
|
const u8 WATER_SIZE = 100;
|
||||||
|
|
||||||
const u8 OYSTERS_COUNT = 15;
|
const u8 MINES_COUNT = 15;
|
||||||
|
const u8 OYSTERS_COUNT = 5;
|
||||||
|
|
||||||
float Dolphin::engineFPS = 60.F;
|
float Dolphin::engineFPS = 60.F;
|
||||||
|
|
||||||
Dolphin::Dolphin(Engine *t_engine) : engine(t_engine), camera(&engine->screen)
|
Dolphin::Dolphin(Engine *t_engine) : engine(t_engine), camera(&engine->screen)
|
||||||
{
|
{
|
||||||
oysters = new Collectible[OYSTERS_COUNT];
|
oysters = new Collectible[OYSTERS_COUNT];
|
||||||
|
mines = new Mine[MINES_COUNT];
|
||||||
}
|
}
|
||||||
|
|
||||||
Dolphin::~Dolphin() {}
|
Dolphin::~Dolphin()
|
||||||
|
{
|
||||||
|
delete[] oysters;
|
||||||
|
delete[] mines;
|
||||||
|
}
|
||||||
|
|
||||||
void Dolphin::onInit()
|
void Dolphin::onInit()
|
||||||
{
|
{
|
||||||
@@ -37,6 +43,7 @@ void Dolphin::onInit()
|
|||||||
surfaceAmbient = engine->audio.loadADPCM("sound/surface.sad");
|
surfaceAmbient = engine->audio.loadADPCM("sound/surface.sad");
|
||||||
underwaterAmbient = engine->audio.loadADPCM("sound/underwater.sad");
|
underwaterAmbient = engine->audio.loadADPCM("sound/underwater.sad");
|
||||||
pickupSound = engine->audio.loadADPCM("sound/pickup.sad");
|
pickupSound = engine->audio.loadADPCM("sound/pickup.sad");
|
||||||
|
boomSound = engine->audio.loadADPCM("sound/boom.sad");
|
||||||
|
|
||||||
engine->audio.playADPCM(surfaceAmbient, 0);
|
engine->audio.playADPCM(surfaceAmbient, 0);
|
||||||
engine->audio.playADPCM(underwaterAmbient, 1);
|
engine->audio.playADPCM(underwaterAmbient, 1);
|
||||||
@@ -53,6 +60,11 @@ void Dolphin::onInit()
|
|||||||
island.shouldBeBackfaceCulled = true;
|
island.shouldBeBackfaceCulled = true;
|
||||||
island.shouldBeFrustumCulled = false;
|
island.shouldBeFrustumCulled = false;
|
||||||
|
|
||||||
|
gameOver.size.set(640.0F, 480.0F);
|
||||||
|
Texture *gameOverTex = texRepo->add("2d/", "gameover", PNG);
|
||||||
|
gameOver.setMode(MODE_STRETCH);
|
||||||
|
gameOverTex->addLink(gameOver.getId());
|
||||||
|
|
||||||
printf("Loading water overlay...\n");
|
printf("Loading water overlay...\n");
|
||||||
waterOverlay.size.set(640.0F, 480.0F);
|
waterOverlay.size.set(640.0F, 480.0F);
|
||||||
Texture *watOverlayTex = texRepo->add("2d/", "underwater_overlay", PNG);
|
Texture *watOverlayTex = texRepo->add("2d/", "underwater_overlay", PNG);
|
||||||
@@ -103,6 +115,25 @@ void Dolphin::onInit()
|
|||||||
oysters[i].mesh.position.set(i * -100, 5.0F, i * -100);
|
oysters[i].mesh.position.set(i * -100, 5.0F, i * -100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printf("Loading mine .obj\n");
|
||||||
|
mines[0].mesh.loadObj("mine/", "mine", 10.F, false);
|
||||||
|
printf("Loaded.");
|
||||||
|
mines[0].mesh.shouldBeBackfaceCulled = false;
|
||||||
|
mines[0].mesh.shouldBeFrustumCulled = false;
|
||||||
|
mines[0].mesh.position.set(5, -15, 32);
|
||||||
|
texRepo->addByMesh("mine/", mines[0].mesh, BMP);
|
||||||
|
printf("Adding mine texture.\n");
|
||||||
|
for (int i = 1; i < MINES_COUNT; i++)
|
||||||
|
{
|
||||||
|
printf("Processing mine %d\n", i);
|
||||||
|
mines[i].mesh.loadFrom(mines[0].mesh);
|
||||||
|
mines[i].mesh.shouldBeBackfaceCulled = false;
|
||||||
|
mines[i].mesh.shouldBeFrustumCulled = false;
|
||||||
|
texRepo->getByMesh(mines[0].mesh.getId(), mines[0].mesh.getMaterial(0).getId())
|
||||||
|
->addLink(mines[i].mesh.getId(), mines[i].mesh.getMaterial(0).getId());
|
||||||
|
mines[i].mesh.position.set(i * -10, 0.0F, i * -68);
|
||||||
|
}
|
||||||
|
|
||||||
Texture *pLifeTex = texRepo->add("2d/", "life", PNG);
|
Texture *pLifeTex = texRepo->add("2d/", "life", PNG);
|
||||||
//pLifeTex->addLink(lifeSprites[0].getId());
|
//pLifeTex->addLink(lifeSprites[0].getId());
|
||||||
for (int i = 0; i < 3; i++)
|
for (int i = 0; i < 3; i++)
|
||||||
@@ -125,6 +156,14 @@ void Dolphin::onInit()
|
|||||||
|
|
||||||
void Dolphin::onUpdate()
|
void Dolphin::onUpdate()
|
||||||
{
|
{
|
||||||
|
if (player.getLifes() <= 0)
|
||||||
|
{
|
||||||
|
engine->audio.stopSong();
|
||||||
|
engine->audio.setADPCMVolume(0, 0);
|
||||||
|
engine->audio.setADPCMVolume(75, 1);
|
||||||
|
engine->renderer->draw(gameOver);
|
||||||
|
return;
|
||||||
|
}
|
||||||
Dolphin::engineFPS = engine->fps;
|
Dolphin::engineFPS = engine->fps;
|
||||||
if (engine->pad.isCrossClicked)
|
if (engine->pad.isCrossClicked)
|
||||||
printf("Delta multiplier: %f\n", 60.0F / engine->fps);
|
printf("Delta multiplier: %f\n", 60.0F / engine->fps);
|
||||||
@@ -146,16 +185,36 @@ void Dolphin::onUpdate()
|
|||||||
{
|
{
|
||||||
oysters[i].update();
|
oysters[i].update();
|
||||||
Vector3 vecDist = oysters[i].mesh.position - player.mesh.position;
|
Vector3 vecDist = oysters[i].mesh.position - player.mesh.position;
|
||||||
float dist = Math::sqrt(vecDist.x + vecDist.y + vecDist.z);
|
float dist = vecDist.length();
|
||||||
if (dist < 2.5F && player.isJumping() && oysters[i].isActive())
|
if (dist < 20.F && player.isJumping() && oysters[i].isActive())
|
||||||
{
|
{
|
||||||
printf("Pickup %d Dist %d\n", i, dist);
|
printf("Pickup %d Dist %d\n", i, dist);
|
||||||
oysters[i].disappear();
|
oysters[i].disappear();
|
||||||
|
player.setLife(player.getLifes() + 1);
|
||||||
engine->audio.setADPCMVolume(30, 3);
|
engine->audio.setADPCMVolume(30, 3);
|
||||||
engine->audio.playADPCM(pickupSound, 3);
|
engine->audio.playADPCM(pickupSound, 3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < MINES_COUNT; i++)
|
||||||
|
{
|
||||||
|
mines[i].update();
|
||||||
|
Vector3 vecDist = mines[i].mesh.position - player.mesh.position;
|
||||||
|
float dist = vecDist.length();
|
||||||
|
|
||||||
|
if (dist < 20.F && !mines[i].getExplosionTicks())
|
||||||
|
{
|
||||||
|
printf("Vecdist %f,%f,%f\n", vecDist.x, vecDist.y, vecDist.z);
|
||||||
|
printf("Explode %d Dist %d\n", i, dist);
|
||||||
|
mines[i].explode();
|
||||||
|
player.setLife(player.getLifes() - 1);
|
||||||
|
//Buffer switching to prevent playing two sounds on one buffer
|
||||||
|
engine->audio.setADPCMVolume(65, Mine::lastSoundBuffer);
|
||||||
|
engine->audio.playADPCM(boomSound, Mine::lastSoundBuffer);
|
||||||
|
Mine::lastSoundBuffer = Mine::lastSoundBuffer == 4 ? 5 : 4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (player.mesh.position.y > WATER_LEVEL - 5)
|
if (player.mesh.position.y > WATER_LEVEL - 5)
|
||||||
player.mesh.position.y = WATER_LEVEL - 5;
|
player.mesh.position.y = WATER_LEVEL - 5;
|
||||||
|
|
||||||
@@ -175,6 +234,11 @@ void Dolphin::onUpdate()
|
|||||||
engine->renderer->draw(oysters[i].mesh);
|
engine->renderer->draw(oysters[i].mesh);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (u8 i = 0; i < MINES_COUNT; i++)
|
||||||
|
{
|
||||||
|
if (mines[i].getExplosionTicks() < MINE_EXPLOSION_TICKS)
|
||||||
|
engine->renderer->draw(mines[i].mesh);
|
||||||
|
}
|
||||||
for (u8 i = 0; i < player.getLifes(); i++)
|
for (u8 i = 0; i < player.getLifes(); i++)
|
||||||
{
|
{
|
||||||
engine->renderer->draw(lifeSprites[i]);
|
engine->renderer->draw(lifeSprites[i]);
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
#include "./camera.hpp"
|
#include "./camera.hpp"
|
||||||
#include "./objects/player.hpp"
|
#include "./objects/player.hpp"
|
||||||
#include "./objects/collectible.hpp"
|
#include "./objects/collectible.hpp"
|
||||||
|
#include "./objects/mine.hpp"
|
||||||
|
|
||||||
class Dolphin : public Game
|
class Dolphin : public Game
|
||||||
{
|
{
|
||||||
@@ -41,6 +42,7 @@ private:
|
|||||||
Mesh seabed;
|
Mesh seabed;
|
||||||
Mesh island;
|
Mesh island;
|
||||||
Mesh skybox;
|
Mesh skybox;
|
||||||
|
Mesh mine;
|
||||||
LightBulb bulb;
|
LightBulb bulb;
|
||||||
Player player;
|
Player player;
|
||||||
Camera camera;
|
Camera camera;
|
||||||
@@ -50,8 +52,11 @@ private:
|
|||||||
Mesh water;
|
Mesh water;
|
||||||
Mesh waterbox;
|
Mesh waterbox;
|
||||||
Sprite lifeSprites[3];
|
Sprite lifeSprites[3];
|
||||||
|
Sprite gameOver;
|
||||||
audsrv_adpcm_t *underwaterAmbient, *surfaceAmbient;
|
audsrv_adpcm_t *underwaterAmbient, *surfaceAmbient;
|
||||||
audsrv_adpcm_t *pickupSound;
|
audsrv_adpcm_t *pickupSound;
|
||||||
|
audsrv_adpcm_t *boomSound;
|
||||||
|
Mine *mines;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
# ______ ____ ___
|
||||||
|
# | \/ ____| |___|
|
||||||
|
# | | | \ | |
|
||||||
|
#-----------------------------------------------------------------------
|
||||||
|
# Copyright 2020, tyra - https://github.com/h4570/tyra
|
||||||
|
# Licenced under Apache License 2.0
|
||||||
|
# Michał Mostowik <mostek3pl@gmail.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "mine.hpp"
|
||||||
|
|
||||||
|
u8 Mine::lastSoundBuffer = 4;
|
||||||
|
|
||||||
|
Mine::Mine()
|
||||||
|
{
|
||||||
|
mesh.position.set(0.0F, 0.0F, 0.0F);
|
||||||
|
|
||||||
|
bExploding = false;
|
||||||
|
explosionTicks = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
Mine::~Mine()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Mine::update()
|
||||||
|
{
|
||||||
|
if (bExploding && explosionTicks < MINE_EXPLOSION_TICKS)
|
||||||
|
{
|
||||||
|
explosionTicks++;
|
||||||
|
mesh.scale++;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
# ______ ____ ___
|
||||||
|
# | \/ ____| |___|
|
||||||
|
# | | | \ | |
|
||||||
|
#-----------------------------------------------------------------------
|
||||||
|
# Copyright 2020, tyra - https://github.com/h4570/tyra
|
||||||
|
# Licenced under Apache License 2.0
|
||||||
|
# Michał Mostowik <mostek3pl@gmail.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _MINE_
|
||||||
|
#define _MINE_
|
||||||
|
|
||||||
|
#include <tamtypes.h>
|
||||||
|
#include <models/mesh.hpp>
|
||||||
|
|
||||||
|
#define MINE_EXPLOSION_TICKS 10
|
||||||
|
|
||||||
|
class Mine
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static u8 lastSoundBuffer;
|
||||||
|
Mesh mesh;
|
||||||
|
void explode() { bExploding = true; }
|
||||||
|
void update();
|
||||||
|
Mine();
|
||||||
|
~Mine();
|
||||||
|
const u8 &getExplosionTicks() { return explosionTicks; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
u8 bExploding;
|
||||||
|
u8 explosionTicks;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -23,7 +23,7 @@ Player::Player()
|
|||||||
mesh.shouldBeFrustumCulled = false;
|
mesh.shouldBeFrustumCulled = false;
|
||||||
mesh.position.set(0.0F, 0.0F, 10.0f);
|
mesh.position.set(0.0F, 0.0F, 10.0f);
|
||||||
mesh.rotation.x = -1.6F;
|
mesh.rotation.x = -1.6F;
|
||||||
mesh.setAnimSpeed(0.05F);
|
mesh.setAnimSpeed(0.04F);
|
||||||
bIsJumping = false;
|
bIsJumping = false;
|
||||||
lifes = 3;
|
lifes = 3;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ public:
|
|||||||
void update(Pad &t_pad);
|
void update(Pad &t_pad);
|
||||||
const u8 &isJumping() { return bIsJumping; }
|
const u8 &isJumping() { return bIsJumping; }
|
||||||
const u8 &getLifes() { return lifes; }
|
const u8 &getLifes() { return lifes; }
|
||||||
|
void setLife(const u8 &l) { lifes = lifes = l < 4 ? l : 3; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
u8 bIsJumping;
|
u8 bIsJumping;
|
||||||
|
|||||||
Reference in New Issue
Block a user