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 ==============
|
||||
|
||||
- bug: background horizon position depends on resolution! fix
|
||||
- make a small txt game menual
|
||||
- test:
|
||||
- long replay
|
||||
|
@ -34,6 +33,7 @@
|
|||
=========== HANDLED ==============
|
||||
|
||||
- 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)
|
||||
- drawing dithered transparent objects fills z-buffer in the transparent parts
|
||||
and then the geometry behind it isn't drawn <- PARTIALLY FIXED, LOOKS GOOD
|
||||
|
|
18
audio.h
18
audio.h
|
@ -11,15 +11,15 @@
|
|||
file, left to be optionally loaded and played by the frontend).
|
||||
*/
|
||||
|
||||
#define LCR_SOUND_NONE 0
|
||||
#define LCR_SOUND_CLICK 1
|
||||
#define LCR_SOUND_CRASH_SMALL 2
|
||||
#define LCR_SOUND_CRASH_BIG 3
|
||||
#define LCR_SOUND_ACCELERATOR 4
|
||||
#define LCR_SOUND_FAN 5
|
||||
#define LCR_SOUND_NONE 0
|
||||
#define LCR_SOUND_CLICK 1
|
||||
#define LCR_SOUND_CRASH_SMALL 2
|
||||
#define LCR_SOUND_CRASH_BIG 3
|
||||
#define LCR_SOUND_ACCELERATOR 4
|
||||
#define LCR_SOUND_FAN 5
|
||||
|
||||
#define LCR_AUDIO_CRASH_SOUND_LEN 2048
|
||||
#define LCR_AUDIO_FAN_SOUND_LEN 4096
|
||||
#define LCR_AUDIO_CRASH_SOUND_LEN 2048
|
||||
#define LCR_AUDIO_FAN_SOUND_LEN 4096
|
||||
|
||||
struct
|
||||
{
|
||||
|
@ -178,7 +178,7 @@ uint8_t LCR_audioGetNextSample(void)
|
|||
else if (LCR_audio.engineIntensity)
|
||||
{
|
||||
LCR_audio.engineOsc += LCR_audio.engineInc ? (((_LCR_audioNoise() % 256) <
|
||||
(10 + LCR_audio.engineIntensity))) : -31;
|
||||
(10 + LCR_audio.engineIntensity))) : -31;
|
||||
|
||||
if (LCR_audio.engineInc && LCR_audio.engineOsc >
|
||||
(90 + (LCR_audio.engineIntensity / 8)))
|
||||
|
|
7
game.h
7
game.h
|
@ -850,22 +850,25 @@ void LCR_gameInit(int argc, const char **argv)
|
|||
}
|
||||
}
|
||||
|
||||
LCR_gameLoadMainMenuItems();
|
||||
|
||||
if (quickLoad == 1)
|
||||
{
|
||||
LCR_gameLoadMap(LCR_countData('M') - 1);
|
||||
LCR_gameSetState(LCR_GAME_STATE_LOADING);
|
||||
LCR_game.menu.selectedTab = 1;
|
||||
LCR_gameLoadDataFileChunk(0,'M');
|
||||
}
|
||||
else if (quickLoad == 2 || quickLoad == 3)
|
||||
{
|
||||
LCR_gameLoadReplay(LCR_countData('R') - 1);
|
||||
LCR_gameSetState(LCR_GAME_STATE_LOADING);
|
||||
LCR_game.menu.selectedTab = quickLoad;
|
||||
LCR_gameLoadDataFileChunk(0,'R');
|
||||
}
|
||||
else
|
||||
{
|
||||
LCR_gameLoadMainMenuItems();
|
||||
LCR_gameSetState(LCR_GAME_STATE_MENU);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
2
make.sh
2
make.sh
|
@ -3,5 +3,5 @@
|
|||
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];
|
||||
}
|
||||
|
||||
// TODO: magic constants
|
||||
|
||||
if (input & (LCR_RACING_INPUT_FORW | LCR_RACING_INPUT_BACK))
|
||||
{
|
||||
LCR_GameUnit rotateBy =
|
||||
|
@ -1336,7 +1334,7 @@ uint32_t LCR_racingStep(unsigned int input)
|
|||
LCR_racing.carBody.joints[i].velocity[2] = jv.z;
|
||||
}
|
||||
|
||||
driftFriction /= 4;
|
||||
driftFriction /= 4; // divide by 4 wheels
|
||||
|
||||
if ((!LCR_racing.carDrifting) &&
|
||||
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[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")
|
||||
|
||||
|
@ -1559,8 +1557,7 @@ uint32_t LCR_racingStep(unsigned int input)
|
|||
Draws a simple 3D debug overlap of the physics world.
|
||||
*/
|
||||
void LCR_physicsDebugDraw(LCR_GameUnit camPos[3], LCR_GameUnit camRot[2],
|
||||
LCR_GameUnit camFov,
|
||||
void (*drawPixel)(uint16_t, uint16_t, uint8_t))
|
||||
LCR_GameUnit camFov, void (*drawPixel)(uint16_t, uint16_t, uint8_t))
|
||||
{
|
||||
#if LCR_SETTING_DEBUG_PHYSICS_DRAW
|
||||
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,
|
||||
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
|
||||
}
|
||||
|
||||
|
|
15
renderer.h
15
renderer.h
|
@ -41,8 +41,8 @@
|
|||
// NOTE: ^ S3L_F sometimes makes some triangles bug, S3L_F/2 seems to fix it
|
||||
// but it's more jerky, maybe try to apply anti-overflow in S3L?
|
||||
|
||||
#define LCR_RENDERER_CHUNK_RESOLUTION 4 // do not change
|
||||
#define LCR_RENDERER_LOD_BLOCKS 64 // do not change
|
||||
#define LCR_RENDERER_CHUNK_RESOLUTION 4 // do not change
|
||||
#define LCR_RENDERER_LOD_BLOCKS 64 // do not change
|
||||
|
||||
#define LCR_RENDERER_CHUNK_SIZE_HORIZONTAL \
|
||||
((LCR_MAP_SIZE_BLOCKS * LCR_RENDERER_UNIT) / LCR_RENDERER_CHUNK_RESOLUTION)
|
||||
|
@ -1346,18 +1346,15 @@ void LCR_rendererDrawSky(int sky, S3L_Unit offsetH, S3L_Unit offsetV)
|
|||
LCR_loadImage(sky + 3);
|
||||
bottomColor = LCR_sampleImage(LCR_IMAGE_SIZE - 1,LCR_IMAGE_SIZE - 1);
|
||||
|
||||
anchorPoint[0] = ((LCR_EFFECTIVE_RESOLUTION_X * offsetH)
|
||||
/ S3L_F) %
|
||||
anchorPoint[0] = ((LCR_EFFECTIVE_RESOLUTION_X * offsetH) / S3L_F) %
|
||||
(2 * LCR_IMAGE_SIZE * LCR_SETTING_SKY_SIZE);
|
||||
|
||||
if (anchorPoint[0] < 0)
|
||||
anchorPoint[0] += 2 * LCR_IMAGE_SIZE * LCR_SETTING_SKY_SIZE;
|
||||
|
||||
anchorPoint[1] =
|
||||
(LCR_EFFECTIVE_RESOLUTION_Y) / 2 - // 3: we place the center a bit more up
|
||||
(LCR_SETTING_HORIZON_SHIFT * LCR_EFFECTIVE_RESOLUTION_Y) / 100 -
|
||||
(LCR_EFFECTIVE_RESOLUTION_Y * offsetV) / S3L_F
|
||||
- LCR_IMAGE_SIZE * LCR_SETTING_SKY_SIZE;
|
||||
anchorPoint[1] = LCR_EFFECTIVE_RESOLUTION_Y / 2 - (LCR_EFFECTIVE_RESOLUTION_Y
|
||||
* offsetV) / S3L_F - ((LCR_IMAGE_SIZE * LCR_SETTING_HORIZON_SHIFT) / 100 *
|
||||
LCR_SETTING_SKY_SIZE);
|
||||
|
||||
pixelIndex = 0;
|
||||
y = anchorPoint[1] < 0 ? anchorPoint[1] : 0;
|
||||
|
|
14
settings.h
14
settings.h
|
@ -17,16 +17,18 @@
|
|||
#define LCR_SETTING_RESOLUTION_Y 768
|
||||
#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
|
||||
/** Rendering frames per second. Note this only applies to graphics, NOT
|
||||
physics. */
|
||||
#define LCR_SETTING_FPS 30
|
||||
#endif
|
||||
|
||||
#ifndef LCR_SETTING_RESOLUTION_SUBDIVIDE
|
||||
#define LCR_SETTING_RESOLUTION_SUBDIVIDE 1
|
||||
#endif
|
||||
|
||||
#ifndef LCR_SETTING_FREE_CAMERA_SPEED
|
||||
/** Move speed of free camera, in 1/8ths of block length. */
|
||||
#define LCR_SETTING_FREE_CAMERA_SPEED 50
|
||||
|
@ -197,8 +199,8 @@
|
|||
#endif
|
||||
|
||||
#ifndef LCR_SETTING_HORIZON_SHIFT
|
||||
/** Vertical offset of the background horizon in percents of screen height. */
|
||||
#define LCR_SETTING_HORIZON_SHIFT 30
|
||||
/** Vertical offset of the background sky image in percents. */
|
||||
#define LCR_SETTING_HORIZON_SHIFT 180
|
||||
#endif
|
||||
|
||||
#ifndef LCR_SETTING_TIME_MULTIPLIER
|
||||
|
|
Loading…
Reference in a new issue