• ### Announcements

#### Archived

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

## Recommended Posts

LessThanJoe    122
Ok, I have tried reading windows game programming for dummies, and it seemed to give me one way to do something, then another, then go back to the first, and in the end I was lost. I have tried reading the tutorials here, but they don''t give me any idea what is going on. Could anyone here show me how I would go about outputting a 2darray onto the screen, using a different .bmp for each value in the 2d array? I''m not quite sure how much I''m asking, but I am sure I would appreciate it a lot. Another thing that I am sure of is that once I see the code I would at least be able to understand it. What would be great would be a function that all you had to do was pass in the x and y to the top left of the image + the filename. You could run this function as many times as you want before you call another function that sends this all to the screen at once. In fact, if someone is kind enough to do the thing from my second paragraph, I believe I will make a class to do this. Thanks.

##### Share on other sites
Tok    262
Hey there... I think I might just make your day.
My own little "project" for the last few months has been a sidescroller- and I just happen to a) use (multiple) bmp files for all my graphics (with colorkey transparency), b) use a (dynamically allocated) array for map information, c) have written a function that takes a "tile value", map coordinates, and a few other variables to draw the tile onto the screen, AND d)Notate the HELL out of my work.

You can grab the entire project: MSVC++ project files, source code, graphics, and data here.

Comments and questions are both very welcome- bug me on icq or email me.

---email--- Tok ----surf----
~The Feature Creep of the Family~

##### Share on other sites
LessThanJoe    122
Thank you, i'll take a look at it. You wouldn;t care if I make a few mods to it so I can get it to work for pacman, would you?

EDIT:
Woah, any chance I could get you to explain how I might use that for pacman.

Either that or I'll have to have someone respond with a simpler explination...While that is some of the best commenting of code I have ever seen, I've also never even glanced at direct3d, and that is a bit complex for me as of now.

some psudocode of what i'm looking for
  bool Output(){ int counter = 0; int temp = 0; int origX = 1; // starting positions for where int origY = 1; // to draw to //directdraw stuff, such as locking // put board onto backbuffer for (counter = 0; counter < BOARDHEIGHT; counter++) { for (temp = 0; temp < BOARDWIDTH; temp++) { origX += TILEWIDTH; // code to output a tile here } origY += TILEHEIGHT; } // put dots onto backbuffer for (counter = 0; counter < NUMDOTS; counter++) { //more directx stuff } // a little bit more code to put pacman on screen //flip backbuffer and primary surface // close directx stuff return true;}

Edited by - lessthanjoe on January 31, 2002 9:01:41 PM

##### Share on other sites
LonelyTower    122
quote:
Original post by LessThanJoe

Could anyone here show me how I would go about outputting a 2darray onto the screen, using a different .bmp for each value in the 2d array? I''m not quite sure how much I''m asking, but I am sure I would appreciate it a lot. Another thing that I am sure of is that once I see the code I would at least be able to understand it.

Store all the individual BMP into a linear (1x1) array. In your 2D array, you will put in the index of the BMP that you want to show.

For example, let say I have 2 bitmaps, one of that of a bush, the other of that of a dirt path. I stick them into the array

BitMapArray[0]= "Bush BMP"
BitMapArray[1]= "Dirt Path BMP"

Let say I want to have at the picture of a bush at the top lefthand corner of the screen. Hence, it will look like

Map[0][0]=0

Hence, in your 2D array, you only store the number that represent the bitmap.

Another way of putting is that - each bitmap is represented by a number. You plug the number into the 2D array. On the for-next loop you check the number and decide which bitmap to dump out.

Hope I have helped.