~ubuntu-branches/ubuntu/hardy/codeblocks/hardy-backports

« back to all changes in this revision

Viewing changes to src/plugins/contrib/byogames/byosnake.h

  • Committer: Bazaar Package Importer
  • Author(s): Michael Casadevall
  • Date: 2008-07-17 04:39:23 UTC
  • Revision ID: james.westby@ubuntu.com-20080717043923-gmsy5cwkdjswghkm
Tags: upstream-8.02
ImportĀ upstreamĀ versionĀ 8.02

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef BYOSNAKE_H
 
2
#define BYOSNAKE_H
 
3
 
 
4
#include <wx/font.h>
 
5
#include <wx/timer.h>
 
6
#include "byogamebase.h"
 
7
 
 
8
class wxPaintEvent;
 
9
class wxTimerEvent;
 
10
class wxEraseEvent;
 
11
 
 
12
/** \brief Game with traditional snake eating something */
 
13
class byoSnake : public byoGameBase
 
14
{
 
15
    public:
 
16
 
 
17
        /** \brief Ctor */
 
18
        byoSnake(wxWindow* parent,const wxString& GameName);
 
19
 
 
20
        /** \brief Dctor */
 
21
        virtual ~byoSnake();
 
22
 
 
23
    private:
 
24
 
 
25
        static const int m_FieldHoriz = 30;
 
26
        static const int m_FieldVert = 15;
 
27
        static const int m_FieldTotal = m_FieldHoriz * m_FieldVert;
 
28
        static const int m_BorderColour = 0;
 
29
        static const int m_SnakeColour = 1;
 
30
        static const int m_AppleColour = 2;
 
31
        static const int m_MaxKillCnt = 2;
 
32
 
 
33
        enum Direction
 
34
        {
 
35
            dLeft, dRight, dUp, dDown
 
36
        };
 
37
 
 
38
        int m_AppleX;
 
39
        int m_AppleY;
 
40
 
 
41
        int m_SnakeX[m_FieldTotal+2];
 
42
        int m_SnakeY[m_FieldTotal+2];
 
43
        int m_SnakeLen;
 
44
        bool m_Field[m_FieldHoriz][m_FieldVert];
 
45
 
 
46
        int m_Delay;
 
47
        int m_Lives;
 
48
        int m_Score;
 
49
        int m_InitialSlowdownCnt;
 
50
        int m_KillCnt;
 
51
        wxFont m_Font;
 
52
 
 
53
        wxTimer m_Timer;
 
54
 
 
55
        Direction m_Direction;
 
56
 
 
57
        void OnKeyDown(wxKeyEvent& event);
 
58
        void OnPaint(wxPaintEvent& event);
 
59
        void OnTimer(wxTimerEvent& event);
 
60
        void OnEraseBack(wxEraseEvent& event);
 
61
 
 
62
        void InitializeSnake();
 
63
        void RandomizeApple();
 
64
        void StartSnake();
 
65
        void RebuildField();
 
66
        void Move();
 
67
        void Died();
 
68
        void GameOver();
 
69
        void GetsBigger();
 
70
        void UpdateSpeed();
 
71
 
 
72
        void DrawBorder(wxDC* DC);
 
73
        void DrawSnake(wxDC* DC);
 
74
        void DrawApple(wxDC* DC);
 
75
        void DrawStats(wxDC* DC);
 
76
 
 
77
        DECLARE_EVENT_TABLE()
 
78
};
 
79
 
 
80
#endif