C++ Game Development

Moderators: Lundin
Number of threads: 236
Number of posts: 517

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Win32 Tetris Problem Posted by audioslaved on 3 Jun 2007 at 7:46 AM
I decided to make a Tetris Clone for my school project, and found this link on the forum

http://triplebuffer.devmaster.net/file.php?id=3&page=0

in the main file it says:
//FALLING BLOCK GAME!
//main.cpp
//tell compiler to not include the evil MFC overhead.
#define WIN32_LEAN_AND_MEAN

//need this for windows stuff.
#include 

//need this for srand and rand
#include 

//now let's include our bitmapobject definitions
#include "bitmapobject.h"


Someone left out the include part on purpose. Which 2 libraries do you think need to be included? Please check out the rest of the code...
Report
Re: Win32 Tetris Problem Posted by BitByBit_Thor on 3 Jun 2007 at 1:48 PM
: I decided to make a Tetris Clone for my school project, and found
: this link on the forum
:
: http://triplebuffer.devmaster.net/file.php?id=3&page=0
:
: in the main file it says:
: //FALLING BLOCK GAME!
: //main.cpp
: //tell compiler to not include the evil MFC overhead.
: #define WIN32_LEAN_AND_MEAN
: 
: //need this for windows stuff.
: #include 
: 
: //need this for srand and rand
: #include 
: 
: //now let's include our bitmapobject definitions
: #include "bitmapobject.h"
:
:
: Someone left out the include part on purpose. Which 2 libraries do
: you think need to be included? Please check out the rest of the
: code...
:

Fairly easy to guess:
windows.h for sure on the first one.
With the newest version of Visual C++, rand and srand are declared in stdlib.h

I'm doubting if it was so for the older versions...
Report
Re: Win32 Tetris Problem Posted by audioslaved on 4 Jun 2007 at 2:30 PM
I am really new to programming, and would really appreciate if someone would take a look at the entire tutorial at
http://triplebuffer.devmaster.net/file.php?id=3&pa%20ge=0

And explain the last part of page 4 to me. It says:

"And that's it! You've got the code, now you just need the graphics. To make the graphics, create a new bitmap of a size TILESIZE*9 width, and TILESIZE*2 height. Now, divide this into 16x16 squares, or whatever TILESIZE you have, and you'll have two rows of 9 columns. Make the bottom row totally black (0 r,0 g,0 b). Make each column of the top row a different color. In order, make the columns Black, Grey, Blue, Red, Green, Yellow, White, Steel, and Purple. Black and Grey should be totally 1 color, with maybe a little shading for a better look."

I do not know how create a bitmap, and also I do not where to implement it.
I know I sound really stupid but i just got into this (i have basic level C knowledge), but I want to make this Tetris thing work.
Please Help!
Report
Re: Win32 Tetris Problem Posted by MT2002 on 5 Jun 2007 at 7:04 PM
: I am really new to programming, and would really appreciate if
: someone would take a look at the entire tutorial at
: http://triplebuffer.devmaster.net/file.php?id=3&pa%20ge=0
:
: And explain the last part of page 4 to me. It says:
:
: "And that's it! You've got the code, now you just need the graphics.
: To make the graphics, create a new bitmap of a size TILESIZE*9
: width, and TILESIZE*2 height. Now, divide this into 16x16 squares,
: or whatever TILESIZE you have, and you'll have two rows of 9
: columns. Make the bottom row totally black (0 r,0 g,0 b). Make each
: column of the top row a different color. In order, make the columns
: Black, Grey, Blue, Red, Green, Yellow, White, Steel, and Purple.
: Black and Grey should be totally 1 color, with maybe a little
: shading for a better look."
:
: I do not know how create a bitmap, and also I do not where to
: implement it.
: I know I sound really stupid but i just got into this (i have basic
: level C knowledge), but I want to make this Tetris thing work.
: Please Help!
:

lol--I seen that tutorials first post on gamedev.net!

Anywho...

To create a bitmap, just open up paint and draw the tiles in it.
Then save it as a 24bit bitmap file.

His tutorial has a bitmap you can use. In the 4th tutorial,
on the bottom of the page (displayed "Example bitmap"). Just
copy that and save the bitmap.

Following his tutorial, GameInit() loads the file (Displyed in red):

bool GameInit()
{
    //set the client area size
    RECT rcTemp;
    
    //160x480 client area
    SetRect(&rcTemp,
            0,0,
            MAPWIDTH*TILESIZE+TILESIZE*GREY,
            MAPHEIGHT*TILESIZE);
            
    //adjust the window size based on desired client area
    AdjustWindowRect(
	&rcTemp,
 	WS_BORDER | WS_SYSMENU | WS_CAPTION| WS_VISIBLE,FALSE);
    
    //set the window width and height
    SetWindowPos(hWndMain,
                 NULL,
                 0,0,
                 rcTemp.right-rcTemp.left,
                 rcTemp.bottom-rcTemp.top,
                 SWP_NOMOVE);

    //create map image
    HDC hdc=GetDC(hWndMain);
    bmoMap.Create(hdc,MAPWIDTH*TILESIZE+TILESIZE*GREY,MAPHEIGHT*TILESIZE);
    FillRect(bmoMap,&rcTemp,(HBRUSH)GetStockObject(BLACK_BRUSH));
    ReleaseDC(hWndMain,hdc);

    bmoBlocks.Load(NULL,"blocks.bmp");
    NewGame();

    return(true);//return success
}

It will load whatever filename you give it and treat it as the tileset.


[.:EvolutionEngine][.:MicroOS Operating System][Website]
Report
Re: Win32 Tetris Problem Posted by audioslaved on 6 Jun 2007 at 10:46 AM
Thank you, thank you thank you all sooo much!!!

You have made this a lot easier for me. Now I will study the code, and learn to do this myself. I promise!!!



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.