34 lines
1.0 KiB
C
34 lines
1.0 KiB
C
#ifndef PIXELDEFENSE_UTILS_H
|
|
#define PIXELDEFENSE_UTILS_H
|
|
|
|
#include <raylib.h>
|
|
#include <breeze.h>
|
|
#include <stdlib.h>
|
|
|
|
static Rectangle getCameraBounds(Camera2D camera) {
|
|
Rectangle bounds = {
|
|
.x = camera.target.x,
|
|
.y = camera.target.y,
|
|
.width = GetScreenWidth() * camera.zoom,
|
|
.height = GetScreenHeight() * camera.zoom,
|
|
};
|
|
//bounds.width *= 0.8f;
|
|
//bounds.height *= 0.8f;
|
|
bounds.x -= bounds.width * 0.5f;
|
|
bounds.y -= bounds.height * 0.5f;
|
|
return bounds;
|
|
}
|
|
|
|
// https://stackoverflow.com/questions/13408990/how-to-generate-random-float-number-in-c
|
|
static inline f32 randFloatRange(f32 min, f32 max) {
|
|
float scale = rand() / (float) RAND_MAX; /* [0, 1.0] */
|
|
return min + scale * ( max - min ); /* [min, max] */
|
|
}
|
|
|
|
// Implemented in main.c
|
|
bool serializeGameData(const char *path, const GameData *gameData);
|
|
bool deserializeGameData(const char *path, GameData *gameData);
|
|
void applyOptions(const Options *options);
|
|
|
|
#endif //PIXELDEFENSE_UTILS_H
|