home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD Direkt: Spezial 1
/
CDD_SPIELE_.ISO
/
wingames
/
pyramid
/
pyramid.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1993-08-18
|
46KB
|
1,630 lines
//-------------------------------------------------------------------
// PROGRAM: PYRAMID.CPP
//
// DESCRIPTION: Sample program that utilizes Borland's
// OWL
//
// Written by Carlos Yu
//
// NOTE: The program design is kinda hacked because
// this is my first attempt at creating a
// fully functional Windows program using
// OWL and C++.
//
// Any suggestions on making the program better,
// specially the DealCards module which is
// painfully slow, would be greatly appreciated.
//
// Compuserve ID 72672,1567
//-------------------------------------------------------------------
//--------------------------------
// Include files
//--------------------------------
#include <owl.h>
#include <bwcc.h>
#include <stdio.h>
#include <string.h>
#include <dialog.h>
#include <button.h>
#include <static.h>
#include <bbutton.h>
#include <bgrpbox.h>
#include <tcollect.h>
//--------------------------------
// User Include Files
//--------------------------------
#include "cardwin.h"
#include "CDialog.h"
//-------------------------------------------------------------------
// GLOBAL VARIABLES AND DEFINITIONS
//-------------------------------------------------------------------
//--------------------------------
// Menu Item Constants
//--------------------------------
#define CM_DEAL 101
#define CM_OPTIONS 102
#define CM_QUIT 103
#define CM_INSTRUCT 104
#define CM_ABOUT 105
//--------------------------------
// Push Button Constants
//--------------------------------
#define ID_DEAL 111
#define ID_OPTIONS 112
#define ID_QUIT 113
#define ID_INSTRUCT 114
#define ID_ABOUT 115
//--------------------------------
// Custom Control Constants
//--------------------------------
#define ID_STATUSGROUP 121
#define ID_STATUSTEXT 122
//--------------------------------
// Constant variables
//--------------------------------
#define DIALOGQUIT 400
#define DIALOGPLAY 800
#define DIALOGABOUT 500
#define DIALOGINSTRUCT 600
#define MAINMENU 100
#define MAINACCEL 100
#define MAINICON 100
#define WINWIDTH 301
#define WINHEIGHT 240
#define STATUSLEN 255
#define WINBITMSG 589
#define BACKGROUNDBIT 7777
#define ORIGIN_X 43
#define ORIGIN_Y 20
#define CHILD_CLICK 20
POINT PYRAMID_POS[] =
{
{ ORIGIN_X + 222, ORIGIN_Y },
{ ORIGIN_X + 185, ORIGIN_Y + 25 },
{ ORIGIN_X + 259, ORIGIN_Y + 25 },
{ ORIGIN_X + 148, ORIGIN_Y + 50 },
{ ORIGIN_X + 222, ORIGIN_Y + 50 },
{ ORIGIN_X + 296, ORIGIN_Y + 50 },
{ ORIGIN_X + 111, ORIGIN_Y + 75 },
{ ORIGIN_X + 185, ORIGIN_Y + 75 },
{ ORIGIN_X + 259, ORIGIN_Y + 75 },
{ ORIGIN_X + 333, ORIGIN_Y + 75 },
{ ORIGIN_X + 74, ORIGIN_Y + 100 },
{ ORIGIN_X + 148, ORIGIN_Y + 100 },
{ ORIGIN_X + 222, ORIGIN_Y + 100 },
{ ORIGIN_X + 296, ORIGIN_Y + 100 },
{ ORIGIN_X + 370, ORIGIN_Y + 100 },
{ ORIGIN_X + 37, ORIGIN_Y + 125 },
{ ORIGIN_X + 111, ORIGIN_Y + 125 },
{ ORIGIN_X + 185, ORIGIN_Y + 125 },
{ ORIGIN_X + 259, ORIGIN_Y + 125 },
{ ORIGIN_X + 333, ORIGIN_Y + 125 },
{ ORIGIN_X + 407, ORIGIN_Y + 125 },
{ ORIGIN_X, ORIGIN_Y + 150 },
{ ORIGIN_X + 74, ORIGIN_Y + 150 },
{ ORIGIN_X + 148, ORIGIN_Y + 150 },
{ ORIGIN_X + 222, ORIGIN_Y + 150 },
{ ORIGIN_X + 296, ORIGIN_Y + 150 },
{ ORIGIN_X + 370, ORIGIN_Y + 150 },
{ ORIGIN_X + 444, ORIGIN_Y + 150 }
};
/*******************************************************************
*******************************************************************
************************ PROGRAM STARTS *************************
*******************************************************************
*******************************************************************/
//-------------------------------------------------------------------
// CLASS: TPyramidApp
//
// DESCRIPTION: Derive TApplication to create TPyramidApp
//
// RETURNS: NONE
//-------------------------------------------------------------------
class TPyramidApp : public TApplication
{
public:
TPyramidApp(LPSTR AName, HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow) : TApplication(AName, hInstance,
hPrevInstance, lpCmdLine, nCmdShow) {};
virtual void InitInstance();
virtual void InitMainWindow();
};
//-------------------------------------------------------------------
// CLASS: TPyramidWin
//
// DESCRIPTION: Derive TWindow to create TPyramidWin which is
// the main window class of the application
//
// RETURNS: NONE
//-------------------------------------------------------------------
_CLASSDEF(TPyramidWin)
class TPyramidWin : public TWindow
{
private:
int tagIdx,
playIdx,
childIndex,
discardCount;
char statusMsg[255];
BOOL isTagged,
hasDealt,
playOccupied;
HMENU MenuHandle,
MenuPopup1,
MenuPopup2,
MenuSystem;
HBRUSH GrayBrush;
HBITMAP hBitBack;
PTStatic StatusText;
PTButton PushDeal,
PushAbout,
PushInstruct,
PushQuit;
PTBGroupBox StatusGroup;
PTNSCollection allObjects;
PTCardWin cardPtr[53];
public:
// Constructor
TPyramidWin(PTWindowsObject AParent, LPSTR ATitle);
//----------------------------
// Window default functions
// and events
//----------------------------
virtual BOOL CanClose();
virtual void SetupWindow();
virtual LPSTR GetClassName();
virtual void GetWindowClass(WNDCLASS& AWndClass);
virtual void WMMove(RTMessage Msg)
= [WM_FIRST + WM_MOVE];
virtual void WMEraseBkgnd(RTMessage)
= [WM_FIRST + WM_ERASEBKGND];
virtual void WMDestroy(RTMessage Msg)
= [WM_FIRST + WM_DESTROY];
virtual void WMCtlColor(RTMessage Msg)
= [WM_FIRST + WM_CTLCOLOR];
virtual void WMMouseMove(RTMessage)
= [WM_FIRST + WM_MOUSEMOVE];
virtual void WMMenuSelect(RTMessage Msg)
= [WM_FIRST + WM_MENUSELECT];
virtual void WMLButtonDown(RTMessage Msg)
= [WM_FIRST + WM_LBUTTONDOWN];
virtual void WMRButtonDown(RTMessage Msg)
= [WM_FIRST + WM_RBUTTONDOWN];
//----------------------------
// User functions
//----------------------------
virtual void WMNotifyClick(RTMessage Msg)
= [WM_USER + CHILD_CLICK];
void Animate();
BOOL TestKing();
void DealCards();
void PlayAgain();
BOOL ProcessTag();
void ReturnToDeck();
void InitializeDeck();
int GetValue(int Value);
//---------------
// Push Button
//---------------
virtual void IDQuit(RTMessage)
= [ID_FIRST + ID_QUIT];
virtual void IDDeal(RTMessage)
= [ID_FIRST + ID_DEAL];
virtual void IDInstruct(RTMessage)
= [ID_FIRST +