Got gameplay working and board resizing with window.
[gmemory:gmemory.git] / src / gmemory-game.h
1 /*
2  *  GMemory - gmemory-game.h
3  *
4  *  Copyright (C) 2010 Openismus GmbH
5  *
6  *  Author: Chris Kühl <chrisk@openismus.com>
7  *
8  *  This program is free software: you can redistribute it and/or modify
9  *  it under the terms of the GNU General Public License as published by
10  *  the Free Software Foundation, either version 3 of the License, or
11  *  (at your option) any later version.
12  *
13  *  This program is distributed in the hope that it will be useful,
14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  *  GNU General Public License for more details.
17  *
18  *  You should have received a copy of the GNU General Public License
19  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
20  */
21
22 #ifndef __GMEMORY_GAME_H__
23 #define __GMEMORY_GAME_H__
24
25 #include <clutter/clutter.h>
26 #include "gmemory-card.h"
27
28 G_BEGIN_DECLS /* Start extern "C" wrap */
29
30 #define GMEMORY_TYPE_GAME            (gmemory_game_get_type())
31 #define GMEMORY_GAME(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMEMORY_TYPE_GAME, GMemoryGame))
32 #define GMEMORY_IS_GAME(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GMEMORY_TYPE_GAME))
33 #define GMEMORY_GAME_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST  ((klass), GMEMORY_TYPE_GAME, GMemoryGameClass))
34 #define GMEMORY_IS_GAME_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE  ((klass), GMEMORY_TYPE_GAME))
35 #define GMEMORY_GAME_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS  ((obj), GMEMORY_TYPE_GAME, GMemoryGameClass))
36
37 typedef struct _GMemoryGame        GMemoryGame;
38 typedef struct _GMemoryGameClass   GMemoryGameClass;
39 typedef struct _GMemoryGamePrivate GMemoryGamePrivate;
40
41 #define GAME_MIN_WIDTH  200
42 #define GAME_MIN_HEIGHT GAME_MIN_WIDTH
43
44 typedef struct {
45         GMemoryCard *card1;
46         GMemoryCard *card2;
47 } GMemoryCardPair;
48
49 typedef enum {
50         GAME_STATE_IDLE,
51         GAME_STATE_START,
52         GAME_STATE_AWAITING_NEXT_MOVE,
53         GAME_STATE_ONE_CARD_CHOSEN,
54         GAME_STATE_CHECKING_FOR_MATCH,
55         GAME_STATE_FINISHED
56 } GMemoryGameState;
57
58 typedef enum {
59         GAME_DIFFICULTY_EASY    = 4, /* Grid size will be 4-by-4. */
60         GAME_DIFFICULTY_NORMAL  = 5, /* and so on... */
61         GAME_DIFFICULTY_HARD    = 6,
62         GAME_DIFFICULTY_EXTREME = 7,
63 } GMemoryGameDifficulty;
64
65 struct _GMemoryGame {
66         ClutterGroup parent;
67
68         /* private */
69         GMemoryGamePrivate *priv;
70 };
71
72 struct _GMemoryGameClass {
73         ClutterGroupClass parent_class;
74
75         /* class members */
76         void (* start_game)  (GMemoryGame *);
77         void (* end_game)    (GMemoryGame *);
78         void (* attempt_made)(GMemoryGame *, gboolean is_match);
79 };
80
81 /* Used by GMEMORY_TYPE_GAME. */
82 GType gmemory_game_get_type(void);
83
84 /* Method definitions. */
85 GMemoryGame *gmemory_game_new();
86
87 void  gmemory_game_start         (GMemoryGame *game);
88 guint gmemory_game_get_difficulty(GMemoryGame *game);
89 void  gmemory_game_set_difficulty(GMemoryGame *game, guint difficulty);
90
91 G_END_DECLS /* End extern "C" wrap */
92
93 #endif /* __GMEMORY_GAME_H__ */