Nooncraft/src/game.h

39 lines
1009 B
C

// nooncraft.game: Most game data randomly thrown in a structure
#pragma once
#include "world.h"
#include "camera.h"
struct Game
{
World *world;
Camera *camera;
/* Current player/cursor positions (they are linked) */
WorldCoord playerPos;
WorldCoord cursorPos;
/* Info on the pointed block */
BlockInfo *pointedBlockInfo() const;
/* Current ticks spent damaging the pointed block, ≥ 0 when breaking */
int damageTicks;
bool isBreakingBlock() const {
return this->damageTicks >= 0;
}
/* Time required to break currently selected block */
int blockBreakingDuration() const;
/* Block breaking progress as a range 0-3 */
int8_t blockBreakingProgress() const;
/* Move the player by specified amount. */
bool movePlayerBy(WorldCoord dir, bool camera_follow=true);
/* Move the cursor by the specified amount. */
bool moveCursorBy(WorldCoord dir);
// --== Tick update functions ==--
void updateBlockBreaking();
};