-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathplayer.inc
106 lines (93 loc) · 2.26 KB
/
player.inc
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
105
106
{ player management }
{ set player position in random room }
Procedure GeneratePlayer;
Var
I : Integer;
Valid: Boolean;
Begin
I := Random(RoomI);
Repeat
Begin
With CPlayer, Rooms[I] Do
Begin
DX := Random(X2 - X1 - 1) + X1 + 1;
DY := Random(Y2 - Y1 - 1) + Y1 + 1;
Valid := HitItem(DX, DY) = -1;
If Valid Then
Begin
X := DX;
Y := DY; { first play - no tidy }
Room := I;
Discovered := True;
End;
End;
End;
Until Valid;
TakeItem(0);
End;
{ move player, report on if redraw is necessary }
Function MovePlayer : Boolean;
Var
X, Y: Integer;
FoundDoorI: Integer;
FoundItemI: Integer;
Redraw, Valid: Boolean;
NewRoom: Integer;
Begin
X := CPlayer.X;
Y := CPlayer.Y;
Redraw := False;
Valid := True;
If (D >= 0) And (D < 4) Then
Begin
Case D Of
0: X := CPlayer.X - 1;
1: X := CPlayer.X + 1;
2: Y := CPlayer.Y - 1;
3: Y := CPlayer.Y + 1;
End;
{ if going though door, open door and adjacent rooms }
FoundDoorI := HitDoor(X, Y);
If FoundDoorI <> -1 Then
Begin
With Doors[FoundDoorI] Do
Begin
Rooms[Room1I].Discovered := True;
Rooms[Room2I].Discovered := True;
Opened := True;
End;
Redraw := True;
End
Else Valid := Not HitWall(X, Y);
If Valid Then
Begin
CPlayer.X := X;
CPlayer.Y := Y;
{ check for change in room }
NewRoom := HitRoom(X, Y);
If (NewRoom <> -1) And (CPlayer.Room <> NewRoom) Then
Begin
CPlayer.Room := NewRoom;
Redraw := True;
End;
{ check for items }
FoundItemI := HitItem(X, Y);
If FoundItemI <> -1 Then
Begin
TakeItem(FoundItemI);
Redraw := True;
End
Else
Begin
If (L > 0) Then L := L - 1;
If L = 0 Then
Begin
SetAllRedraw;
Redraw := True; { Hide items }
End
End;
MoveMonsters;
End;
End;
MovePlayer := Redraw;
End;