C++ SDL TileMap System ERRORS! HELP! :P
Posted: Sun May 01, 2011 2:44 am
UPDATED!
Basically I'm working on a 2D Game Engine using SDL as the backend and C++ as the frontend.
But I'm getting some irritating errors with my TileMap system.
Tile.hpp:
Tile.cpp:
Map.hpp:
Map.cpp:
Errors:
It's really late here and I'm too tired to try and work this out.
All help greatly appreciated as usual.
Basically I'm working on a 2D Game Engine using SDL as the backend and C++ as the frontend.
But I'm getting some irritating errors with my TileMap system.
Tile.hpp:
Code: Select all
#ifndef TILE_HPP
#define TILE_HPP
#include <iostream>
#include "SDL\SDL.h"
#include "Windows.h"
#include "Globals.hpp"
#include "Sprite.cpp"
using namespace std;
class Tile{
public:
Tile();
Tile(int id2,int x,int y);
//destructor needed
void tileFile(int id);
Sprite *sprite;
int id;
};
#endif
Code: Select all
#ifndef TILE_CPP
#define TILE_CPP
#include "Tile.hpp"
void Tile::TileFile(int id){
sprite->file=("Tiles\\"+id+".bmp").str();
}
Tile::Tile(){
id=0;
TileFile(id);
sprite->offset.x=0;
sprite->offset.y=0;
sprite->visible=true;
}
Tile::Tile(int id2,int x,int y){
id=id2;
TileFile(id);
sprite->offset.x=x;
sprite->offset.y=y;
sprite->visible=true;
}
#endif
Code: Select all
#ifndef MAP_HPP
#define MAP_HPP
#include <iostream>
#include "SDL\SDL.h"
#include "Windows.h"
#include "Globals.hpp"
#include "Tile.hpp"
using namespace std;
class Map{
public:
Map(int tileIds2[TILE_TOTAL]);
~Map();
Tile *tiles[TILE_TOTAL];
void drawAll(SDL_Surface *screen);
};
#endif
Code: Select all
#ifndef MAP_CPP
#define MAP_CPP
#include "Map.hpp"
Map::Map(int tileIds2[TILE_TOTAL]){
int x=0;
int y=0;
for(int i=0;i<TILE_TOTAL;i++){
if(x==649){
x=0;
y+=TILE_HPPEIGHT;
tiles[i]->id=tileIds2[i];
tiles[i]->sprite->offset.x=x;
tiles[i]->sprite->offset.y=y;
tiles[i]->tileFile(tiles[i]->id);
x++;
}else{
x+=TILE_WIDTH;
tiles[i]->id=tileIds2[i];
tiles[i]->sprite->offset.x=x;
tiles[i]->sprite->offset.y=y;
tiles[i]->tileFile(tiles[i]->id);
x++;
}
}
}
Map::~Map(){
delete[] tiles;
delete this;
}
void Map::drawAll(SDL_Surface *screen){
for(int i=0;i<TILE_TOTAL;i++){
tiles[i]->sprite->draw(screen);
}
}
#endif
Errors:
Code: Select all
In file included from src\Main.hpp:11,
from src\Main.cpp:1:
src\Tile.cpp:5: error: no `void Tile::TileFile(int)' member function declared in
class `Tile'
src\Tile.cpp: In member function `void Tile::TileFile(int)':
src\Tile.cpp:6: error: invalid operands of types `const char*' and `const char[5
]' to binary `operator+'
src\Tile.cpp: In constructor `Tile::Tile()':
src\Tile.cpp:10: error: `TileFile' was not declared in this scope
src\Tile.cpp: In constructor `Tile::Tile(int, int, int)':
src\Tile.cpp:17: error: `TileFile' was not declared in this scope
All help greatly appreciated as usual.