Fix horizon offset
This commit is contained in:
parent
f24db847ce
commit
7f00b5aa5f
7 changed files with 34 additions and 40 deletions
2
TODO.txt
2
TODO.txt
|
@ -1,6 +1,5 @@
|
||||||
=========== GENERAL ==============
|
=========== GENERAL ==============
|
||||||
|
|
||||||
- bug: background horizon position depends on resolution! fix
|
|
||||||
- make a small txt game menual
|
- make a small txt game menual
|
||||||
- test:
|
- test:
|
||||||
- long replay
|
- long replay
|
||||||
|
@ -34,6 +33,7 @@
|
||||||
=========== HANDLED ==============
|
=========== HANDLED ==============
|
||||||
|
|
||||||
- allow stopping car rotation in air like in Trackmania
|
- allow stopping car rotation in air like in Trackmania
|
||||||
|
- bug: background horizon position depends on resolution! fix
|
||||||
- option to disable crash sounds (and so code that detects crashes)
|
- option to disable crash sounds (and so code that detects crashes)
|
||||||
- drawing dithered transparent objects fills z-buffer in the transparent parts
|
- drawing dithered transparent objects fills z-buffer in the transparent parts
|
||||||
and then the geometry behind it isn't drawn <- PARTIALLY FIXED, LOOKS GOOD
|
and then the geometry behind it isn't drawn <- PARTIALLY FIXED, LOOKS GOOD
|
||||||
|
|
7
game.h
7
game.h
|
@ -850,23 +850,26 @@ void LCR_gameInit(int argc, const char **argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LCR_gameLoadMainMenuItems();
|
|
||||||
|
|
||||||
if (quickLoad == 1)
|
if (quickLoad == 1)
|
||||||
{
|
{
|
||||||
LCR_gameLoadMap(LCR_countData('M') - 1);
|
LCR_gameLoadMap(LCR_countData('M') - 1);
|
||||||
LCR_gameSetState(LCR_GAME_STATE_LOADING);
|
LCR_gameSetState(LCR_GAME_STATE_LOADING);
|
||||||
LCR_game.menu.selectedTab = 1;
|
LCR_game.menu.selectedTab = 1;
|
||||||
|
LCR_gameLoadDataFileChunk(0,'M');
|
||||||
}
|
}
|
||||||
else if (quickLoad == 2 || quickLoad == 3)
|
else if (quickLoad == 2 || quickLoad == 3)
|
||||||
{
|
{
|
||||||
LCR_gameLoadReplay(LCR_countData('R') - 1);
|
LCR_gameLoadReplay(LCR_countData('R') - 1);
|
||||||
LCR_gameSetState(LCR_GAME_STATE_LOADING);
|
LCR_gameSetState(LCR_GAME_STATE_LOADING);
|
||||||
LCR_game.menu.selectedTab = quickLoad;
|
LCR_game.menu.selectedTab = quickLoad;
|
||||||
|
LCR_gameLoadDataFileChunk(0,'R');
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
LCR_gameLoadMainMenuItems();
|
||||||
LCR_gameSetState(LCR_GAME_STATE_MENU);
|
LCR_gameSetState(LCR_GAME_STATE_MENU);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Loads up to LCR_RESOURCE_ITEM_CHUNK items of given type, starting at given
|
Loads up to LCR_RESOURCE_ITEM_CHUNK items of given type, starting at given
|
||||||
|
|
2
make.sh
2
make.sh
|
@ -3,5 +3,5 @@
|
||||||
clear
|
clear
|
||||||
clear
|
clear
|
||||||
|
|
||||||
gcc -std=c99 -g -Wall -Wextra -pedantic -O1 -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers `sdl2-config --libs --static-libs` -o game frontend_sdl.c && ./game $@
|
gcc -std=c99 -g -Wall -Wextra -pedantic -O1 -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -o game frontend_sdl.c `sdl2-config --libs --static-libs` && ./game $@
|
||||||
|
|
||||||
|
|
14
racing.h
14
racing.h
|
@ -1245,8 +1245,6 @@ uint32_t LCR_racingStep(unsigned int input)
|
||||||
LCR_racing.carBody.joints[LCR_CAR_JOINTS - 1].velocity[j];
|
LCR_racing.carBody.joints[LCR_CAR_JOINTS - 1].velocity[j];
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: magic constants
|
|
||||||
|
|
||||||
if (input & (LCR_RACING_INPUT_FORW | LCR_RACING_INPUT_BACK))
|
if (input & (LCR_RACING_INPUT_FORW | LCR_RACING_INPUT_BACK))
|
||||||
{
|
{
|
||||||
LCR_GameUnit rotateBy =
|
LCR_GameUnit rotateBy =
|
||||||
|
@ -1336,7 +1334,7 @@ uint32_t LCR_racingStep(unsigned int input)
|
||||||
LCR_racing.carBody.joints[i].velocity[2] = jv.z;
|
LCR_racing.carBody.joints[i].velocity[2] = jv.z;
|
||||||
}
|
}
|
||||||
|
|
||||||
driftFriction /= 4;
|
driftFriction /= 4; // divide by 4 wheels
|
||||||
|
|
||||||
if ((!LCR_racing.carDrifting) &&
|
if ((!LCR_racing.carDrifting) &&
|
||||||
driftFriction > LCR_CAR_DRIFT_THRESHOLD_1)
|
driftFriction > LCR_CAR_DRIFT_THRESHOLD_1)
|
||||||
|
@ -1411,7 +1409,7 @@ uint32_t LCR_racingStep(unsigned int input)
|
||||||
LCR_racing.carBody.joints[4].position,
|
LCR_racing.carBody.joints[4].position,
|
||||||
LCR_racing.carBody.joints[0].position)));
|
LCR_racing.carBody.joints[0].position)));
|
||||||
|
|
||||||
if (angle < TPE_F / 64) // TODO: magic constant
|
if (angle < TPE_F / 64) // TPE_F / 64 is a magic constant
|
||||||
{
|
{
|
||||||
LCR_LOG2("roof squeezed, applying anti force")
|
LCR_LOG2("roof squeezed, applying anti force")
|
||||||
|
|
||||||
|
@ -1559,8 +1557,7 @@ uint32_t LCR_racingStep(unsigned int input)
|
||||||
Draws a simple 3D debug overlap of the physics world.
|
Draws a simple 3D debug overlap of the physics world.
|
||||||
*/
|
*/
|
||||||
void LCR_physicsDebugDraw(LCR_GameUnit camPos[3], LCR_GameUnit camRot[2],
|
void LCR_physicsDebugDraw(LCR_GameUnit camPos[3], LCR_GameUnit camRot[2],
|
||||||
LCR_GameUnit camFov,
|
LCR_GameUnit camFov, void (*drawPixel)(uint16_t, uint16_t, uint8_t))
|
||||||
void (*drawPixel)(uint16_t, uint16_t, uint8_t))
|
|
||||||
{
|
{
|
||||||
#if LCR_SETTING_DEBUG_PHYSICS_DRAW
|
#if LCR_SETTING_DEBUG_PHYSICS_DRAW
|
||||||
LCR_LOG2("drawing physics debug");
|
LCR_LOG2("drawing physics debug");
|
||||||
|
@ -1581,11 +1578,6 @@ void LCR_physicsDebugDraw(LCR_GameUnit camPos[3], LCR_GameUnit camRot[2],
|
||||||
|
|
||||||
TPE_worldDebugDraw(&(LCR_racing.physicsWorld),drawPixel,
|
TPE_worldDebugDraw(&(LCR_racing.physicsWorld),drawPixel,
|
||||||
cPos,cRot,cView,16,LCR_PHYSICS_UNIT / 4,LCR_racing.tick * 4);
|
cPos,cRot,cView,16,LCR_PHYSICS_UNIT / 4,LCR_racing.tick * 4);
|
||||||
|
|
||||||
/*
|
|
||||||
TPE_worldDebugDraw(&(LCR_racing.physicsWorld),_LCR_drawPhysicsDebugPixel,
|
|
||||||
cPos,cRot,cView,16,LCR_PHYSICS_UNIT / 4,LCR_racing.tick * 4);
|
|
||||||
*/
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
11
renderer.h
11
renderer.h
|
@ -1346,18 +1346,15 @@ void LCR_rendererDrawSky(int sky, S3L_Unit offsetH, S3L_Unit offsetV)
|
||||||
LCR_loadImage(sky + 3);
|
LCR_loadImage(sky + 3);
|
||||||
bottomColor = LCR_sampleImage(LCR_IMAGE_SIZE - 1,LCR_IMAGE_SIZE - 1);
|
bottomColor = LCR_sampleImage(LCR_IMAGE_SIZE - 1,LCR_IMAGE_SIZE - 1);
|
||||||
|
|
||||||
anchorPoint[0] = ((LCR_EFFECTIVE_RESOLUTION_X * offsetH)
|
anchorPoint[0] = ((LCR_EFFECTIVE_RESOLUTION_X * offsetH) / S3L_F) %
|
||||||
/ S3L_F) %
|
|
||||||
(2 * LCR_IMAGE_SIZE * LCR_SETTING_SKY_SIZE);
|
(2 * LCR_IMAGE_SIZE * LCR_SETTING_SKY_SIZE);
|
||||||
|
|
||||||
if (anchorPoint[0] < 0)
|
if (anchorPoint[0] < 0)
|
||||||
anchorPoint[0] += 2 * LCR_IMAGE_SIZE * LCR_SETTING_SKY_SIZE;
|
anchorPoint[0] += 2 * LCR_IMAGE_SIZE * LCR_SETTING_SKY_SIZE;
|
||||||
|
|
||||||
anchorPoint[1] =
|
anchorPoint[1] = LCR_EFFECTIVE_RESOLUTION_Y / 2 - (LCR_EFFECTIVE_RESOLUTION_Y
|
||||||
(LCR_EFFECTIVE_RESOLUTION_Y) / 2 - // 3: we place the center a bit more up
|
* offsetV) / S3L_F - ((LCR_IMAGE_SIZE * LCR_SETTING_HORIZON_SHIFT) / 100 *
|
||||||
(LCR_SETTING_HORIZON_SHIFT * LCR_EFFECTIVE_RESOLUTION_Y) / 100 -
|
LCR_SETTING_SKY_SIZE);
|
||||||
(LCR_EFFECTIVE_RESOLUTION_Y * offsetV) / S3L_F
|
|
||||||
- LCR_IMAGE_SIZE * LCR_SETTING_SKY_SIZE;
|
|
||||||
|
|
||||||
pixelIndex = 0;
|
pixelIndex = 0;
|
||||||
y = anchorPoint[1] < 0 ? anchorPoint[1] : 0;
|
y = anchorPoint[1] < 0 ? anchorPoint[1] : 0;
|
||||||
|
|
14
settings.h
14
settings.h
|
@ -17,16 +17,18 @@
|
||||||
#define LCR_SETTING_RESOLUTION_Y 768
|
#define LCR_SETTING_RESOLUTION_Y 768
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef LCR_SETTING_RESOLUTION_SUBDIVIDE
|
||||||
|
/** Subdivides the whole game resolution by this amount by making each pixel
|
||||||
|
this number of times bigger. */
|
||||||
|
#define LCR_SETTING_RESOLUTION_SUBDIVIDE 2
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef LCR_SETTING_FPS
|
#ifndef LCR_SETTING_FPS
|
||||||
/** Rendering frames per second. Note this only applies to graphics, NOT
|
/** Rendering frames per second. Note this only applies to graphics, NOT
|
||||||
physics. */
|
physics. */
|
||||||
#define LCR_SETTING_FPS 30
|
#define LCR_SETTING_FPS 30
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef LCR_SETTING_RESOLUTION_SUBDIVIDE
|
|
||||||
#define LCR_SETTING_RESOLUTION_SUBDIVIDE 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef LCR_SETTING_FREE_CAMERA_SPEED
|
#ifndef LCR_SETTING_FREE_CAMERA_SPEED
|
||||||
/** Move speed of free camera, in 1/8ths of block length. */
|
/** Move speed of free camera, in 1/8ths of block length. */
|
||||||
#define LCR_SETTING_FREE_CAMERA_SPEED 50
|
#define LCR_SETTING_FREE_CAMERA_SPEED 50
|
||||||
|
@ -197,8 +199,8 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef LCR_SETTING_HORIZON_SHIFT
|
#ifndef LCR_SETTING_HORIZON_SHIFT
|
||||||
/** Vertical offset of the background horizon in percents of screen height. */
|
/** Vertical offset of the background sky image in percents. */
|
||||||
#define LCR_SETTING_HORIZON_SHIFT 30
|
#define LCR_SETTING_HORIZON_SHIFT 180
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef LCR_SETTING_TIME_MULTIPLIER
|
#ifndef LCR_SETTING_TIME_MULTIPLIER
|
||||||
|
|
Loading…
Reference in a new issue