Jump to content
  • Advertisement
Sign in to follow this  
walnut100

Anyone care to help a novice programmer?

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

Ok, a little bit of background here. I'm using DirectX9 with the Feb 2007 SDK and C++. My IDE is MSVC8. With some help from DrunkenHyena's tutorials (Which are great by the way!) I've successfully made an application that can use textured quads. My ultimate goal is to create a 2D platformer akin to Mario. I've decided to use a tile based system for graphics. My questions are... 1. How do I handle resolution changes with a tiled background? I don't want to draw anything off the screen I don't need to... 2. I read something on the forums while I was searching yesterday about storing maps for this type of game in a 2D array or something like that? Can anyone elaborate on what that means exactly? 3. Is there a better way to draw textures to quads for 2D than containers in the vertex buffer? It seems like a pain having to set all those coordinates everytime you want to draw something, especially with map design. 4. Does anyone have any examples of a 2D sidescrolling platformer written in Direct3D and C++? Or maybe some tutorials that could point me in the right direction? Thank you very much.

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by walnut100
Ok, a little bit of background here. I'm using DirectX9 with the Feb 2007 SDK and C++. My IDE is MSVC8. With some help from DrunkenHyena's tutorials (Which are great by the way!) I've successfully made an application that can use textured quads. My ultimate goal is to create a 2D platformer akin to Mario. I've decided to use a tile based system for graphics.

My questions are...
1. How do I handle resolution changes with a tiled background? I don't want to draw anything off the screen I don't need to...
2. I read something on the forums while I was searching yesterday about storing maps for this type of game in a 2D array or something like that? Can anyone elaborate on what that means exactly?
3. Is there a better way to draw textures to quads for 2D than containers in the vertex buffer? It seems like a pain having to set all those coordinates everytime you want to draw something, especially with map design.
4. Does anyone have any examples of a 2D sidescrolling platformer written in Direct3D and C++? Or maybe some tutorials that could point me in the right direction?

Thank you very much.


I'm going to suggest a path for you, whether you take it is up to you. A lot of people have said that it doesn't work, but it really helps me.

If I were in your shoes, I'd do the following:
1) Make a list of every detail of Mario. For example, I'd include a list of all of the entity types (Goomba, Mario, Bullet Bill, etc), all of the block types (including coin bricks, multi-coin bricks, ice bricks, etc), all of the power-ups (star and flower power for Super Mario Bros. 1), etc.
2) Play through at least 5 levels of the game and update the list, adding what you missed.
3) Repeat step 2 once more.
4) Make a small design document; do the reverse of steps 1-3. List out everything you want in your game. Read through it and then add anything you missed, change/remove anything you don't like, etc.
5) Make a small, non-scrolling platformer. Nothing special, just you, a couple baddies, and a goal (kill all the baddies and get to the exit or something.)
6) Upgrade 1 - Add scoring and lives.
7) Upgrade 2 - Add pick-ups and power-ups.
8) Upgrade 3 - Add scrolling.
9) Upgrade 4 - Add extras. Bonus characters, secret areas, etc.
10) Add polish.
11) Repeat 8 until satisfactory.

Doing steps 1-3 will hopefully give you an idea of what you're getting into, it certainly helps me.

At some point you need to try to figure out how things work, usually step 1 or step 4. For example, how ice bricks make you slide, springs launch you, warp tubes work, etc.

Anyway, to answer your questions:

1) I'm not understanding what you're asking here. Are you asking how to handle different resolutions or resolution changes?

2) You can store map data in any form; I prefer regular arrays, but 2D arrays work as well. For example, a simple map system might look like so:

class Tile
{
public:
int TileNumber;
bool Passable;
};

class Map
{
public:
Tile *Data;
int ColumnCount, RowCount;

Map()
{
ColumnCount = 5;
RowCount = 5;
Data = new Tile[RowCount * ColumnCount];
}

void Render()
{
for(int Row = 0; Row < RowCount; ++Row)
{
for(int Column = 0; Column < ColumnCount; ++Column)
{
// render tile here
// To figure out what tile to use, we multiply the current row by the number of columns and then add the current color:
// TileIndex = (Row * ColumnCount) + Column
// So, the tile data to use is stored in Data[TileIndex]
}
}
}
};



3) I'm not really sure what you're asking here. Are you asking for a better way to store vertices than in a vertex buffer?

4) jnrdev.72dpiarmy.com will help. It's made with SDL rather than DirectX, but it's got all the info you need to get started.

HTH and good luck!

Share this post


Link to post
Share on other sites
Quote:
Original post by walnut100

3. Is there a better way to draw textures to quads for 2D than containers in the vertex buffer? It seems like a pain having to set all those coordinates everytime you want to draw something, especially with map design.



