commit 554442b331c0b37ba286add683caff6db3c0addc Author: Bog13 Date: Mon May 29 14:27:32 2017 +0200 First commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b2d553a --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +*~* +*\#* +build/ \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..31be9ee --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.5) +project(kraken) + +file(GLOB + sources + src/*.cpp) + +add_executable(kraken.elf + ${sources}) + +find_package(PkgConfig) +pkg_check_modules(SFML sfml-all) + +target_link_libraries(kraken.elf ${SFML_LDFLAGS}) \ No newline at end of file diff --git a/assets/BearRoaring.wav b/assets/BearRoaring.wav new file mode 100755 index 0000000..9c06bc9 Binary files /dev/null and b/assets/BearRoaring.wav differ diff --git a/assets/Explosion2.wav b/assets/Explosion2.wav new file mode 100755 index 0000000..68a1990 Binary files /dev/null and b/assets/Explosion2.wav differ diff --git a/assets/bubbleunderwater.wav b/assets/bubbleunderwater.wav new file mode 100755 index 0000000..223df66 Binary files /dev/null and b/assets/bubbleunderwater.wav differ diff --git a/assets/explosion.WAV b/assets/explosion.WAV new file mode 100755 index 0000000..d9cefb0 Binary files /dev/null and b/assets/explosion.WAV differ diff --git a/assets/explosion.jpg b/assets/explosion.jpg new file mode 100755 index 0000000..17d0d5d Binary files /dev/null and b/assets/explosion.jpg differ diff --git a/assets/screamingMan.wav b/assets/screamingMan.wav new file mode 100755 index 0000000..b155cbe Binary files /dev/null and b/assets/screamingMan.wav differ diff --git a/assets/screamingMan2.wav b/assets/screamingMan2.wav new file mode 100755 index 0000000..628f232 Binary files /dev/null and b/assets/screamingMan2.wav differ diff --git a/assets/tilesetNew.png b/assets/tilesetNew.png new file mode 100755 index 0000000..2f11e71 Binary files /dev/null and b/assets/tilesetNew.png differ diff --git a/assets/tilesetNew2.png b/assets/tilesetNew2.png new file mode 100755 index 0000000..b42e5e3 Binary files /dev/null and b/assets/tilesetNew2.png differ diff --git a/src/Case.cpp b/src/Case.cpp new file mode 100755 index 0000000..84d3a13 --- /dev/null +++ b/src/Case.cpp @@ -0,0 +1,59 @@ +#include "Case.h" + +#include +#include +#include + +#include +#include + +#define TILE_WIDTH 30 +#define TILE_HEIGHT 30 + +using namespace sf; + +Case::Case() +{ + //ctor +} + +Case::Case(sf::RenderWindow* window, float x, float y) +{ + m_positionX=x; + m_positionY=y; + m_value=0; + m_statut=false; + m_window=window; + +} + +void Case::Settexture(std::string name) +{ + if(!m_texture.loadFromFile(name.c_str())){std::cout<<"|!|Texture loading failed :" << name << std::endl;} + m_sprite.setTexture(m_texture); + m_sprite.setTextureRect(IntRect(m_value*(TILE_WIDTH+1),0,TILE_WIDTH, TILE_HEIGHT)); + std::cout<< "0) Texture loaded "<draw(m_sprite); + +} + +void Case::drawFree(int whichOneX,int whichOneY,float x, float y) +{ + {m_sprite.setTextureRect(IntRect(whichOneX*(TILE_WIDTH+1),whichOneY*(TILE_HEIGHT+1),TILE_WIDTH, TILE_HEIGHT));} + + m_sprite.setPosition(x,y); + m_window->draw(m_sprite); + +} + +Case::~Case() +{ + //dtor +} diff --git a/src/Case.h b/src/Case.h new file mode 100755 index 0000000..067fec1 --- /dev/null +++ b/src/Case.h @@ -0,0 +1,49 @@ +#ifndef CASE_H +#define CASE_H + +#include +#include +#include + +#include + +class Case +{ + public: + Case(); + Case(sf::RenderWindow* window, float x=0, float y=0); + virtual ~Case(); + + float GetpositionX() { return m_positionX; } + void SetpositionX(float val) { m_positionX = val; } + + float GetpositionY() { return m_positionY; } + void SetpositionY(float val) { m_positionY = val; } + void Setposition(float x, float y){m_positionX=x;m_positionY=y;} + + int Getvalue(){return m_value;} + + sf::RenderWindow* Getwindow() { return m_window; } + void Setwindow(sf::RenderWindow* val) { m_window = val; } + + sf::Texture Gettexture() { return m_texture; } + void Settexture(std::string name) ; + + sf::Sprite Getsprite() { return m_sprite; } + void Setsprite(sf::Sprite val) { m_sprite = val; } + /// /// /// /// /// + void draw(int whichOneX,int whichOneY,int x, int y); + void drawFree(int whichOneX,int whichOneY,float x, float y); + bool ifClicked(); + + protected: + float m_positionX; + float m_positionY; + int m_value; + bool m_statut; + sf::RenderWindow* m_window; + sf::Texture m_texture; + sf::Sprite m_sprite; +}; + +#endif // CASE_H diff --git a/src/Hero.cpp b/src/Hero.cpp new file mode 100755 index 0000000..fa733d6 --- /dev/null +++ b/src/Hero.cpp @@ -0,0 +1,193 @@ +#include "Hero.h" + + +#include "Case.h" +#include "Level.h" +#include "Kraken.h" + +#include +#include +#include + +#include +#include +#include + +#define TILE_WIDTH 30 +#define TILE_HEIGHT 30 + +Hero::Hero(Kraken* kraken, float pozX, float pozY) +{ + m_speedX=0; + m_speedY=0; + m_pozX=pozX; + m_pozY=pozY; + m_attacking=false; + m_start.x=pozX; + m_start.y=pozY; + m_statut=1; + m_kraken=kraken; + hidden=false; + circle.setRadius(0); + circle.setPosition(m_pozX,m_pozY); + test=0; + m_dead=false; + m_clock.restart(); + hasAttacked=false; + + + //ctor +} + +void Hero::die() +{ + m_dead=true; + + +} + +bool Hero::attack() +{ + sf::Time time; + time=m_clock.getElapsedTime(); + + if(time.asSeconds()<=0.3) + { + time=m_clock.getElapsedTime(); + int coinH(0), coinV(0); + if(m_statut==0){m_speedX=0.5;} + if(m_statut==1){m_speedX=-0.5;} + if(m_statut==2){m_speedY=-0.5;} + if(m_statut==3){m_speedY=0.5;} + + + if(m_speedX>0){coinH=m_pozX+TILE_WIDTH+m_speedX;} + else if (m_speedX<0) {coinH=m_pozX+m_speedX; } + else if(m_speedX==0) {coinH=m_pozX+TILE_WIDTH/2;} + + if(m_speedY>0){coinV=m_pozY+TILE_HEIGHT+m_speedY;} + else if (m_speedY<0) {coinV=m_pozY+m_speedY;} + else if (m_speedY==0) {coinV=m_pozY+2*TILE_HEIGHT/3;} + + if (next(coinH,coinV)==3 || next(coinH,coinV)==5 ) {die();} + justMove(); + if(m_pozX>=m_kraken->Gethead().getPosition().x - TILE_WIDTH && m_pozX<=m_kraken->Gethead().getPosition().x +3*TILE_WIDTH && m_pozY<=m_kraken->Gethead().getPosition().y+3*TILE_HEIGHT && m_pozY>=m_kraken->Gethead().getPosition().y && hasAttacked==false){m_kraken->Damaged(); hasAttacked=true;} + } + else {m_speedX=0;m_speedY=0; + m_attacking=false;hasAttacked=false;} + +} + + +void Hero::Settexture(std::string name) +{ + if(!m_texture.loadFromFile(name.c_str())){std::cout<<"Echec chargement texture Hero"<0 && m_speedY==0){m_statut=0;} + if(m_speedX<0 && m_speedY==0){m_statut=1;} + if(m_speedY>0 && m_speedX==0){m_statut=3;} + if(m_speedY<0 && m_speedX==0){m_statut=2;} + /// + + ///Draw the hero + if(hidden==false) + { + m_sprite.setTextureRect(sf::IntRect(6*(TILE_WIDTH+1)+m_statut*(TILE_WIDTH+1),0,TILE_WIDTH,TILE_HEIGHT)); + m_sprite.setPosition(m_pozX,m_pozY); + m_kraken->Getlevel()->Getcase()->Getwindow()->draw(m_sprite); + } + + ///LIFE + if (m_color==2){m_sprite.setColor(sf::Color::Green);} + else if (m_color==3){m_sprite.setColor(sf::Color::Red);} + + ///DEAD + if (m_dead) + { +// m_kraken->restart(); + //circle.setFillColor(sf::Color::Red); + test=0; + sf::Texture Texplosion; + if(!Texplosion.loadFromFile("explosion.jpg")){std::cout<<"Error loading texture explosion"<Getlevel()->Getcase()->Getwindow()->draw(circle); + m_kraken->Getlevel()->Getcase()->Getwindow()->display(); + // for(int j(0);j<1000;j+=0.1){} + } + SetpozX(m_start.x); + SetpozY(m_start.y); + m_attacking=false; + m_dead=false; + m_speedX=0; + m_speedY=0; + } + +} + +void Hero::justMove() +{ + if(next(m_pozX+TILE_WIDTH+m_speedX,m_pozY+2*TILE_HEIGHT/3+m_speedY)==5){m_speedX=0;} ///RIGHT + if(next(m_pozX+m_speedX,m_pozY+2*TILE_HEIGHT/3+m_speedY)==5){m_speedX=0;} ///LEFT + if(next(m_pozX+m_speedX+TILE_WIDTH/2, m_pozY+2*TILE_HEIGHT/3+m_speedY)==5){m_speedY=0;} ///UP & DOWN + + if(m_kraken->Getlevel()->getCoord(convertCoordX(m_pozX+TILE_WIDTH/2),convertCoordY(m_pozY+2*TILE_HEIGHT/3))=='4') + { + + + + for(int i(0);i<100;i++) + { + m_speedX=0; m_speedY=0; + m_statut=i%4; + m_sprite.setTextureRect(sf::IntRect(6*(TILE_WIDTH+1)+m_statut*(TILE_WIDTH+1),0,TILE_WIDTH,TILE_HEIGHT)); + m_kraken->Getlevel()->Getcase()->Getwindow()->draw(m_sprite); + m_kraken->Getlevel()->Getcase()->Getwindow()->display();} + + + + + SetpozY(m_kraken->Getlevel()->findAnother2('4').first*TILE_WIDTH); + SetpozX(m_kraken->Getlevel()->findAnother2('4').second*TILE_HEIGHT); +} + + m_pozX+=m_speedX; + m_pozY+=m_speedY; + +} + +void Hero::update() +{ + if (m_attacking && m_dead==false){attack();} + else if(m_attacking==false){justMove();} + + if(m_kraken->getcounter()==2 && hidden==false){if(m_kraken->isThereCollision(convertCoordX(m_pozX+TILE_WIDTH/2),convertCoordY(m_pozY+TILE_HEIGHT/2))){ + m_dead=true; m_kraken->setVector(std::vector(10,10)); + }} + + if(next(m_pozX+TILE_WIDTH/2,m_pozY+TILE_HEIGHT/2)==3){ + m_sprite.setTextureRect(sf::IntRect(11*(TILE_WIDTH+1),0,TILE_WIDTH,TILE_HEIGHT)); + m_sprite.setPosition(m_pozX,m_pozY); + m_kraken->Getlevel()->Getcase()->draw(0,6,convertCoordX(m_pozX+TILE_WIDTH/2),convertCoordY(m_pozY+TILE_HEIGHT/2)); + hidden=true;} + else if (next(m_pozX,m_pozY)!=3) {draw();hidden=false;} + +} + +Hero::~Hero() +{ + //dtor +} diff --git a/src/Hero.h b/src/Hero.h new file mode 100755 index 0000000..294acd1 --- /dev/null +++ b/src/Hero.h @@ -0,0 +1,86 @@ +#ifndef HERO_H +#define HERO_H + +#include "Case.h" +#include "Level.h" +#include "Kraken.h" + +#include +#include +#include + +#include +#include + +#define TILE_WIDTH 30 +#define TILE_HEIGHT 30 + + +class Hero +{ + public: + Hero(Kraken* kraken, float pozX, float pozY); + virtual ~Hero(); + + float GetspeedX() { return m_speedX; } + void SetspeedX(float val) { m_speedX = val; } + + float GetspeedY() { return m_speedY; } + void SetspeedY(float val) { m_speedY = val; } + + float GetpozX() { return m_pozX; } + void SetpozX(float val) { m_pozX = val; } + + float GetpozY() { return m_pozY; } + void SetpozY(float val) { m_pozY = val; } + + bool Getattacking() { return m_attacking; } + void Setattacking(bool val) { m_attacking = val; } + + sf::Vector2f Getstart() { return m_start; } + void Setstart(sf::Vector2f val) { m_start = val; } + + sf::Texture Gettexture() { return m_texture; } + void Settexture(std::string name); + + sf::Sprite Getsprite() { return m_sprite; } + void Setsprite(sf::Sprite val) { m_sprite = val; } + + int Getstatut() { return m_statut; } + void Setstatut(int val) { m_statut = val; } + /// // /// /// // /// // /// // /// + void draw(); + void update(); + bool attack(); + void justMove(); + void die(); + int convertCoordX(float a) {return int(a/TILE_WIDTH);} + int convertCoordY(float a) {return int(a/TILE_HEIGHT);} + int next(float a, float b){return m_kraken->Getlevel()->getCoord(convertCoordX(a),convertCoordY(b))-'0';} + void restartClock() {m_clock.restart();} + void setAttacking(bool val){m_attacking=val;} + bool isDead() {return m_dead;} + + + protected: + float m_speedX; + float m_speedY; + float m_pozX; + float m_pozY; + bool m_attacking; + bool hasAttacked; + bool underWater; + sf::Vector2f m_start; + sf::Texture m_texture; + sf::Sprite m_sprite; + int m_statut; + Kraken* m_kraken; + bool hidden; + bool m_dead; + int m_color; + sf::CircleShape circle; + float test; + sf::Clock m_clock; +}; + +#endif // HERO_H diff --git a/src/Kraken.cpp b/src/Kraken.cpp new file mode 100755 index 0000000..b67d647 --- /dev/null +++ b/src/Kraken.cpp @@ -0,0 +1,214 @@ +#include "Kraken.h" + +#include +#include +#include + +#include "Case.h" +#include "Level.h" +#include "Kraken.h" +#include "Hero.h" + +#include +#include +#include + +#define TILE_WIDTH 30 +#define TILE_HEIGHT 30 + +Kraken::Kraken(Level* level,int width, int height, int numberTenta) +{ + m_level=level; + m_clock.restart(); + m_tentacleClock.restart(); + m_maxX=width; + m_maxY=height; + pozX=rand()%(m_maxX-3)*TILE_WIDTH+1; + pozY=rand()%(m_maxY-6)*TILE_HEIGHT+1; + m_head.setPosition(pozX,pozY); + m_counter=0; + m_life=5; + m_damaged=false; + m_dead=false; + m_numberTenta=numberTenta; + m_coords=std::vector(10,0); + m_temp.restart(); + rapidity=1; + + +} + + +void Kraken::Settexture(std::string name) +{ + if(!m_texture.loadFromFile(name)){std::cout<<"Echec de l'ouverture texture Kraken" << std::endl;} + m_head.setTexture(m_texture); + m_tentacle.setTexture(m_texture); + + ///Head + +} + +void Kraken::drawTheHead(int a) +{ + m_head.setTextureRect(sf::IntRect(a*2*(1+TILE_WIDTH),TILE_HEIGHT,TILE_WIDTH*2, TILE_HEIGHT*3)); + // m_head.setPosition(x*TILE_WIDTH,y*TILE_HEIGHT); + m_level->Getcase()->Getwindow()->draw(m_head); + int x= int(m_head.getPosition().x/TILE_WIDTH); + int y=int(m_head.getPosition().y/TILE_HEIGHT); + + for (int i(x-1);i<=x+2;i++) + { + for(int j(y-1);j<=y+3;j++) + { + m_level->setCoordCase(i,j,'5'); + } + } + m_level->setCoordCase(x,y+3,'2'); + m_level->setCoordCase(x+1,y+3,'2'); + + m_level->setCoordCase(x-2,y+4,'1'); + m_level->setCoordCase(x-1,y+4,'1'); + m_level->setCoordCase(x,y+4,'1'); + m_level->setCoordCase(x+1,y+4,'1'); + m_level->setCoordCase(x+2,y+4,'1'); + m_level->setCoordCase(x+3,y+4,'1'); + + + +} + +void Kraken::placeTheHeadAnywhere() +{ + { + pozX=rand()%(m_maxX-3)*TILE_WIDTH+3; + pozY=rand()%(m_maxY-6)*TILE_HEIGHT+1; + m_head.setPosition(pozX,pozY);} +} + + +void Kraken::drawATentacle() +{ + + + m_tentacleTime=m_tentacleClock.getElapsedTime(); + int counteur; + bool pick(false), ended(true); + ///Go + if(m_tentacleTime.asMilliseconds()%2000<=50 && m_tentacleTime.asMilliseconds()%2000>=25){pick=true; ended=false;} + else if(m_tentacleTime.asMilliseconds()%2000<=100*rapidity && m_tentacleTime.asMilliseconds()%2000>=50){counteur=0;ended=false;} + else if(m_tentacleTime.asMilliseconds()%2000<=200*rapidity){counteur=1;ended=false;} + else if(m_tentacleTime.asMilliseconds()%2000<=300*rapidity){counteur=2;ended=false;} + else if(m_tentacleTime.asMilliseconds()%2000<=400*rapidity){counteur=3;ended=false;} + else if(m_tentacleTime.asMilliseconds()%2000<=500*rapidity){counteur=4;ended=false;} + else if(m_tentacleTime.asMilliseconds()%2000<=600*rapidity){counteur=5;ended=false;} + else if(m_tentacleTime.asMilliseconds()%2000<=700*rapidity){counteur=6;ended=false;} + else if(m_tentacleTime.asMilliseconds()%2000<=800*rapidity){counteur=7;ended=false;} + else if(m_tentacleTime.asMilliseconds()%2000<=900*rapidity){counteur=8;ended=false;} + else if(m_tentacleTime.asMilliseconds()%2000<=1000*rapidity){counteur=9;ended=false;} + ///Back + else if(m_tentacleTime.asMilliseconds()%2000<=1100*rapidity){counteur=8;ended=false;} + else if(m_tentacleTime.asMilliseconds()%2000<=1200*rapidity){counteur=7;ended=false;} + else if(m_tentacleTime.asMilliseconds()%2000<=1300*rapidity){counteur=6;ended=false;} + else if(m_tentacleTime.asMilliseconds()%2000<=1400*rapidity){counteur=5;ended=false;} + else if(m_tentacleTime.asMilliseconds()%2000<=1500*rapidity){counteur=4;ended=false;} + else if(m_tentacleTime.asMilliseconds()%2000<=1600*rapidity){counteur=3;ended=false;} + else if(m_tentacleTime.asMilliseconds()%2000<=1700*rapidity){counteur=2;ended=false;} + else if(m_tentacleTime.asMilliseconds()%2000<=1800*rapidity){counteur=1;ended=false;} + else if(m_tentacleTime.asMilliseconds()%2000<=1900*rapidity){counteur=0;ended=false;} + else if(m_tentacleTime.asMilliseconds()%2000<=1999*rapidity){counteur=0;ended=true;} + else {m_tentacleClock.restart();} + + if(pick){ + + m_coords.erase(m_coords.begin(),m_coords.end()); + setNumberTenta(rand()%6+1); + + for(int i(0);i<2*m_numberTenta-1;i+=2){ + + + m_coords.push_back(abs(pickX())); + m_coords.push_back(abs(pickY())); + } + } + + + + m_tentacle.setTextureRect(sf::IntRect(counteur*(TILE_WIDTH+1),4*(TILE_HEIGHT+2),TILE_WIDTH, TILE_HEIGHT*2)); + for(int i(0);iGetcase()->Getwindow()->draw(m_tentacle);} + +if (ended){for(int i(0); i2000) {m_counter=3;m_damaged=false; m_life-=1; if(m_life<=0){m_counter=4;} placeTheHeadAnywhere(); m_damaged=false; } + //rapidity-=0.17; + + + + + } + /// + + ///DEAD + if(isDead()){m_counter=4;} + /// + + if(m_counter==2){drawATentacle();} + + + drawTheHead(m_counter); + + ///TENTACLE + +} + + + + +Kraken::~Kraken() +{ + //dtor +} diff --git a/src/Kraken.h b/src/Kraken.h new file mode 100755 index 0000000..f5c0490 --- /dev/null +++ b/src/Kraken.h @@ -0,0 +1,95 @@ +#ifndef KRAKEN_H +#define KRAKEN_H + +#include "Case.h" +#include "Level.h" +#include "Kraken.h" + +#include +#include +#include + +#include +#include +#include + +#define TILE_WIDTH 30 +#define TILE_HEIGHT 30 + +class Kraken +{ + public: + Kraken(Level* level, int width=50, int height=50, int numberTenta=0); + virtual ~Kraken(); + + Level* Getlevel() { return m_level; } + void Setlevel(Level* val) { m_level = val; } + + sf::Texture Gettexture() { return m_texture; } + void Settexture(std::string name); + + sf::Sprite Gethead() { return m_head; } + void Sethead(sf::Sprite val) { m_head = val; } + + sf::Sprite Gettentacle() { return m_tentacle; } + void Settentacle(sf::Sprite val) { m_tentacle = val; } + + int getcounter(){return m_counter;} + sf::Vector2f getposition(){return sf::Vector2f(pozX,pozY);} + + std::vector Gettab() { return m_tab; } + void Settab(std::vector val) { m_tab = val; } + + void placeTheHeadAnywhere(); + + void setNumberTenta(int a){m_numberTenta=a;} + + + /// /// /// /// /// // /// /// /// /// + void setCoord(float x, float y){m_heroCoordX=x; m_heroCoordY=y;} + void drawTheHead(int a=0); + void drawATentacle(); + void update(); + bool isThereCollision(int x, int y); + void setVector(std::vector tab){m_coords=tab;} + const bool isDamaged(){return m_damaged;} + void Damaged(){ m_temp.restart(); m_damaged=true;} + bool isAttacking() {if (m_counter==2) return true; return false;} + + const bool isDead(){if(m_life==0){return true;} else {return false;}} + void setDead(bool val){m_dead=val;} + int pickX(){return rand()%10+int(m_heroCoordX/TILE_WIDTH)-5;} + int pickY(){return rand()%10+int(m_heroCoordY/TILE_HEIGHT)-5;} + // void restart() {m_clock.restart();} + + + + + + protected: + float m_heroCoordX; + float m_heroCoordY; + int pozY; + int pozX; + Level* m_level; + sf::Clock m_clock; + sf::Clock m_tentacleClock; + sf::Clock m_temp; + sf::Time m_tentacleTime; + sf::Texture m_texture; + sf::Sprite m_head; + sf::Sprite m_tentacle; + sf::Time m_time; + std::vector m_tab; + int m_maxX; + int m_maxY; + int m_counter; + int m_life; + int m_numberTenta; + bool m_damaged; + bool m_dead; + float rapidity; + std::vector m_coords; +}; + +#endif // KRAKEN_H diff --git a/src/Level.cpp b/src/Level.cpp new file mode 100755 index 0000000..ede4fc0 --- /dev/null +++ b/src/Level.cpp @@ -0,0 +1,107 @@ +#include "Level.h" +#include "Case.h" + +#include +#include +#include + +#include +#include +#include + +using namespace sf; + +Level::Level(Case* aCase, int width, int height) +{ + m_width=width; + m_height=height; + m_case=aCase; + srand(time(NULL)); + +} + +char Level::findAnother(char val) +{ + + int x(0),y(0); + while (m_tab[y][x]!=val) + { + x=rand()%(m_width+1), y=rand()%(m_height+1); + } + return m_tab[y][x]; + + +} + +std::pair Level::findAnother2(char val) +{ + + int x(0),y(0); + while (m_tab[y][x]!=val) + { + x=rand()%(m_width+1), y=rand()%(m_height+1); + } + return std::pair (x,y); + + +} + +void Level::create() +{ + std::string line; + for(int i(0);idraw(m_tab[i][j]-'0',0,i,j); + } + } +} + +const void Level::show() +{ + for(int i(0);i +#include +#include + +#include "Case.h" + +#include +#include + +class Level +{ + public: + Level(Case* aCase, int width=20, int height=20); + virtual ~Level(); + + int Getwidth() { return m_width; } + void Setwidth(int val) { m_width = val; } + + int Getheight() { return m_height; } + void Setheight(int val) { m_height = val; } + + Case* Getcase() { return m_case; } + void Setcase(Case* val) { m_case = val; } + /// /// /// /// /// /// /// /// /// /// /// /// /// + void setCoordCase(int x, int y, char val) {m_tab[x][y]=val;} + char getCoord(int x, int y){ return m_tab[x][y];} + char findAnother(char val) ; + std::pair findAnother2(char val); + void create(); + const void show(); + const void draw(); + + protected: + + int m_width; + int m_height; + std::vector m_tab; + Case* m_case; +}; + +#endif // LEVEL_H diff --git a/src/main.cpp b/src/main.cpp new file mode 100755 index 0000000..fc6bc09 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,161 @@ +#include +#include +#include +#include + +#include +#include + +#include "Case.h" +#include "Level.h" +#include "Kraken.h" +#include "Hero.h" + +#define TILE_WIDTH 30 +#define TILE_HEIGHT 30 +#define ASSETS_PATH "../assets/" +using namespace sf; + + + +void funct(std::string name) +{ + SoundBuffer Ssound; + if(!Ssound.loadFromFile(name.c_str())){std::cout<<"bug music (loading)"<