-
Notifications
You must be signed in to change notification settings - Fork 0
/
fall.c
62 lines (51 loc) · 2.98 KB
/
fall.c
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
/*****************************************************/
/* Ultimate Blocks */
/* Copyright (c) An Ly 2000, Owen Rudge 2001, 2008 */
/*****************************************************/
#include <allegro.h>
#include "blocks3.h"
void Check_Fall(int p_no)
{
if (map[ply[p_no].x/_block_width][ply[p_no].y/_block_height][ply[p_no].z/_block_depth] == FALL)
map[ply[p_no].x/_block_width][ply[p_no].y/_block_height][ply[p_no].z/_block_depth] = FALL_PRIME;
if (map[(ply[p_no].x + (_block_width-1))/_block_width][ply[p_no].y/_block_height][ply[p_no].z/_block_depth] == FALL)
map[(ply[p_no].x + (_block_width-1))/_block_width][ply[p_no].y/_block_height][ply[p_no].z/_block_depth] = FALL_PRIME;
if (map[ply[p_no].x/_block_width][(ply[p_no].y + (_block_height-1))/_block_height][ply[p_no].z/_block_depth] == FALL)
map[ply[p_no].x/_block_width][(ply[p_no].y + (_block_height-1))/_block_height][ply[p_no].z/_block_depth] = FALL_PRIME;
if (map[(ply[p_no].x + (_block_width-1))/_block_width][(ply[p_no].y + _block_height)/_block_height][ply[p_no].z/_block_depth] == FALL)
map[(ply[p_no].x + (_block_width-1))/_block_width][(ply[p_no].y + _block_height)/_block_height][ply[p_no].z/_block_depth] = FALL_PRIME;
}
void Check_Fall_Prime(void)
{
int i, j, k;
for (k = 0; k < 2; k++)
{
for (j = 0; j < 15; j++)
{
for (i = 0; i < 20; i++)
{
if ((map[i][j][k] == FALL_PRIME) && (!Player_On_Fall(i, j)))
{
map[i][j][k] = SOLID;
DirtyList(i*_block_width - (_block_width/2), j*_block_height - (_block_height/2), k*_block_depth, _block_width, _block_height+_block_depth, blank);
DirtyList(i*_block_width + (_block_width/2), j*_block_height - (_block_height/2), k*_block_depth, _block_width, _block_height+_block_depth, blank);
DirtyList(i*_block_width - (_block_width/2), j*_block_height + (_block_height/2), k*_block_depth, _block_width, _block_height+_block_depth, blank);
DirtyList(i*_block_width + (_block_width/2), j*_block_height + (_block_height/2), k*_block_depth, _block_width, _block_height+_block_depth, blank);
Add_Sound(i, SFX_FALL);
}
}
}
}
}
int Player_On_Fall(int x, int y)
{
if ((ply[0].x/_block_width == x) && (ply[0].y/_block_height == y)) return 1;
if (((ply[0].x + (_block_width-1))/_block_width == x) && (ply[0].y/_block_height == y)) return 1;
if ((ply[0].x/_block_width == x) && ((ply[0].y + (_block_height-1))/_block_height == y)) return 1;
if (((ply[0].x + (_block_width-1))/_block_width == x) && ((ply[0].y + (_block_height-1))/_block_height == y)) return 1;
if ((ply[1].x/_block_width == x) && (ply[1].y/_block_height == y)) return 1;
if (((ply[1].x + (_block_width-1))/_block_width == x) && (ply[1].y/_block_height == y)) return 1;
if ((ply[1].x/_block_width == x) && ((ply[1].y + (_block_height-1))/_block_height == y)) return 1;
if (((ply[1].x + (_block_width-1))/_block_width == x) && ((ply[1].y + (_block_height-1))/_block_height == y)) return 1;
return 0;
}