diff options
| -rw-r--r-- | inc/Character.hpp | 6 | ||||
| -rw-r--r-- | inc/List.hpp | 18 | ||||
| -rw-r--r-- | inc/main.hpp | 1 | ||||
| -rw-r--r-- | src/Character.cpp | 9 | ||||
| -rw-r--r-- | src/List.cpp | 16 | ||||
| -rw-r--r-- | src/Screen.cpp | 2 | ||||
| -rw-r--r-- | src/main.cpp | 10 | 
7 files changed, 56 insertions, 6 deletions
| diff --git a/inc/Character.hpp b/inc/Character.hpp index 4e0869a..f2753a9 100644 --- a/inc/Character.hpp +++ b/inc/Character.hpp @@ -1,11 +1,14 @@  #ifndef character_h  #define character_h +#include <ncurses.h> +  class Character  {      public: -        Character(char nSymbol, int nRow, int nCol); +        Character(char nSymbol, int nColor,int nRow, int nCol);          void move(int nRow, int nCol); +        void draw(WINDOW * w);          int getRow();          int getCol();          char getSymbol(); @@ -14,6 +17,7 @@ class Character          char symbol;          int row;          int col; +        int color;  };  #endif diff --git a/inc/List.hpp b/inc/List.hpp new file mode 100644 index 0000000..5f83846 --- /dev/null +++ b/inc/List.hpp @@ -0,0 +1,18 @@ +#ifndef list_h +#define list_h + +#include "Character.hpp" +#include <vector> +#include <ncurses.h> +using namespace std; + +class List +{ +    public: +        List(); +        void draw(WINDOW * w); +    private: +        vector <Character> men; +}; + +#endif diff --git a/inc/main.hpp b/inc/main.hpp index 6d3cae3..441e0d2 100644 --- a/inc/main.hpp +++ b/inc/main.hpp @@ -4,5 +4,6 @@  #include "Screen.hpp"  #include "Character.hpp"  #include "Frame.hpp" +#include "List.hpp"  #endif diff --git a/src/Character.cpp b/src/Character.cpp index 71a47bb..7f12035 100644 --- a/src/Character.cpp +++ b/src/Character.cpp @@ -1,10 +1,11 @@  #include "Character.hpp" -Character::Character(char nSymbol, int nRow, int nCol) +Character::Character(char nSymbol, int nColor, int nRow, int nCol)  {      symbol = nSymbol;      row = nRow;      col = nCol; +    color = nColor;  }  void Character::move(int nRow, int nCol) @@ -13,6 +14,12 @@ void Character::move(int nRow, int nCol)      col = nCol;  } +void Character::draw(WINDOW * w) +{ +    wattron(w,COLOR_PAIR(color)); +    mvwaddch(w,row,col,symbol); +} +  int Character::getRow()  {      return row; diff --git a/src/List.cpp b/src/List.cpp new file mode 100644 index 0000000..ce206c5 --- /dev/null +++ b/src/List.cpp @@ -0,0 +1,16 @@ +#include "List.hpp" + +List::List() +{ +    for(int i = 0; i < 10; i++) +    { +        Character x ('@',3,150,150+i); +        men.push_back(x); +    }  +} + +void List::draw(WINDOW * w) +{ +    for(int i = 0; i < 10; i++) +        men[i].draw(w); +} diff --git a/src/Screen.cpp b/src/Screen.cpp index 54033f7..ebaae4e 100644 --- a/src/Screen.cpp +++ b/src/Screen.cpp @@ -13,7 +13,7 @@ Screen::Screen()      start_color();      init_pair(1, COLOR_GREEN, COLOR_BLACK);      init_pair(2, COLOR_YELLOW,COLOR_BLACK); -    init_pair(3, COLOR_WHITE, COLOR_WHITE); +    init_pair(3, COLOR_WHITE, COLOR_BLUE);  }  Screen::~Screen() diff --git a/src/main.cpp b/src/main.cpp index 5c550de..baba44a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -6,12 +6,14 @@ int main()      Frame map("scripts/map.txt",0,0);      Frame view(map,s.getHeight(),s.getWidth(),0,0); +    List L; -    Character cursor('X',map.getHeight()/2,map.getWidth()/2); +    Character cursor('X',3,map.getHeight()/2,map.getWidth()/2);      map.fillWindow(); -    map.add(cursor); -    view.center(cursor); +    cursor.draw(map.getWin()); +    //view.center(cursor); +    L.draw(map.getWin());      view.refresh();       while(true) @@ -32,6 +34,8 @@ int main()          view.center(cursor);          view.refresh();          map.fillWindow(); +        cursor.draw(map.getWin()); +        L.draw(map.getWin());      }      return 0; | 
