Sign in to follow this  

Visual Studio 2005

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

Well, hi there. I am new, and I am new to programming (only because I let my skills drop). I have just gotten Visual Studio 2005, and I am trying to get the tetris clone working in it. I originally programmed the game in an Introductory edition of Visual C++ 6.0 - it compiled fine, but I couldn't run it, as the introductory version doesn't allow exe files to be made...which is why I upgraded. Now I've tried opening the 6.0 version in 2005, and it asks me if I want to covert it to 2005 spec, so I do, and it compiles, but when I click on the exe files, it doesn't do anything. If I start the debug process in Visual C++, it returns with "exit code 0 (0x0)" I tried turning off/on the unicode option, but nothing is helping...hell with unicode on it won't even compile! can someone help me out? I really want to know what resources I have to be able to make games using VS-2005...

Share this post


Link to post
Share on other sites
Code that's in the BITMAPOBJECT.H file


// BITMAPOBJECT.H - Crazy Header File for the game TETTRY /////////////////////////////////////////

// DEFINITIONS AND INCLUDES ///////////////////////////////////////////////////////////////////////

#ifndef BITMAPOBJECT_H // If not defined already...
#define BITMAPOBJECT_H // ,,,define it!

#pragma once // and make sure it doesn't do it again once it's been defined.

#include <windows.h> // again, more windows variables, so we need this header file.

// BITMAP CLASSES /////////////////////////////////////////////////////////////////////////////////

class BitMapObject
{
private:
HDC hdcMemory; // bitmap allocation to memory
HBITMAP hbmNewBitmap; // New Bitmap
HBITMAP hbmOldBitmap; // Old Bitmap

int iWidth; // bitmap width
int iHeight; // bitmap height

public:
BitMapObject(); // constructor for handling bitmaps
~BitMapObject(); // desstructor for killing bitmaps...lol.

void Load(HDC hdcCompatible, LPCTSTR lpszFileName); // Load a bitmap from disk file
void Create(HDC hdcCompatible, int width, int height); // create a black bitmap
void Destroy(); // delete current bitmap image

int GetWidth(); // Get bitmap width
int GetHeight(); // Get bitmap height

operator HDC(); // converts to HDC
};

#endif






now the code that's in the BITMAPOBJECT.CPP file


// BITMAPOBJECT.CPP ///////////////////////////////////////////////////////////////////////////////

// DECLARATIONS and INCLUDES //////////////////////////////////////////////////////////////////////

#include "bitmapobject.h" // include our custom made header file using "" instead of <>

// FUNCTIONS //////////////////////////////////////////////////////////////////////////////////////

BitMapObject::BitMapObject() // This is the creation structure for our bitmaps
{
hdcMemory = NULL;
hbmNewBitmap = NULL;
hbmOldBitmap = NULL;

iWidth = 0;
iHeight = 0;
}

BitMapObject::~BitMapObject() // This is the destroy structure for our bitmaps
{
if (hdcMemory)
Destroy();
}

// Now we've made those structures, we can use them to load a bitmap //////////////////////////////
// into the playing field, so lets do that now. ///////////////////////////////////////////////////

void BitMapObject::Load(HDC hdcCompatible, LPCTSTR lpszFileName)
{
if(hdcMemory)
Destroy(); // if the memory isn't NULL/Clear, then do that first

// create memory declaration
hdcMemory = CreateCompatibleDC(hdcCompatible);

// next, load the bitmap...
hbmNewBitmap = (HBITMAP)LoadImage(NULL, lpszFileName, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);

// ...and load it into memory
hbmOldBitmap = (HBITMAP)SelectObject(hdcMemory, hbmNewBitmap);

// get the images properties
BITMAP bmp;
GetObject(hbmNewBitmap, sizeof(BITMAP), (LPVOID)&bmp);

// get the images dimensions
iWidth = bmp.bmWidth;
iHeight = bmp.bmHeight;
}

// lets create the bitmap using the create function

void BitMapObject::Create(HDC hdcCompatible, int width, int height)
{
// if the memory isn't clear, then clear it!
if(hdcMemory)
Destroy();

// create the memory dc
hdcMemory = CreateCompatibleDC(hdcCompatible);

// create the bitmap
hbmNewBitmap = CreateCompatibleBitmap(hdcCompatible, width, height);

// put the bitmap into memory
hbmOldBitmap = (HBITMAP)SelectObject(hdcMemory,hbmNewBitmap);

// change the width and height
iWidth = width;
iHeight = height;
}

