diff --git a/gfx/atlas/atlas.png b/gfx/atlas/atlas.png index d295aec..f550d48 100644 Binary files a/gfx/atlas/atlas.png and b/gfx/atlas/atlas.png differ diff --git a/src/hub/hub.c b/src/hub/hub.c index 5e00fbf..1cfdf70 100644 --- a/src/hub/hub.c +++ b/src/hub/hub.c @@ -58,6 +58,7 @@ static PointF cursor; static float blipSize; static float blipValue; static int showingWidgets; +static PointF cloudPos; void initHub(void) { @@ -183,6 +184,9 @@ void initHub(void) teeka->status = MS_LOCKED; } + cloudPos.x = randF() - randF(); + cloudPos.y = randF() - randF(); + app.delegate.logic = &logic; app.delegate.draw = &draw; @@ -197,6 +201,8 @@ static void logic(void) blipSize = 64 + (sin(blipValue) * 16); + scrollBackground(cloudPos.x, cloudPos.y); + animateSprites(); doCursor(); @@ -291,6 +297,8 @@ static void draw(void) { blitRectScaled(atlasTexture->texture, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, &worldMap->rect, 0); + drawBackground(atlasTexture->texture, &clouds->rect); + drawMissions(); drawInfoBar(); diff --git a/src/hub/hub.h b/src/hub/hub.h index eafab87..635c73c 100644 --- a/src/hub/hub.h +++ b/src/hub/hub.h @@ -50,6 +50,9 @@ extern void stopMusic(void); extern void startSectionTransition(void); extern void endSectionTransition(void); extern void initWorld(void); +extern void drawBackground(SDL_Texture *texture, SDL_Rect *srcRect); +extern void scrollBackground(float x, float y); +extern double randF(void); extern App app; extern Colors colors; diff --git a/src/system/draw.c b/src/system/draw.c index e46739c..b0adfca 100644 --- a/src/system/draw.c +++ b/src/system/draw.c @@ -22,6 +22,23 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. static void initColor(SDL_Color *c, int r, int g, int b); +static PointF backgroundPoint[4]; + +void initBackground(void) +{ + backgroundPoint[0].x = -SCREEN_WIDTH / 2; + backgroundPoint[0].y = -SCREEN_HEIGHT / 2; + + backgroundPoint[1].x = SCREEN_WIDTH / 2; + backgroundPoint[1].y = -SCREEN_HEIGHT / 2; + + backgroundPoint[2].x = -SCREEN_WIDTH / 2; + backgroundPoint[2].y = SCREEN_HEIGHT / 2; + + backgroundPoint[3].x = SCREEN_WIDTH / 2; + backgroundPoint[3].y = SCREEN_HEIGHT / 2; +} + void initGraphics(void) { initColor(&colors.red, 255, 0, 0); @@ -187,6 +204,47 @@ void drawOutlineRect(int x, int y, int w, int h, int r, int g, int b, int a) SDL_RenderDrawRect(app.renderer, &rect); } +void scrollBackground(float x, float y) +{ + int i; + + for (i = 0 ; i < 4 ; i++) + { + backgroundPoint[i].x += x; + backgroundPoint[i].y += y; + + if (backgroundPoint[i].x < 0) + { + backgroundPoint[i].x += (SCREEN_WIDTH * 2); + } + + if (backgroundPoint[i].x >= SCREEN_WIDTH) + { + backgroundPoint[i].x -= (SCREEN_WIDTH * 2); + } + + if (backgroundPoint[i].y < 0) + { + backgroundPoint[i].y += (SCREEN_HEIGHT * 2); + } + + if (backgroundPoint[i].y >= SCREEN_HEIGHT) + { + backgroundPoint[i].y -= (SCREEN_HEIGHT * 2); + } + } +} + +void drawBackground(SDL_Texture *texture, SDL_Rect *srcRect) +{ + int i; + + for (i = 0 ; i < 4 ; i++) + { + blitRectScaled(texture, backgroundPoint[i].x, backgroundPoint[i].y, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1, srcRect, 0); + } +} + static void initColor(SDL_Color *c, int r, int g, int b) { memset(c, 0, sizeof(SDL_Color)); diff --git a/src/system/init.c b/src/system/init.c index 7081947..72c1cb5 100644 --- a/src/system/init.c +++ b/src/system/init.c @@ -134,6 +134,7 @@ void initGameSystem(void) int i, numInitFuns; void (*initFuncs[]) (void) = { initGraphics, + initBackground, initFonts, initAtlas, initWidgets, diff --git a/src/system/init.h b/src/system/init.h index f5464a7..82ceec3 100644 --- a/src/system/init.h +++ b/src/system/init.h @@ -29,6 +29,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. extern void createSaveFolder(void); extern void setLanguage(char *applicationName, char *languageCode); +extern void initBackground(void); extern void initGraphics(void); extern void initFonts(void); extern void initAtlas(void);