From 109692b17156ab1a25be07d3de45431c257d5e6e Mon Sep 17 00:00:00 2001 From: SlyVTT Date: Wed, 23 Aug 2023 20:16:30 +0200 Subject: [PATCH] added boss tarjectory based on splines + corrected bullet vector trajectory taht was not correctly rounded during num32->int conversion --- .../__pycache__/converters.cpython-310.pyc | Bin 1530 -> 0 bytes src/boss.cpp | 22 ++++++++--- src/bullet.cpp | 37 ++++++++++++++++++ src/bullet.h | 1 + src/main.cpp | 22 +++++++++++ 5 files changed, 76 insertions(+), 6 deletions(-) delete mode 100644 assets-cg/__pycache__/converters.cpython-310.pyc diff --git a/assets-cg/__pycache__/converters.cpython-310.pyc b/assets-cg/__pycache__/converters.cpython-310.pyc deleted file mode 100644 index c9120c5c729c7cc2323b59fb39dc945bede3850c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1530 zcmZ8h&1)k!6qhub58LCfBwepBZCPlk4{P@W+Diz94LuYZmL?}dFq6^5o^-w2P?+EWoq>#djC~HL_ymg8g1(){8vK5v>=IL{J zS47%MgMwqQy*C6xwZc5RiMX7>j}g^&oE4?iPF~7-Edm~-LOU|x^GN=IxVeuv$CE{# zMiX(D+yrqpdCBuRY)bU zrSO3GxPvLCg!>@;=jaEZfcxJbeF>>cw8oMsxbYR);EF2B2wa5)lMd0^GWWV6l`W~V zS5OaSuWjaTF!P3}azJue1El5vRW5Vau0p&2NVzTaJ@|sZ?f~oth_zss2hltet!kLq z3aqQ9YOX!z1J_cGbz_4d4rT43p`9Tjr1Gma>$2W!qv;RPFdEd3RsC%|)q~US zsXcaJVxKpveboowJ+)uk^{;=fqxV&R>*x9h*}U3QU4_{@0InxPG(eYDjFj~o{;@_i zKx%NJG1s1qlgQMyMw50#Uh*(n(yO5~ZTc~YjC(DtjC z$%S?nQ9NJB(4g^Qn5Hr|r!a-7{2Z`-?o^lo!f((|jPhIv{XePFy9*9U0%-XqYD50g9$5^)5~!(Qzq!5yIVOw%}>&-fGL3(qvo zf;1ZKYg(U$CV9X#&5H=m#iJq#!bsZ%hsM>mD3TbKFfT!(S9zRi3pxliNiHJoT;7@- zbmLU=GL$8U)+|5!R9if{)HbyL99&)8$w+|ylh3tPNUp6Yxf~sshX`@gG~6@|Zx~W% z*fQyzZR?`DkA$yy6lpKJ_%@PICf(ZA?qvWKaCd_C&2`S+N;_sI;$@`qD~%Vrm0g^H z_xf&hL)4jn1MkUG$Urx1^~^ZY_I3+3KK@q{ZeFksOfd%1!%r;_cSwhPNSdUHo7ls9 z6m;YnIe^!|w;b%l*TX&X%&Kiio_5Uhn5W!SlYeB$yFj#CzCalculatePosition( dt, speed, true, &x, &y ); + } + + + xmin = (int) x - width; xmax = (int) x + width; ymin = (int) y - height; @@ -228,7 +238,7 @@ void Boss::Update( float dt ) Vector2D shootDirection( MyPlayer->x - xGuns[i], MyPlayer->y - yGuns[i] ); shootDirection.Normalise(); - Bullet *b = new Bullet( (int) xGuns[i] , (int) yGuns[i], (int) shootDirection.x, (int) shootDirection.y, BULLET_ENEMY_RED ); + Bullet *b = new Bullet( xGuns[i] , yGuns[i], shootDirection.x, shootDirection.y, BULLET_ENEMY_RED ); MyEnemiesBullets.push_back( b ); hasExternalGun = true; @@ -411,7 +421,7 @@ bool Boss::Shoot_OK( uint32_t tempshoot, uint8_t shootID ) { if (shootID==BULLET_ENEMY_RED) { - if(tempshoot-lastshoot0>10) + if(tempshoot-lastshoot0>1) { lastshoot0=tempshoot; return true; @@ -420,7 +430,7 @@ bool Boss::Shoot_OK( uint32_t tempshoot, uint8_t shootID ) } else if (shootID==BULLET_ENEMY_GREEN) { - if(tempshoot-lastshoot1>25) + if(tempshoot-lastshoot1>1) { lastshoot1=tempshoot; return true; diff --git a/src/bullet.cpp b/src/bullet.cpp index bb5c375..6e3a207 100644 --- a/src/bullet.cpp +++ b/src/bullet.cpp @@ -56,6 +56,43 @@ Bullet::Bullet( uint16_t lx, uint16_t ly, int16_t dx, int16_t dy, uint8_t id ) toberemoved = false; } +Bullet::Bullet( libnum::num lx, libnum::num ly, libnum::num dx, libnum::num dy, uint8_t id ) +{ + x = lx; + y = ly; + + sx = dx; + sy = dy; + + ID=id; + + if (ID==BULLET_NORMAL) + { + strength = 5; + } + else if (ID==BULLET_BLUE) + { + strength = 2; + } + else if (ID==BULLET_LASER) + { + strength = 1; + } + else if (ID==BULLET_ENEMY_BLUE) + { + strength = 2; + } + else if (ID==BULLET_ENEMY_RED) + { + strength = 3; + } + else if (ID==BULLET_ENEMY_GREEN) + { + strength = 5; + } + toberemoved = false; +} + Bullet::~Bullet() { diff --git a/src/bullet.h b/src/bullet.h index 8ae9470..826290e 100644 --- a/src/bullet.h +++ b/src/bullet.h @@ -20,6 +20,7 @@ class Bullet { public: Bullet( uint16_t lx, uint16_t ly, int16_t dx, int16_t dy, uint8_t id ); + Bullet( libnum::num lx, libnum::num ly, libnum::num dx, libnum::num dy, uint8_t id ); ~Bullet(); void Update( float dt ); void Render(); diff --git a/src/main.cpp b/src/main.cpp index f788db2..1f0a2b5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -489,6 +489,28 @@ int main(void) MyPlayer = new Player( azrp_width/4, azrp_height/2, 0); MyBoss = new Boss( 3*azrp_width/4, azrp_height/2, 0); + + + Point2D *A = new Point2D( 348, 112 ); + Point2D *B = new Point2D( 371, 199 ); + Point2D *C = new Point2D( 198, 149 ); + Point2D *D = new Point2D( 25, 199 ); + Point2D *E = new Point2D( 25, 25 ); + Point2D *F = new Point2D( 198, 75 ); + Point2D *G = new Point2D( 371, 25 ); + + Trajectory *MyTrajectory= new Trajectory(); + MyTrajectory->AddPoint( A ); + MyTrajectory->AddPoint( B ); + MyTrajectory->AddPoint( C ); + MyTrajectory->AddPoint( D ); + MyTrajectory->AddPoint( E ); + MyTrajectory->AddPoint( F ); + MyTrajectory->AddPoint( G ); + + MyBoss->hasTrajectory = true; + MyBoss->pathToFollow = MyTrajectory; + /* #if(DBGCRSH)