Move camera

This commit is contained in:
Miloslav Ciz 2023-09-16 22:52:03 +02:00
parent edcde03fa3
commit ee15824329
3 changed files with 60 additions and 3 deletions

22
game.h
View file

@ -1,6 +1,6 @@
/**
Licar game: this file implements the backend of a complete, actually playable
licar game, and is meant to be included and used by specific frontends (which
game: this file implements the backend of a complete, actually playable
game, and is meant to be included and used by specific frontends (which
will handle each platform's hardware details and I/O).
*/
@ -78,7 +78,7 @@ void LCR_drawPixelUnsafe(unsigned int x, unsigned int y,
static inline void LCR_drawPixelSafe(unsigned int x, unsigned int y,
uint_fast16_t color);
#include "map.h"
#include "racing.h"
#include "assets.h"
#include "renderer.h"
@ -133,6 +133,22 @@ for (int i = 0; i < LCR_EFFECTIVE_RESOLUTION_X; ++i)
for (int i = 0; i < LCR_KEYS_TOTAL; ++i)
_LCR_keyStates[i] = LCR_keyPressed(i);
LCR_SpaceUnit camPos[3];
LCR_getCameraPos(camPos);
#define N 10
if (_LCR_keyStates[LCR_KEY_UP]) camPos[2] += N;
else if (_LCR_keyStates[LCR_KEY_DOWN]) camPos[2] -= N;
if (_LCR_keyStates[LCR_KEY_LEFT]) camPos[0] -= N;
else if (_LCR_keyStates[LCR_KEY_RIGHT]) camPos[0] += N;
if (_LCR_keyStates[LCR_KEY_A]) camPos[1] -= N;
else if (_LCR_keyStates[LCR_KEY_B]) camPos[1] += N;
LCR_setCameraPos(camPos);
LCR_drawBackground(200 + aaa / 10);