Beltar
Member
- Joined
- Feb 13, 2007
- Messages
- 214
- Age
- 35
- Location
- Stein (nähe St. Pölten(A))
- ICQ
- 232357654
- LOCATION
- Stein (nähe St. Pölten(A))
Ich habe ein eigenes Programm geschrieben:
Main
#include <stdio>
#include <stdlib>
#include <string>
#include <unistd>
#include <SDL>
#include "GP2xut.h"
/* GP2X button mapping */
enum MAP_KEY
{
VK_UP , // 0
VK_UP_LEFT , // 1
VK_LEFT , // 2
VK_DOWN_LEFT , // 3
VK_DOWN , // 4
VK_DOWN_RIGHT , // 5
VK_RIGHT , // 6
VK_UP_RIGHT , // 7
VK_START , // 8
VK_SELECT , // 9
VK_FL , // 10
VK_FR , // 11
VK_FA , // 12
VK_FB , // 13
VK_FX , // 14
VK_FY , // 15
VK_VOL_UP , // 16
VK_VOL_DOWN , // 17
VK_TAT // 18
};
/* The screen surface, joystick device */
class ID
{
public:
char path[100];
};
class Welt
{
public:
char World [20];
char backr[50];
int Felder [16][12];
void load();
void draw();
ID id[999];
};
SDL_Joystick *joy = NULL;
void Terminate(void)
{
SDL_Quit();
#ifdef GP2X
chdir("/usr/gp2x");
execl("/usr/gp2x/gp2xmenu", "/usr/gp2x/gp2xmenu", NULL);
#endif
}
int main (int argc, char *argv[])
{
int done;
Welt work;
/* Initialize SDL */
if (SDL_Init (SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK) <0> 0) {
joy = SDL_JoystickOpen(0);
if(!joy) {
fprintf (stderr, "Couldn't open joystick 0: %s\n", SDL_GetError ());
}
}
#ifdef GP2X
/* Only use GP2X code here */
#endif
#ifdef WIN32
/* Only use Windows code here */
#endif
/* rectSdl(0, 0, 320, 240, WHITE);
bmpSdl(0,0,0,0,0,0,"test.bmp");
SDL_Flip(screen);*/
sprintf(work.World,"Welt1");
work.load();
printf("test");
work.draw();
done = 0;
while (!done)
{
SDL_Event event;
/* Check for events */
while (SDL_PollEvent (&event))
{
switch (event.type)
{
case SDL_KEYDOWN:
/* if press Ctrl + C, terminate program */
if ( (event.key.keysym.sym == SDLK_c) && (event.key.keysym.mod & (KMOD_LCTRL | KMOD_RCTRL)) )
done = 1;
break;
case SDL_KEYUP:
break;
case SDL_JOYBUTTONDOWN:
/* if press Start button, terminate program */
if ( event.jbutton.button == VK_START )
done = 1;
break;
case SDL_JOYBUTTONUP:
break;
case SDL_QUIT:
done = 1;
break;
default:
break;
}
}
/* Processing */
}
return 0;
}
inline void Welt::load()
{
FILE *fp;
char path[100];
int x;
sprintf(path,".\\Data\\Welten\\%s\\init",World);
fp=fopen ( path, "r");
fscanf(fp, "%s", backr);
printf("%s",backr);
for(x=1;x!=0;x++)
{
fscanf(fp,"%i",&x);
if(x==0) break;
if(x!=999)
{
fscanf(fp,"%s",id[x].path);
printf("\n%d %s",x,id[x].path);
}
else break;
}
for(int y=0;y<12;y++)
{
printf("\n");
for(int z=0;z<16;z++)
{
fscanf(fp,"%d",&Felder[z][y]);
printf("%d",Felder[z][y]);
}
}
fclose(fp);
}
inline void Welt::draw()
{
//char path [50]={0};
int x,y;
//initSdl(1000,600,0);
// bmpSdl(0,0,0,0, 0, 0, backr);
bmpSdl(0,0,0,0, 0, 0, backr);
//strcpy(Welten.path[500],localPerson.curpath);
for(int y=0;y < 12;y++)
{
for(int x=0;x<16> 199 && Felder[x][y] <290> 0 && Welten.Typ [x][y] <500>0)
bmpSdl(0,0,0,0,x*20,y*20,id[Felder[x][y]].path);
/* if( Welten.Typ [x][y] == 500 )
{
bmpSdl(0,0,0,0,x*20+2,y*20+2,Welten.path[Welten.Typ [x][y]]);
} */
}
}
SDL_Flip(screen);
}Main
Es lest aus einer Textdatei heraus wo es die Pfade für die Bitmaps gibt und gibt diese aus.
Wenn ich es auf den GP2x Starte: Schwarze Screen und dann zurück zum Menü
Muss ich irgendwas bei den Pfaden aufpassen oder brauch ich irgendwelche Addons für den GP2x. Unter Windows läuft es
Main
#include <stdio>
#include <stdlib>
#include <string>
#include <unistd>
#include <SDL>
#include "GP2xut.h"
/* GP2X button mapping */
enum MAP_KEY
{
VK_UP , // 0
VK_UP_LEFT , // 1
VK_LEFT , // 2
VK_DOWN_LEFT , // 3
VK_DOWN , // 4
VK_DOWN_RIGHT , // 5
VK_RIGHT , // 6
VK_UP_RIGHT , // 7
VK_START , // 8
VK_SELECT , // 9
VK_FL , // 10
VK_FR , // 11
VK_FA , // 12
VK_FB , // 13
VK_FX , // 14
VK_FY , // 15
VK_VOL_UP , // 16
VK_VOL_DOWN , // 17
VK_TAT // 18
};
/* The screen surface, joystick device */
class ID
{
public:
char path[100];
};
class Welt
{
public:
char World [20];
char backr[50];
int Felder [16][12];
void load();
void draw();
ID id[999];
};
SDL_Joystick *joy = NULL;
void Terminate(void)
{
SDL_Quit();
#ifdef GP2X
chdir("/usr/gp2x");
execl("/usr/gp2x/gp2xmenu", "/usr/gp2x/gp2xmenu", NULL);
#endif
}
int main (int argc, char *argv[])
{
int done;
Welt work;
/* Initialize SDL */
if (SDL_Init (SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK) <0> 0) {
joy = SDL_JoystickOpen(0);
if(!joy) {
fprintf (stderr, "Couldn't open joystick 0: %s\n", SDL_GetError ());
}
}
#ifdef GP2X
/* Only use GP2X code here */
#endif
#ifdef WIN32
/* Only use Windows code here */
#endif
/* rectSdl(0, 0, 320, 240, WHITE);
bmpSdl(0,0,0,0,0,0,"test.bmp");
SDL_Flip(screen);*/
sprintf(work.World,"Welt1");
work.load();
printf("test");
work.draw();
done = 0;
while (!done)
{
SDL_Event event;
/* Check for events */
while (SDL_PollEvent (&event))
{
switch (event.type)
{
case SDL_KEYDOWN:
/* if press Ctrl + C, terminate program */
if ( (event.key.keysym.sym == SDLK_c) && (event.key.keysym.mod & (KMOD_LCTRL | KMOD_RCTRL)) )
done = 1;
break;
case SDL_KEYUP:
break;
case SDL_JOYBUTTONDOWN:
/* if press Start button, terminate program */
if ( event.jbutton.button == VK_START )
done = 1;
break;
case SDL_JOYBUTTONUP:
break;
case SDL_QUIT:
done = 1;
break;
default:
break;
}
}
/* Processing */
}
return 0;
}
inline void Welt::load()
{
FILE *fp;
char path[100];
int x;
sprintf(path,".\\Data\\Welten\\%s\\init",World);
fp=fopen ( path, "r");
fscanf(fp, "%s", backr);
printf("%s",backr);
for(x=1;x!=0;x++)
{
fscanf(fp,"%i",&x);
if(x==0) break;
if(x!=999)
{
fscanf(fp,"%s",id[x].path);
printf("\n%d %s",x,id[x].path);
}
else break;
}
for(int y=0;y<12;y++)
{
printf("\n");
for(int z=0;z<16;z++)
{
fscanf(fp,"%d",&Felder[z][y]);
printf("%d",Felder[z][y]);
}
}
fclose(fp);
}
inline void Welt::draw()
{
//char path [50]={0};
int x,y;
//initSdl(1000,600,0);
// bmpSdl(0,0,0,0, 0, 0, backr);
bmpSdl(0,0,0,0, 0, 0, backr);
//strcpy(Welten.path[500],localPerson.curpath);
for(int y=0;y < 12;y++)
{
for(int x=0;x<16> 199 && Felder[x][y] <290> 0 && Welten.Typ [x][y] <500>0)
bmpSdl(0,0,0,0,x*20,y*20,id[Felder[x][y]].path);
/* if( Welten.Typ [x][y] == 500 )
{
bmpSdl(0,0,0,0,x*20+2,y*20+2,Welten.path[Welten.Typ [x][y]]);
} */
}
}
SDL_Flip(screen);
}Main
Es lest aus einer Textdatei heraus wo es die Pfade für die Bitmaps gibt und gibt diese aus.
Wenn ich es auf den GP2x Starte: Schwarze Screen und dann zurück zum Menü
Muss ich irgendwas bei den Pfaden aufpassen oder brauch ich irgendwelche Addons für den GP2x. Unter Windows läuft es