// So we managed to load it, but now we have to destroy it, so we'll use our destroy function /////

void BitMapObject::Destroy()
{
// restore the old bitmap
SelectObject(hdcMemory, hbmOldBitmap);

// delete New Bitmap
DeleteObject(hbmNewBitmap);

// delete the device context
DeleteDC(hdcMemory);

// set numbers to NULL/0
hdcMemory = NULL;
hbmOldBitmap = NULL;
hbmNewBitmap = NULL;

iWidth = 0;
iHeight = 0;
}

// OK, the last function to finish this .cpp file off /////////////////////////////////////////////

BitMapObject::operator HDC()
{
// return hdcMemory/
return (hdcMemory);
}

int BitMapObject::GetWidth()
{
// return width
return(iWidth);
}

int BitMapObject::GetHeight()
{
// return height
return(iHeight);
}





and the code thats in the MAIN.CPP file


// TETTRY!!! My Tetris clone //////////////////////////////////////////////////////////////////////

// MAIN.CPP ///////////////////////////////////////////////////////////////////////////////////////

#define WIN32_LEAN_AND_MEAN // discard uneeded header files

// now the "include" files

#include <windows.h> // it's windows, so we need it
#include <stdlib.h> // for the srand and rand functions
#include "bitmapobject.h" // for our bitmap object properties

// Let's give our game, a name! ///////////////////////////////////////////////////////////////////

#define WINDOWCLASS "TETTRY"
#define WINDOWTITLE "TETTRY - A Tetris Clone"

// Now we need to define the playing field, and block dimensions //////////////////////////////////

// Tile Size first. We're using square blocks, so we only need to
// define one size setting for this.

const int TILESIZE = 16;

// Now the map demensions - For where the blocks will fall is here

const int MAPWIDTH = 10;
const int MAPHEIGHT = 30;
const int GREY = 8;

// NOW! We need to define the tile types, so the game works properly
// and doesn't end up turning into crap with no definitions.

const int TILENODRAW = -1;
const int TILEBLACK = 0;
const int TILEGREY = 1;
const int TILEBLUE = 2;
const int TILERED = 3;
const int TILEGREEN = 4;
const int TILEYELLOW = 5;
const int TILEWHITE = 6;
const int TILESTEEL = 7;
const int TILEPURPLE = 8;

// Now for the Game Type Definitions //////////////////////////////////////////////////////////////

bool GameInit(); // Start the Game!!!
void GameLoop(); // Uh, the Game Loop?
void GameDone(); // What...we want to exit???
void DrawTile(int x, int y, int tile); // Drawing tiles yourself sucks.
void DrawMap(); // Draw the whole map, render function really
void NewBlock(); // Spit another one out will ya!
void RotateBlock(); // Let's put a Spin on things!
void Move(int x, int y); // Got to be able to move now.

int CollisionTest(int nx, int ny); // CRASH!!!

void RemoveRow(int row); // If any row is complete, remove it from the field
void NewGame(); // AND Start all over again!

// GLOBALS - for windows stuff ////////////////////////////////////////////////////////////////////

HINSTANCE hInstMain = NULL; // The applcatins handle.
HWND hWndMain = NULL; // The main window handle,,,Interesting huh...

// And if we want to be able to see the playing field, and use it, we need to delare it.

int Map[MAPWIDTH][MAPHEIGHT+1]; // The Game Area, for where the blocks will fall is here.

// Now we'll create a structure - or 'struct' - so we can declare a tile in the game
// whatever that tiles function may be.

struct Piece
{
int size [4][4];
int x;
int y;
};

Piece sPrePiece; // The piece coming after the current one, the preview piece
Piece sPiece; // The "s" stands for "struct" in this case of definition.

// Now timing is everything in the case of computer games, so we need to declare something so
// we don't end up out of sync. So lets make a DWORD timing variable.

DWORD start_time; // used in timing
bool GameStarted = false; // We don't want to start the game yet! This is used by "NewBlock()"

BitMapObject bmoMap; // map for the program
BitMapObject bmoBlocks; // block images




// Now we'll build a simple message handler so we can process the events and draw the window //////

