Added: collectibles class. Collectibles are strewn around the level and can be 'picked up' (deactivated, won't be rendered), when the player gets close and jumps.

This commit is contained in:
Foxar
2020-12-05 22:04:38 +01:00
parent b547de9cbb
commit c0ab97585c
7 changed files with 122 additions and 1 deletions
@@ -0,0 +1,39 @@
/*
# ______ ____ ___
# | \/ ____| |___|
# | | | \ | |
#-----------------------------------------------------------------------
# Copyright 2020, tyra - https://github.com/h4570/tyra
# Licenced under Apache License 2.0
# Michał Mostowik <mostek3pl@gmail.com>
*/
#include "collectible.hpp"
#include <loaders/obj_loader.hpp>
#include <loaders/bmp_loader.hpp>
#include <modules/gif_sender.hpp>
#include <utils/debug.hpp>
#include <utils/math.hpp>
Collectible::Collectible()
{
mesh.loadObj("oyster/", "oyster", 10.F, false);
mesh.shouldBeFrustumCulled = false;
mesh.position.set(0.0F, 0.0F, 0.0f);
bActive = true;
}
Collectible::~Collectible()
{
}
void Collectible::setActive(u8 b)
{
bActive = b;
}
u8 Collectible::isActive()
{
return bActive;
}
@@ -0,0 +1,33 @@
/*
# ______ ____ ___
# | \/ ____| |___|
# | | | \ | |
#-----------------------------------------------------------------------
# Copyright 2020, tyra - https://github.com/h4570/tyra
# Licenced under Apache License 2.0
# Michał Mostowik <mostek3pl@gmail.com>
*/
#ifndef _COLLECTIBLE_
#define _COLLECTIBLE_
#include "../camera.hpp"
#include <tamtypes.h>
class Collectible
{
public:
float rotation;
Mesh mesh;
Collectible();
~Collectible();
void update();
void setActive(u8 b);
u8 isActive();
private:
u8 bActive;
};
#endif
+5
View File
@@ -86,4 +86,9 @@ void Player::update(Pad &t_pad)
mesh.position.x +=
Math::sin(mesh.rotation.z) * velocity * (isJumping + 1);
mesh.position.y += lift;
}
u8 Player::getIsJumping()
{
return isJumping;
}
+1
View File
@@ -26,6 +26,7 @@ public:
Player();
~Player();
void update(Pad &t_pad);
u8 getIsJumping();
private:
u8 isJumping;