feat: add wake, rose, terrain, pathfinding, gameover, clouds, enemy shooting, variable bird speed refactor: some things
This commit is contained in:
+10
-18
@@ -1,13 +1,8 @@
|
||||
#include "engine.h"
|
||||
#include "engineCamera.h"
|
||||
#include <raymath.h>
|
||||
|
||||
Camera2D* GetCamera(void){
|
||||
static Camera2D camera;
|
||||
return &camera;
|
||||
}
|
||||
|
||||
Rectangle GetCameraRectangle(void)
|
||||
Rectangle GetCameraRectangle(Camera2D *camera)
|
||||
{
|
||||
Camera2D *camera = GetCamera();
|
||||
float screenWidth = GetScreenWidth();
|
||||
float screenHeight = GetScreenHeight();
|
||||
|
||||
@@ -38,11 +33,10 @@ Rectangle GetCameraRectangle(void)
|
||||
};
|
||||
}
|
||||
|
||||
void CreateCamera(Vector2 playerPosition, float initZoom){
|
||||
Camera2D* camera = GetCamera();
|
||||
Camera2D CreateCamera(Vector2 playerPosition, float initZoom){
|
||||
int windowWidth = GetScreenWidth();
|
||||
int windowHeight = GetScreenHeight();
|
||||
*camera = (Camera2D){
|
||||
return (Camera2D){
|
||||
.offset = (Vector2){windowWidth / 2.0f, windowHeight / 2.0f},
|
||||
.target = playerPosition,
|
||||
.rotation = 0.0f,
|
||||
@@ -50,19 +44,17 @@ void CreateCamera(Vector2 playerPosition, float initZoom){
|
||||
};
|
||||
}
|
||||
|
||||
void UpdateCameraTarget(Vector2 *position, const float smoothness){
|
||||
Camera2D* camera = GetCamera();
|
||||
void UpdateCameraTarget(Camera2D *camera, Vector2 *position, const float smoothness){
|
||||
camera->target = Vector2Lerp(camera->target, *position, smoothness * GetFrameTime());
|
||||
}
|
||||
|
||||
void UpdateCameraZoom(const float *scaleFactor, const float *minZoom, const float *maxZoom){
|
||||
Camera2D *camera = GetCamera();
|
||||
void UpdateCameraZoom(Camera2D *camera, const float *scaleFactor, const float *minZoom, const float *maxZoom){
|
||||
float targetZoom = Clamp(camera->zoom * *scaleFactor, *minZoom, *maxZoom);
|
||||
camera->zoom = Lerp(camera->zoom, targetZoom, 0.1f);
|
||||
}
|
||||
|
||||
void UpdateCamera2D(Vector2* position, Mouse* mouse){
|
||||
UpdateCameraTarget(position, 5.0f);
|
||||
UpdateCameraZoom(&mouse->scaleFactor, &mouse->minZoom, &mouse->maxZoom);
|
||||
void UpdateCamera2D(Camera2D *camera, Vector2* position, Mouse* mouse){
|
||||
UpdateCameraTarget(camera, position, 5.0f);
|
||||
UpdateCameraZoom(camera, &mouse->scaleFactor, &mouse->minZoom, &mouse->maxZoom);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user