Compare commits
9 Commits
3526b65ea7
...
d429d21c4f
Author | SHA1 | Date | |
---|---|---|---|
d429d21c4f | |||
45a3c1a7c2 | |||
80015a530e | |||
7a9ef864a6 | |||
83250406b3 | |||
96326263a2 | |||
31adb6cbc9 | |||
f12e61b1b5 | |||
28b4575bbc |
105
CMakeLists.txt
105
CMakeLists.txt
@ -10,69 +10,43 @@ set(PROJECT_VERSION 1.0)
|
||||
project(${PROJECT_NAME} VERSION ${PROJECT_VERSION})
|
||||
|
||||
##############################################################
|
||||
# set(RAYLIB_DIR "path/to/raylib")
|
||||
# set(IMGUI_DIR "path/to/imgui-docking")
|
||||
# set(RLIMGUI_DIR "path/to/rlImGui")
|
||||
# set(INIFILE_DIR "path/to/inifile-cpp")
|
||||
option(PANDA_INCLUDE_IMGUI "include imgui" ON)
|
||||
|
||||
### Fallback link
|
||||
set(RAYLIB_LINK "https://github.com/raysan5/raylib/archive/refs/tags/5.0.zip")
|
||||
set(IMGUI_LINK "https://github.com/ocornut/imgui/archive/refs/tags/v1.90.zip")
|
||||
set(RLIMGUI_LINK "https://github.com/raylib-extras/rlImGui/archive/refs/heads/main.zip")
|
||||
set(INIFILE_LINK "https://github.com/Rookfighter/inifile-cpp/archive/refs/heads/master.zip")
|
||||
if(NOT RAYLIB_LINK)
|
||||
set(RAYLIB_LINK "https://github.com/raysan5/raylib/archive/refs/tags/5.0.zip")
|
||||
endif()
|
||||
|
||||
if(NOT IMGUI_LINK)
|
||||
set(IMGUI_LINK "https://github.com/ocornut/imgui/archive/refs/heads/docking.zip")
|
||||
endif()
|
||||
|
||||
if(NOT RLIMGUI_LINK)
|
||||
set(RLIMGUI_LINK "https://github.com/raylib-extras/rlImGui/archive/refs/heads/main.zip")
|
||||
endif()
|
||||
|
||||
if(NOT INIFILE_LINK)
|
||||
set(INIFILE_LINK "https://github.com/Rookfighter/inifile-cpp/archive/refs/heads/master.zip")
|
||||
endif()
|
||||
|
||||
##############################################################
|
||||
if (EXISTS ${RAYLIB_DIR})
|
||||
add_subdirectory(${RAYLIB_DIR} raylib)
|
||||
else()
|
||||
message(STATUS "Downloading raylib library")
|
||||
include(FetchContent)
|
||||
set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
|
||||
FetchContent_Declare(raylib URL ${RAYLIB_LINK})
|
||||
FetchContent_MakeAvailable(raylib)
|
||||
endif()
|
||||
include(FetchContent)
|
||||
|
||||
if (EXISTS ${IMGUI_DIR})
|
||||
set(imgui_SOURCE_DIR ${IMGUI_DIR})
|
||||
else()
|
||||
message(STATUS "Downloading imgui library")
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(imgui URL ${IMGUI_LINK})
|
||||
FetchContent_MakeAvailable(imgui)
|
||||
endif()
|
||||
message(STATUS "Downloading raylib library")
|
||||
set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
|
||||
FetchContent_Declare(raylib URL ${RAYLIB_LINK})
|
||||
FetchContent_MakeAvailable(raylib)
|
||||
|
||||
if (EXISTS ${RLIMGUI_DIR})
|
||||
set(rlimgui_SOURCE_DIR ${RLIMGUI_DIR})
|
||||
else()
|
||||
message(STATUS "Downloading rlImGui library")
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(rlimgui URL ${RLIMGUI_LINK})
|
||||
FetchContent_MakeAvailable(rlimgui)
|
||||
endif()
|
||||
|
||||
if (EXISTS ${INIFILE_DIR})
|
||||
set(inifile-cpp_SOURCE_DIR ${INIFILE_DIR})
|
||||
else()
|
||||
message(STATUS "Downloading inifile-cpp library")
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(inifile-cpp URL ${INIFILE_LINK})
|
||||
FetchContent_MakeAvailable(inifile-cpp)
|
||||
endif()
|
||||
message(STATUS "Downloading inifile-cpp library")
|
||||
FetchContent_Declare(inifile-cpp URL ${INIFILE_LINK})
|
||||
FetchContent_MakeAvailable(inifile-cpp)
|
||||
|
||||
##############################################################
|
||||
# yes... im using glob... dont judge me....
|
||||
file(GLOB_RECURSE PROJECT_SOURCES CONFIGURE_DEPENDS "src/*.cpp")
|
||||
|
||||
file(GLOB VENDOR_SOURCES CONFIGURE_DEPENDS
|
||||
"${imgui_SOURCE_DIR}/*.cpp"
|
||||
"${imgui_SOURCE_DIR}/misc/cpp/*.cpp"
|
||||
"${rlimgui_SOURCE_DIR}/*.cpp")
|
||||
|
||||
set(PROJECT_INCLUDE
|
||||
set(PROJECT_INCLUDE
|
||||
"src"
|
||||
${imgui_SOURCE_DIR}
|
||||
${imgui_SOURCE_DIR}/backends
|
||||
${rlimgui_SOURCE_DIR}
|
||||
${inifile-cpp_SOURCE_DIR}/include)
|
||||
|
||||
set(PROJECT_LIBRARY raylib)
|
||||
@ -81,7 +55,34 @@ set(PROJECT_DEFINITION "_PANDA_CORE_")
|
||||
|
||||
##############################################################
|
||||
|
||||
add_library(${PROJECT_NAME} STATIC ${PROJECT_SOURCES} ${VENDOR_SOURCES})
|
||||
if(PANDA_INCLUDE_IMGUI)
|
||||
set(PROJECT_DEFINITION ${PROJECT_DEFINITION} PANDA_INCLUDE_IMGUI)
|
||||
|
||||
message(STATUS "Downloading imgui library")
|
||||
FetchContent_Declare(imgui URL ${IMGUI_LINK})
|
||||
FetchContent_MakeAvailable(imgui)
|
||||
|
||||
message(STATUS "Downloading rlImGui library")
|
||||
FetchContent_Declare(rlimgui URL ${RLIMGUI_LINK})
|
||||
FetchContent_MakeAvailable(rlimgui)
|
||||
|
||||
file(GLOB IMGUI_SOURCES CONFIGURE_DEPENDS
|
||||
"${imgui_SOURCE_DIR}/*.cpp"
|
||||
"${imgui_SOURCE_DIR}/misc/cpp/*.cpp"
|
||||
"${rlimgui_SOURCE_DIR}/*.cpp")
|
||||
|
||||
set (PROJECT_SOURCES ${PROJECT_SOURCES} ${IMGUI_SOURCES})
|
||||
|
||||
set(PROJECT_INCLUDE
|
||||
${PROJECT_INCLUDE}
|
||||
${imgui_SOURCE_DIR}
|
||||
${imgui_SOURCE_DIR}/backends
|
||||
${rlimgui_SOURCE_DIR})
|
||||
endif()
|
||||
|
||||
##############################################################
|
||||
|
||||
add_library(${PROJECT_NAME} STATIC ${PROJECT_SOURCES})
|
||||
target_include_directories(${PROJECT_NAME} PUBLIC ${PROJECT_INCLUDE})
|
||||
target_link_libraries(${PROJECT_NAME} PUBLIC ${PROJECT_LIBRARY})
|
||||
target_compile_definitions(${PROJECT_NAME} PUBLIC ${PROJECT_DEFINITION})
|
||||
|
101
src/Panda.hpp
101
src/Panda.hpp
@ -1,17 +1,58 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "utils/Random.hpp"
|
||||
|
||||
struct Vector2;
|
||||
struct Color;
|
||||
struct Rectangle;
|
||||
struct Texture;
|
||||
struct RenderTexture;
|
||||
struct Color;
|
||||
struct Vector2;
|
||||
struct Rectangle;
|
||||
struct Camera2D;
|
||||
|
||||
#ifdef PANDA_INCLUDE_TYPE
|
||||
|
||||
struct Vector2 {
|
||||
float x;
|
||||
float y;
|
||||
};
|
||||
|
||||
struct Color {
|
||||
unsigned char r;
|
||||
unsigned char g;
|
||||
unsigned char b;
|
||||
unsigned char a;
|
||||
};
|
||||
|
||||
struct Rectangle {
|
||||
float x;
|
||||
float y;
|
||||
float width;
|
||||
float height;
|
||||
}
|
||||
|
||||
struct Texture {
|
||||
unsigned int id;
|
||||
int width;
|
||||
int height;
|
||||
int mipmaps;
|
||||
int format;
|
||||
}
|
||||
|
||||
struct RenderTexture {
|
||||
unsigned int id;
|
||||
Texture texture;
|
||||
Texture depth;
|
||||
}
|
||||
|
||||
struct Camera2D {
|
||||
Vector2 offset;
|
||||
Vector2 target;
|
||||
float rotation;
|
||||
float zoom;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
namespace panda
|
||||
{
|
||||
@ -29,7 +70,10 @@ namespace panda
|
||||
public:
|
||||
Scene() {}
|
||||
virtual ~Scene() {}
|
||||
virtual void update() {}
|
||||
virtual void Preload() {}
|
||||
virtual void Update() {}
|
||||
|
||||
bool preloaded = false;
|
||||
};
|
||||
|
||||
struct Sprite {
|
||||
@ -73,23 +117,41 @@ namespace panda
|
||||
void concat(Matrix m);
|
||||
};
|
||||
|
||||
class Random {
|
||||
public:
|
||||
Random(uint64_t seed = 521288629);
|
||||
void SetSeed(uint64_t seed);
|
||||
|
||||
uint64_t Next();
|
||||
double Next_UNI();
|
||||
double Range(double min, double max);
|
||||
|
||||
private:
|
||||
uint64_t s[4];
|
||||
};
|
||||
|
||||
class App {
|
||||
public:
|
||||
void CreateWindow(int w, int h, const char *str);
|
||||
|
||||
void AppUpdate();
|
||||
void SetScene(Scene* scene);
|
||||
Scene* GetScene();
|
||||
|
||||
private:
|
||||
Scene* _scene_current = nullptr;
|
||||
};
|
||||
|
||||
// ############################################################################################
|
||||
|
||||
// Core
|
||||
void CreateWindow(int w, int h, const char *str);
|
||||
|
||||
void AppUpdate();
|
||||
void SetScene(Scene* scene);
|
||||
Scene* GetScene();
|
||||
|
||||
// # Graphic
|
||||
|
||||
// ### GUI
|
||||
#ifdef PANDA_INCLUDE_IMGUI
|
||||
void GuiInit();
|
||||
void GuiDestroy();
|
||||
void GuiBegin();
|
||||
void GuiEnd();
|
||||
void GuiThemeSetup();
|
||||
#endif
|
||||
|
||||
// ### atlas
|
||||
bool LoadTextureAtlas(const char *image_path, const char *ini_path, std::string AtlasKey);
|
||||
@ -117,9 +179,6 @@ namespace panda
|
||||
// ### texture utils
|
||||
Rectangle GetTextureRect(const Texture &tex, bool flipX, bool flipY);
|
||||
|
||||
// Utils
|
||||
Random &GetDefaultRandom();
|
||||
|
||||
// Euclidean Distance
|
||||
double distance(const Vector2 &p1, const Vector2 &p2);
|
||||
double distanceSqrt(const Vector2 &p1, const Vector2 &p2);
|
||||
|
47
src/core/App.cpp
Executable file
47
src/core/App.cpp
Executable file
@ -0,0 +1,47 @@
|
||||
#include "Panda.hpp"
|
||||
#include <raylib.h>
|
||||
|
||||
void panda::App::CreateWindow(int w, int h, const char *str)
|
||||
{
|
||||
SetConfigFlags(
|
||||
FLAG_MSAA_4X_HINT | FLAG_WINDOW_RESIZABLE);
|
||||
|
||||
#if PLATFORM_ANDROID
|
||||
InitWindow(0, 0, str);
|
||||
#elif PLATFORM_DESKTOP
|
||||
InitWindow(w, h, str);
|
||||
SetWindowMinSize(w*0.8f, h*0.8f);
|
||||
#endif
|
||||
|
||||
SetExitKey(-1);
|
||||
}
|
||||
|
||||
void panda::App::AppUpdate()
|
||||
{
|
||||
if (_scene_current != nullptr)
|
||||
{
|
||||
while (!_scene_current->preloaded)
|
||||
{
|
||||
_scene_current->preloaded = true;
|
||||
_scene_current->Preload();
|
||||
}
|
||||
|
||||
_scene_current->Update();
|
||||
}
|
||||
}
|
||||
|
||||
void panda::App::SetScene(Scene* scene)
|
||||
{
|
||||
if (_scene_current != nullptr)
|
||||
{
|
||||
delete _scene_current;
|
||||
_scene_current = nullptr;
|
||||
}
|
||||
|
||||
_scene_current = scene;
|
||||
}
|
||||
|
||||
panda::Scene* panda::App::GetScene()
|
||||
{
|
||||
return _scene_current;
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
#include <raylib.h>
|
||||
|
||||
#include "Panda.hpp"
|
||||
|
||||
static panda::Scene* currentScene = nullptr;
|
||||
|
||||
// CORE
|
||||
void panda::CreateWindow(int w, int h, const char *str)
|
||||
{
|
||||
Random::getInstance().setSeedFromTime();
|
||||
|
||||
SetConfigFlags(
|
||||
FLAG_MSAA_4X_HINT | FLAG_WINDOW_RESIZABLE);
|
||||
|
||||
#if PLATFORM_ANDROID
|
||||
InitWindow(0, 0, str);
|
||||
#elif PLATFORM_DESKTOP
|
||||
InitWindow(w, h, str);
|
||||
SetWindowMinSize(w*0.8f, h*0.8f);
|
||||
#endif
|
||||
|
||||
SetExitKey(-1);
|
||||
}
|
||||
|
||||
void panda::AppUpdate()
|
||||
{
|
||||
if (currentScene != nullptr)
|
||||
currentScene->update();
|
||||
}
|
||||
|
||||
void panda::SetScene(Scene* scene)
|
||||
{
|
||||
if (currentScene != nullptr)
|
||||
{
|
||||
delete currentScene;
|
||||
currentScene = nullptr;
|
||||
}
|
||||
|
||||
currentScene = scene;
|
||||
}
|
||||
|
||||
panda::Scene* panda::GetScene()
|
||||
{
|
||||
return currentScene;
|
||||
}
|
||||
|
||||
// UTILS
|
||||
panda::Random &panda::GetDefaultRandom()
|
||||
{
|
||||
return Random::getInstance();
|
||||
}
|
@ -2,9 +2,10 @@
|
||||
#include <rlImGui.h>
|
||||
#include <rlgl.h>
|
||||
#include <stdbool.h>
|
||||
#include <raylib.h>
|
||||
#ifdef PANDA_INCLUDE_IMGUI
|
||||
|
||||
#include "Panda.hpp"
|
||||
#include <raylib.h>
|
||||
|
||||
#if PLATFORM_ANDROID
|
||||
|
||||
@ -143,19 +144,8 @@ void panda::GuiThemeSetup()
|
||||
style.Colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.20f, 0.20f, 0.20f, 0.35f);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void panda::DrawRenderTexture(const RenderTexture &buffer, const float &x, const float &y, const Color &color)
|
||||
{
|
||||
DrawTextureRec(
|
||||
buffer.texture,
|
||||
{0.0f, 0.0f, 1.0f*buffer.texture.width, -1.0f*buffer.texture.height},
|
||||
{x, y}, color);
|
||||
}
|
||||
|
||||
Rectangle panda::GetTextureRect(const Texture &tex, bool flipX, bool flipY)
|
||||
{
|
||||
return { 0.0f, 0.0f, (flipX ? -tex.width : tex.width)*1.0f, (flipY ? -tex.height : tex.height)*1.0f };
|
||||
}
|
||||
|
||||
/////////////////////////////////
|
||||
|
@ -1,7 +1,6 @@
|
||||
#include <cmath>
|
||||
#include <raylib.h>
|
||||
|
||||
#include "Panda.hpp"
|
||||
#include <raylib.h>
|
||||
#include <cmath>
|
||||
|
||||
double panda::distance(const Vector2 &p1, const Vector2 &p2)
|
||||
{
|
||||
|
@ -1,6 +1,5 @@
|
||||
#include <cmath>
|
||||
|
||||
#include "utils/Easing.hpp"
|
||||
#include <cmath>
|
||||
|
||||
namespace cur = easing;
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "GridMap.hpp"
|
||||
#include "Panda.hpp"
|
||||
#include <raylib.h>
|
||||
|
||||
void panda::DrawGridMap(Texture texture, Camera2D cam)
|
||||
{
|
||||
|
@ -1,20 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "utils/RaylibDeprecated.hpp"
|
||||
#include <raylib.h>
|
||||
|
||||
/**
|
||||
* Draw GridMap using cam, use this inside BeginMode2D
|
||||
* @param {Texture} texture :
|
||||
* @param {Camera2D} cam :
|
||||
*/
|
||||
void DrawGridMap(Texture texture, Camera2D cam);
|
||||
|
||||
/**
|
||||
* This is quick version without cam, does not support zoom
|
||||
* @param {Texture} texture :
|
||||
* @param {Camera2D} cam :
|
||||
*/
|
||||
void DrawGridMapQuick(Texture texture, Vector2 offset);
|
||||
|
||||
Texture LoadDefaultGridMap();
|
@ -1,6 +1,5 @@
|
||||
#include <cmath>
|
||||
|
||||
#include "Panda.hpp"
|
||||
#include <cmath>
|
||||
|
||||
namespace panda {
|
||||
void Matrix::identity()
|
||||
|
@ -1,54 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
#include <list>
|
||||
#include <vector>
|
||||
#include <functional>
|
||||
|
||||
#include "utils/Random.hpp"
|
||||
|
||||
namespace panda
|
||||
{
|
||||
|
||||
// template<typename T>
|
||||
// class Pool
|
||||
// {
|
||||
// public:
|
||||
// Pool(int size) : container(size) { }
|
||||
|
||||
// T &get()
|
||||
// {
|
||||
// if (activeIndex != container.size())
|
||||
// {
|
||||
// activeIndex++;
|
||||
// return container[activeIndex-1];
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// if (custom)
|
||||
// {
|
||||
// return container[custom()];
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// int r = Random::getInstance().UNI() * (container.size()-1);
|
||||
// return container[r];
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// void put(int index)
|
||||
// {
|
||||
// activeIndex--;
|
||||
// std::swap(container[activeIndex], container[index]);
|
||||
// }
|
||||
|
||||
// // int countActive() { return activeIndex; }
|
||||
// int activeIndex;
|
||||
// std::vector<T> container;
|
||||
// std::function<int()> custom;
|
||||
// };
|
||||
|
||||
template<typename T, size_t SIZE>
|
||||
class PoolPointer {
|
||||
private:
|
||||
|
@ -1,66 +1,45 @@
|
||||
#include <chrono>
|
||||
#include <cmath>
|
||||
#include "Panda.hpp"
|
||||
|
||||
#include "utils/Random.hpp"
|
||||
|
||||
panda::Random::Random(uint32_t _w, uint32_t _z) {
|
||||
m_w = _w;
|
||||
m_z = _z;
|
||||
static inline uint64_t splitmix64(uint64_t &x) {
|
||||
uint64_t z = (x += 0x9e3779b97f4a7c15);
|
||||
z = (z ^ (z >> 30)) * 0xbf58476d1ce4e5b9;
|
||||
z = (z ^ (z >> 27)) * 0x94d049bb133111eb;
|
||||
return z ^ (z >> 31);
|
||||
}
|
||||
|
||||
void panda::Random::setSeed(uint32_t w) {
|
||||
if (w != 0) m_w = w;
|
||||
static inline uint64_t rotl(const uint64_t x, int k) {
|
||||
return (x << k) | (x >> (64 - k));
|
||||
}
|
||||
|
||||
void panda::Random::setSeed(uint32_t w, uint32_t z) {
|
||||
if (w != 0) m_w = w;
|
||||
if (z != 0) m_z = z;
|
||||
|
||||
panda::Random::Random(uint64_t seed) {
|
||||
for(int i=0; i<4; i++) s[i] = splitmix64(seed);
|
||||
}
|
||||
|
||||
void panda::Random::setSeedFromTime() {
|
||||
m_w = std::chrono::system_clock::now().time_since_epoch().count();
|
||||
void panda::Random::SetSeed(uint64_t seed) {
|
||||
for(int i=0; i<4; i++) s[i] = splitmix64(seed);
|
||||
}
|
||||
|
||||
uint32_t panda::Random::MWC() {
|
||||
m_z = 36969 * (m_z & 65535) + (m_z >> 16);
|
||||
m_w = 18000 * (m_w & 65535) + (m_w >> 16);
|
||||
return (m_z << 16) + m_w;
|
||||
uint64_t panda::Random::Next() {
|
||||
const uint64_t result = s[0] + s[3];
|
||||
|
||||
const uint64_t t = s[1] << 17;
|
||||
|
||||
s[2] ^= s[0];
|
||||
s[3] ^= s[1];
|
||||
s[1] ^= s[2];
|
||||
s[0] ^= s[3];
|
||||
|
||||
s[2] ^= t;
|
||||
|
||||
s[3] = rotl(s[3], 45);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
float panda::Random::UNI() {
|
||||
return MWC() * inv_uni;
|
||||
double panda::Random::Next_UNI() {
|
||||
return (Next() >> 11) * 0x1.0p-53;
|
||||
}
|
||||
|
||||
float panda::Random::range(float min, float max) {
|
||||
return min + (max-min) * UNI();
|
||||
}
|
||||
|
||||
float panda::Random::rangeEx(float min, float max, float lamda) {
|
||||
const float u = UNI();
|
||||
return min + (max-min) * std::pow(u, lamda);
|
||||
}
|
||||
|
||||
|
||||
|
||||
float panda::Random::xorshift_uni(uint32_t x) {
|
||||
return xorshift(x) * inv_uni;
|
||||
}
|
||||
|
||||
float panda::Random::xorshift64_uni(uint64_t x) {
|
||||
return xorshift64(x) * inv_uni64;
|
||||
}
|
||||
|
||||
uint32_t panda::Random::xorshift(uint32_t x) {
|
||||
x ^= x << 13;
|
||||
x ^= x >> 17;
|
||||
x ^= x << 5;
|
||||
return x;
|
||||
}
|
||||
|
||||
uint64_t panda::Random::xorshift64(uint64_t x) {
|
||||
x ^= x << 13;
|
||||
x ^= x >> 7;
|
||||
x ^= x << 17;
|
||||
return x;
|
||||
}
|
||||
double panda::Random::Range(double min, double max) {
|
||||
return min + (max-min) * Next_UNI();
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
|
||||
namespace panda
|
||||
{
|
||||
class Random {
|
||||
public:
|
||||
static Random& getInstance()
|
||||
{
|
||||
static Random instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
Random(uint32_t _w = 521288629, uint32_t _z = 362436069);
|
||||
void setSeed(uint32_t w);
|
||||
void setSeed(uint32_t w, uint32_t z);
|
||||
void setSeedFromTime();
|
||||
|
||||
uint32_t MWC();
|
||||
float UNI();
|
||||
float range(float min, float max);
|
||||
float rangeEx(float min, float max, float lamda);
|
||||
|
||||
float xorshift_uni(uint32_t x);
|
||||
float xorshift64_uni(uint64_t x);
|
||||
uint32_t xorshift(uint32_t x);
|
||||
uint64_t xorshift64(uint64_t x);
|
||||
|
||||
private:
|
||||
uint32_t m_w;
|
||||
uint32_t m_z;
|
||||
float inv_uni = 2.3283064e-10;
|
||||
float inv_uni64 = 5.4210109e-20;
|
||||
};
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
#include <raylib.h>
|
||||
|
||||
#include "Panda.hpp"
|
||||
#include <raylib.h>
|
||||
|
||||
// Draw part of a texture (defined by a rectangle) with rotation and scale tiled into dest.
|
||||
void panda::DrawTextureTiled(Texture texture, Rectangle source, Rectangle dest, Vector2 origin, float rotation, float scale, Color tint)
|
||||
@ -84,4 +83,17 @@ void panda::DrawTextureTiled(Texture texture, Rectangle source, Rectangle dest,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void panda::DrawRenderTexture(const RenderTexture &buffer, const float &x, const float &y, const Color &color)
|
||||
{
|
||||
DrawTextureRec(
|
||||
buffer.texture,
|
||||
{0.0f, 0.0f, 1.0f*buffer.texture.width, -1.0f*buffer.texture.height},
|
||||
{x, y}, color);
|
||||
}
|
||||
|
||||
Rectangle panda::GetTextureRect(const Texture &tex, bool flipX, bool flipY)
|
||||
{
|
||||
return { 0.0f, 0.0f, (flipX ? -tex.width : tex.width)*1.0f, (flipY ? -tex.height : tex.height)*1.0f };
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
#include "Panda.hpp"
|
||||
#include <raylib.h>
|
||||
#include <sstream>
|
||||
#include <inicpp.h>
|
||||
#include <raylib.h>
|
||||
|
||||
#include "Panda.hpp"
|
||||
#include <unordered_map>
|
||||
|
||||
namespace
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user