LRESULT CALLBACK TheWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
// What was the message?
switch(uMsg)
{
case WM_KEYDOWN:
{
// check for the pressing of the escape key
if (wParam==VK_ESCAPE)
{
DestroyWindow(hWndMain); // kill the application and revert back to windows
return(0); // handled message
}

// did the player press the down arrow?
else if (wParam==VK_DOWN)
{
Move(0,1); // move down one row each click of the timer
// when the down arrow is depressed
return(0); // handled message
}

// did the player press the up arrow?
else if (wParam==VK_UP)
{
RotateBlock(); // rotate the current block
return(0); // handled message
}

// did the player press the left arrow?
else if (wParam==VK_LEFT)
{
Move(-1,0); // Move the block peice to the left one for every click
// until it reaches the edge of the playing field
return(0); // handled message
}

// did the player press the right arrow?
else if (wParam==VK_RIGHT)
{
Move(1,0); // Move the block peice to the right one unit space for
// every click of the timer until it touches the right
// side of the window
return(0); // handled message
}

}break;

case WM_DESTROY:
{
// let the application know that we are quitting...we've had enough torture - lol.
PostQuitMessage(0);

// phew, we handled that OK, so return 0
return(0);
}

case WM_PAINT:
{
PAINTSTRUCT ps; // structure we use to paint the window

HDC hdc = BeginPaint(hwnd, &ps); // start painting!

// redraw the map
BitBlt(hdc, 0, 0, TILESIZE*MAPWIDTH+TILESIZE*GREY, TILESIZE*MAPHEIGHT, bmoMap, 0, 0, SRCCOPY);

// end painting
EndPaint(hwnd, &ps);

// we handled it, so return NULL/0
return(0);

} break;
}

// pass along any other message to the message handler
return(DefWindowProc(hwnd, uMsg, wParam, lParam));
}

// Now with the variable declarations done, it's onto the good stuff //////////////////////////////

// MAIN ///////////////////////////////////////////////////////////////////////////////////////////

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
// define instance to globale variable
hInstMain = hInstance;

// create window class
WNDCLASSEX wcx;

// set the size of the structure
wcx.cbSize = sizeof(WNDCLASSEX);

// class style
wcx.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;

// windowprocedure
wcx.lpfnWndProc = TheWindowProc;

// class extra?
wcx.cbWndExtra = 0;

// application handle
wcx.hInstance = hInstMain;

// icon
wcx.hIcon = LoadIcon(NULL, IDI_APPLICATION);

// Cursor
wcx.hCursor = LoadCursor(NULL, IDC_ARROW);

// background colour
wcx.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);

// menu?
wcx.lpszMenuName = NULL;

// class name
wcx.lpszClassName = WINDOWCLASS;

// small icon
wcx.hIconSm = NULL;

// register the window class and if not successful, return 0
if(!RegisterClassEx(&wcx)) return(0);

// create the main window
hWndMain=CreateWindowEx(0, WINDOWCLASS, WINDOWTITLE, WS_BORDER | WS_SYSMENU | WS_CAPTION | WS_VISIBLE, 0, 0, 320, 240, NULL, NULL, hInstMain, NULL);

// check to see if window was created
if(!hWndMain) return(0);

//if program initialization failed, return 0 and exit
if(!GameInit()) return(0);

// message structure
MSG msg;

// message pump
for( ; ; )
{
// look for a message
if (PeekMessage(&msg, NULL, 0, 0,PM_REMOVE))
{
// there is a message

// check that we aren't quitting
if(msg.message==WM_QUIT) break;

// translate message
TranslateMessage(&msg);

// dispatch the message
DispatchMessage(&msg);
}

// run game loop
GameLoop();

}

// clean up the data
GameDone();

// return the wparam from the WM_QUIT message
return(msg.wParam);
}

// NOW THE GAME LOOP! /////////////////////////////////////////////////////////////////////////////

bool GameInit()
{
// see the client area
RECT rcTemp;

SetRect(&rcTemp, 0, 0, MAPWIDTH*TILESIZE+TILESIZE*GREY, MAPHEIGHT*TILESIZE); // 160x480 client area

// adjust the window size based on the desired client area
AdjustWindowRect(&rcTemp, WS_BORDER | WS_SYSMENU | WS_CAPTION | WS_VISIBLE, FALSE);

// setup the window width and height
SetWindowPos(hWndMain, NULL, 0, 0, rcTemp.right-rcTemp.left, rcTemp.bottom-rcTemp.top, SWP_NOMOVE);


//create the 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
}

void GameDone()
{
// whatever you want to put here to help
}

void GameLoop()
{
if((GetTickCount() - start_time) > 1000)
{
Move(0,1);
start_time = GetTickCount();
}
}

