Moved game time into world struct
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
* psychological effects. *
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
long l, gameTime;
|
||||
long l;
|
||||
|
||||
World world = { 0 };
|
||||
|
||||
@@ -62,7 +62,7 @@ int screenshot ();
|
||||
*/
|
||||
void gameLoop_resetGame () {
|
||||
l = SDL_GetTicks();
|
||||
gameTime = 2048;
|
||||
world.time = 2048;
|
||||
|
||||
player = (const Player) { 0 };
|
||||
player.pos.x = 96.5;
|
||||
@@ -209,7 +209,7 @@ int gameLoop (
|
||||
float timeCoef;
|
||||
switch (world.dayNightMode) {
|
||||
case 0:
|
||||
timeCoef = (float)(gameTime % 102944) / 16384;
|
||||
timeCoef = (float)(world.time % 102944) / 16384;
|
||||
timeCoef = sin(timeCoef);
|
||||
timeCoef /= sqrt(timeCoef * timeCoef + (1.0 / 128.0));
|
||||
timeCoef = (timeCoef + 1) / 2;
|
||||
@@ -259,7 +259,7 @@ int gameLoop (
|
||||
of CPU power. If the rendering takes a long time, this
|
||||
will fire more times to compensate. */
|
||||
while (SDL_GetTicks() - l > 10L) {
|
||||
gameTime++;
|
||||
world.time++;
|
||||
l += 10L;
|
||||
gameLoop_processMovement(inputs, feetInWater);
|
||||
}
|
||||
@@ -697,7 +697,7 @@ int gameLoop (
|
||||
|
||||
// Chat
|
||||
case 6:
|
||||
popup_chat(renderer, inputs, &gameTime);
|
||||
popup_chat(renderer, inputs, world.time);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -547,7 +547,7 @@ void popup_inventory (
|
||||
* Allows the user to type in chat, and view farther back in the message
|
||||
* history. Capable of closing itself.
|
||||
*/
|
||||
void popup_chat (SDL_Renderer *renderer, Inputs *inputs, long *gameTime) {
|
||||
void popup_chat (SDL_Renderer *renderer, Inputs *inputs, u_int64_t gameTime) {
|
||||
static char buffer[64] = { 0 };
|
||||
static InputBuffer chatBox = {
|
||||
.buffer = buffer,
|
||||
@@ -599,7 +599,7 @@ void popup_chat (SDL_Renderer *renderer, Inputs *inputs, long *gameTime) {
|
||||
white(renderer);
|
||||
drawChar (
|
||||
renderer,
|
||||
95 + 32 * ((*gameTime >> 6) % 2),
|
||||
95 + 32 * ((gameTime >> 6) % 2),
|
||||
drawStr (
|
||||
renderer, chatBox.buffer,
|
||||
0, BUFFER_H - 8
|
||||
@@ -838,7 +838,7 @@ int menu_optionsMain (SDL_Renderer *renderer, Inputs *inputs) {
|
||||
"Capture Mouse: ON"
|
||||
};
|
||||
if (button(renderer, trapMouseTexts[data_options.trapMouse],
|
||||
BUFFER_HALF_W - 64, 48, 128,
|
||||
BUFFER_HALF_W - 64, 42, 128,
|
||||
inputs->mouse.x, inputs->mouse.y) &&
|
||||
inputs->mouse.left
|
||||
) {
|
||||
|
||||
@@ -16,7 +16,7 @@ void popup_hud (
|
||||
int *, u_int32_t *, Player *
|
||||
);
|
||||
void popup_inventory (SDL_Renderer *, Inputs *, Player *, int *);
|
||||
void popup_chat (SDL_Renderer *, Inputs *, long *);
|
||||
void popup_chat (SDL_Renderer *, Inputs *, u_int64_t);
|
||||
void popup_pause (SDL_Renderer *, Inputs *, int *, int *);
|
||||
void popup_options (SDL_Renderer *, Inputs *, int *);
|
||||
void popup_debugTools (SDL_Renderer *, Inputs *, int *);
|
||||
|
||||
@@ -54,8 +54,9 @@ struct _Chunk {
|
||||
* Stores chunks.
|
||||
*/
|
||||
struct _World {
|
||||
int type;
|
||||
int seed;
|
||||
int dayNightMode;
|
||||
int type;
|
||||
int seed;
|
||||
int dayNightMode;
|
||||
u_int64_t time;
|
||||
Chunk chunk[CHUNKARR_SIZE];
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user