Jump to content
  • Advertisement
Sign in to follow this  
ShadyFocker

Confused Programmer

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

First I'd like to say hello. Here's my story, I have an extensive background in C/C++, as well as algorithm design. I have been working in programming for many years, but the heart of my passion for programming has always been that one day I would program games (just like many I'm sure). As of now I've finally found the time to sit down and begin this process, and am very excited. Now to the problem... I've reviewed some of DirectX through various tutorials and books, but have yet to find anything that really gets to the point. Many seem to show you how to draw a box and work with user input, but none seem to explain to you the meat of it. For example, its great that I can make a box and have it move down the screen, but how do I make another one =)? Also, how can you keep a scene's integrity and add a new box with it? These are horrible examples I'm sure, let me try it this way. If you had a tetris type game (since that seems to be the common example here...) I know how to make a box, I know how to make it flow down the screen, but how do I make it stay there for the next box. Which also leads into collision detection as well. Ok enough of my babbling, basically I was wondering if anyone knew of a good place to start for someone who is a veteran programmer and algorithm designer and needs a decent book/tutorial to get started (I've been through all of DrunkenHyena). Apologizes for the long post…

Share this post


Link to post
Share on other sites
Advertisement
Tutorials are the devil.

Spend some time thinking about the structure of your game. Break it down into discrete steps, and then break those into steps as well until you virtually have source code. Rocket science, it isn't.

It's not that hard putting a simple game together, particularly for someone with experience programming and authoring algorithms.

Share this post


Link to post
Share on other sites
seems to me not like a problem of directx-api but of programm design. example: create an array of f.e. 1000 entries (maybe structs and save the pointers in the array) if the arrayentry is NULL no box is to be drawn. loop through the array, take the struct and paint the box in your "scene" and thats it...

or didnt i got the point in your post???

Share this post


Link to post
Share on other sites
I read my post over and didn't understand it =) sorry about that.

Basically lets say you have a tetris game. Now you have your first block flow down the screen, gets to a point and stops. You save that coordinate onto some master grid, now the part I dont get is according to the tutorials you need to redraw the scene/screen to have another block fall. Well by doing that you eliminate the block that just fell.

I've tried several algorithm's and have gotten it to hold block position, but only be redrawing them again in that final position through another array. Which can get massive as this iterates. Also, if these were not square blocks and had different dimmensions my algorithm would not work I think.

Hope thats a little more clear.

Share this post


Link to post
Share on other sites
there are many ways of doing this in theory.
but if you're talking about redrawing stuff...
i would do this...
make a function that draws the static blocks at the bottom.
then make a function that draws and updates the falling block.
keep in mind...
one single object can be drawn multiple times.
so you only have to create one block object in order to
draw a whole screen of blocks.
so basically you create an array of booleans.
one boolean for each tile.
if the boolean is true, draw a block there, if false,
don't draw a block.
so the function loops through all the booleans and
draws blocks accordingly.
then you have a separate function that draws and updates the
falling block.
you must keep track of this blocks position.
when the boolean below it's current position in the
pre-mentioned array is true, then it landed on another block.
so you make that element of the array true.
then that block would be rendered each time as a static block.
then you make a NEW falling block.
then it's a matter of setting up if statements
to test if the block hit the top, or is trying to move right
when there's a block in the way, etc.
fairly simple stuff.

Share this post


Link to post
Share on other sites
you could just have an array (or some other container) of objects representing all of the shapes that are on the screen, and have each object keep track of its translation and rotation (since you can spin blocks in tetris-like games). Then each frame, for each object, you just translate and rotate by the saved amounts, and then draw the shape. You could make each object contain the code to draw itself pretty easily, so then your render function wouldn't be much more than a loop calling that draw method for each object. You're generally supposed to redraw the entire (visible) scene each frame, not just the parts that change - only redrawing sections can improve framerate etc, but it can be a major hassle and isn't something you should even consider for something so simple as a tetris game.

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!