Randomize planet and background in Challenge Home.

This commit is contained in:
Steve 2016-02-29 16:00:32 +00:00
parent 25d68b27fb
commit 9d846fd137
5 changed files with 13 additions and 11 deletions

View File

@ -60,13 +60,13 @@ void initChallengeHome(void)
app.delegate.draw = &draw;
memset(&app.keyboard, 0, sizeof(int) * MAX_KEYBOARD_KEYS);
background = getTexture("gfx/backgrounds/background06.jpg");
planetTexture = getTexture("gfx/planets/bluePlanet.png");
background = getTexture(getBackgroundTextureName(rand()));
planetTexture = getTexture(getPlanetTextureName(rand()));
battle.camera.x = battle.camera.y = 0;
planet.x = SCREEN_WIDTH;
planet.y = (rand() % SCREEN_HEIGHT - 128);
planet.x = rand() % SCREEN_WIDTH;
planet.y = rand() % SCREEN_HEIGHT;
game.currentMission = NULL;
@ -174,7 +174,7 @@ static void draw(void)
{
drawBackground(background);
blit(planetTexture, planet.x, planet.y, 0);
blit(planetTexture, planet.x, planet.y, 1);
drawStars();

View File

@ -55,6 +55,8 @@ extern void selectWidget(const char *name, const char *group);
extern void updateAllMissions(void);
extern char *getTranslatedString(char *string);
extern void blit(SDL_Texture *t, int x, int y, int centered);
extern char *getBackgroundTextureName(int n);
extern char *getPlanetTextureName(int n);
extern App app;
extern Battle battle;

View File

@ -113,12 +113,12 @@ void drawBackground(SDL_Texture *texture)
}
}
char *getBackgroundTexture(int i)
char *getBackgroundTextureName(int i)
{
return backgrounds[i % numBackgrounds];
}
char *getPlanetTexture(int i)
char *getPlanetTextureName(int i)
{
return planets[i % numPlanets];
}

View File

@ -228,7 +228,7 @@ static char *getAutoBackground(char *filename)
hash = hashcode(filename);
}
return getBackgroundTexture(hash);
return getBackgroundTextureName(hash);
}
static char *getAutoPlanet(char *filename)
@ -244,7 +244,7 @@ static char *getAutoPlanet(char *filename)
hash = hashcode(filename);
}
return getPlanetTexture(hash);
return getPlanetTextureName(hash);
}
void completeMission(void)

View File

@ -51,8 +51,8 @@ extern void initMissionInfo(void);
extern char *getTranslatedString(char *string);
extern void updateStarSystemMissions(void);
extern void updateChallengeMissions(void);
extern char *getBackgroundTexture(int n);
extern char *getPlanetTexture(int n);
extern char *getBackgroundTextureName(int n);
extern char *getPlanetTextureName(int n);
extern Battle battle;
extern Entity *player;