source: trunk/MagicSoft/Mars/mtools/MagicSnake.h@ 3077

Last change on this file since 3077 was 1907, checked in by tbretz, 22 years ago
*** empty log message ***
File size: 2.6 KB
Line 
1#ifndef MARS_MagicSnake
2#define MARS_MagicSnake
3
4#ifndef MARS_MAGIC
5#include "MAGIC.h"
6#endif
7
8#ifndef ROOT_TText
9#include <TText.h>
10#endif
11#ifndef ROOT_TTimer
12#include <TTimer.h>
13#endif
14#ifndef ROOT_TClonesArray
15#include <TClonesArray.h>
16#endif
17
18class TMarker;
19class TVirtualPad;
20
21class MGeomCam;
22class MHexagon;
23
24class MagicSnake : public TObject
25{
26private:
27 enum {
28 kRightTop,
29 kRight,
30 kRightBottom,
31 kLeftBottom,
32 kLeft,
33 kLeftTop
34 };
35
36 enum
37 {
38 kBackground = 50,
39 kHasBomb = BIT(16),
40 kHasFood = BIT(17),
41 kHasWorm = BIT(18),
42 kHasTransport = BIT(19),
43 kHasDoor = BIT(20),
44 kUserBits = 0x7fc000 // 14-23 are allowed
45
46 };
47
48 Byte_t fLength; // actual length of worm
49 Int_t *fArray; // inices of pixels which are 'wormed'
50 Char_t fDirection; // actual direction of worm
51
52 TTimer fTimer; // timer rising the 500ms interrputs
53
54 MGeomCam *fGeomCam; // pointer to camera geometry
55
56 UShort_t fTransport[2]; // pixel ids with the yellow transpoters
57 UInt_t fNumPixels; // number of pixels in the present geometry
58 Byte_t fNumBombs; // number of bombs in the field
59 Byte_t fNumFood; // number of food packages
60 Float_t fRange; // the range in millimeters of the present geometry
61
62 TText *fDone; // TText showing the 'Game over'
63 TText *fPaused; // TText showing the 'Game over'
64 TText fShow; // TText showing the numbers of pixels and bombs
65
66 UInt_t fW; // Width of canvas
67 UInt_t fH; // Height of canvas
68
69 TClonesArray *fPixels; // array of all hexagons
70 TVirtualPad *fDrawingPad; // pad in which we are drawing
71
72 MHexagon &operator[](int i) { return *((MHexagon*)fPixels->At(i)); }
73
74 void Remove(TObject *);
75 void Done(TString, Int_t col);
76 void Step(Int_t newpix);
77 void Update();
78 void Free();
79 void DrawHexagons();
80 Int_t ScanNeighbours();
81 void SetNewCamera(MGeomCam *);
82 void SetWormColor();
83 void Pause(Bool_t yes=kTRUE);
84
85 Bool_t HandleTimer(TTimer *timer);
86 void Draw(Option_t *option="");
87 void Paint(Option_t *option="");
88 void ExecuteEvent(Int_t event, Int_t px, Int_t py);
89 Int_t DistancetoPrimitive(Int_t px, Int_t py) { return 0; }
90
91public:
92 MagicSnake();
93 ~MagicSnake();
94
95 void Reset(); //*MENU*
96 void ChangeCamera(); //*MENU*
97
98 ClassDef(MagicSnake, 0) // Magic Camera Games: Snake
99};
100
101#endif
Note: See TracBrowser for help on using the repository browser.