Agora ele olha pra frente deitado
[Projeto-PCG.git] / mapa.cpp
blobaf92f3bc51727199c68f5bcf76984e62c63adaa6
1 #include "mapa.h"
2 #include "maploader.h"
3 #include "weaponitem.h"
5 Mapa::Mapa(std::string name, Game* g) {
6 game = g;
7 MapLoader loader;
8 loader.load(name,this);
11 Mapa::~Mapa() {
12 std::list<Platform*>::iterator it;
13 for (it = platforms.begin(); it != platforms.end(); it++)
14 delete (*it);
15 game->removePlatforms();
18 void Mapa::setTamanho(double width, double height) {
19 tamanho.x = width;
20 tamanho.y = height;
23 void Mapa::setSpawn(Ponto spawn) {
24 game->setSpawn(spawn);
27 void Mapa::novaPlataforma(double xmin, double ymin, double xmax, double ymax, bool pass, double r, double g, double b) {
28 Linha l(xmin, ymin, xmax, ymax);
29 Platform *plat = new Platform(l, pass, r, g, b);
30 platforms.push_front(plat);
31 game->addPlatform(plat);
34 void Mapa::dropWeapon(std::string name, Ponto p) {
35 WeaponItem *a = game->dropWeapon(name);
36 a->setPosition(p.x, p.y);
37 items.push_front(a);
40 void Mapa::desenha() {
41 std::list<Platform*>::iterator itP;
42 for (itP = platforms.begin(); itP != platforms.end(); itP++)
43 (*itP)->desenha();
44 std::list<WeaponItem*>::iterator itW;
45 for (itW = items.begin(); itW != items.end(); itW++)
46 (*itW)->desenha();
49 double Mapa::xmax() {
50 return tamanho.x;
53 double Mapa::ymax() {
54 return tamanho.y;
57 void Mapa::move() {
58 std::list<WeaponItem*>::iterator it;
59 for (it = items.begin(); it != items.end(); it++)
60 (*it)->move();