big refactor: i see i need header files
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
#include "engine.h"
|
||||
|
||||
Camera2D CreateCamera(Vector2 playerPosition, float initZoom){
|
||||
int windowWidth = GetScreenWidth();
|
||||
int windowHeight = GetScreenHeight();
|
||||
return (Camera2D){
|
||||
.offset = (Vector2){windowWidth / 2.0f, windowHeight / 2.0f},
|
||||
.target = playerPosition,
|
||||
.rotation = 0.0f,
|
||||
.zoom = initZoom
|
||||
};
|
||||
}
|
||||
|
||||
void UpdateCameraTarget(Camera2D *camera, Vector2 *position, const float smoothness){
|
||||
camera->target = Vector2Lerp(camera->target, *position, smoothness * GetFrameTime());
|
||||
}
|
||||
|
||||
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(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