Jump to content
  • Advertisement
Sign in to follow this  
chadsxe

This might be a very broad question but when using an API what would be the....

This topic is 4257 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

I have made some very basic ascii maze games in the console before. I used an array to draw the maze, and checked each index of the array to determine if I have ran into a wall. I am now trying to learn how to do something like this in DirectX. My question to you would be this... 1) I am assuming that I would use one sprite to lay down the maze in the window, correct? 2) Because I am using one sprite as the maze I have no clue how i would determine if I am running into walls. Care to shead some light... Any fingers to point me in the correct direction would be greatly appreciated. Regards Chad

Share this post


Link to post
Share on other sites
Advertisement
Rather than using one sprite, why not use many, for all the walls, corners, edges, etc, in a grid? You can represent each square with a data structure which contains wall information as well as an associated sprite, and you can design many different dungeons from the same basic building blocks.

Share this post


Link to post
Share on other sites
You can make the maze using one image, but draw it as though it were split into many different tiles. That way you can use the array method and have each array value be an index to a tile. Look at the D3DXSprite interface.

Share this post


Link to post
Share on other sites
So essentialy I would draw a image in a photo editor, chope that image into a grid, and load them from an array?

Share this post


Link to post
Share on other sites
Quote:
Original post by chadsxe
So essentialy I would draw a image in a photo editor, chope that image into a grid, and load them from an array?


Try making it just like you made the ASCII maze game, except that instead of using text, use sprites.

Share this post


Link to post
Share on other sites
You only "chop" the image as a concept, you still only have the one image loaded into memory. The D3DXSprite interface draw commands takes a rectangle as a parameter which specifies which pixels you want to draw.

So say you had a 128x32 sized image and you want 32x32 tiles, create 4 rectangles to match them. Then have an array of integers which are indices into that rectangle array.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!