windows programming, directX, and tiles. Oh my!
Sigh........ I took a break from this stuff and forgot all i learned about tiles...
But what my question is today is where to put direct3d code in a windows program. I got the wondows message loop and stuff down, now where do i initialize direct3d? and where do i place the tile code itself (to view the tiles)?
Hehe... You might wanna re-read some of your old books or tutorials if you cant remember to initialize, draw, and erase everything.
lol. I got initializing down. What i guess im really asking is: should I put everything (directx, tile arrays, and windows init.) in the same .cpp file? and if i do, then where do i place it in relevence to each other?
personally I would keep them in seperate files one for initilization one for rendering one for tile specifics etc....also out of curiousity did you get your name from the simpsons episode where homers face is on the box of soap I think it was and at the end they find out it was a mix of symbols of a fish and a light bulb then bart calls him fish bulb?
yeah i guess thats what ill do.. thanks!
and yes, i did get it from simpsons. That is one of the best episodes ever, IMO. Ive had this name for like 3 years now.
"If there truly is a God of Destiny, he must be fond of plot twists." - Ghaleon (Lunar 2)
and yes, i did get it from simpsons. That is one of the best episodes ever, IMO. Ive had this name for like 3 years now.
"If there truly is a God of Destiny, he must be fond of plot twists." - Ghaleon (Lunar 2)
oh yeah... and i also have one more question... whats the best way to reference tiles? As in: now that i have drawn a bunch of tiles, how should i organize them for the program to find them using an ID number? Should i do 1 bitmap with all the tiles just put together, or is putting 1 tile/animation into its own file better?
"If there truly is a God of Destiny, he must be fond of plot twists." - Ghaleon (Lunar 2)
"If there truly is a God of Destiny, he must be fond of plot twists." - Ghaleon (Lunar 2)
I prefer to use the one bitmap (templated image). For this I use a one tile wide, n tiles high bitmap. I use the following code :
#define TILE_W #
#define TILE_H #
#define MAP_W # (how many tiles wide the world is)
#define MAP_H # (same but height)
typedef char map_data[MAP_H][MAP_W];
map_data Map_Name = {
"##########",
"##########";
// Which corresponds to the map height and width
Then render the map data the way you want.
#define TILE_W #
#define TILE_H #
#define MAP_W # (how many tiles wide the world is)
#define MAP_H # (same but height)
typedef char map_data[MAP_H][MAP_W];
map_data Map_Name = {
"##########",
"##########";
// Which corresponds to the map height and width
Then render the map data the way you want.
Oops, forgot the draw tile function to draw a tile.
tiles = LoadBMPFunctionForAPI("bitmapoftiles");
void Draw_TileInAPI(Surface *screen, Surface *tiles, int x, int y, char tile)
{
API_Rect source, dest;
if('' '' == tile) // no tile, dont draw
return;
source.x = 0; // Bitmap only one column thick
source.y = (tile - ''0'') * TILE_H // which tile
source.w = TILE_W;
source.h = TILE_H;
dest.x = x;
dest.y = y;
APIBlitSurface(tiles, &source, screen, &dest);
}
P.S. These are not actual function calls, you must find the function depending on the API you use. And I don''t use DirectX, so I don''t know.
tiles = LoadBMPFunctionForAPI("bitmapoftiles");
void Draw_TileInAPI(Surface *screen, Surface *tiles, int x, int y, char tile)
{
API_Rect source, dest;
if('' '' == tile) // no tile, dont draw
return;
source.x = 0; // Bitmap only one column thick
source.y = (tile - ''0'') * TILE_H // which tile
source.w = TILE_W;
source.h = TILE_H;
dest.x = x;
dest.y = y;
APIBlitSurface(tiles, &source, screen, &dest);
}
P.S. These are not actual function calls, you must find the function depending on the API you use. And I don''t use DirectX, so I don''t know.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement