mirror of
https://github.com/NoelFB/tiny_link.git
synced 2025-07-01 19:45:27 +08:00
bunch of stuff
This commit is contained in:
@ -72,15 +72,18 @@ void Collider::set_cells(int x, int y, int w, int h, bool value)
|
||||
|
||||
bool Collider::check(uint32_t mask, Point offset) const
|
||||
{
|
||||
auto other = world()->first<Collider>();
|
||||
while (other)
|
||||
if (world())
|
||||
{
|
||||
if (other != this &&
|
||||
(other->mask & mask) == mask &&
|
||||
overlaps(other, offset))
|
||||
return true;
|
||||
auto other = world()->first<Collider>();
|
||||
while (other)
|
||||
{
|
||||
if (other != this &&
|
||||
(other->mask & mask) == mask &&
|
||||
overlaps(other, offset))
|
||||
return true;
|
||||
|
||||
other = (Collider*)other->next();
|
||||
other = (Collider*)other->next();
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
10
src/components/enemy.h
Normal file
10
src/components/enemy.h
Normal file
@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
#include "../world.h"
|
||||
|
||||
namespace TL
|
||||
{
|
||||
class Enemy : public Component
|
||||
{
|
||||
|
||||
};
|
||||
}
|
@ -9,6 +9,7 @@ void Hurtable::update()
|
||||
{
|
||||
if (collider->check(hurt_by))
|
||||
{
|
||||
Time::pause_for(0.1f);
|
||||
stun_timer = 0.5f;
|
||||
flicker_timer = 0.5f;
|
||||
on_hurt(this);
|
||||
|
@ -87,6 +87,10 @@ bool Mover::on_ground(int dist) const
|
||||
|
||||
void Mover::update()
|
||||
{
|
||||
// apply friction maybe
|
||||
if (friction > 0 && on_ground())
|
||||
speed.x = Calc::approach(speed.x, 0, friction * Time::delta);
|
||||
|
||||
// apply gravity
|
||||
if (gravity != 0 && (!collider || !collider->check(Mask::solid, Point(0, 1))))
|
||||
speed.y += gravity * Time::delta;
|
||||
|
@ -17,6 +17,7 @@ namespace TL
|
||||
Collider* collider = nullptr;
|
||||
Vec2 speed;
|
||||
float gravity = 0;
|
||||
float friction = 0;
|
||||
std::function<void(Mover*)> on_hit_x;
|
||||
std::function<void(Mover*)> on_hit_y;
|
||||
|
||||
|
@ -68,6 +68,9 @@ void Player::update()
|
||||
// START
|
||||
if (m_state == st_start)
|
||||
{
|
||||
while (hitbox->check(Mask::solid))
|
||||
entity()->position.y++;
|
||||
|
||||
anim->play("sword");
|
||||
m_start_timer -= Time::delta;
|
||||
if (m_start_timer <= 0)
|
||||
|
@ -14,8 +14,9 @@ namespace TL
|
||||
static constexpr int st_attack = 1;
|
||||
static constexpr int st_hurt = 2;
|
||||
static constexpr int st_start = 3;
|
||||
static constexpr int max_health = 3;
|
||||
|
||||
int health = 3;
|
||||
int health = max_health;
|
||||
|
||||
VirtualStick input_move;
|
||||
VirtualButton input_jump;
|
||||
|
Reference in New Issue
Block a user