Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

fishbulb52

windows programming, directX, and tiles. Oh my!

This topic is 5808 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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)?

Share this post


Link to post
Share on other sites
Advertisement
Hehe... You might wanna re-read some of your old books or tutorials if you cant remember to initialize, draw, and erase everything.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!