void NewGame()
{
start_time = GetTickCount();
GameStarted = false;

// start out the map
for (int x = 0; x < MAPWIDTH; x++) // if the maximum width hasn't been reached
{ // then keep adding columns to the width
for (int y = 0; y < MAPHEIGHT; y++) // if the maximum height hasn't been reached
{ // then keep adding rows to the height
if(y==MAPHEIGHT) // if the height equals that specified
Map[x][y] = TILEGREY; // put a grey tile in
else
Map[x][y] = TILEBLACK; // otherwise keep drawing the playing field
}
}

NewBlock(); // add some more new blocks

DrawMap(); // now draw them
}

void DrawTile(int x, int y, int tile)
{
// make the mask first
BitBlt(bmoMap, x*TILESIZE, y*TILESIZE, TILESIZE, TILESIZE, bmoBlocks, tile*TILESIZE, TILESIZE, SRCAND);

// next, the image
BitBlt(bmoMap, x*TILESIZE, y*TILESIZE, TILESIZE, TILESIZE, bmoBlocks, tile*TILESIZE, 0, SRCPAINT);
}

void DrawMap()
{
int xmy, ymx;

// now place the toolbar
for(xmy = MAPWIDTH; xmy < MAPWIDTH+GREY; xmy++)
for (ymx = MAPHEIGHT; ymx < MAPHEIGHT; ymx++)
DrawTile(xmy, ymx, TILEGREY);

// draw the preview block - the one that comes next!
for(xmy = 0; xmy < 4; xmy++)
for (ymx = 0; ymx < 4; ymx++)
if(sPrePiece.size[xmy][ymx] != TILENODRAW)
DrawTile(sPrePiece.x+xmy, sPrePiece.y+ymx, sPrePiece.size[xmy][ymx]);

// draw the map now, loop through the positions
for (xmy = 0; xmy < MAPWIDTH; xmy++)
for (ymx = 0; ymx < MAPHEIGHT; ymx++)
DrawTile(xmy, ymx, Map[xmy][ymx]);

// draw a moving block
for (xmy = 0; xmy < 4; xmy++)
for (ymx = 0; ymx < 4; ymx++)
if (sPiece.size[xmy][ymx] != TILENODRAW)
DrawTile(sPiece.x+xmy, sPiece.y+ymx, sPiece.size[xmy][ymx]);

// now invalidate the window rectangle
InvalidateRect(hWndMain, NULL, NULL);
}

