From 36182673efdda6004d38ac3fdecd5f961bad39b7 Mon Sep 17 00:00:00 2001 From: Noel Berry Date: Sun, 3 Jan 2021 17:03:48 -0800 Subject: [PATCH] more rooms and enemies! --- content/map/0x0.png | Bin 187 -> 215 bytes content/map/1x0.png | Bin 130 -> 280 bytes content/map/2x0.png | Bin 0 -> 261 bytes content/map/3x0.png | Bin 0 -> 261 bytes content/map/3x1.png | Bin 0 -> 338 bytes content/map/4x1.png | Bin 0 -> 323 bytes content/map/5x1.png | Bin 0 -> 325 bytes content/sprites/bullet.ase | Bin 0 -> 700 bytes content/sprites/mosquito.ase | Bin 0 -> 823 bytes content/sprites/player.ase | Bin 1888 -> 2136 bytes content/sprites/spitter.ase | Bin 0 -> 1129 bytes content/tilesets/back.ase | Bin 0 -> 635 bytes src/components/hurtable.cpp | 18 ++++- src/components/hurtable.h | 6 +- src/components/mover.cpp | 10 ++- src/components/mover.h | 3 + src/components/player.cpp | 10 ++- src/components/player.h | 4 +- src/factory.cpp | 151 ++++++++++++++++++++++++++++++++++- src/factory.h | 3 + src/game.cpp | 36 +++++++-- 21 files changed, 220 insertions(+), 21 deletions(-) create mode 100644 content/map/2x0.png create mode 100644 content/map/3x0.png create mode 100644 content/map/3x1.png create mode 100644 content/map/4x1.png create mode 100644 content/map/5x1.png create mode 100644 content/sprites/bullet.ase create mode 100644 content/sprites/mosquito.ase create mode 100644 content/sprites/spitter.ase create mode 100644 content/tilesets/back.ase diff --git a/content/map/0x0.png b/content/map/0x0.png index 1642027036fd645b30078c160a615e6d38f57991..371fb6fd88ff4f63b36db0fda23e22ef881ce78c 100644 GIT binary patch delta 174 zcmV;f08#(D0oMVLF@KRsL_t(YiDP77VEE540Dx&AEFHCYWLV5XZwp;DY#10A=(#qZ#26Xylw9Z*@4j(_EQ|mD$Fzb4=8}?kr6>|x zr(eWSoVCw@VVctg2JcLL3^nLtxXgtC#{TJE1k37zjI9`A6DMYP6Viqk4DNhPsqe6X ckym5_0BUwAOO^rHGXMYp07*qoM6N<$g6XSI+W-In delta 146 zcmV;D0B!%*0lNW^F@JSQL_t(YiDP77VEE540Dx&AEFHCY)Z$T#hn~gPt9LP6uik|s z#>ha2lI#C}Oe>?4RyM(8mQC zTQS5Y%gbe@y9pNJUK|C}@01E&B07*qoM6N<$f-uED AS^xk5 diff --git a/content/map/1x0.png b/content/map/1x0.png index d71c89f02b7f0f4d5bdea8b78a72b334388f7fe1..5e9ed8085b351a06d5ff62b331ebe727f0e79829 100644 GIT binary patch delta 239 zcmVUMJ`};)v!VF%I+ISa9RkH!v)aw;8TxbF*ZQRLTr{2($BK%`eCe! z-85~9vJjUggrbP?KaN!6rfJK-=J=U`fq{XcN2r^Dfq{WRvuM?gA#0xj!^71GEnBBw zWbn?^XZW?Bmw|zS0j}rQeqM%ju5S!8zj49EVCoqd7#JA)r+cATT#&I9#Q_s$coXs@ ph8}DH-JAi-#~41Q7Z`a(CIBVKNA3b0N1Ffu002ovPDHLkV1nBJa@PO= delta 88 zcmbQi)WkT!Fwn-+#WBRAGx^W||NraT7#Vz+6JMU#GGk(6W1>l)yRKZE*yaaXJ0v6} sGqVgm?atjwcQEaibU*znusf5Lp&^d9aL>duy$nF$>FVdQ&MBb@08Mow)&Kwi diff --git a/content/map/2x0.png b/content/map/2x0.png new file mode 100644 index 0000000000000000000000000000000000000000..fe45f8d4a13619f625f29ab0e0ac3f5a08947655 GIT binary patch literal 261 zcmeAS@N?(olHy`uVBq!ia0vp^azHG|!3HExrOA{7DaPU;cPEB*=VV?2Ir}|b978-h zlT#8Bew;U8XvkF1k=zT`Ug_elvra3cD4ixT_g+sapZmH374Tm4mHPX1q_KdEV#Lb7(-jTXs!5=91v zF%3@^xS0#g^gm&g(s22>!S%^W5}FAIy!6CkgtmOr=fRu1=6wbRMi&&V6{ESBOFkR&yxCPZqp`8^ zRNV zVEK1D)?U_6vXGc2K!0b1izLb>aqBy8n!ay`gg^P82-X#v;JnCAUdP zd{gR+M+T=8_ua33%n`QL#Q*AvgZ*z3RxQhVvOtZ6ZOsW5hLg1kxo*h}SwOEac)I$z JtaD0e0sv5tXzc(1 literal 0 HcmV?d00001 diff --git a/content/map/3x1.png b/content/map/3x1.png new file mode 100644 index 0000000000000000000000000000000000000000..f405b2a2f93d39271aba9ec71cd690755cc45cd0 GIT binary patch literal 338 zcmV-Y0j>UtP)Px$3`s;mR7i=nl`)ROFc3wbS8U5IRtgu`3L2zPz(qm_H7(Ro0T+QHlu%L8CFekN z6y9RxXcA%^Tj7`EWd8p%KaN`O#+nu}OAY{xdV`{tW@i94`$Y<*@syt#=@BUiJgh@(F6@BA&XFPe%o0;>4fj_Y882f}g4cx59fr`83h z<5_ZeA*ds@)oj8(KI-6bxyGlIda2n0B_|T(ST-;u*&-!dq(IrFO+@hLBoRk_qGb$# zUe@2hN~w~FAjdxGmEt5CJ9gb{X4jIS8Z3F{HR|X6m+$V?=apjbz14_QenD&PPh3Z8 ket9lbci)(}jUR`^A7*M+Xhf@=jsO4v07*qoM6N<$f(E3L;{X5v literal 0 HcmV?d00001 diff --git a/content/map/4x1.png b/content/map/4x1.png new file mode 100644 index 0000000000000000000000000000000000000000..e7fb624f31f1b8e297109e733dc167fdf2fb10c0 GIT binary patch literal 323 zcmV-J0lfZ+P)Px#{YgYYR7iPx#|4BqaR7i=;*{ezQd~L9*VjmT0I6Xl{(&c z3FL|VjR+Be4xd^Lsm}Ao?QLyxAmX#eyUU6t@{w}neV15!xjeSU^rRFz)pSMI(3Q_Y zywzEpit4!hP@vQ@O=V-Do#0w#(5;rhoAhN{)+ek X`S5Y7rTC~}00000NkvXXu0mjfyBLi3 literal 0 HcmV?d00001 diff --git a/content/sprites/bullet.ase b/content/sprites/bullet.ase new file mode 100644 index 0000000000000000000000000000000000000000..5514a4f48badb91f745fb1c3e115b1a2eea28340 GIT binary patch literal 700 zcmb`EODIH99Ebm2&4e^7Miz4#!p_VjV=^_RB*wy{NEYZCHIqg($)hAh*~~_Xv9Pfq z)=IL#PIgLIpvG3Q66*NwWuk1I)A{cI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>a_~!kBe-nZ1vY#<0xF-1!LX}2V4PwHD2ej}gCoMh$Vd$+ zmX?DlIa8pli3Za~roo|iW{}1rq^Z3dyii&RDwIkvIY|N*?5zgx2M2@3<1%pUTn|`N ze-NzB71K%#z_L7d3I&G11c;C92#(Zx>G-#956_dAjAeq~UbS~sd$;0xzZ`}dC-gu2pV&css8Na9y*e(^(9 z6+_plXpz@Q{BM5GjHj6&)amVoa4pR-tOw6>+_G2QyuaK$xMk8P2Hh#m=qpoc_lI=M zZhFPz=MRR~$tSy-_#t}JtsX|qo}N@qxZ|*4g_ou7nDy`T;&%;(I?YVxGw;kqy_wWFd#lCs z`cJX-vR?1p#m{~(;tk<%#ll~{Tc30;R%EJQE-;C?BzmOWX064jmTB{BRyJ|6v$_#i zSX+-qyAX*Z6I+8x`{3XF15iEG*1 m;U9X=Y-~5zyLo5h`9tH|0^f^N(K> literal 0 HcmV?d00001 diff --git a/content/tilesets/back.ase b/content/tilesets/back.ase new file mode 100644 index 0000000000000000000000000000000000000000..5a14ee756f039265e6eb4471287d3ab7a5ab0684 GIT binary patch literal 635 zcmcJN%PWLY7>AF`G!_;X(y%bcrC}p8LoQKM%EBedg0L_elu=|zq(+I+jK$2tC6|Sb zY|zX?%0h{aWF-j;goTCs$|cA14dNg0e!WlUdry78=X{;PNFmM_BZL%jbc7J1h5jvO z+EB#s{71d<_18yTI8{eL0tP`dDo*4h^gqKQ)RGAA)GmBwcp#}PDi{M$e z2_7%B!Mp8Q`1X_sXRfQEbJGm-Cpuw8dp4}8NQc(qLTIz~LbH7sHg;Y>$DD#q`&V%9 z^c^Znh`E(@IN~0I?M^4GudRW7B|f-pwZh{%2Rs_wfd1)n=<6~oCkKeu{<~zsAvgj0 zxFe1=%J?FSDVjJUh#hKpA%zh-nu}6cpg=z1Boj*}fus>-)RJTr{3#TKUQ{*@w7R6l z#fwgUZ7D9rS83Oxf4=81_;T;_BpM9nouD`Ex%(zX@5mVs7_x3N;*({PXE)R#Eg`qb ucheck(hurt_by)) { - m_cooldown_timer = cooldown; + stun_timer = 0.5f; + flicker_timer = 0.5f; on_hurt(this); } } - m_cooldown_timer -= Time::delta; + stun_timer -= Time::delta; + + if (flicker_timer > 0) + { + flicker_timer -= Time::delta; + + if (Time::on_interval(0.05f)) + entity()->visible = !entity()->visible; + if (flicker_timer <= 0) + entity()->visible = true; + } } diff --git a/src/components/hurtable.h b/src/components/hurtable.h index f4d477b..3ba8417 100644 --- a/src/components/hurtable.h +++ b/src/components/hurtable.h @@ -10,13 +10,11 @@ namespace TL { class Hurtable : public Component { - private: - float m_cooldown_timer = 0; - public: + float stun_timer = 0; + float flicker_timer = 0; Collider* collider = nullptr; uint32_t hurt_by = 0; - float cooldown = 1.0f; std::function on_hurt; void update() override; diff --git a/src/components/mover.cpp b/src/components/mover.cpp index a0bebb8..fad527d 100644 --- a/src/components/mover.cpp +++ b/src/components/mover.cpp @@ -13,7 +13,10 @@ bool Mover::move_x(int amount) { if (collider->check(Mask::solid, Point(sign, 0))) { - stop_x(); + if (on_hit_x) + on_hit_x(this); + else + stop_x(); return true; } @@ -37,7 +40,10 @@ bool Mover::move_y(int amount) { if (collider->check(Mask::solid, Point(0, sign))) { - stop_y(); + if (on_hit_y) + on_hit_y(this); + else + stop_y(); return true; } diff --git a/src/components/mover.h b/src/components/mover.h index c231c3f..e3b6735 100644 --- a/src/components/mover.h +++ b/src/components/mover.h @@ -2,6 +2,7 @@ #include "../world.h" #include "collider.h" #include +#include using namespace Blah; @@ -16,6 +17,8 @@ namespace TL Collider* collider = nullptr; Vec2 speed; float gravity = 0; + std::function on_hit_x; + std::function on_hit_y; bool move_x(int amount); bool move_y(int amount); diff --git a/src/components/player.cpp b/src/components/player.cpp index 9ded4a1..59e525e 100644 --- a/src/components/player.cpp +++ b/src/components/player.cpp @@ -65,8 +65,16 @@ void Player::update() anim->scale.x = Calc::abs(anim->scale.x) * m_facing; } + // START + if (m_state == st_start) + { + anim->play("sword"); + m_start_timer -= Time::delta; + if (m_start_timer <= 0) + m_state = st_normal; + } // NORMAL STATE - if (m_state == st_normal) + else if (m_state == st_normal) { // Current Animation if (m_on_ground) diff --git a/src/components/player.h b/src/components/player.h index 9a072da..3b3e3ed 100644 --- a/src/components/player.h +++ b/src/components/player.h @@ -13,6 +13,7 @@ namespace TL static constexpr int st_normal = 0; static constexpr int st_attack = 1; static constexpr int st_hurt = 2; + static constexpr int st_start = 3; int health = 3; @@ -24,12 +25,13 @@ namespace TL void update() override; private: - int m_state = st_normal; + int m_state = st_start; int m_facing = 1; float m_jump_timer = 0; float m_attack_timer = 0; float m_hurt_timer = 0; float m_invincible_timer = 0; + float m_start_timer = 1; Collider* m_attack_collider = nullptr; bool m_on_ground; }; diff --git a/src/factory.cpp b/src/factory.cpp index edfa36d..a4f833b 100644 --- a/src/factory.cpp +++ b/src/factory.cpp @@ -59,9 +59,154 @@ Entity* Factory::pop(World* world, Point position) anim->depth = -20; auto timer = en->add(Timer(anim->animation()->duration(), [](Timer* self) - { - self->entity()->destroy(); - })); + { + self->entity()->destroy(); + })); + + return en; +} + +Entity* Factory::spitter(World* world, Point position) +{ + auto en = world->add_entity(position); + + auto anim = en->add(Animator("spitter")); + anim->play("idle"); + anim->depth = -5; + + auto hitbox = en->add(Collider::make_rect(RectI(-6, -12, 12, 12))); + hitbox->mask = Mask::enemy; + + auto hurtable = en->add(Hurtable()); + hurtable->hurt_by = Mask::player_attack; + hurtable->collider = hitbox; + hurtable->on_hurt = [](Hurtable* self) mutable + { + Time::pause_for(0.1f); + pop(self->world(), self->entity()->position + Point(0, -4)); + self->entity()->destroy(); + }; + + auto timer = en->add(Timer(1.0f, [](Timer* self) + { + bullet(self->world(), self->entity()->position + Point(-8, -8), -1); + self->get()->play("shoot"); + self->entity()->add(Timer(0.4f, [](Timer* self) { self->get()->play("idle"); })); + self->start(3.0f); + })); + + return en; +} + +Entity* Factory::bullet(World* world, Point position, int direction) +{ + auto en = world->add_entity(position); + + auto anim = en->add(Animator("bullet")); + anim->play("idle"); + anim->depth = -5; + + auto hitbox = en->add(Collider::make_rect(RectI(-4, -4, 8, 8))); + hitbox->mask = Mask::enemy; + + auto mover = en->add(Mover()); + mover->collider = hitbox; + mover->speed = Vec2(direction * 40, 0); + mover->gravity = 130; + mover->on_hit_x = [](Mover* self) { self->entity()->destroy(); }; + mover->on_hit_y = [](Mover* self) { self->speed.y = -60; }; + + auto hurtable = en->add(Hurtable()); + hurtable->hurt_by = Mask::player_attack; + hurtable->collider = hitbox; + hurtable->on_hurt = [](Hurtable* self) mutable + { + Time::pause_for(0.1f); + pop(self->world(), self->entity()->position + Point(0, -4)); + self->entity()->destroy(); + }; + + en->add(Timer(2.5f, [](Timer* self) + { + self->get()->flicker_timer = 100; + })); + + en->add(Timer(3.0f, [](Timer* self) + { + self->entity()->destroy(); + })); + + return en; +} + +namespace +{ + class MosquitoBehavior : public Component + { + public: + int health = 2; + float timer = 0; + + void update() override + { + auto mover = get(); + auto player = world()->first(); + if (player) + { + auto diff = player->entity()->position.x - entity()->position.x; + auto dist = Calc::abs(diff); + + if (dist < 100) + mover->speed.x += Calc::sign(diff) * 100 * Time::delta; + else + mover->speed.x = Calc::approach(mover->speed.x, 0, 100 * Time::delta); + + if (Calc::abs(mover->speed.x) > 50) + mover->speed.x = Calc::approach(mover->speed.x, Calc::sign(mover->speed.x) * 50, 800 * Time::delta); + + mover->speed.y = Calc::sin(timer) * 10; + } + + timer += Time::delta * 4; + } + + void hurt() + { + health--; + if (health <= 0) + { + Factory::pop(world(), entity()->position); + entity()->destroy(); + } + else + { + auto mover = get(); + auto player = world()->first(); + auto sign = Calc::sign(player->entity()->position.x - entity()->position.x); + mover->speed.x = -sign * 140; + } + } + }; +} + +Entity* Factory::mosquito(World* world, Point position) +{ + auto en = world->add_entity(position); + auto mosquito = en->add(MosquitoBehavior()); + + auto anim = en->add(Animator("mosquito")); + anim->play("fly"); + anim->depth = -5; + + auto hitbox = en->add(Collider::make_rect(RectI(-4, -4, 8, 8))); + hitbox->mask = Mask::enemy; + + auto mover = en->add(Mover()); + + auto hurtable = en->add(Hurtable()); + hurtable->hurt_by = Mask::player_attack; + hurtable->collider = hitbox; + hurtable->on_hurt = [](Hurtable* self) { self->get()->hurt(); }; return en; } diff --git a/src/factory.h b/src/factory.h index 72334aa..8e86303 100644 --- a/src/factory.h +++ b/src/factory.h @@ -11,5 +11,8 @@ namespace TL Entity* player(World* world, Point position); Entity* bramble(World* world, Point position); Entity* pop(World* world, Point position); + Entity* spitter(World* world, Point position); + Entity* bullet(World* world, Point position, int direction); + Entity* mosquito(World* world, Point position); } } \ No newline at end of file diff --git a/src/game.cpp b/src/game.cpp index 9094d32..2e7031d 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -24,12 +24,11 @@ void Game::startup() // set batcher to use Nearest Filter batch.default_sampler = TextureSampler(TextureFilter::Nearest); - m_draw_colliders = false; - // camera setup - camera = Vec2::zero; + // load first room load_room(Point(0, 0)); + camera = Vec2(room.x * width, room.y * height); } void Game::load_room(Point cell) @@ -45,6 +44,7 @@ void Game::load_room(Point cell) auto castle = Content::find_tileset("castle"); auto grass = Content::find_tileset("grass"); auto plants = Content::find_tileset("plants"); + auto backs = Content::find_tileset("back"); // make the floor auto floor = world.add_entity(offset); @@ -56,7 +56,7 @@ void Game::load_room(Point cell) for (int x = 0; x < columns; x ++) for (int y = 0; y < rows; y++) { - Point world_position = offset + Point(x * tile_width, y * tile_height); + Point world_position = offset + Point(x * tile_width, y * tile_height) + Point(tile_width / 2, tile_height); Color col = grid->pixels[x + y * columns]; uint32_t rgb = ((uint32_t)col.r << 16) | @@ -86,15 +86,30 @@ void Game::load_room(Point cell) tilemap->set_cell(x, y, &plants->random_tile()); break; + // back tiles + case 0x45283c: + tilemap->set_cell(x, y, &backs->random_tile()); + break; + // player (only if it doesn't already exist) case 0x6abe30: if (!world.first()) - Factory::player(&world, world_position + Point(tile_width / 2, tile_height)); + Factory::player(&world, world_position); break; // brambles case 0xd77bba: - Factory::bramble(&world, world_position + Point(tile_width / 2, tile_height)); + Factory::bramble(&world, world_position); + break; + + // spitter plant + case 0xac3232: + Factory::spitter(&world, world_position); + break; + + // mosquito + case 0xfbf236: + Factory::mosquito(&world, world_position + Point(0, -8)); break; } } @@ -164,7 +179,14 @@ void Game::update() { player->entity()->position = Point( Calc::clamp_int(pos.x, bounds.x, bounds.x + bounds.w), - Calc::clamp_int(pos.y, bounds.y, bounds.y + bounds.h)); + Calc::clamp_int(pos.y, bounds.y, bounds.y + bounds.h + 100)); + + // reload if they fell out the bottom + if (player->entity()->position.y > bounds.y + bounds.h + 64) + { + world.clear(); + load_room(room); + } } } }