trying to make a rpg engine..need help.

thanks everyone. it works.

[This message has been edited by method5 (edited 03-24-2002).]

please note: the first few structures are for the collision detection which i have not converted yet… and if you want more info on the hosting… goto method5.com and check plan2…

and if you want the .cpp file contact me on icq @ 21159213, aim contact: kdghsu or email jason@method5.com

copy of the test map file it loads:

20,20
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1

[This message has been edited by method5 (edited 03-24-2002).]

And exactly what error do you get when you run it? I’m guessing that information would be more valuable than your code.

Please see http://www.method5.com/opengl/screenshot.gif for a screenshot…

and I found out it has to do with the actual drawing of the map… cause when i comment that part out it runs without errors.

Try compiling and running the program in debug mode. You will get more information about the error.

okay thanks guys… I figured out what was causing the error… it was calling the draw routine before i set up my camera…

but now… it runs… but doesnt display the map… only a white box in the corner… ?

you can try it if you wish… ive updated the above code…

In load_gl_textures(), replace glGenTextures(251, &tiles[251]); with glGenTextures(251,tiles);.

still nothing…

From your drawing function:

for(i = 0; i<numberofobjects; i++) {
    if (objects[i].objecttype == 1) {
    ...
    }
}

You only initialize objecttype for object[0]. All other objects won’t make the if statement so they won’t draw. You also use the .x and .y members, which are again not initialized for anything besides object[0]. That explains why you only get a single box drawn.

Oops! Disregard my last post

You need to add glEnable(GL_TEXTURE_2D); to your init code for your textures to show.

Originally posted by zeckensack:
[b]From your drawing function:[quote]

for(i = 0; i<numberofobjects; i++) {
    if (objects[i].objecttype == 1) {
    ...
    }
}

You only initialize objecttype for object[0]. All other objects won’t make the if statement so they won’t draw. You also use the .x and .y members, which are again not initialized for anything besides object[0]. That explains why you only get a single box drawn.[/b][/QUOTE]

Nope… cause object 0 is the character… and the rest are not needed right now since i havent converted the npc coding… it has nothing to do with the map/camera anyway,

....
glutDisplayFunc(drawscreen);
glutKeyboardFunc(inputevent);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glutMainLoop();
load_gl_textures();

do {
    FocusCamera(0); // MAIN LOOP
} while (1 != 0);
return 0;

This is very very wrong. By calling glutMainLoop(), you’re giving control to glut, everything after that call won’t get executed.

Change it to this:

....
glutDisplayFunc(drawscreen);
glutKeyboardFunc(inputevent);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
load_gl_textures();
FocusCamera(0);
glutMainLoop();
return 0;

Originally posted by zeckensack:
[b]Oops! Disregard my last post

You need to add glEnable(GL_TEXTURE_2D); to your init code for your textures to show.[/b]

Where exactually should I put it… tried it in a few spots and none of them worked…

Originally posted by method5:
Where exactually should I put it… tried it in a few spots and none of them worked…

Into your main function, but put it before glutMainLoop();. Just like I said in my last post .

ok now I get an error… it has to do with the load_gl_textures(); cause if i comment out it works. (well loads with no windows error box)

i think it has to do with my poorly coded thing to get filename…

itoa(t,tem,10);
temp = strcat(strcat(“tile”, tem), “.bmp”);
tilesimage[t] = loadbmp(temp);

heh… please help. im trying to get it like
tile#.bmp but not good with strings

You are improperly using strcat. Read about it.

Originally posted by method5:
itoa(t,tem,10);
temp = strcat(strcat(“tile”, tem), “.bmp”);
tilesimage[t] = loadbmp(temp);

heh… please help. im trying to get it like
tile#.bmp but not good with strings

Yeah, this shouldn’t even compile I think.

First of all, don’t declare temp as a plain char*, this won’t reserve any memory for the string, instead do this:
char temp[64];

Then try this:

sprintf(temp,"tile%u.bmp",t);
tilesimage[t] = loadbmp(temp);

This will get you tile0.bmp , tile1.bmp ,tile 20.bmp …
If you want names like tile00.bmp, use “tile%02u.bmp” in sprintf
If you want names like tile000.bmp, use “tile%03u.bmp”

Oh, and you can scrap the ‘tem’ variable altogether.

ok thank you… it kinda shows a map now…

but the tiles it shows… are not correct… like it is only showing them in one color…

any idea why it would do this?? just show them in one solid color…