Merge pull request #14 from Tempetas/minor-changes
Some tiny changes here and there
This commit is contained in:
@@ -57,7 +57,7 @@ int gameLoop (
|
||||
|
||||
static long l, gameTime;
|
||||
|
||||
static int m,
|
||||
static int axis,
|
||||
blockSelected = 0,
|
||||
selectedPass,
|
||||
i6,
|
||||
@@ -282,16 +282,16 @@ int gameLoop (
|
||||
playerMovement.z += f10 * playerSpeedFB - f9 * playerSpeedLR;
|
||||
playerMovement.y += 0.003;
|
||||
|
||||
for (m = 0; m < 3; m++) {
|
||||
for (axis = 0; axis < 3; axis++) {
|
||||
f16 =
|
||||
player.pos.x +
|
||||
playerMovement.x * ((m + 2) % 3 / 2);
|
||||
playerMovement.x * ((axis + 2) % 3 / 2);
|
||||
f17 =
|
||||
player.pos.y +
|
||||
playerMovement.y * ((m + 1) % 3 / 2);
|
||||
playerMovement.y * ((axis + 1) % 3 / 2);
|
||||
f19 =
|
||||
player.pos.z +
|
||||
playerMovement.z * ((m + 3) % 3 / 2);
|
||||
playerMovement.z * ((axis + 3) % 3 / 2);
|
||||
|
||||
for (i12 = 0; i12 < 12; i12++) {
|
||||
i13 = (int)(f16 + (i12 >> 0 & 0x1) * 0.6 - 0.3) - 64;
|
||||
@@ -299,7 +299,7 @@ int gameLoop (
|
||||
i15 = (int)(f19 + (i12 >> 1 & 0x1) * 0.6 - 0.3) - 64;
|
||||
|
||||
if (World_getBlock(world, i13, i14, i15) > 0) {
|
||||
if (m != 1) {
|
||||
if (axis != 1) {
|
||||
goto label208;
|
||||
}
|
||||
if (
|
||||
@@ -427,6 +427,12 @@ int gameLoop (
|
||||
&player.inventory.offhand
|
||||
);
|
||||
}
|
||||
|
||||
if (!gamePopup && inputs->numPressed != 0 && inputs->numPressed != 10) {
|
||||
player.inventory.hotbarSelect = inputs->numPressed - 1;
|
||||
|
||||
inputs->numPressed = 0;
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef small
|
||||
@@ -642,7 +648,7 @@ int gameLoop (
|
||||
(pixelY == BUFFER_HALF_H
|
||||
&& abs(BUFFER_HALF_W - pixelX) < 4)
|
||||
)) {
|
||||
finalPixelColor = 16777216 - finalPixelColor;
|
||||
finalPixelColor = 0x1000000 - finalPixelColor;
|
||||
}
|
||||
|
||||
if (finalPixelColor > 0) {
|
||||
|
||||
@@ -137,6 +137,10 @@ int handleEvent (Inputs *inputs, const u_int8_t *keyboard, SDL_Event event) {
|
||||
inputs->keyboard_F = keyboard[SDL_SCANCODE_F];
|
||||
|
||||
inputs->keySym = event.key.keysym.sym;
|
||||
|
||||
if (event.key.keysym.scancode >= SDL_SCANCODE_1 && event.key.keysym.scancode <= SDL_SCANCODE_0) {
|
||||
inputs->numPressed = event.key.keysym.scancode - SDL_SCANCODE_1 + 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
@@ -31,6 +31,8 @@ typedef struct {
|
||||
|
||||
int keyTyped;
|
||||
int keySym;
|
||||
|
||||
int numPressed;
|
||||
} Inputs;
|
||||
|
||||
int controlLoop(Inputs *inputs, const u_int8_t *keyboard);
|
||||
|
||||
@@ -253,9 +253,9 @@ int genChunk (
|
||||
int force,
|
||||
Coords coords
|
||||
) {
|
||||
xOffset = (xOffset / 64) * 64;
|
||||
yOffset = (yOffset / 64) * 64;
|
||||
zOffset = (zOffset / 64) * 64;
|
||||
xOffset = (xOffset / CHUNK_SIZE) * CHUNK_SIZE;
|
||||
yOffset = (yOffset / CHUNK_SIZE) * CHUNK_SIZE;
|
||||
zOffset = (zOffset / CHUNK_SIZE) * CHUNK_SIZE;
|
||||
// To make sure structure generation accross chunks is
|
||||
// different, but predictable
|
||||
srand(seed * (xOffset * yOffset * zOffset + 1));
|
||||
@@ -306,7 +306,7 @@ int genChunk (
|
||||
|
||||
Block *blocks = chunk->blocks;
|
||||
|
||||
for (int i = 0; i < 262144; i++) {
|
||||
for (int i = 0; i < CHUNK_DATA_SIZE; i++) {
|
||||
blocks[i] = 0;
|
||||
}
|
||||
|
||||
@@ -367,9 +367,9 @@ int genChunk (
|
||||
}
|
||||
|
||||
void ch_genClassic (Block *blocks) {
|
||||
for (int x = 0; x < 64; x ++)
|
||||
for (int y = 32; y < 64; y ++)
|
||||
for (int z = 0; z < 64; z ++) {
|
||||
for (int x = 0; x < CHUNK_SIZE; x ++)
|
||||
for (int y = 32; y < CHUNK_SIZE; y ++)
|
||||
for (int z = 0; z < CHUNK_SIZE; z ++) {
|
||||
ch_setBlock(blocks, x, y, z,
|
||||
randm(2) == 0 ? randm(8) : 0);
|
||||
}
|
||||
@@ -385,27 +385,27 @@ void ch_genNew (
|
||||
) {
|
||||
// Generate heightmap
|
||||
int heightmap[CHUNK_SIZE][CHUNK_SIZE];
|
||||
for (int x = 0; x < 64; x ++)
|
||||
for (int z = 0; z < 64; z ++) {
|
||||
for (int x = 0; x < CHUNK_SIZE; x ++)
|
||||
for (int z = 0; z < CHUNK_SIZE; z ++) {
|
||||
heightmap[x][z] =
|
||||
perlin2d ( // Base noise
|
||||
seed,
|
||||
x + xOffset + 16777215,
|
||||
z + zOffset + 16777215,
|
||||
x + xOffset + 0xFFFFFF,
|
||||
z + zOffset + 0xFFFFFF,
|
||||
0.0625
|
||||
) * 16 +
|
||||
perlin2d ( // Detail noise
|
||||
seed,
|
||||
x + xOffset + 16777215,
|
||||
z + zOffset + 16777215,
|
||||
x + xOffset + 0xFFFFFF,
|
||||
z + zOffset + 0xFFFFFF,
|
||||
0.0078125
|
||||
) * 64;
|
||||
}
|
||||
|
||||
// Make terrain from heightmap
|
||||
for (int x = 0; x < 64; x ++)
|
||||
for (int y = 0; y < 64; y ++)
|
||||
for (int z = 0; z < 64; z ++) {
|
||||
for (int x = 0; x < CHUNK_SIZE; x ++)
|
||||
for (int y = 0; y < CHUNK_SIZE; y ++)
|
||||
for (int z = 0; z < CHUNK_SIZE; z ++) {
|
||||
if (y + yOffset > heightmap[x][z] + 4)
|
||||
ch_setBlock(blocks, x, y, z, 4);
|
||||
else if (y + yOffset > heightmap[x][z])
|
||||
@@ -417,12 +417,12 @@ void ch_genNew (
|
||||
}
|
||||
|
||||
// Generate caves
|
||||
for (int x = 0; x < 64; x ++)
|
||||
for (int z = 0; z < 64; z ++) {
|
||||
for (int x = 0; x < CHUNK_SIZE; x ++)
|
||||
for (int z = 0; z < CHUNK_SIZE; z ++) {
|
||||
float noisePoint = perlin2d (
|
||||
seed + yOffset,
|
||||
x + xOffset + 16777215,
|
||||
z + zOffset + 16777215,
|
||||
x + xOffset + 0xFFFFFF,
|
||||
z + zOffset + 0xFFFFFF,
|
||||
0.0625
|
||||
);
|
||||
|
||||
@@ -430,15 +430,15 @@ void ch_genNew (
|
||||
|
||||
int elevation = perlin2d (
|
||||
seed + 2 + yOffset,
|
||||
x + xOffset + 16777215,
|
||||
z + zOffset + 16777215,
|
||||
x + xOffset + 0xFFFFFF,
|
||||
z + zOffset + 0xFFFFFF,
|
||||
0.0625
|
||||
) * 8;
|
||||
|
||||
int height = perlin2d (
|
||||
seed + 3 + yOffset,
|
||||
x + xOffset + 16777215,
|
||||
z + zOffset + 16777215,
|
||||
x + xOffset + 0xFFFFFF,
|
||||
z + zOffset + 0xFFFFFF,
|
||||
0.0625
|
||||
) * 4 + 2 - (randm(1) > 0);
|
||||
|
||||
@@ -487,8 +487,8 @@ void ch_genNew (
|
||||
}
|
||||
|
||||
void ch_genStone (Block *blocks) {
|
||||
for (int x = 0; x < 64; x ++)
|
||||
for (int z = 0; z < 64; z ++) {
|
||||
for (int x = 0; x < CHUNK_SIZE; x ++)
|
||||
for (int z = 0; z < CHUNK_SIZE; z ++) {
|
||||
for (int y = 0; y < 32; y ++) {
|
||||
ch_setBlock(blocks, x, y, z, 4);
|
||||
}
|
||||
@@ -499,9 +499,9 @@ void ch_genStone (Block *blocks) {
|
||||
}
|
||||
|
||||
void ch_genFlat (Block *blocks) {
|
||||
for (int x = 0; x < 64; x ++)
|
||||
for (int z = 0; z < 64; z ++)
|
||||
for (int y = 0; y < 64; y ++) {
|
||||
for (int x = 0; x < CHUNK_SIZE; x ++)
|
||||
for (int z = 0; z < CHUNK_SIZE; z ++)
|
||||
for (int y = 0; y < CHUNK_SIZE; y ++) {
|
||||
if (y < 32) { ch_setBlock(blocks, x, y, z, 0); }
|
||||
if (y == 32) { ch_setBlock(blocks, x, y, z, 1); }
|
||||
if (y > 32) { ch_setBlock(blocks, x, y, z, 2); }
|
||||
|
||||
Reference in New Issue
Block a user