Changeset 62ee2ce in network-game for common/WorldMap.cpp


Ignore:
Timestamp:
Feb 5, 2013, 7:02:32 PM (12 years ago)
Author:
dportnoy <dmp1488@…>
Branches:
master
Children:
384b7e0, 60017fc
Parents:
60b77d2
Message:

The client shows the map and converts between screen and map coordinates

File:
1 moved

Legend:

Unmodified
Added
Removed
  • common/WorldMap.cpp

    r60b77d2 r62ee2ce  
    1 #include "Map.h"
     1#include "WorldMap.h"
    22
    33using namespace std;
    44
    5 Map::Map(int width, int height)
     5WorldMap::WorldMap(int width, int height)
    66{
    77   this->width = width;
     
    2020}
    2121
    22 Map::~Map()
     22WorldMap::~WorldMap()
    2323{
    2424   for (int x=0; x<width; x++)
     
    2828}
    2929
    30 void Map::setElement(int x, int y, TerrainType t)
     30WorldMap::TerrainType WorldMap::getElement(int x, int y)
     31{
     32   return (*(*vctMap)[x])[y];
     33}
     34
     35void WorldMap::setElement(int x, int y, TerrainType t)
    3136{
    3237   (*(*vctMap)[x])[y] = t;
    3338}
    3439
    35 Map* Map::createDefaultMap()
     40WorldMap* WorldMap::createDefaultMap()
    3641{
    37    Map* m = new Map(20l, 20);
     42   WorldMap* m = new WorldMap(12l, 12);
    3843
    39    for(int x=0; x<20; x++)
     44   for(int x=0; x<12; x++)
    4045   {   
    41       for(int y=0; y<20; y++)
     46      for(int y=0; y<12; y++)
    4247      {
    43          if (x ==0 || y == 0 || x == 19 || y == 19)
     48         if (x ==0 || y == 0 || x == 11 || y == 11)
    4449            m->setElement(x, y, TERRAIN_OCEAN);
    4550         else
     
    4853   }
    4954
     55   m->setElement(5, 5, TERRAIN_ROCK);
     56
    5057   return m;
    5158}
Note: See TracChangeset for help on using the changeset viewer.