Aloha all. I'm quite new to C++ programming.
I've been asked to make a demo app - a dungeon RPG with characters for graphics.
I decided to draw the map in notepad and use fstream in C++ to read from the file and draw the map. I will then draw the player into the world (as the letter 'x' to start with) and set the controls to the arrow keys to move the character around. The collision detection will work on detecting what type of character occupies the space you are trying to move to, | and _ for doors, # for walls and a space for open floor etc.
I've run into the problem of placing the player in the map:
I can't seem to attach the map file
#include <string> //This allows creation and manipulation of strings.
#include <fstream> //This allows opening and reading of files.
#include <process> //This allows the use of system("cls");
using namespace std;
//This is the function that will open the map file
//and draw it into the console
//Open the map file for reading
//Store each line of the file in a string to be displayed
//Read from the file until the end is reached
while (! mapfile.eof())
//Read each line and output it to the screen.
//This will loop through each line until there
//are no lines left to read.
cout << line << endl;
//Set the starting location of the player
//0,0 is at the top left of the map file.
//Positive X values move horizontally right,
//Positive Y values move vertically down.
int x = 15;
int y = 5;
//Location variables (link with initPlayer and controlPlayer)?
//int x, y;
//Clear the screen ready for the game
//Draw the map
//Position the player
As you can see, I've initialised two integers (x and y) to hold the co-ords of the start position but I cannot think of how to place a character at a position on the screen relating to these values. Any suggestions?