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:
@@ -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
|
||||
@@ -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;
|
||||
}
|
||||
@@ -26,6 +26,7 @@ public:
|
||||
Player();
|
||||
~Player();
|
||||
void update(Pad &t_pad);
|
||||
u8 getIsJumping();
|
||||
|
||||
private:
|
||||
u8 isJumping;
|
||||
|
||||
Reference in New Issue
Block a user