Jump to content

  • Log In with Google      Sign In   
  • Create Account


Anubiss

Member Since 10 Jan 2012
Offline Last Active Mar 28 2012 12:59 AM
-----

Posts I've Made

In Topic: Creating A New Object Ingame

25 January 2012 - 07:56 AM

what do you mean with that i "dont take keypad input in my menu loop"? they´re in each loop as i see. in the first Menu it´s even working, but if i´m pressing the A-Button the new menu appears but with each klick on up or down the "o" will put out on each y-value


EDIT:
Allright, I understood what you mean.
made it now so:

//Handelsbildschirm:
/////////////////////////////////////////////////
void handelsbildschirm(void){

  PA_OutputText(1,0,1,"++++++++++++++++");
  PA_OutputText(1,0,2," Station: %02d", stations[istationen].id);
  PA_OutputText(1,0,3,"++++++++++++++++");
  PA_OutputText(1,2,5,"Handelsbildschirm");
  PA_OutputText(1,0,6,"++++++++++++++++");
  PA_OutputText(1,0,optionskursor,"o");
  if(Pad.Newpress.Down)optionskursor++;
  if(Pad.Newpress.Up)optionskursor--;
}

//Stations-Menü:
/////////////////////////////////////////////////
void stationsmenu(void){

PA_OutputText(1,0,1,"++++++++++++++++");
PA_OutputText(1,0,2," Station: %02d", stations[istationen].id);
PA_OutputText(1,0,3,"++++++++++++++++");
PA_OutputText(1,2,5,"Handelsbildschirm");
PA_OutputText(1,2,6,"Stationsinformationen");
PA_OutputText(1,2,7,"Schiffsinformationen");
PA_OutputText(1,0,optionskursor,"o");
if(Pad.Newpress.Down)optionskursor++;
if(Pad.Newpress.Up)optionskursor--;

}

and to call the menu:

while ((stations[istationen].entfx<30)&&(stations[istationen].entfy<30)){
   //PA_OutputText(1,2,9,"'X' zum kaufen");
  //
   //menu();
   if(optionsflag==0)stationsmenu();
   if(Pad.Newpress.A)optionsflag=1;
   if(optionsflag==1)handelsbildschirm();
  
   break;
  }

I´m of course not ready with it, but seeing that it´s working, is bringing me forward. Have much thanks!

In Topic: Creating A New Object Ingame

24 January 2012 - 03:57 PM

But i only have to use free() if i really want to destroy an "object"? So i can create, create and create and only for "n"- 1 (for example) i need to free the memory then?

EDIT:

btw, there´s a new question i have.
i made an option-menu

//Handelsbildschirm:
/////////////////////////////////////////////////
void handelsbildschirm(void){
while(1){
  PA_OutputText(1,0,1,"++++++++++++++++");
  PA_OutputText(1,0,2," Station: %02d", stations[istationen].id);
  PA_OutputText(1,0,3,"++++++++++++++++");
  PA_OutputText(1,2,5,"Handelsbildschirm");
  PA_OutputText(1,0,6,"++++++++++++++++");
 
  PA_OutputText(1,0,optionskursor,"o");
   if(Pad.Newpress.Down)optionskursor++;
if(Pad.Newpress.Up)optionskursor--;
  if(Pad.Newpress.B)break;
}
}

//Stations-Menü:
/////////////////////////////////////////////////
void stationsmenu(void){

PA_OutputText(1,0,1,"++++++++++++++++");
PA_OutputText(1,0,2," Station: %02d", stations[istationen].id);
PA_OutputText(1,0,3,"++++++++++++++++");
PA_OutputText(1,2,5,"Handelsbildschirm");
PA_OutputText(1,2,6,"Stationsinformationen");
PA_OutputText(1,2,7,"Schiffsinformationen");
PA_OutputText(1,0,optionskursor,"o");
if(Pad.Newpress.Down)optionskursor++;
if(Pad.Newpress.Up)optionskursor--;
if(Pad.Newpress.A){
  PA_ClearTextBg(1);
  switch(optionskursor){
 
  case 5:
  handelsbildschirm();
 
  }
}
}

I choose with my cursor the option "Handelsbildschirm" an it leads me to the new menu, but there the cursor does not move. is it because of the "while()" ?

In Topic: Creating A New Object Ingame

13 January 2012 - 05:39 AM

glorious!
have much thanks. it´s working very fine.

but for understanding. realloc is reserving memory as malloc is doing. But realloc keeps the given values and new values are simply added behind the already excisting values?

In Topic: Creating A New Object Ingame

13 January 2012 - 05:24 AM

i´m calling it in each frame.
should i make some kind of counter or something like that?

but i don´t think it can be a lack of mem, because a few minutes ago i was able to load about 30 new stations, with 30 sprites. but they just where created on the same coordinates.. and didn´t move

In Topic: Creating A New Object Ingame

13 January 2012 - 05:14 AM

thank you.
now i have one problem more.

my function is now looking like that:

oid ladestationen(void){
stations = (ownstation*) malloc(n*sizeof(ownstation));
istationen=0;
while (istationen<n){
  if (stations[istationen].flag!=1){
   stations[istationen].x=330;
   stations[istationen].y=120;
   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, istationen, ((stations[istationen].x-16)+(-scrollx>>8))-16, ((stations[istationen].y-16)+(scrolly>>8))-16);
  istationen++;
}
}

It works everything so far, but when i create a new station the game freezes.
it does not freeze, when it looks like so:


void ladestationen(void){
stations = (ownstation*) malloc(n*sizeof(ownstation));
while (istationen<n){
  if (stations[istationen].flag!=1){
   stations[istationen].x=330;
   stations[istationen].y=120;
   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, istationen, ((stations[istationen].x-16)+(-scrollx>>8))-16, ((stations[istationen].y-16)+(scrolly>>8))-16);
  istationen++;
}
}

but now the x and y values of the station do not change..

PARTNERS