Add buffer
To store data for mounten and star with a moon struct. It allows easy storage, loading and mutating
This commit is contained in:
@@ -2,3 +2,4 @@
|
||||
|
||||
Color ColorLerp(Color c1, Color c2, float amount);
|
||||
Vector2 CalculateVector(float rotation, float offSet, float len);
|
||||
float GetRandomFloat();
|
@@ -1,5 +1,13 @@
|
||||
#include <vector>
|
||||
#include "raylib.h"
|
||||
#include "values/RandBuffer.hpp"
|
||||
|
||||
struct Moon
|
||||
{
|
||||
float x;
|
||||
float y;
|
||||
float size;
|
||||
};
|
||||
|
||||
class BackGround
|
||||
{
|
||||
@@ -9,29 +17,34 @@ public:
|
||||
~BackGround() = default;
|
||||
void init(int size);
|
||||
void newGen();
|
||||
void draw();
|
||||
|
||||
private:
|
||||
void starts();
|
||||
void moon();
|
||||
void mounten(size_t mountenSegments, float scale, int min, int max, Color color);
|
||||
void drawStarts();
|
||||
void drawMoon();
|
||||
void drawMounten(size_t mountenSegments, int min, int max, Color color);
|
||||
|
||||
RandBuffer starBuff;
|
||||
RandBuffer mountenBuff;
|
||||
Moon m_moon;
|
||||
|
||||
int size = 0;
|
||||
Texture2D texShapes = {1, 1, 1, 1, 7};
|
||||
|
||||
size_t numOfStarts = 150;
|
||||
|
||||
float minSizeOfMoon = 0.05f;
|
||||
float maxSizeOfMoon = 0.075f;
|
||||
float maxYPosOfMoon = 0.75f;
|
||||
float bigRingRatio = 0.5f;
|
||||
float smallRingRatio = 0.25f;
|
||||
float bigRingBlend = 0.02f;
|
||||
float smallRingBlend = 0.05f;
|
||||
|
||||
float colorRatio1 = 0.3f;
|
||||
float colorRatio2 = 0.5f;
|
||||
float mounten1 = 0.6875f;
|
||||
float mounten2 = 0.8125f;
|
||||
float mounten3 = 0.9125;
|
||||
float mounten4 = 0.975f;
|
||||
constexpr static size_t numOfStarts = 150;
|
||||
constexpr static float moonXOffset = 0.1f;
|
||||
constexpr static float minSizeOfMoon = 0.05f;
|
||||
constexpr static float maxSizeOfMoon = 0.075f;
|
||||
constexpr static float maxYPosOfMoon = 0.80f;
|
||||
constexpr static float bigRingRatio = 0.5f;
|
||||
constexpr static float smallRingRatio = 0.25f;
|
||||
constexpr static float bigRingBlend = 0.02f;
|
||||
constexpr static float smallRingBlend = 0.05f;
|
||||
constexpr static float colorRatio1 = 0.3f;
|
||||
constexpr static float colorRatio2 = 0.7f;
|
||||
constexpr static float mounten1min = 0.78f;
|
||||
constexpr static float mounten1max = 0.81f;
|
||||
constexpr static float mounten2min = 0.83f;
|
||||
constexpr static float mounten2max = 0.87;
|
||||
constexpr static float mounten3min = 0.90f;
|
||||
constexpr static float mounten3max = 0.95f;
|
||||
};
|
||||
|
40
inc/values/Buffer.hpp
Normal file
40
inc/values/Buffer.hpp
Normal file
@@ -0,0 +1,40 @@
|
||||
#ifndef BUFFER_HPP
|
||||
#define BUFFER_HPP
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
class Buffer
|
||||
{
|
||||
public:
|
||||
uint8_t *buffer = nullptr;
|
||||
size_t taken = 0;
|
||||
size_t size = 0;
|
||||
std::string file_path;
|
||||
|
||||
Buffer(size_t size);
|
||||
Buffer();
|
||||
~Buffer();
|
||||
bool resize(size_t new_size);
|
||||
uint32_t add_end(uint8_t *data, size_t data_size);
|
||||
int add_middle(uint8_t *data, size_t data_size, size_t index);
|
||||
|
||||
// Removes data from buffer without checking if it's in the buffer
|
||||
void remove_fast(uint8_t *data, size_t data_size);
|
||||
|
||||
void remove(size_t index, size_t data_size);
|
||||
|
||||
size_t find(uint8_t *data, size_t data_size);
|
||||
|
||||
void remove(uint8_t *data, size_t data_size);
|
||||
|
||||
void clear() { taken = 0; }
|
||||
|
||||
bool save_to_file();
|
||||
bool save_to_file(std::string file_path);
|
||||
|
||||
bool load_from_file();
|
||||
bool load_from_file(std::string file_path);
|
||||
};
|
||||
|
||||
#endif
|
15
inc/values/RandBuffer.hpp
Normal file
15
inc/values/RandBuffer.hpp
Normal file
@@ -0,0 +1,15 @@
|
||||
#include "values/Buffer.hpp"
|
||||
|
||||
class RandBuffer
|
||||
{
|
||||
public:
|
||||
RandBuffer() = default;
|
||||
~RandBuffer() = default;
|
||||
|
||||
void reset();
|
||||
float next();
|
||||
|
||||
private:
|
||||
Buffer m_buffer;
|
||||
size_t m_pos = 0;
|
||||
};
|
Reference in New Issue
Block a user