/[anoncvs]/projects/roguelike/NPC.cpp


UCC Code Repository

Contents of /projects/roguelike/NPC.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (show annotations) (download)
Thu Apr 13 06:18:15 2006 UTC (15 years ago) by banana
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +1 -2 lines
In the middle of adding LOS

1 #include "NPC.h"
2
3 NPC::NPC(std::wstring n, wchar_t s, int c, World *w) {
4 name = n;
5 symbol = s;
6 colour = c;
7 time = 0;
8 my = w;
9 }
10
11 int NPC::moveDelay() {
12 if (symbol == L'r') { //rats move fast!
13 return 20;
14 }
15 return 100;
16 }
17
18 int NPC::attackDelay() {
19 if (symbol == L'r') { //rats attack slow!!!
20 return 80;
21 }
22 return 39;
23 }
24
25 //This is the AI!
26 bool NPC::act() {
27
28 if (!seen && my->at(x, y).los) core_display();
29
30 static int dir;
31 if (x == 16 || (x == 17 && dir == -1)) {
32 dir = 1;
33 } else if (x == 21 && dir == 1) {
34 dir = -1;
35 }
36 my->move(this, x+dir, y);
37
38 seen = false;
39
40 return false;
41 }

Managed by UCC Webmasters ViewVC Help
Powered by ViewVC 1.1.26