2023-08-02 10:59:06 +00:00
|
|
|
#ifndef JUMPARTIFACT_DOT_COM_DEMO_0_TANK_RUNNER_H_
|
|
|
|
#define JUMPARTIFACT_DOT_COM_DEMO_0_TANK_RUNNER_H_
|
|
|
|
|
|
|
|
#include "screen.h"
|
|
|
|
|
|
|
|
// standard library includes
|
|
|
|
#include <array>
|
|
|
|
#include <bitset>
|
2023-08-21 06:07:03 +00:00
|
|
|
#include <memory>
|
2023-08-08 02:33:07 +00:00
|
|
|
#include <optional>
|
2023-08-02 10:59:06 +00:00
|
|
|
|
|
|
|
// third party includes
|
|
|
|
#include <raylib.h>
|
|
|
|
|
2023-08-10 04:28:45 +00:00
|
|
|
// local includes
|
2023-08-11 03:38:55 +00:00
|
|
|
#include "common_constants.h"
|
2023-08-21 05:37:50 +00:00
|
|
|
#include "surface_triangle.h"
|
2023-08-10 04:28:45 +00:00
|
|
|
#include "walker.h"
|
|
|
|
|
2023-08-07 05:11:58 +00:00
|
|
|
constexpr float POS_VALUE_INC_RATE = 0.2F;
|
2023-08-07 03:54:23 +00:00
|
|
|
constexpr float CAMERA_UPDATE_RATE = 1.0F;
|
2023-08-02 10:59:06 +00:00
|
|
|
|
2023-08-09 05:23:55 +00:00
|
|
|
constexpr float SURFACE_HEIGHT_INTERVAL = 0.7F;
|
2023-08-08 02:33:07 +00:00
|
|
|
|
2023-08-15 02:53:26 +00:00
|
|
|
constexpr int BUTTON_FONT_SIZE = 30;
|
|
|
|
|
2023-08-21 05:37:50 +00:00
|
|
|
constexpr float SURFACE_RESET_TIME = 4.0F;
|
|
|
|
constexpr float SURFACE_RESET_TIME_TRI_DRAW = 3.0F;
|
|
|
|
constexpr float SURFACE_RESET_Y_OFFSET = 40.0F;
|
|
|
|
|
2023-08-02 10:59:06 +00:00
|
|
|
class TRunnerScreen : public Screen {
|
|
|
|
public:
|
2023-08-21 05:37:50 +00:00
|
|
|
struct SurfaceUnit {
|
|
|
|
float nw, ne, sw, se;
|
|
|
|
};
|
|
|
|
|
2023-08-02 10:59:06 +00:00
|
|
|
TRunnerScreen(std::weak_ptr<ScreenStack> stack);
|
|
|
|
~TRunnerScreen() override;
|
|
|
|
|
|
|
|
bool update(float dt) override;
|
|
|
|
bool draw() override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
enum Pixel : unsigned char {
|
|
|
|
PIXEL_BLANK,
|
|
|
|
PIXEL_BLACK,
|
|
|
|
PIXEL_RED,
|
|
|
|
PIXEL_GREEN,
|
|
|
|
PIXEL_BLUE,
|
|
|
|
PIXEL_YELLOW,
|
|
|
|
PIXEL_CYAN,
|
|
|
|
PIXEL_MAGENTA,
|
|
|
|
PIXEL_ORANGE,
|
|
|
|
PIXEL_BROWN,
|
|
|
|
PIXEL_TURQUOISE,
|
|
|
|
PIXEL_SKY,
|
|
|
|
PIXEL_WHITE
|
|
|
|
};
|
|
|
|
|
|
|
|
static Color PixelToColor(Pixel p);
|
|
|
|
|
2023-08-08 02:33:07 +00:00
|
|
|
std::array<std::optional<SurfaceUnit>,
|
|
|
|
SURFACE_UNIT_WIDTH * SURFACE_UNIT_HEIGHT>
|
|
|
|
surface;
|
2023-08-09 04:54:56 +00:00
|
|
|
std::array<BoundingBox, SURFACE_UNIT_WIDTH * SURFACE_UNIT_HEIGHT> surface_bbs;
|
2023-08-11 03:38:55 +00:00
|
|
|
std::array<Walker, 4> walkers;
|
2023-08-10 04:28:45 +00:00
|
|
|
|
2023-08-07 03:54:23 +00:00
|
|
|
Camera3D camera;
|
2023-08-21 05:37:50 +00:00
|
|
|
/*
|
|
|
|
* 0 - resetting surface
|
|
|
|
*/
|
2023-08-02 10:59:06 +00:00
|
|
|
std::bitset<64> flags;
|
2023-08-04 05:32:05 +00:00
|
|
|
Model TEMP_cube_model;
|
|
|
|
Texture2D TEMP_cube_texture;
|
2023-08-02 10:59:06 +00:00
|
|
|
Matrix TEMP_matrix;
|
2023-08-21 05:37:50 +00:00
|
|
|
RenderTexture2D bgRenderTexture;
|
|
|
|
RenderTexture2D fgRenderTexture;
|
2023-08-07 03:54:23 +00:00
|
|
|
Vector3 camera_pos;
|
|
|
|
Vector3 camera_target;
|
2023-08-09 03:38:09 +00:00
|
|
|
Vector3 mouse_hit;
|
2023-08-21 06:07:03 +00:00
|
|
|
std::unique_ptr<std::array<SurfaceTriangle,
|
|
|
|
SURFACE_UNIT_WIDTH * SURFACE_UNIT_HEIGHT * 2> >
|
|
|
|
surface_triangles;
|
2023-08-08 03:20:26 +00:00
|
|
|
unsigned int idx_hit;
|
2023-08-15 02:53:26 +00:00
|
|
|
std::optional<unsigned int> controlled_walker_idx;
|
|
|
|
const int left_text_width;
|
|
|
|
const int right_text_width;
|
|
|
|
const int forward_text_width;
|
2023-08-21 05:37:50 +00:00
|
|
|
const int reset_surface_text_width;
|
|
|
|
float surface_reset_anim_timer;
|
2023-08-07 03:54:23 +00:00
|
|
|
|
|
|
|
void camera_to_targets(float dt);
|
2023-08-21 02:41:04 +00:00
|
|
|
void generate_surface();
|
2023-08-21 05:37:50 +00:00
|
|
|
void generate_surface_with_triangles();
|
2023-08-02 10:59:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|