• Create Account

### #ActualAnubiss

Posted 13 January 2012 - 04:29 AM

Alright. It´s working so far. I can add a new station. But after making one station the game freezes.

void ladestationen(void){
while (istationen<n){
stations[istationen].x=210;
stations[istationen].y=100;
if (stations[istationen].flag!=1){
PA_CreateSprite(0, istationen,(void*)station01_Sprite, OBJ_SIZE_64X64,1, 1, stations[istationen].x-16, stations[istationen].y-16);
stations[istationen].flag=1;
}
PA_SetSpriteXY(0, 3, ((stations[istationen].x-16)+(-scrollx>>8))-16, ((stations[istationen].y-16)+(scrolly>>8))-16);
}
}


I almost think, that this is correct.
But following I wrote out of a function and out of the main-function:

ownstation* stations;
stations = (ownstation*) malloc(n*sizeof(ownstation));

And how does it work with resizing?
I don´t really understand where exactly this has to be written.

EDIT:
That´s wrong, aye?

stations = (ownstation*) malloc(n*sizeof(ownstation));
while (istationen<n){
stations[istationen].x=210;
stations[istationen].y=100;
if (stations[istationen].flag!=1){
PA_CreateSprite(0, istationen,(void*)station01_Sprite, OBJ_SIZE_64X64,1, 1, stations[istationen].x-16, stations[istationen].y-16);
stations[istationen].flag=1;
}
PA_SetSpriteXY(0, 3, ((stations[istationen].x-16)+(-scrollx>>8))-16, ((stations[istationen].y-16)+(scrolly>>8))-16);
}

temp = (ownstation*) malloc(newlen*sizeof(ownstation));
memcpy(temp, stations, oldlen*sizeof(ownstation));
free(stations);
stations=temp;

}

### #1Anubiss

Posted 13 January 2012 - 04:17 AM

Alright. It´s working so far. I can add a new station. But after making one station the game freezes.

void ladestationen(void){
while (istationen<n){
stations[istationen].x=210;
stations[istationen].y=100;
if (stations[istationen].flag!=1){
PA_CreateSprite(0, istationen,(void*)station01_Sprite, OBJ_SIZE_64X64,1, 1, stations[istationen].x-16, stations[istationen].y-16);
stations[istationen].flag=1;
}
PA_SetSpriteXY(0, 3, ((stations[istationen].x-16)+(-scrollx>>8))-16, ((stations[istationen].y-16)+(scrolly>>8))-16);
}
}


I almost think, that this is correct.
But following I wrote out of a function and out of the main-function:

ownstation* stations;
stations = (ownstation*) malloc(n*sizeof(ownstation));

And how does it work with resizing?
I don´t really understand where exactly this has to be written.

PARTNERS