diff options
author | salaaad2 <arthurdurant263@gmail.com> | 2022-08-20 23:45:40 +0200 |
---|---|---|
committer | salaaad2 <arthurdurant263@gmail.com> | 2022-08-20 23:45:40 +0200 |
commit | e9f441064c50af95a1803fd616a3b577648be668 (patch) | |
tree | 8acaae1139b449f885a4d212b56297fbd1c4a016 | |
parent | dod (diff) | |
download | yabs-e9f441064c50af95a1803fd616a3b577648be668.tar.gz yabs-e9f441064c50af95a1803fd616a3b577648be668.tar.bz2 yabs-e9f441064c50af95a1803fd616a3b577648be668.tar.xz yabs-e9f441064c50af95a1803fd616a3b577648be668.tar.zst yabs-e9f441064c50af95a1803fd616a3b577648be668.zip |
something probably happenned I dunno
-rw-r--r-- | README.org | 0 | ||||
-rw-r--r-- | src/yabs_core.cpp | 41 | ||||
-rw-r--r-- | src/yabs_core.h | 6 |
3 files changed, 26 insertions, 21 deletions
diff --git a/README.org b/README.org new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/README.org diff --git a/src/yabs_core.cpp b/src/yabs_core.cpp index c6fdb1a..31cfa3c 100644 --- a/src/yabs_core.cpp +++ b/src/yabs_core.cpp @@ -7,6 +7,7 @@ /*********************************/ #include <raylib.h> +#include <raymath.h> #include <stdlib.h> #include <iostream> #include <strings.h> @@ -127,31 +128,35 @@ int tick(TickObjs& tobjs, Scene3D& scene_3d) { YABS_DOUBLEPI - scene_3d.rotation.x, 0}); Matrix transform = MatrixMultiply(translation, rotation2); + // apply camera rotation scene_3d.camera.target.x = scene_3d.camera.position.x - transform.m12; scene_3d.camera.target.y = scene_3d.camera.position.y - transform.m13; scene_3d.camera.target.z = scene_3d.camera.position.z - transform.m14; - // shoot - range = {{ - scene_3d.camera.target.x, - scene_3d.camera.target.y, - scene_3d.camera.target.z - }, { - scene_3d.camera.target.x + 1.5f, - scene_3d.camera.target.y + 5.5f, - scene_3d.camera.target.z + 1.5f - }}; + range = { + {scene_3d.camera.target.x - 10.5f, + scene_3d.camera.target.y - 1.0f, + scene_3d.camera.target.z - 10.5f}, + {scene_3d.camera.target.x + 10.5f, + scene_3d.camera.target.y + 1.5f, + scene_3d.camera.target.z + 10.5f} + }; if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) { - for (auto it = tobjs.vEnemyBounds.begin(); it != tobjs.vEnemyBounds.end(); ++it) { - if(CheckCollisionBoxes(range, *(*it))) { // :^} + for (auto i = 0; i < tobjs.vEnemyBounds.size(); ++i) { + if(CheckCollisionBoxes(range, *tobjs.vEnemyBounds[i])) { // :^} std::cerr << "hit enemy\n"; break ; - // erase() invalidates iterators, we have to break - // empty space + //std::cout << "r: " << + //"{" << range.min.x<< "," << range.min.x << "," << range.min.z << "}," << + //"{" << range.max.x<< "," << range.max.x << "," << range.max.z << "}\n"; + //std::cout << "b: " << + //"{" << (*it)->min.x<< "," << (*it)->min.x << "," << (*it)->min.z << "}," << + //"{" << (*it)->max.x << ","<< (*it)->max.x << "," << (*it)->max.z << "}\n"; } } + std::cerr << "missed\n"; } return (1); } @@ -201,17 +206,17 @@ void init_game() for (int i = 0; i < ENEMIES_N; i++) { Enemy * e = new Enemy(); - e->enemyStartPos.x = rand() % 32; + e->enemyStartPos.x = GetRandomValue(20, 40); e->enemyStartPos.y = 1.0f; - e->enemyStartPos.z = rand() % 32; + e->enemyStartPos.z = GetRandomValue(20, 40); e->enemyBoxPos.x = e->enemyStartPos.x; e->enemyBoxPos.y = e->enemyStartPos.y; e->enemyBoxPos.z = e->enemyStartPos.z; e->enemyBoxSize = cubeSize; e->active = true; e->enemyBounds = { - {e->enemyBoxPos.x - 2.5f, 0.0f, e->enemyBoxPos.z - 2.5f}, - {e->enemyBoxPos.x + 2.5f, 2.5f, e->enemyBoxPos.z + 2.5f} + {e->enemyBoxPos.x -2.5f, 0.0f, e->enemyBoxPos.z-2.5f}, + {e->enemyBoxPos.x+2.5f, 2.5f, e->enemyBoxPos.z+2.5f} }; robjs.vEnemyPos.push_back(&e->enemyBoxPos); tobjs.vEnemyBounds.push_back(&e->enemyBounds); diff --git a/src/yabs_core.h b/src/yabs_core.h index 8ca4cfe..dd712eb 100644 --- a/src/yabs_core.h +++ b/src/yabs_core.h @@ -16,11 +16,11 @@ #include "yabs_structs.h" #ifdef __FreeBSD__ -# define YABS_SCREENWIDTH 1280 +# define YABS_SCREENWIDTH 1080 # define YABS_SCREENHEIGHT 720 #else -# define YABS_SCREENWIDTH 1600 -# define YABS_SCREENHEIGHT 900 +# define YABS_SCREENWIDTH 1080 +# define YABS_SCREENHEIGHT 720 #endif #define YABS_TITLE "YABS" |