Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Win32 Tetris Problem

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: [code]//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"[/code]

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...

Comments

  • BitByBit_ThorBitByBit_Thor Posts: 2,444Member
    : 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: [code]: //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"[/code]:
    :
    : 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...
  • audioslavedaudioslaved Posts: 3Member
    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 ge=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!
  • MT2002MT2002 Posts: 1,444Member
    : 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 ge=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 [color=Red]red[/color]):
    [code]

    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);

    [color=Red][b] bmoBlocks.Load(NULL,"blocks.bmp");[/b][/color]
    NewGame();

    return(true);//return success
    }
    [/code]
    It will load whatever filename you give it and treat it as the tileset.

    [hr][size=1][leftbr].:EvolutionEngine[rightbr][leftbr].:MicroOS Operating System[rightbr][leftbr][link=http://www.mt2002.sitesled.com]Website[rightbr][/link][/size]
  • audioslavedaudioslaved Posts: 3Member
    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!!!
Sign In or Register to comment.