/[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 - (hide annotations) (download)
Thu Apr 13 06:18:15 2006 UTC (15 years, 2 months ago) by banana
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +1 -2 lines
In the middle of adding LOS

1 banana 1.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 banana 1.2 if (symbol == L'r') { //rats move fast!
13     return 20;
14     }
15 banana 1.1 return 100;
16     }
17    
18     int NPC::attackDelay() {
19 banana 1.2 if (symbol == L'r') { //rats attack slow!!!
20 banana 1.1 return 80;
21     }
22     return 39;
23     }
24    
25     //This is the AI!
26     bool NPC::act() {
27 banana 1.2
28 banana 1.3 if (!seen && my->at(x, y).los) core_display();
29 banana 1.2
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 banana 1.1 }
36 banana 1.2 my->move(this, x+dir, y);
37 banana 1.1
38 banana 1.2 seen = false;
39 banana 1.1
40     return false;
41     }

Managed by UCC Webmasters ViewVC Help
Powered by ViewVC 1.1.26