aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsalaaad2 <arthurdurant263@gmail.com>2022-01-13 19:21:04 +0100
committersalaaad2 <arthurdurant263@gmail.com>2022-01-13 19:21:04 +0100
commit0aad778336ef25336ca51611419b306aff9020ab (patch)
treee1d3c8b67cd028496e8803687754ccebf0cfd36b
parentMerge pull request #1 from Paure42/master (diff)
downloadthreshold-0aad778336ef25336ca51611419b306aff9020ab.tar.gz
threshold-0aad778336ef25336ca51611419b306aff9020ab.tar.bz2
threshold-0aad778336ef25336ca51611419b306aff9020ab.tar.xz
threshold-0aad778336ef25336ca51611419b306aff9020ab.tar.zst
threshold-0aad778336ef25336ca51611419b306aff9020ab.zip
this is starting to get boring.ill see
-rw-r--r--CMakeLists.txt1
-rw-r--r--meta/maps/stage_1_boss.bfm1
-rw-r--r--meta/media/sprites/crosshair.pngbin0 -> 184 bytes
-rw-r--r--src/gameplay.cpp31
-rw-r--r--src/gameplay.hpp5
-rw-r--r--src/main.cpp2
-rw-r--r--src/wp_enemyslingshot.cpp41
-rw-r--r--src/wp_enemyslingshot.hpp22
8 files changed, 93 insertions, 10 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5d9e149..95b6ce5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -14,6 +14,7 @@ add_executable(${PROJECT_NAME}
src/weapon.cpp
src/wp_shotty.cpp
src/wp_assaultrifle.cpp
+ src/wp_enemyslingshot.cpp
src/terrain.cpp
src/entity.cpp)
diff --git a/meta/maps/stage_1_boss.bfm b/meta/maps/stage_1_boss.bfm
index dced68f..3e34285 100644
--- a/meta/maps/stage_1_boss.bfm
+++ b/meta/maps/stage_1_boss.bfm
@@ -1,3 +1,4 @@
BOSS 1 3
ENEMIES 2 100
+WAVES 1 2
NEXT stage_1_boss.bfm
diff --git a/meta/media/sprites/crosshair.png b/meta/media/sprites/crosshair.png
new file mode 100644
index 0000000..d17bcb5
--- /dev/null
+++ b/meta/media/sprites/crosshair.png
Binary files differ
diff --git a/src/gameplay.cpp b/src/gameplay.cpp
index de4ba66..b4c6477 100644
--- a/src/gameplay.cpp
+++ b/src/gameplay.cpp
@@ -18,6 +18,7 @@
#include "window.hpp"
#include "wp_assaultrifle.hpp"
#include "wp_shotty.hpp"
+#include "wp_enemyslingshot.hpp"
Game::Game(std::string const& path) : current(path) {
std::ifstream ifs(path);
@@ -56,19 +57,33 @@ Game::Game(std::string const& path) : current(path) {
}
ifs.close();
enemies = new std::vector<Entity>;
+
+ AWeapon* shotty = new wp_shotty(SHOTTY_BANG,
+ SHOTTY_RELOAD
+ );
+ AWeapon* ar = new wp_assaultrifle(AR_BANG,
+ SHOTTY_RELOAD // TODO: get sound
+ );
+ AWeapon* sling = new wp_enemysling(SHOTTY_BANG,
+ SHOTTY_RELOAD
+ );
+
for (auto i = 0; i < nPerWave; i++) {
if (ehp == 0) {
- Entity en(ehp);
+ Entity en(1);
en.radius = radius;
en.idleTex = LoadTexture(SBIRE_TEX_IDLE);
en.hurtTex = LoadTexture(SBIRE_TEX_HURT);
enemies->push_back(en);
+ en.currentWeapon = nullptr;
} else {
Entity en(ehp);
en.radius = radius;
+ en.wp[0] = shotty;
+ en.currentWeapon = en.wp[0];
en.idleTex = LoadTexture(SBIRE_TEX_IDLE);
en.hurtTex = LoadTexture(SBIRE_TEX_HURT);
- enemies->push_back(en); // legacy code. TODO: remove
+ enemies->push_back(en); // legacy code. TODO: remove AKchually no
}
}
player = new Entity;
@@ -81,14 +96,12 @@ Game::Game(std::string const& path) : current(path) {
player->fury = 0;
InitAudioDevice();
+ crosshair = LoadTexture(CROSSHAIR_TEX);
+
cam.target = (Vector2){player->posX, player->posY};
cam.offset = (Vector2){SCREENWIDTH / 2.0f, SCREENHEIGHT / 2.0f};
cam.rotation = 0.0f;
cam.zoom = 1.0f;
- AWeapon* shotty = new wp_shotty(SHOTTY_BANG, SHOTTY_RELOAD);
- AWeapon* ar = new wp_assaultrifle(AR_BANG,
- SHOTTY_RELOAD // TODO: get sound
- );
player->wp[0] = shotty;
player->wp[1] = ar;
@@ -130,7 +143,7 @@ void Game::draw() {
1.0f, 0.6f, WHITE);
}
}
- // Destination rectangle (screen rectangle where drawing part of texture)
+ // Destination rectangle
Rectangle destRec = {player->posX, player->posY, frameWidth * 1.8f,
frameHeight * 1.8f};
@@ -155,7 +168,7 @@ void Game::draw() {
int Game::tick() {
auto target = GetMousePosition();
- DrawLine(player->posX, player->posY, target.x, target.y, RAYWHITE);
+ DrawTexture(crosshair, target.x, target.y, WHITE);
auto v2 = (Vector2){target.x - player->posX, target.y - player->posY};
@@ -221,7 +234,7 @@ int Game::tick() {
return (0);
}
-int Game::getKeys() const {
+int Game::getKeys() {
auto oldX = 0, oldY = 0, speed = 7; // get position before processing keys to check
// for player movement in threshold mode
oldX = player->posX;
diff --git a/src/gameplay.hpp b/src/gameplay.hpp
index a759f42..6fadb79 100644
--- a/src/gameplay.hpp
+++ b/src/gameplay.hpp
@@ -27,6 +27,9 @@
// player textures
#define MUCHACHO_TEX "../meta/media/sprites/cowboy_idle.png"
+// crosshair
+#define CROSSHAIR_TEX "../meta/media/sprites/crosshair.png"
+
// bad boy textures
#define SBIRE_TEX_IDLE "../meta/media/sprites/sbire_idle.png"
#define SBIRE_TEX_HURT "../meta/media/sprites/sbire_hurt.png"
@@ -61,6 +64,8 @@ class Game {
Vector2 origin;
+ Texture2D crosshair;
+
public:
Game(std::string const& path);
~Game();
diff --git a/src/main.cpp b/src/main.cpp
index d277919..488de95 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -28,7 +28,7 @@ int main(void) {
std::string path = "../meta/maps";
int i = 0;
for (const auto& entry :
- std::filesystem::directory_iterator(path)) { // c++17 lol
+ std::filesystem::directory_iterator(path)) { // NOTE: c++17 lol
if (entry.path().filename().generic_string().find("start") !=
std::string::npos) {
pick[i] = entry.path().filename().generic_string();
diff --git a/src/wp_enemyslingshot.cpp b/src/wp_enemyslingshot.cpp
new file mode 100644
index 0000000..2a5b9fc
--- /dev/null
+++ b/src/wp_enemyslingshot.cpp
@@ -0,0 +1,41 @@
+#include "wp_enemyslingshot.hpp"
+
+#include <raylib.h>
+#include <raymath.h>
+#include <iostream>
+
+#include "gameplay.hpp"
+#include "entity.hpp"
+
+wp_enemysling::wp_enemysling(const char* s, const char* r)
+ : AWeapon(300.0f, 10, 2, 0.0, s, r) {}
+
+int wp_enemysling::bang(std::vector<Entity>* enemies, Entity* baddie) {
+ if (barrel == 0) {
+ return (1);
+ } else {
+ barrel--;
+ PlaySound(shot);
+ t = GetTime();
+ // enemysling spawns a new enemy every @reload seconds. thats it.
+ // it's a slingshot
+ //
+ Entity en(1);
+ en.posX = (baddie->posX += range);
+ en.posY = (baddie->posY += range);
+ en.direction = baddie->direction;
+ en.radius = 20;
+ en.currentWeapon = nullptr;
+ en.idleTex = LoadTexture(SBIRE_TEX_IDLE);
+ en.hurtTex = LoadTexture(SBIRE_TEX_HURT);
+ enemies->push_back(en);
+ std::cout << "push back enemy. so far so good " << std::endl;
+
+ //
+ // there
+ if (barrel == 0) {
+ empty = true;
+ }
+ return (0);
+ }
+}
diff --git a/src/wp_enemyslingshot.hpp b/src/wp_enemyslingshot.hpp
new file mode 100644
index 0000000..bcaec09
--- /dev/null
+++ b/src/wp_enemyslingshot.hpp
@@ -0,0 +1,22 @@
+/*********************************/
+/* THRESHOLD ( // */
+/* enemysling ( )/ */
+/* by salade )(/ */
+/* ________________ ( /) */
+/* ()__)____________))))) :^} */
+/*********************************/
+
+#ifndef WP_ENEMYSLING_H_
+#define WP_ENEMYSLING_H_
+
+#include "weapon.hpp"
+
+class wp_enemysling : public AWeapon {
+ public:
+ wp_enemysling(const char* s, const char* r);
+ ~wp_enemysling();
+
+ int bang(std::vector<Entity>* enemies, Entity* player);
+};
+
+#endif