Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
asciiGame/main.cpp
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
77 lines (66 sloc)
1.66 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <ncurses.h> | |
#include <array> | |
#include <cstdlib> | |
#include "player.h" | |
#include <stdlib.h> | |
#include "mainMenu.h" | |
#include "enemy.h" | |
#include "terminalSize.h" | |
#include "collision.h" | |
#include "music_play.h" | |
// --^--\ | |
// | > | |
// --v--/ | |
using namespace std; | |
void encounter(WINDOW* win); | |
int main() | |
{ | |
initscr(); | |
noecho(); | |
cbreak(); | |
//compile with music_play.cpp on the command line aswell as -lsfml-audio and -pthread | |
createMusicThread(); | |
int ymax, xmax; | |
getxy(ymax, xmax); // Returns terminal size (max y and max x) | |
WINDOW* sea=mainMap(ymax, xmax); | |
if (startMenu()=="New Game") | |
{ | |
Island island1(10, 20, 10, 60); | |
island1.newIsland(); | |
Enemy enemy(sea, 13, 30, 'O'); | |
enemy.display(); | |
Player player(sea, 1, 1, '@'); | |
bool first=true; | |
if (first==true){ | |
for (int i=0; i<ymax-14;i++) | |
{ | |
player.mvright(); | |
player.mvdown(); | |
if (i==ymax-15) | |
first=false; | |
} | |
} | |
int n=1; | |
do { | |
island1.newIsland(); | |
if (collision(player, island1)==true) | |
{ | |
mvwprintw(sea, 1, 1, "%d", n); | |
n++; | |
} | |
if (enemy.get_y()==player.get_y() && enemy.get_x()==player.get_x()) | |
{ | |
encounter(sea); | |
} | |
player.display(); | |
refresh(); | |
} while(player.getmv()!='x'); | |
} | |
//getch(); | |
endwin(); | |
return 0; | |
} | |
void encounter(WINDOW* win) | |
{ | |
mvwprintw(win, 5, 8,"Enemy has been slain"); | |
} |