X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/70d26c3f4ffb24d50457d405c9595fd23f9e5b7c..a9b4774c0502f29e0f8eb6757a944420d02d5274:/demos/bombs/game.cpp diff --git a/demos/bombs/game.cpp b/demos/bombs/game.cpp index d49b6a434d..ae07b7dac0 100644 --- a/demos/bombs/game.cpp +++ b/demos/bombs/game.cpp @@ -2,22 +2,22 @@ // Name: bombs1.cpp // Purpose: Implementation of the class BombsGame // Author: P. Foggia 1996 -// Modified by: +// Modified by: Wlodzimierz Skiba (ABX) since 2003 // Created: 1996 // RCS-ID: $Id$ // Copyright: (c) 1996 P. Foggia // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// -#ifdef __GNUG__ -#pragma implementation -#endif - #include "wx/wxprec.h" +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + #ifndef WX_PRECOMP - #include "wx/wx.h" -#endif //precompiled headers +# include "wx/wx.h" +#endif #include "game.h" #include @@ -26,80 +26,109 @@ #define PROB 0.2 #ifndef RAND_MAX -#define RAND_MAX INT_MAX +# define RAND_MAX INT_MAX #endif -/*-------------------- BombsGame::~BombsGame() ---------------------*/ -/*--------------------------------------------------------------------*/ BombsGame::~BombsGame() - { if (field) - free(field); - } - -/*------------------ int BombsGame::Init(width,height) -------------------*/ -/* Initialize the play field. Returns 0 on failure */ -/*--------------------------------------------------------------------------*/ -int BombsGame::Init(int aWidth, int aHeight) - { int x, y; +{ + if (m_field) + { + delete[] m_field; + } +} + +// Initialize the play field. Returns false on failure +bool BombsGame::Init(int aWidth, int aHeight, bool easyCorner) +{ + m_gridFocusX = m_gridFocusY = -1; + + int x, y; int xx, yy; - if (field) - free(field); - field=(short *)malloc(aWidth*aHeight*sizeof(short)); - if (!field) - { width=height=0; - return 0; - } - width=aWidth; - height=aHeight; - - for(x=0; x=0 && xx=0 && yy=0 && xx=0 && yy