Chce zrobić coś al'a to http://www.youtube.com/watch?v=rJeY-iJZy1w&feature=related . Poruszanie (na WASD szukałem coś na temat strzałek ale mi nie wychodziło) już działa, zrobiłem na razie prostą klase rycerza i teraz Visual pokazuje mi parę błędów których znaczenia nie rozumiem. Oto kody:
rycerz.h
ruszanie.h
Gra //główny plik
A oto błędy
rycerz.h
#include <iostream>
#include <string>
using namespace std;
class rycerz
{
private:
string nick;
int zloto;
int hp;
public:
rycerz():zloto(400),hp(10) {}
void setNick(string n)
{
nick = n;
}
char getNick()
{
return nick;
}
int getHp()
{
return hp;
}
void addHp(int x)
{
hp+=x;
}
int getZloto()
{
return zloto;
}
void addZloto(int x)
{
zloto+=x;
}
};ruszanie.h
#include <iostream>
#include <windows.h>
#include <time.h>
#include <string>
#include <conio.h>
#include "rycerz.h"
using namespace std;
void plansza();
void ruszanie(int & x,int & y, rycerz soldier);
void gotoxy(int x, int y)
{
COORD cord;
cord.X = x;
cord.Y = y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), cord);
}
void ruszanie(int & x,int & y , rycerz soldier)
{
cout<<soldier.getNick()<<"\thp="<<soldier.getHp()<<"\tzloto="<<soldier.getZloto()<<endl;
cout<<endl;
cout<<"----------------------------------------------------------------\n";
cout<<endl;
int tempx=x,tempy=y;
char q,b=4;
q = getch();
cout<<"\b ";
gotoxy(0,0);
plansza();
if(q=='w')
{
y-=1;
gotoxy(x,y);
cout<<b;
}
if(q=='a')
{
x-=1;
gotoxy(x,y);
cout<<b;
}
if(q=='s')
{
y+=1;
gotoxy(x,y);
cout<<b;
}
if(q=='d')
{
x+=1;
gotoxy(x,y);
cout<<b;
}
if (q!='w'&& q!='a'&& q!='s'&& q!='d')
{
cout<<"\a";
}
if(x<=0||y<=0||x>27||y>12)
{
cout<<"\a";
x=tempx;
y=tempy;
cout<<"\b ";
gotoxy(x,y);
cout<<b;
}
}
void plansza()
{
cout<<"|--------------------------|\n";
cout<<"| |\n";
cout<<"| |\n";
cout<<"| |\n";
cout<<"| |\n";
cout<<"| |\n";
cout<<"| |\n";
cout<<"| |\n";
cout<<"| |\n";
cout<<"| |\n";
cout<<"| |\n";
cout<<"| |\n";
cout<<"|--------------------------|\n";
}Gra //główny plik
#include <iostream>
#include <string>
#include <conio.h>
#include "ruszanie.h"
#include "rycerz.h"
void c() {system("cls");}; //czyszczenie ekranu
using namespace std;
int main()
{
rycerz soldier;
int x=7,y=7;
string n;
cout<<"Podaj swoj nick:\n";
cin.getline(n,30);
soldier.setNick(n);
c();
for(int q = 0;q<100;q++)
ruszanie(x,y,soldier);
getchar();
getchar();
return 0;
}A oto błędy