void NewBlock()
{
int newblock;
int i, j;
// 0 1 2 3 4 5 6
// # These
// # ## # ## ## ## ## are
// # ## ### ## ## # # block
// # # # types

// now start the game! make a block for the real play area and also make one in preview

srand(GetTickCount());

// initialize the piece to all blank
for(i = 0; i < 4; i++)
for(j = 0; j < 4; j++)
sPiece.size[i][j] = TILENODRAW;

sPiece.x = MAPWIDTH/2-2;
sPiece.y = -1;

// see if the game has started or not yet
if(GameStarted == false)
{
// if not, generate a piece
GameStarted = true;

// create a random block from our extensive block library
newblock = rand()%7;

// now for the block definition
switch(newblock)
{
case 0: // TOWER!!!
{
sPiece.size[1][0] = TILERED;
sPiece.size[1][1] = TILERED;
sPiece.size[1][2] = TILERED;
sPiece.size[1][3] = TILERED;
sPiece.y = 0;

} break;

case 1: // SQUARE!!!
{
sPiece.size[1][1] = TILEBLUE;
sPiece.size[1][2] = TILEBLUE;
sPiece.size[2][1] = TILEBLUE;
sPiece.size[2][2] = TILEBLUE;

} break;

case 2: // PYRAMID!!!
{
sPiece.size[1][1] = TILESTEEL;
sPiece.size[0][2] = TILESTEEL;
sPiece.size[1][2] = TILESTEEL;
sPiece.size[2][2] = TILESTEEL;

} break;

case 3: // LEFT LEANER!!!
{
sPiece.size[0][1] = TILEYELLOW;
sPiece.size[1][1] = TILEYELLOW;
sPiece.size[1][2] = TILEYELLOW;
sPiece.size[2][2] = TILEYELLOW;

} break;

case 4: // RIGHT LEANER!!!
{
sPiece.size[2][1] = TILEGREEN;
sPiece.size[1][1] = TILEGREEN;
sPiece.size[1][2] = TILEGREEN;
sPiece.size[0][2] = TILEGREEN;

} break;

case 5: // LEFT KNIGHT!!!
{
sPiece.size[1][1] = TILEWHITE;
sPiece.size[2][1] = TILEWHITE;
sPiece.size[2][2] = TILEWHITE;
sPiece.size[2][3] = TILEWHITE;

} break;

case 6: // RIGHT KNIGHT!!!
{
sPiece.size[2][1] = TILEPURPLE;
sPiece.size[1][1] = TILEPURPLE;
sPiece.size[1][2] = TILEPURPLE;
sPiece.size[1][3] = TILEPURPLE;

} break;
}
}
else
{
for(i = 0; i < 4; i++)
for(j = 0; j < 4; j++)
sPrePiece.size[i][j] = sPrePiece.size[i][j];
}

newblock = rand()%7;

for(i = 0; i < 4; i++)
for( j = 0; j < 4; j++)
sPiece.size[i][j] = TILENODRAW;

sPrePiece.x = MAPWIDTH+GREY/4;
sPrePiece.y = GREY/4;

switch(newblock)
{
case 0: // TOWER!!!
{
sPiece.size[1][0] = TILERED;
sPiece.size[1][1] = TILERED;
sPiece.size[1][2] = TILERED;
sPiece.size[1][3] = TILERED;
sPiece.y = 0;

} break;

case 1: // SQUARE!!!
{
sPiece.size[1][1] = TILEBLUE;
sPiece.size[1][2] = TILEBLUE;
sPiece.size[2][1] = TILEBLUE;
sPiece.size[2][2] = TILEBLUE;

} break;

case 2: // PYRAMID!!!
{
sPiece.size[1][1] = TILESTEEL;
sPiece.size[0][2] = TILESTEEL;
sPiece.size[1][2] = TILESTEEL;
sPiece.size[2][2] = TILESTEEL;

} break;

case 3: // LEFT LEANER!!!
{
sPiece.size[0][1] = TILEYELLOW;
sPiece.size[1][1] = TILEYELLOW;
sPiece.size[1][2] = TILEYELLOW;
sPiece.size[2][2] = TILEYELLOW;

} break;

case 4: // RIGHT LEANER!!!
{
sPiece.size[2][1] = TILEGREEN;
sPiece.size[1][1] = TILEGREEN;
sPiece.size[1][2] = TILEGREEN;
sPiece.size[0][2] = TILEGREEN;

} break;

case 5: // LEFT KNIGHT!!!
{
sPiece.size[1][1] = TILEWHITE;
sPiece.size[2][1] = TILEWHITE;
sPiece.size[2][2] = TILEWHITE;
sPiece.size[2][3] = TILEWHITE;

} break;

case 6: // RIGHT KNIGHT!!!
{
sPiece.size[2][1] = TILEPURPLE;
sPiece.size[1][1] = TILEPURPLE;
sPiece.size[1][2] = TILEPURPLE;
sPiece.size[1][3] = TILEPURPLE;

} break;
}

DrawMap();

}

// Now for the rotation code - here we will expand the "RotateBlock" declarion
// that we made earlier. Here we rotate the piece, test for collisions and
// then continue on until the block had landed on the others.

void RotateBlock()
{
int i, j, temp[4][4];

// copy the rotated block into the temp array we just created
for(i = 0; i < 4; i++)
for(j = 0; j < 4; j++)
temp[3-j][i] = sPiece.size[i][j];

// next check to see if the block in the temp array has
// collided with any of the borders
for(i = 0; i < 4; i++)
for(j = 0; j < 4; j++)
if(temp[i][j] != TILENODRAW)
if(sPiece.x + i < 0 || sPiece.x - i > MAPWIDTH - 1 || sPiece.y + j < 0 || sPiece.y - j > MAPHEIGHT - 1)
return;

// check to see if the current block has collided with other blocks too
for(int x = 0; x < MAPWIDTH; x++)
for(int y = 0; y < MAPHEIGHT; y++)
if(x >= sPiece.x && x < sPiece.x + 4)
if(y >= sPiece.y && y < sPiece.y + 4)
if(Map[x][y] != TILEBLACK)
if(temp[x - sPiece.x][y - sPiece.y] != TILENODRAW)
return;

// end collision detection
// successful? Great! Now copy the rotated piece in the temp array to the currently active block
for(i = 0; i < 4; i++)
for(j = 0; j < 4; j++)
sPiece.size[i][j] = temp[i][j];


// now draw the result of the collision detection on the playing area so we can see that it has worked
DrawMap();

// and then return
return;

}

