Consertando bug de pulo duplo, removendo controle teclado que nao era mais usado...
[Projeto-PCG.git] / mapa.cpp
blobdb3ed1c9262d7e9efae5e5451f3165cbc9b33888
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) {
28 Linha l(xmin, ymin, xmax, ymax);
29 Platform *plat = new Platform(l, pass);
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();