File: map.h

package info (click to toggle)
xkobo 1.11-4
  • links: PTS
  • area: main
  • in suites: slink
  • size: 580 kB
  • ctags: 628
  • sloc: cpp: 4,869; ansic: 4,403; makefile: 45; sh: 15
file content (61 lines) | stat: -rw-r--r-- 1,876 bytes parent folder | download | duplicates (2)
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

/*
 * XKOBO, a video-oriented game
 * Copyright (C) 1995,1996  Akira Higuchi
 *     a-higuti@math.hokudai.ac.jp
 * 
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation; either version 2 of the License, or (at your
 * option) any later version.
 * 
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 675 Mass Ave, Cambridge, MA 02139, USA.
 * 
 */

#ifndef XKOBO_H_MAP
#define XKOBO_H_MAP

#include "config.h"

#define SITE_MAX       1024

#define SPACE          0
#define WALL           1
#define CORE           (1<<4)
#define U_MASK         (1<<0)
#define R_MASK         (1<<1)
#define D_MASK         (1<<2)
#define L_MASK         (1<<3)
#define HARD           (1<<5)
#define HIT_MASK       (CORE | U_MASK | R_MASK | D_MASK | L_MASK)

class _map{
    const int sx_log2 = MAP_SIZEX_LOG2;
    const int sy_log2 = MAP_SIZEY_LOG2;
    const int sx = 1 << sx_log2;
    const int sy = 1 << sy_log2;
    int sitex[SITE_MAX];
    int sitey[SITE_MAX];
    int site_max;
    char data[1 << (sx_log2 + sy_log2)];
    int maze_pop();
    void maze_push(int x, int y);
    void maze_move_and_push(int x, int y, int d);
    int maze_judge(int cx, int cy, int dx, int dy, int x, int y);
  public:
    void init();
    void make_maze(int x, int y, int difx, int dify);
    void convert(int ratio);   /* ratio < 64 */
    inline char& pos(int x, int y){ return data[(y<<sx_log2) + x];}
};  


#endif // XKOBO_H_MAP