From 164eaa3eb65d26fff1f84ac1f3d7cab1d6c86e2f Mon Sep 17 00:00:00 2001 From: Stephen Seo Date: Wed, 1 Feb 2023 14:57:28 +0900 Subject: [PATCH] Increase amount of 2D objects spawned on hit Also randomize their movement. --- src/3d/anim_falling_2d.cc | 10 ++-------- src/3d/anim_falling_2d.h | 3 --- src/3d/deferred_2d_draw.cc | 9 +++++---- src/3d_renderer.cc | 25 +++++++++++++++++++------ src/constants.h | 3 +++ 5 files changed, 29 insertions(+), 21 deletions(-) diff --git a/src/3d/anim_falling_2d.cc b/src/3d/anim_falling_2d.cc index b30e606..ed4f2be 100644 --- a/src/3d/anim_falling_2d.cc +++ b/src/3d/anim_falling_2d.cc @@ -1,20 +1,14 @@ #include "anim_falling_2d.h" // local includes -#include - #include "../constants.h" +#include "../ems.h" #include "arrays_conv.h" #include "deferred_2d_draw.h" AnimFalling2D::AnimFalling2D(A3F pos, A4C color, Texture2D *texture, A4F txywh, bool is_going_right, Deferred2DMap *map) - : Anims(nullptr, pos, color), - map(map), - wh{txywh.at(2), txywh.at(3)}, - dx(is_going_right ? MODEL_FALLING_2D_DX : -MODEL_FALLING_2D_DX), - dy(MODEL_FALLING_2D_DY), - ddy(MODEL_FALLING_2D_DDY) { + : Anims(nullptr, pos, color), map(map), wh{txywh.at(2), txywh.at(3)} { Deferred2DDraw def(texture, txywh, A2F{pos.at(0), pos.at(1)}, A2F{txywh.at(2) / 2.0F, txywh.at(3) / 2.0F}, color, 0.0F, is_going_right); diff --git a/src/3d/anim_falling_2d.h b/src/3d/anim_falling_2d.h index c3400e8..5ddbc7b 100644 --- a/src/3d/anim_falling_2d.h +++ b/src/3d/anim_falling_2d.h @@ -39,9 +39,6 @@ class AnimFalling2D : public Anims { private: Deferred2DMap *map; A2F wh; - float dx; - float dy; - float ddy; int def_id; }; diff --git a/src/3d/deferred_2d_draw.cc b/src/3d/deferred_2d_draw.cc index 35afcd8..9275e73 100644 --- a/src/3d/deferred_2d_draw.cc +++ b/src/3d/deferred_2d_draw.cc @@ -1,9 +1,8 @@ #include "deferred_2d_draw.h" // local includes -#include - #include "../constants.h" +#include "../ems.h" #include "arrays_conv.h" int Deferred2DDraw::id_counter = 0; @@ -17,8 +16,10 @@ Deferred2DDraw::Deferred2DDraw(Texture2D *texture, A4F txywh, A2F pos, origin(origin), color(color), angle(angle), - dx(is_going_right ? MODEL_FALLING_2D_DX : -MODEL_FALLING_2D_DX), - dy(MODEL_FALLING_2D_DY), + dx(is_going_right ? (MODEL_FALLING_2D_DX * call_js_get_random()) + : (-MODEL_FALLING_2D_DX * call_js_get_random())), + dy(MODEL_FALLING_2D_DY * 2.0F * call_js_get_random() - + MODEL_FALLING_2D_DY), ddy(MODEL_FALLING_2D_DDY), id(id_counter++), activated(false), diff --git a/src/3d_renderer.cc b/src/3d_renderer.cc index e8eaf9d..55bfd53 100644 --- a/src/3d_renderer.cc +++ b/src/3d_renderer.cc @@ -766,9 +766,16 @@ int Renderer3D::setup_anims(int idx, int score) { }, ptr); seqAnim->push_anim(std::move(anim_still)); - seqAnim->push_anim(std::make_unique( - A3F{p1_pos.x, p1_pos.y, 0.0F}, A4C{255, 200, 200, 255}, &spriteSheet, - p1_dims, false, &deferred_2d_draw_map)); + + auto falling_anims = std::make_unique(nullptr); + for (int i = 0; i < ANIM_FALLING_AMT; ++i) { + falling_anims->push_anim(std::make_unique( + A3F{p1_pos.x, p1_pos.y, 0.0F}, A4C{255, 200, 200, 255}, + &spriteSheet, p1_dims, i >= ANIM_FALLING_OPP_THRESHOLD, + &deferred_2d_draw_map)); + } + seqAnim->push_anim(std::move(falling_anims)); + newAnim->push_anim(std::make_unique( p2_model, A3F{score * 2.0F + 1.0F, 0.0F, 0.0F}, A4C{200, 200, 255, 255}, false)); @@ -797,9 +804,15 @@ int Renderer3D::setup_anims(int idx, int score) { }, ptr); seqAnim->push_anim(std::move(anim_still)); - seqAnim->push_anim(std::make_unique( - A3F{p2_pos.x, p2_pos.y, 0.0F}, A4C{200, 200, 255, 255}, &spriteSheet, - p2_dims, true, &deferred_2d_draw_map)); + + auto falling_anims = std::make_unique(nullptr); + for (int i = 0; i < ANIM_FALLING_AMT; ++i) { + falling_anims->push_anim(std::make_unique( + A3F{p2_pos.x, p2_pos.y, 0.0F}, A4C{255, 200, 200, 255}, + &spriteSheet, p2_dims, i < ANIM_FALLING_OPP_THRESHOLD, + &deferred_2d_draw_map)); + } + seqAnim->push_anim(std::move(falling_anims)); } break; case 0: default: diff --git a/src/constants.h b/src/constants.h index 8f799a1..54beff0 100644 --- a/src/constants.h +++ b/src/constants.h @@ -71,6 +71,9 @@ constexpr float BUTTON_COLOR_MAX = 180.0F; constexpr float SCREEN_SHAKE_DEFAULT_FACTOR = 7.0F; constexpr float SCREEN_SHAKE_TIME = 0.3F; +constexpr int ANIM_FALLING_AMT = 7; +constexpr int ANIM_FALLING_OPP_THRESHOLD = 5; + // src/3D/ constexpr float QM_ANGLE_TIMER_VARIANCE = 2.0F; -- 2.49.0