summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortom <tom@ground-control>2015-11-23 17:05:27 -0600
committertom <tom@ground-control>2015-11-23 17:05:27 -0600
commit9d9c1d29dbcd802c89641b70b5574361e775c0e4 (patch)
treebd66508d2db620db21db51c15276055d492297ea
parent8228cd7ef6156d87ccf33335466c86fa30dadd8b (diff)
added collision of trees and map border
-rw-r--r--inc/Character.hpp4
-rw-r--r--inc/Frame.hpp4
-rw-r--r--inc/List.hpp5
-rw-r--r--inc/Location.hpp1
-rw-r--r--scripts/map.txt22
-rw-r--r--src/Character.cpp62
-rw-r--r--src/Frame.cpp42
-rw-r--r--src/List.cpp7
-rw-r--r--src/main.cpp7
9 files changed, 82 insertions, 72 deletions
diff --git a/inc/Character.hpp b/inc/Character.hpp
index 1a7dcdd..a1fc7b7 100644
--- a/inc/Character.hpp
+++ b/inc/Character.hpp
@@ -14,8 +14,8 @@ class Character
Character(char nSymbol, int nColor, Location L);
void move(Location L){l=L;}
void draw(WINDOW * w);
- void action(vector <Character> men);
- bool check(Location L, vector <Character> men);
+ void action(vector <Character> men, vector <Location> impassable);
+ bool check(Location L, vector <Character> men, vector <Location> impassable);
Location getLocation(){return l;}
char getSymbol(){return symbol;}
diff --git a/inc/Frame.hpp b/inc/Frame.hpp
index 4e4b57f..26a7364 100644
--- a/inc/Frame.hpp
+++ b/inc/Frame.hpp
@@ -27,15 +27,17 @@ class Frame
void refresh();
void move(int nRow, int nCol);
void center(Character &ch);
+ vector <Location> getImpassable(){return impassable;}
private:
int height, width;
int row, col;
bool hasSuper;
- bool colored = false;
+ bool filled;
WINDOW * w;
WINDOW * super;
vector <string> m;
+ vector <Location> impassable;
};
#endif
diff --git a/inc/List.hpp b/inc/List.hpp
index ce3f413..447903b 100644
--- a/inc/List.hpp
+++ b/inc/List.hpp
@@ -11,11 +11,12 @@ using namespace std;
class List
{
public:
- List();
+ List(vector <Location> i);
void draw(WINDOW * w);
void action();
private:
- vector <Character> men;
+ vector <Character> men;
+ vector <Location> impassable;
};
#endif
diff --git a/inc/Location.hpp b/inc/Location.hpp
index 5c6f1ea..ed0e2db 100644
--- a/inc/Location.hpp
+++ b/inc/Location.hpp
@@ -5,6 +5,7 @@ class Location
{
public:
Location(){x=0;y=0;}
+ Location(int xn, int yn){x=xn;y=yn;}
int x;
int y;
};
diff --git a/scripts/map.txt b/scripts/map.txt
index f78ab89..335e62d 100644
--- a/scripts/map.txt
+++ b/scripts/map.txt
@@ -144,17 +144,17 @@ O.;: ,.., ..:,:;. . ::,,: , ;:.;:;O;.:..;,,,.;,:.. ;;.;,.;. ,;;;; , , ;., ;
; :..::,;;: ,; :.,., :....; ., .,,::;.:;: ;;;:, :O0;,;;; ,;: .,;.;;; , ; ,O . :.: ;.. .,; ,,.;:;:.::;.,,;;.: : .,;; ;..,,.; ;.;;. ;: ,;;.,;: ;.,:; , ; :..:;;:.;.,;;.;.:,: ; .,;;.;;;., O : :; , .,:;.,.,;.::: .; .;,.;;,;.:,..:, ;, :,, ;.,.;.:, O:,..;:;:; .; ;.;:;.:. :::;;;::;.,; ,; ,; ;.;,:.:
O. ,, ,,:.;. ;,,.::; : 0::O0 , ,.,..,;.; , ;;,: ;:0;..; :; ;,:,;;; .,;0:;;,: :,;.::, .:,;.,, .:;.;, ; :.,;,.: ,.O,; .,.:;;;,.. ;::., ;,:,:::.; ..;, ;.,:. . ;, :;:,;;O ,,;,.;. ::; ,,,;:; ;.:,. O :. ,;:,: :;..: :. :,::,.O,.:.:,;:.; ; ,: ;;O,, :, ,,,. 0 ,;.,:;:,.:0 : 0; ;O:,. ::, :..: :: .,.,,;..
: ;: . ,.:;: ; .;.;,,: :. :;..;:.;: ;0; O ,:;. : O .::,,: ::,. ;:; ;. ,,, ; : ,,;::..;:,,:; : O; ,.;:,;., ;:; .; : ;,:;,: .,, ., ,:.; .;:.,;,,::,:,,,.:; ;::;:,,:.., ;: : : : ,;, : :;: . ;.,.;.,::0 ::, ;:,::,,. ::,,:; :;::,; .., ,., ;0, ....,;;:; :.;:.;.;,.:.. ,,::;;.;,;;; 0, ;; ..: :;; ..;
-; :,:::,.,;::;;, ;0:; ;, :;; ,.,.:.;,. ;, ,,. ,;:,, ;,;: ,,; ::.:,: ,::.:.....;., ;,,;;. .:.::::,;0. ;.:;:. . : : ;O;,;,;. ::; : .;.,, ,::;, :; . ,,,;,. .:; ;,,;.. :.;;.:;.;.,;::,;; :;.. ;; ;; :,:: . :,..;;, ,:, . , :,:. , :. ;; .,;.;, : ;;,..: ;; ,::.,,::;;..;;: ,;:;;.;,:,.:,: ;.:.. :;:,,.
-;;., . .:..:; ; ,;:.,;:,; ;,::,.;: : ;:,,.. ,::.,. .:: . 0;;:.. O , . 0;;:; ;: ;:,.;; ,.,:.,;: ;0 ;0. ,,;, , :::,,: .: .,. ; :. :.::,:. ,;..::.:. ,O;,,,:.,,:,, ,,.,: .. ; .;.; ., ; ;;..; , ;:,..O .,;:; ;:. ,,, ;;:: :,. ,,;. ; : ::,.:;,,0: ;.:;; O.;; .;. :,;::,,;. :,; .:: ,:: :;
-O.O,,;;..::. , ;;:;, ,.. 0;, ;::: :..;,;, ::.:O:: . . . .. .,::,,:;; .:, : ,., ..: ; ;,,. ;.,.:.;. ;; .,,,. ::; ., ;.;.:::.: ,.:;:,;: .::.;,;:: :;.; .,. , ,:;:.,.;. ; 0;..,: . .;; ; . ;;:.; .::. .;.,0;:;.; :;.0:,.,.::,O:;, .,,;;,.:.,.;.,, :.,; : .:;. :;; ..;;:;; ::.. ;.:;; ;:,
-.: ;::. ::,: :; ..,. ::.;;;;;: ;: .;.:, .:::,::.. :,,. :;,: ,:: : ,....,:;:;;.,:.;,:,, ;:;: ;,,. ,;,.,,: :;,,::;:: :;;.;. ;;:,.. :;::. :; :O :;:;, ;:;:.;, ,::, ;;,,. .;. ,.::.;:;,;,: 0, :; : .,;;,. .O ;;:.:: ;.:, , .,;,,::: .,; ,.:::;;.:,;. ;...;;:;:, ,, ;,,: .;.;..,: :,, . , ,.:;;.0. ,.,:
-O;,:,..;;:: .: : ;:. :..:;.;;,;;;.:; ,..;:,,.:,:; : ,; ::;;;::,. :, 0,,, .. ;.:,,.:,::,, :.::,,:;;,.; .;::.;,.;, ;;:, O.:. ..: ,;, :, ,,:;,.,, .,.,,:.,: ,.; .;,::;. , ,.;.: O: 0;:;:.;,.;,,:..::,::::;;:;.; ::; , ,;,,:.::; :.:,.00;:,;:;.,,.;.:. ;.,.;,,; ;. :...:,.. .O::.;.,,O;., :;.,;::; :
-.: ;. :,. : .:,: ;;.;:,: O:;:, ,; ,::,:O,;: :.: .;: ,;,,:, ,;.,:.:;; ,: .,: ,::,,, :;,.0,.,:;;:;,;,.,;; .;, ;, . .;. .;;. ., :;. .:;;: ....,;;,,,.:;:O;; ;, .:. ::,..:. : ,:;. . ... , .;,,:., .;,.:;, .:.;O.;::, ;:., :: ,::..:;.:.,:. ;;; .:. ; ,:::,;;:O:,.,,:: : ;0 ::,,: ,:.,:., :..;:
-,;,, : . ,;..0 O.;:,:.,. ;: , :,;:.:;: .. ,; :. .;,,.,;;,.;.: ,, ;,: ,,, ,:, :;.,.,;.;.:;;; ;,,,,.,. ::; . :.;;,.::;,;. :..: ,:;.; ;O,..:, . ., . :;.,, ;;.;.;: :;,, ,;,,;:::.; ;;::.;, ,: .: ;::.:.:..::.;.,;:. ,,,;: ;, ;.: ::::,: :.;,:.: ;, : .:;, ;.,.:.O;,. , ;,,:;.;, ;;::.. .,.:;,:,::,
-:; :, ;:;..;,. :;;:: ;.: : ;.,;.; ;,.,,:; ;.:,,,;.,, :,.,;;;:,;.,;.:,.O;: :,;.;; ,.;;: ,,,... : , .;..:.;;; .:.;0:.;;,;;;,,: ...::, :,,O:; ::, ;,, ; . ,,...;,; .,:;., , :,..,.: ,.O.:0,,,;,;:,;,,; :;.:: :.,.,:,. ;,:.:;:.; ;.:, ,,,,. , , , ; ..,:.. ;.:;:,.,;,:: : ;. .,;:;,.,;,,...:;;,:,,
-,, :, . ,..,: , .;;,;;,; .; ;; ;,::: :,. ,., :,,.,: :: ::;:; :.::; ,.::. : :::,.:;;;.;;,:.O . .. ; ;.;; :, :,.:.;;:;;,;.;.: ,:,; :. .: ,::; , :; ,;:.;;;O;.: ,.;:;,::. ,::; .; .;;;,,:;,:. :. ,, :. O ;0,, ;.;. ::;;.: .,; ::.; .; ;.:: .,,..;O;:...;,,,,;,:.:; ,,;;,. ,,. .;.,: .:.
-;..,,.;.;.::;;,,: ,:; :;;. . O.,;,. :,,,O: :;.;,:.;..: ..,..,.,,:, ,:. ;,, .,:,.: :,:,,;; ::,,;, , ..,:... ;.;:; ;,.;;;..;.,. ,.:; ,:;, . ; . : ;;.;,,:. ::;;: . ; .::,. ,,, :::.;::,..,.; 0;;,;.,:::,:.:,:;,..;: ,:.;,: ..,O:,.; ;;,;;,.,.::,:,: .:.,:;; ,: ;:,;:, ,:,; ,;. .; :..;;::. ;, :;..;,
-,,.0..., ; ,;; .:... .0;;,::. : .;;.,.,;;, ;; ;,.,;,,; ,;,, 0;;: .,:.;;:.;,:.:,.;,;, :. ;,..,: , :..;;:: ,;.;:,,, ,,:,,;, , ..;;: .:;. ,.,;0;:.;,. :O.,,;..,..,;:,:. , :; , ;; :; ,,, , ;.;, ;,;:......; ,,0,:,..:;::;: ;,0 ;;,; ; ,, ,;; ::, ::;,:;, :.:;;,::,.,;.:,....:,,;..:;; :; ,O:,,:;,;..O,.
+; :,:::,.,;::;;, ;0:; ;, :;; ,.,.:.;,. ;, ,,. ,;:,, ;,;: ,,; ::.:,: ,::.:.....;., ;,,;;. .:.::::,;0. ;.:;:. . : : ;O;,;0000000000000000000000000000000000000000000.. :.;;.:;.;.,;::,;; :;.. ;; ;; :,:: . :,..;;, ,:, . , :,:. , :. ;; .,;.;, : ;;,..: ;; ,::.,,::;;..;;: ,;:;;.;,:,.:,: ;.:.. :;:,,.
+;;., . .:..:; ; ,;:.,;:,; ;,::,.;: : ;:,,.. ,::.,. .:: . 0;;:.. O , . 0;;:; ;: ;:,.;; ,.,:.,;: ;0 ;0. ,,;, , :::,,: .: .,. ; :. :.::,:. ,;..::.:. ,O;,,,:.0,:,, ,,.,: .. ; .;.; ., ; ;;..; , ;:,..O .,;:; ;:. ,,, ;;:: :,. ,,;. ; : ::,.:;,,0: ;.:;; O.;; .;. :,;::,,;. :,; .:: ,:: :;
+O.O,,;;..::. , ;;:;, ,.. 0;, ;::: :..;,;, ::.:O:: . . . .. .,::,,:;; .:, : ,., ..: ; ;,,. ;.,.:.;. ;; .,,,. ::; ., ;.;.:::.: ,.:;:,;: .::.;,;:: :;.;0.,. , ,:;:.,.;. ; 0;..,: . .;; ; . ;;:.; .::. .;.,0;:;.; :;.0:,.,.::,O:;, .,,;;,.:.,.;.,, :.,; : .:;. :;; ..;;:;; ::.. ;.:;; ;:,
+.: ;::. ::,: :; ..,. ::.;;;;;: ;: .;.:, .:::,::.. :,,. :;,: ,:: : ,....,:;:;;.,:.;,:,, ;:;: ;,,. ,;,.,,: :;,,::;::0000:;;.;. ;;:,.. :;::. :; :O :;:;, ;:;:.;, ,::,0;;,,. .;. ,.::.;:;,;,: 0, :; : .,;;,. .O ;;:.:: ;.:, , .,;,,::: .,; ,.:::;;.:,;. ;...;;:;:, ,, ;,,: .;.;..,: :,, . , ,.:;;.0. ,.,:
+O;,:,..;;:: .: : ;:. :..:;.;;,;;;.:; ,..;:,,.:,:; : ,; ::;;;::,. :, 0,,, .. ;.:,,.:,::,, :.::,,:;;,.; .;::.;,.;, ;;:, 0.:. ..: ,;, :, ,,:;,.,, .,.,,:.,: ,0; .;,::;. , ,.;.: O: 0;:;:.;,.;,,:..::,::::;;:;.; ::; , ,;,,:.::; :.:,.00;:,;:;.,,.;.:. ;.,.;,,; ;. :...:,.. .O::.;.,,O;., :;.,;::; :
+.: ;. :,. : .:,: ;;.;:,: O:;:, ,; ,::,:O,;: :.: .;: ,;,,:, ,;.,:.:;; ,: .,: ,::,,, :;,.0,.,:;;:;,;,.,;; .;, ;, . 0;. .;;. ., :;. .:;;: ....,;;,,,.:;:O;0 ;, .:. ::,..:. : ,:;. . ... , .;,,:., .;,.:;, .:.;O.;::, ;:., :: ,::..:;.:.,:. ;;; .:. ; ,:::,;;:O:,.,,:: : ;0 ::,,: ,:.,:., :..;:
+,;,, : . ,;..0 O.;:,:.,. ;: , :,;:.:;: .. ,; :. .;,,.,;;,.;.: ,, ;,: ,,, ,:, :;.,.,;.;.:;;; ;,,,,.,. ::; . :.;;,.::0,;. :..: ,:;.; ;O,..:, . ., . :;.,, ;0.;.;: :;,, ,;,,;:::.; ;;::.;, ,: .: ;::.:.:..::.;.,;:. ,,,;: ;, ;.: ::::,: :.;,:.: ;, : .:;, ;.,.:.O;,. , ;,,:;.;, ;;::.. .,.:;,:,::,
+:; :, ;:;..;,. :;;:: ;.: : ;.,;.; ;,.,,:; ;.:,,,;.,, :,.,;;;:,;.,;.:,.O;: :,;.;; ,.;;: ,,,... : , .;..:.;;; .:.;0:.;0,;;;,,: ...::, :,,O:; ::, ;,, ; . ,,...;,; 0,:;., , :,..,.: ,.O.:0,,,;,;:,;,,; :;.:: :.,.,:,. ;,:.:;:.; ;.:, ,,,,. , , , ; ..,:.. ;.:;:,.,;,:: : ;. .,;:;,.,;,,...:;;,:,,
+,, :, . ,..,: , .;;,;;,; .; ;; ;,::: :,. ,., :,,.,: :: ::;:; :.::; ,.::. : :::,.:;;;.;;,:.O . .. ; ;.;; :, :,0:.;;:;;,;.;.: ,:,; :. .: ,::; , :; ,;:.;;;O0.: ,.;:;,::. ,::; .; .;;;,,:;,:. :. ,, :. O ;0,, ;.;. ::;;.: .,; ::.; .; ;.:: .,,..;O;:...;,,,,;,:.:; ,,;;,. ,,. .;.,: .:.
+;..,,.;.;.::;;,,: ,:; :;;. . O.,;,. :,,,O: :;.;,:.;..: ..,..,.,,:, ,:. ;,, .,:,.: :,:,,;; ::,,;, , ..,:... ;.;:; ;,.;;0..;.,. ,.:; ,:;, . ; . : ;;.;,,:. ::;;: .0; .::,. ,,, :::.;::,..,.; 0;;,;.,:::,:.:,:;,..;: ,:.;,: ..,O:,.; ;;,;;,.,.::,:,: .:.,:;; ,: ;:,;:, ,:,; ,;. .; :..;;::. ;, :;..;,
+,,.0..., ; ,;; .:... .0;;,::. : .;;.,.,;;, ;; ;,.,;,,; ,;,, 0;;: .,:.;;:.;,:.:,.;,;, :. ;,..,: , :..;;:: ,;.;:,,, ,,:0000000000000000000000000000000000000000000000. , :; , ;; :; ,,, , ;.;, ;,;:......; ,,0,:,..:;::;: ;,0 ;;,; ; ,, ,;; ::, ::;,:;, :.:;;,::,.,;.:,....:,,;..:;; :; ,O:,,:;,;..O,.
,0., ,.;:, .,. : , ,: . :::. .: ::: :,; , ,. ,;;,:.,,: :; ,;;:, . ;. :;,:.:.:;, ,;:;,,.: ,;,, :;:. .,.,..;,,.: .::;;,: : : . : ;.;: , , ,:.. ;.. :.,;., ,::,;,:,, ,,O,,;:.. ;O,,;:O,,,,.::; ,;0.:;.,;:: ,,.: ,.:.:.,,, ,;. :.,;;,..;;;, .,,:, ;,:;: ;, ;,;, ,,;,, : .: ;... ,:.;;:,,; :. .;;,,. :
,,; ,;, ;; ;;. ,::::, ;,.: ,, ;:;,:: ,, : ::;..;: ;. ; ;;: .;. ;,:,:; ;:,;,;.:: : ; ,:;.,. ,: .,,:;,;, ,,:. 0 ., ;.:. :0; ;.:;:,,. .; ;.: ::;; .;, . ,;;,.::O;.: ; :.:,;::,;. .;., :,:. ,,:;:,,.:; , .,:: . .:.:;:,:,;, ; ;:;,,::;.;..:.. ,,;:.. :..:, .:;:;,. : ,;, ; .;.;; ;:..;.: .;.,: ,:,;;.
: ,; :;;;;,;. ,: ., .: .,;.,.,. . ::::; ; . ::: O.,, ;;; .: ;: . ;.: :: ;,..,;::,;; .;. ,.::;; . .,:; ,:..: , ,,:. ::;; ;::,:;.:: ::, O; ,;: ,,.:..,. ; ;,:. ,;:O:, .:,:, :, .;;; :...0:,.;,.: ,;:,,: ;;, :;,O:;;: ...; :; ,, ;; ; :.,,; ;.: ,:; .,..,:;;.;, ; ,: : ;..;;:,: : :. ;:,O,O :,,;:.;:.
diff --git a/src/Character.cpp b/src/Character.cpp
index d5f8bc0..24ed475 100644
--- a/src/Character.cpp
+++ b/src/Character.cpp
@@ -13,65 +13,47 @@ void Character::draw(WINDOW * w)
mvwaddch(w,l.x,l.y,symbol);
}
-void Character::action(vector <Character> men)
+void Character::action(vector <Character> men, vector <Location> impassable)
{
if(order == "wander")
- {
- Location Lo;
+ {
int r = rand()%15+1;
+ bool stay = false;
+ Location L;
if(r==1)
- {
- Lo.x = l.x+1;
- Lo.y = l.y;
- }
+ L = Location(l.x+1,l.y);
else if(r==2)
- {
- Lo.x = l.x-1;
- Lo.y = l.y;
- }
+ L = Location(l.x-1,l.y);
else if(r==3)
- {
- Lo.x = l.x;
- Lo.y = l.y+1;
- }
+ L = Location(l.x,l.y+1);
else if(r==4)
- {
- Lo.x = l.x;
- Lo.y = l.y-1;
- }
+ L = Location(l.x,l.y-1);
else if(r==5)
- {
- Lo.x = l.x+1;
- Lo.y = l.y+1;
- }
+ L = Location(l.x+1,l.x+1);
else if(r==6)
- {
- Lo.x = l.x-1;
- Lo.y = l.y-1;
- }
+ L = Location(l.x-1,l.y-1);
else if(r==7)
- {
- Lo.x = l.x+1;
- Lo.y = l.y-1;
- }
+ L = Location(l.x+1,l.y-1);
else if(r==8)
- {
- Lo.x = l.x-1;
- Lo.y = l.y+1;
- }
+ L = Location(l.x-1,l.y+1);
else
- Lo = l;
+ stay = true;
- if(check(Lo,men))
- move(Lo);
+ if (!stay)
+ if(check(L,men,impassable))
+ move(L);
}
}
-bool Character::check(Location L, vector <Character> men)
+bool Character::check(Location L, vector <Character> men, vector <Location> impassable)
{
for(int i = 0; i < men.size(); i++)
if(L.x == men[i].getLocation().x && L.y == men[i].getLocation().y)
return false;
-
+
+ for(int i = 0; i < impassable.size(); i++)
+ if(L.x == impassable[i].x && L.y == impassable[i].y)
+ return false;
+
return true;
}
diff --git a/src/Frame.cpp b/src/Frame.cpp
index c63aeb4..ca0e41e 100644
--- a/src/Frame.cpp
+++ b/src/Frame.cpp
@@ -4,7 +4,7 @@ Frame::Frame(string location, int nRow, int nCol)
{
hasSuper = FALSE;
super = NULL;
-
+ filled = false;
int i, j=0;
string line;
ifstream file (location);
@@ -31,6 +31,7 @@ Frame::Frame(string location, int nRow, int nCol)
Frame::Frame(Frame &sw, int rows, int cols, int nRow, int nCol)
{
+ filled = false;
hasSuper = TRUE;
super = sw.getWin();
w = derwin(super,rows,cols,nRow,nCol);
@@ -103,28 +104,51 @@ void Frame::move(int nRow, int nCol)
void Frame::fillWindow()
{
- if(!colored)
- for(int i = 0; i < width; i++)
- for(int j = 0; j < height; j++)
+
+ for(int i = 0; i < width; i++)
+ for(int j = 0; j < height; j++)
+ {
+ if(m[j][i] == 'O' || m[j][i] == '0')
{
- if(m[j][i] == 'O' || m[j][i] == '0')
- wattron(w,COLOR_PAIR(2));
- else
- wattron(w,COLOR_PAIR(1));
- mvwaddch(w,j,i,m[j][i]);
+ wattron(w,COLOR_PAIR(2));
+ if(!filled)
+ {
+ Location l(j,i);
+ impassable.push_back(l);
+ }
}
+ else
+ wattron(w,COLOR_PAIR(1));
+
+ mvwaddch(w,j,i,m[j][i]);
+ }
wattron(w,COLOR_PAIR(3));
for(int y = 0; y < height; ++y)
{
mvwaddch(w, y, 0, '-');
mvwaddch(w, y, width - 1, '-');
+ if(!filled)
+ {
+ Location l1(y,0);
+ Location l2(y,width-1);
+ impassable.push_back(l1);
+ impassable.push_back(l2);
+ }
}
for(int x = 0; x < width; ++x)
{
mvwaddch(w, 0, x, '|');
mvwaddch(w, height - 1, x, '|');
+ if(!filled)
+ {
+ Location l1(0,x);
+ Location l2(height-1,x);
+ impassable.push_back(l1);
+ impassable.push_back(l2);
+ }
}
wattroff(w,COLOR_PAIR(3));
+ filled = true;
}
diff --git a/src/List.cpp b/src/List.cpp
index d4bc796..fefb37d 100644
--- a/src/List.cpp
+++ b/src/List.cpp
@@ -1,8 +1,8 @@
#include "List.hpp"
-List::List()
+List::List(vector <Location> i)
{
- for(int i = 0; i < 50; i++)
+ for(int i = 0; i < 10; i++)
{
Location L;
L.x = 150;
@@ -10,6 +10,7 @@ List::List()
Character x ('@',4,L);
men.push_back(x);
}
+ impassable = i;
}
void List::draw(WINDOW * w)
@@ -21,5 +22,5 @@ void List::draw(WINDOW * w)
void List::action()
{
for(int i = 0; i < men.size(); i++)
- men[i].action(men);
+ men[i].action(men,impassable);
}
diff --git a/src/main.cpp b/src/main.cpp
index c0d59af..8f5208f 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -6,14 +6,13 @@ int main()
Frame map("scripts/map.txt",0,0);
Frame view(map,s.getHeight(),s.getWidth(),0,0);
- List L;
- Location l;
- l.x =150;
- l.y =150;
+ Location l(150,150);
Character cursor('X',3,l);
map.fillWindow();
+ List L(map.getImpassable());
+
L.draw(map.getWin());
cursor.draw(map.getWin());