[Fix] Stars make a bit more sense now! :D
This commit is contained in:
parent
246bdff2c8
commit
fd22930673
50
src/space.c
50
src/space.c
@ -54,8 +54,8 @@ static gl_texture* starBG_create(const int density) {
|
||||
w = (int)((float)gl_screen.w * 1.5);
|
||||
if((w & (w-1)) != 0) {
|
||||
w = 1;
|
||||
while(h < (int)((float)gl_screen.h*1.5))
|
||||
h <<= 1;
|
||||
while(w < (int)((float)gl_screen.w*1.5))
|
||||
w <<= 1;
|
||||
}
|
||||
h = (int)((float)gl_screen.h * 1.5);
|
||||
if((h & (h-1)) != 0) {
|
||||
@ -94,12 +94,13 @@ void space_init(void) {
|
||||
|
||||
void space_render(FP dt) {
|
||||
int i;
|
||||
Vec2 tmp = { .x = starPos[0].x };
|
||||
Vec2 tmp;
|
||||
FP f;
|
||||
|
||||
for(i = 0; i < STAR_LAYERS; i++) {
|
||||
// Movement.
|
||||
starPos[i].x -= player->solid->vel.x / (FP)(2*i+4)*dt;
|
||||
starPos[i].y -= player->solid->vel.y / (FP)(2*i+4)*dt;
|
||||
starPos[i].x -= player->solid->vel.x / (FP)(2*i+10)*dt;
|
||||
starPos[i].y -= player->solid->vel.y / (FP)(2*i+104)*dt;
|
||||
|
||||
// Displaces x if reaches edge.
|
||||
if(starPos[i].x > 0)
|
||||
@ -119,23 +120,28 @@ void space_render(FP dt) {
|
||||
tmp.x = starPos[i].x;
|
||||
tmp.y = starPos[i].y;
|
||||
|
||||
// TODO: This needs optimizing.
|
||||
tmp.x -= starBG[i]->w;
|
||||
gl_blitStatic(starBG[i], &tmp);
|
||||
tmp.y += starBG[i]->h;
|
||||
gl_blitStatic(starBG[i], &tmp);
|
||||
tmp.x += starBG[i]->w;
|
||||
gl_blitStatic(starBG[i], &tmp);
|
||||
tmp.x += starBG[i]->w;
|
||||
gl_blitStatic(starBG[i], &tmp);
|
||||
tmp.y -= starBG[i]->h;
|
||||
gl_blitStatic(starBG[i], &tmp);
|
||||
tmp.y -= starBG[i]->h;
|
||||
gl_blitStatic(starBG[i], &tmp);
|
||||
tmp.x -= starBG[i]->w;
|
||||
gl_blitStatic(starBG[i], &tmp);
|
||||
tmp.x -= starBG[i]->w;
|
||||
gl_blitStatic(starBG[i], &tmp);
|
||||
// More blits if part of the screen is blank.
|
||||
if(starPos[i].x < starBG[i]->w/4.)
|
||||
tmp.x += starBG[i]->w;
|
||||
else if(starPos[i].x < starBG[i]->w*3./4.)
|
||||
tmp.y -= starBG[i]->w;
|
||||
|
||||
if(starPos[i].y < starBG[i]->h/4.)
|
||||
tmp.y += starBG[i]->h;
|
||||
else if(starPos[i].y < starBG[i]->h*3./4.)
|
||||
tmp.y -= starBG[i]->h;
|
||||
|
||||
if(tmp.x != starPos[i].x && tmp.y != starPos[i].y) {
|
||||
gl_blitStatic(starBG[i], &tmp);
|
||||
f = tmp.x;
|
||||
tmp.x = starPos[i].x;
|
||||
gl_blitStatic(starBG[i], &tmp);
|
||||
tmp.x = f;
|
||||
tmp.y = starPos[i].y;
|
||||
gl_blitStatic(starBG[i], &tmp);
|
||||
}
|
||||
else if(tmp.x != starPos[i].x || tmp.y != starPos[i].y)
|
||||
gl_blitStatic(starBG[i], &tmp);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user