summaryrefslogtreecommitdiff
path: root/include/minesweeper.h
blob: 6bc7738f33c80feb4fcc1c0a28fc27138e3fa69c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#ifndef MINESWEEPER_H
#define	MINESWEEPER_H

#include <sysexits.h>
#include <SDL/SDL.h>
#include <SDL/SDL_thread.h>
#include <SDL/SDL_mutex.h>
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#include <sdl_digit.h>

#if defined (_WIN32)
# include <windows.h>
#endif

#ifndef __cplusplus
  typedef unsigned char	bool;
  enum { true = 1, false = 0 };
#endif

SDL_Surface *scr;
SDL_Surface *surf_number[9];
SDL_Surface *bmb_surf;
SDL_Surface *hidden_surf;
SDL_Surface *selection_surf;
SDL_Surface *flag_surf;
SDL_Surface *wrong_flag;

SDL_mutex *mutex;

unsigned int discovered;
unsigned int g_flags;

#define BLOCK_SIZE 30
#define BLOCK_W    30
#define BLOCK_H    16
#define BOMBS      100

typedef struct {
  bool flagged;
  bool type;
  bool hidden;
  bool selected;
  int  touch;
  int  x, y;
} case_t;

typedef struct {
  case_t       tab[BLOCK_H][BLOCK_W];
  unsigned int bombs;
} map_t;

void init_map(map_t *map);
int get_nbr_touch(bool tab[BLOCK_H][BLOCK_W], int j, int i);
void show_map(map_t *map);
void load_surfaces(void);

int move_left(map_t *map, int *selection);
int move_right(map_t *map, int *selection);
int move_up(map_t *map, int *selection);
int move_down(map_t *map, int *selection);

int flip(map_t *map, int *selection);
int flag(map_t *map, int *selection);

void dsp_ribbon_flags(void);
SDL_Thread *start_clock(void);
void dsp_clock(Uint32 base_ticks);
int xSDL_BlitSurface(SDL_Surface *, SDL_Rect *, SDL_Surface *, SDL_Rect *);
void xSDL_Flip(SDL_Surface *);

#endif		/* !MINESWEEPER_H */