X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/70d26c3f4ffb24d50457d405c9595fd23f9e5b7c..c0b0635cf69537ca32377bad5650b39402cb21b6:/demos/bombs/game.cpp?ds=sidebyside diff --git a/demos/bombs/game.cpp b/demos/bombs/game.cpp index d49b6a434d..3778780869 100644 --- a/demos/bombs/game.cpp +++ b/demos/bombs/game.cpp @@ -2,7 +2,7 @@ // Name: bombs1.cpp // Purpose: Implementation of the class BombsGame // Author: P. Foggia 1996 -// Modified by: +// Modified by: Wlodzimierz Skiba (ABX) 2003 // Created: 1996 // RCS-ID: $Id$ // Copyright: (c) 1996 P. Foggia @@ -10,14 +10,18 @@ /////////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ -#pragma implementation +# 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 +30,92 @@ #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) +{ + 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