// Now for the move function. Here we test for more collisions - GREAT!!! lol. Also we test to see
// if it is indeed moving and if the current block is touching another block

void Move(int x, int y)
{
if(CollisionTest(x, y))
{
if(y == 1)
{
if(sPiece.y < 1) // if the block ends up starting above the playing field
{
NewGame(); // start a new game because the field is chockers!
}
else
{
bool killblock = false; // otherwise keep going and don't reset

int i, j;

for(i = 0; i < 4; i++) // add a new block to the list
for(j = 0; j < 4; j++)
if(sPiece.size[i][j] != TILENODRAW)
Map[sPiece.x + i][sPiece.y + j] = sPiece.size[i][j];

// next, check for a cleared row
for(j = 0; j < MAPHEIGHT; j++)
{
bool filled = true; // if the row is full
for(i = 0; i < MAPWIDTH; i++)
if(Map[i][j] == TILEBLACK) // then clear the row
filled = false; // and draw black tiles

if(filled)
{
RemoveRow(j); // but also remove the row of blocks
killblock = true; // and delte those blocks from the game
}

}

// if killblock = true then don't draw anything and process this
if(killblock)
{
for(i = 0; i < 4; i++)
for(j = 0; j < 4; j++)
sPiece.size[i][j] = TILENODRAW;
}

NewBlock(); // give the player a new block
}
}
}
else
{
sPiece.x += x;
sPiece.y += y;
}

DrawMap();

}

// Now the CollisionTest() algorithm

int CollisionTest(int nx, int ny)
{
int newx = sPiece.x + nx;
int newy = sPiece.y + ny;

int i, j, x, y;

for(i=0; i< 4; i++)
for(j=0; j< 4; j++)
if(sPiece.size[ i ][j] != TILENODRAW)
if(newx + i < 0 || newx + i > MAPWIDTH - 1 || newy + j < 0 || newy + j > MAPHEIGHT - 1)
return 1;


for(x = 0; x < MAPWIDTH; x++)
for(y = 0; y < MAPHEIGHT; y++)
if(x >= newx && x < newx + 4)
if(y >= newy && y < newy + 4)
if(Map[x][y] != TILEBLACK)
if(sPiece.size[x - newx][y - newy] != TILENODRAW)

return 1;

return 0;

}

// And finally the RemoveBlock() function

void RemoveRow(int row)
{
int x, y;

int counter = 0;

for(x = 0; x < MAPWIDTH; x++)
for(y = row; y > 0; y--)
Map[x][y] = Map[x][y-1];
}





hope that wasn't too much.

EDIT: Changed your post to use Source tags rather than Code. You can read about them in the faq. -jba

EDIT 2: Changing tags from code to source tends to leave escape codes for angle brackets inside the source boxes. This can be fixed by simply re-editing the post and not making any changes. -Zahlman

[Edited by - Zahlman on June 10, 2009 3:53:53 PM]

Share this post


Link to post
Share on other sites
OK, try debugging again, but this time step through your code to see what's going on. You can do this by pressing F10 and F11 depending on whether you want to step into a function or step over a function. Keep an eye on the 'locals' window while in WinMain. Learning to use the debugger is essential for any serious developer.

In any case I think I can help you narrow the problem down. You have 4 return statements in WinMain. Because your code is exiting 'normally' (in the window you were looking at "exit code 'x'" is whatever you returned from WinMain with, in this case you used '0' for everything) we know that one of those 4 returns is the problem. The first 3 occur at initialization only so start with those. Either RegisterClassEx failed, CreateWindowEx, or GameInit failed. GameInit always returns true so that's probably not the problem.

Share this post


Link to post
Share on other sites
In your code, RegisterClassEx() returns 0 because you do not set the cbClsExtra member of the WNDCLASSEX structure, and thus it contains garbage.
I suggest using a declaration like this to automatically zero out the entire structure, and then initialize only the fields you need:



WNDCLASSEX wcx = {0};



Share this post


Link to post
Share on other sites
OK. so I tried that last tip out, and cancelled the WNDCLASSEX structure by making it zero, but now when I play it the blocks are there, but then they dissapear by themselves...maybe my dimensions are wrong or something.

I am trying to scout through the code to see where these four initialization parameters are...I'll get back to you.

Share this post


Link to post
Share on other sites

This topic is 3109 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this