Hey, you could use the sprite interface provided in DirectX Graphics. These are very easy to manipulate in both 2D and 3D and allow an image to be set as its texture.

Share this post


Link to post
Share on other sites
Quote:
Original post by walnut100
1. How do I handle resolution changes with a tiled background? I don't want to draw anything off the screen I don't need to...


The way I did it was to have all the code work as if the game was running at 1024x768, but then have scaling factor that I would multiply all co-ordinates by prior to rendering each quad. For example, for 800 across, the factor was 800/1024=0.78.

Quote:
Original post by walnut100
2. I read something on the forums while I was searching yesterday about storing maps for this type of game in a 2D array or something like that? Can anyone elaborate on what that means exactly?


Dealt with well by Programmer16.

Quote:
Original post by walnut100
3. Is there a better way to draw textures to quads for 2D than containers in the vertex buffer? It seems like a pain having to set all those coordinates everytime you want to draw something, especially with map design.


While deviantDarren makes a good suggestion, if you want the added flexibility of using vertex buffers directly, you can wrap the operations up nicely in a class so that you only mess about with verticies in one place, and the rest of the code just does stuff like:

Buffer.Add(10,20,32,32,Texture);

Quote:
Original post by walnut100
4. Does anyone have any examples of a 2D sidescrolling platformer written in Direct3D and C++? Or maybe some tutorials that could point me in the right direction?


My half-finished 2D Mario-style scroller demo is here. Send me a PM if you want to look at the source code.

Share this post


Link to post
Share on other sites
Hi guys,

EasilyConfused:
http://img530.imageshack.us/img530/857/25070997cv3.jpg


I'm stuck at that point.

Share this post


Link to post
Share on other sites
Quote:
Original post by Dolf
EasilyConfused:
http://img530.imageshack.us/img530/857/25070997cv3.jpg

I'm stuck at that point.


That's the end of the demo level. There's no way to exit the level at the moment.

I did say it was a half-finished demo [smile].

Share this post


Link to post
Share on other sites
I would like to look at your source code for your "half-finished" mario clone. I really just need to get a good perspective on how everything comes together.
Thanks.
-durfy

Share this post


Link to post
Share on other sites
Tell you what - I'll put the VS project and all the necessary files up on my GameDev webspace tonight in a zip then edit this post with a link. I guess you can then PM me if you've got any questions, but I can't make any promises about how fast I'll reply [smile].

Not sure how much use this will be, but here you go.

It's not particularly well engineered code and I doubt it will be particularly easy to follow, but I'm all done with this project now so feel free to take whatever you want from it.

As above, please PM me with any specific questions rather than swamping this thread.

HTH

[Edited by - EasilyConfused on July 27, 2007 12:04:13 PM]

Share this post


Link to post
Share on other sites
Hey guys! Thanks for your replies.

Quote:
I'm going to suggest a path for you, whether you take it is up to you. A lot of people have said that it doesn't work, but it really helps me.


Well... I've been following that path already really. My ultimate goal is to recreate a game I made when I was 13 in GameMaker with DX9, just to learn the API. I've found the best way to learn for me is to go off the deepend, keep trying things until it works how I want, building up in small increments and figuring out how the smaller parts work into the bigger picture.

Quote:
2) You can store map data in any form; I prefer regular arrays, but 2D arrays work as well. For example, a simple map system might look like so:


Ahh! Thanks for that, it helps a lot.

Quote:
4) jnrdev.72dpiarmy.com will help. It's made with SDL rather than DirectX, but it's got all the info you need to get started.


I'll look into these and see how they work for me.

Quote:
Hey, you could use the sprite interface provided in DirectX Graphics. These are very easy to manipulate in both 2D and 3D and allow an image to be set as its texture.


Yeah, I read up on the subject before I started this project of mine. Some of the articles on this site said that the sprite interface is buggy and causes sprites to distort, and besides that, I thought it'd be fun to try to write it without the interface, maybe even add some 3D effects to the game if I ever got the 2D down well.

Quote:
The way I did it was to have all the code work as if the game was running at 1024x768, but then have scaling factor that I would multiply all co-ordinates by prior to rendering each quad. For example, for 800 across, the factor was 800/1024=0.78.


That's a fantastic idea. I can't believe I didn't think of something like that...

Quote:
While deviantDarren makes a good suggestion, if you want the added flexibility of using vertex buffers directly, you can wrap the operations up nicely in a class so that you only mess about with verticies in one place, and the rest of the code just does stuff like:

Buffer.Add(10,20,32,32,Texture);


Hmm... I never thought about wrapping up everything in a class. I was trying to use variables to lessen the amount of work I had to do, but this beats the heck out of what I was doing.

Thanks for the help everyone! I think I can get myself off the ground from here. You all have been very helpful.

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.

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

Sign me up!