-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtilecomp.prg
104 lines (87 loc) · 2.61 KB
/
tilecomp.prg
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
COMPILER_OPTIONS _case_sensitive;
// ****************************************************************************
// Matamarcianos con DIV 2 Games Studio para el DivCompo
//
// Tests de tilemaps
//
// https://divcompo.now.sh
// ****************************************************************************
program tilecompo;
const
// cte. para las rutas
PATH_USER="zardoz";
PATH_PROG="mata";
global
local
private
int tiles[8, 16] =
// 0 1 2 3 4 5 6 7
16, 16, 2, 13, 13, 13, 13, 13, // 0
16, 16, 2, 13, 13, 13, 13, 13, // 1
4, 4, 9, 13, 13, 13, 13, 13, // 2
13, 13, 13, 13, 13, 13, 13, 13, // 3
13, 13, 13, 13, 13, 13, 13, 13, // 4
13, 13, 13, 13, 13, 13, 13, 13, // 5
13, 13, 13, 13, 13, 13, 13, 13, // 6
13, 13, 13, 13, 13, 13, 13, 13, // 7
13, 13, 13, 13, 13, 13, 13, 13, // 8
16, 16, 2, 13, 13, 13, 13, 13, // 0
16, 16, 2, 13, 13, 13, 13, 13, // 1
4, 4, 9, 13, 13, 13, 13, 13, // 2
13, 13, 13, 13, 13, 13, 13, 13, // 3
13, 13, 13, 13, 13, 13, 13, 13, // 4
13, 13, 13, 13, 4, 13, 13, 13, // 5
13, 13, 13, 13, 13, 13, 13, 13, // 6
13, 13, 13, 13, 13, 13, 13, 13, // 7
13, 13, 13, 13, 13, 13, 13, 13; // 8
tileMap;
begin
set_mode(m640x480);
set_fps(60, 0);
vsync=1;
load_fpg(pathResolve("fpg\tilemap.fpg"));
ctype=c_scroll;
scroll.camera = id;
tileMap = drawTiles(offset tiles, 8, 16, 24, 28);
start_scroll(0, 0, tileMap, 0, 0, 0);
loop
x = mouse.x;
y = mouse.y;
frame;
end
end
/**
* Genera la ruta relativa a los ficheros del juego
*/
function pathResolve(file)
begin
return (PATH_USER + "\" + PATH_PROG + "\" + file);
end
function drawTiles(int pointer tilesPtr, mapColumns, mapRows, tileWidth, tileHeight)
private
bufferWidth;
bufferHeight;
buffer;
tileIndex;
tileMap;
halfTileWidth;
halfTileHeight;
begin
bufferWidth = tileWidth * mapColumns;
bufferHeight = tileHeight * (mapRows + 1);
buffer = new_map(bufferWidth, bufferHeight,
bufferWidth >> 1, bufferHeight >> 1,
196);
halfTileWidth = tileWidth >> 1;
halfTileHeight = tileHeight >> 1;
for (y = 0; y <= mapRows; y++)
for (x = 0; x < mapColumns; x++)
tileIndex = mapColumns * y + x;
tileMap = tilesPtr[tileIndex];
map_put(0, buffer, tileMap,
(x * tileWidth) + halfTileWidth,
(y * tileHeight) + halfTileHeight);
end
end
return(buffer);
end