Infinite background
This commit is contained in:
+19
-2
@@ -60,7 +60,6 @@ static RenderId_t strengthBarId;
|
||||
static float strength = 0.f;
|
||||
static bool increaseStrength = true;
|
||||
|
||||
|
||||
static float adameStrength = 2.f; // this value is not const as it will be possible to improve the strenght of Adame.
|
||||
|
||||
static RenderObject_t strengthBarSlider;
|
||||
@@ -73,6 +72,11 @@ static bool increaseStrengthBarSlider = true;
|
||||
|
||||
void game_handleFKeyInput(void);
|
||||
|
||||
static RenderId_t backgrounds[2];
|
||||
static int currentBackground = 0;
|
||||
static int backgroundOffset = 0;
|
||||
static int backgroundStep;
|
||||
|
||||
RenderId_t steroidText;
|
||||
|
||||
|
||||
@@ -112,7 +116,9 @@ int game_staticRender(void){
|
||||
gameBackground.surface = gameBackgroundSurface;
|
||||
scaller(gameBackground.surface, 1, &gameBackground.width, &gameBackground.height);
|
||||
gameBackground.height = 1;
|
||||
scene_addRenderObject(&gameScene, gameBackground, 0, 0);
|
||||
backgrounds[0] = scene_addRenderObject(&gameScene, gameBackground, 0, 0);
|
||||
backgrounds[1] = scene_addRenderObject(&gameScene, gameBackground, gameBackground.width * CAMERA_WIDTH, 0);
|
||||
backgroundStep = gameBackground.width * CAMERA_WIDTH;
|
||||
|
||||
SDL_Surface* buildingSurface = IMG_Load("./assets/img/building.png");
|
||||
RenderObject_t building = EMPTY_RENDER_OBJECT;
|
||||
@@ -274,6 +280,12 @@ int game_staticRender(void){
|
||||
int game_render(float delta){
|
||||
deltaAccu += delta;
|
||||
|
||||
if(personPositionX - backgroundOffset > backgroundStep) {
|
||||
currentBackground = 1 - currentBackground;
|
||||
backgroundOffset += backgroundStep;
|
||||
scene_moveRenderObject(&gameScene, backgrounds[currentBackground], backgroundOffset, 0);
|
||||
}
|
||||
|
||||
if(!isSpaceKeypressed && !crashed && deltaAccu >= SLIDER_SPEED){
|
||||
if(increaseStrengthBarSlider && strengthBarSliderDistance >= 0.50f)
|
||||
increaseStrengthBarSlider = false;
|
||||
@@ -373,6 +385,11 @@ void game_handleSpaceKeyInput(void){
|
||||
scene_moveRenderObject(&gameScene, personId, 0, CAMERA_HEIGHT * 2);
|
||||
personId = victims[rand() % 4];
|
||||
kicked=false;
|
||||
|
||||
backgroundOffset = 0;
|
||||
currentBackground = 0;
|
||||
scene_moveRenderObject(&gameScene, backgrounds[0], 0, 0);
|
||||
scene_moveRenderObject(&gameScene, backgrounds[1], backgroundStep, 0);
|
||||
} else{
|
||||
isSpaceKeypressed = true;
|
||||
strength = - 32 * powf(fabs(strengthBarSliderDistance - 0.5f/2), 2) + 2;
|
||||
|
||||
Reference in New Issue
Block a user