source: trunk/Mars/mtools/MagicSnake.h@ 17613

Last change on this file since 17613 was 9369, checked in by tbretz, 16 years ago
*** empty log message ***
File size: 2.5 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#ifndef ROOT_TArrayI
18#include <TArrayI.h>
19#endif
20
21class TMarker;
22class TVirtualPad;
23
24class MGeomCam;
25class MHexagon;
26
27class MagicSnake : public TObject
28{
29private:
30 enum {
31 kRightTop,
32 kRight,
33 kRightBottom,
34 kLeftBottom,
35 kLeft,
36 kLeftTop
37 };
38
39 enum
40 {
41 kBackground = 50,
42 kHasBomb = BIT(16),
43 kHasFood = BIT(17),
44 kHasWorm = BIT(18),
45 kHasTransport = BIT(19),
46 kHasDoor = BIT(20),
47 kUserBits = 0x7fc000 // 14-23 are allowed
48
49 };
50
51 Byte_t fLength; // actual length of worm
52 Int_t *fArray; // inices of pixels which are 'wormed'
53 Char_t fDirection; // actual direction of worm
54
55 TTimer fTimer; // timer rising the 500ms interrputs
56
57 MGeomCam *fGeomCam; // pointer to camera geometry
58
59 UShort_t fTransport[2]; // pixel ids with the yellow transpoters
60 UInt_t fNumPixels; // number of pixels in the present geometry
61 Byte_t fNumBombs; // number of bombs in the field
62 Byte_t fNumFood; // number of food packages
63 Float_t fRange; // the range in millimeters of the present geometry
64
65 TArrayI fColors;
66
67 TText *fDone; // TText showing the 'Game over'
68 TText *fPaused; // TText showing the 'Game over'
69 TText fShow; // TText showing the numbers of pixels and bombs
70
71 TVirtualPad *fDrawingPad; // pad in which we are drawing
72
73 void Done(TString, Int_t col);
74 void Step(Int_t newpix);
75 void Update();
76 void Free();
77 void DrawHexagons();
78 Int_t ScanNeighbours();
79 void SetNewCamera(MGeomCam *);
80 void SetWormColor();
81 void Pause(Bool_t yes=kTRUE);
82 void Init();
83
84 Bool_t HandleTimer(TTimer *timer);
85 void Draw(Option_t *option="");
86 void Paint(Option_t *option="");
87 void ExecuteEvent(Int_t event, Int_t px, Int_t py);
88 Int_t DistancetoPrimitive(Int_t px, Int_t py) { return 0; }
89
90public:
91 MagicSnake();
92 MagicSnake(const MGeomCam &geom);
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.