void MapEditor::addatcsr(int c) {
    MapObjectType tmp;
    switch (c) {
        case 'w':
            tmp = WALL; 
            break;
        case 'p':
            tmp = PLAYER;
            // remove the old player
            for (int i = 0; i < STD_Y; i++) {
                for (int j = 0; j < STD_X; j++) {
                    if ((pmap->getAtLocation(i, j))->mapObjectType == PLAYER)
                        pmap->setAtLocation(i, j, MapObject(i, j, EMPTY));
                }
            }
            break;
        case 'e':
            tmp = ENTRANCE;
            // remove the old door
            for (int i = 0; i < STD_Y; i++) {
                for (int j = 0; j < STD_X; j++) {
                    if ((pmap->getAtLocation(i, j))->mapObjectType == ENTRANCE)
                        pmap->setAtLocation(i, j, MapObject(i, j, EMPTY));
                }
            }
            break;
        case 'x':
            tmp = EXIT;
            // remove the old exit
            for (int i = 0; i < STD_Y; i++) {
                for (int j = 0; j < STD_X; j++) {
                    if ((pmap->getAtLocation(i, j))->mapObjectType == EXIT)
                        pmap->setAtLocation(i, j, MapObject(i, j, EMPTY));
                }
            }
            break;
        case 'c':
            tmp = TREASURE_CHEST;
            break;
        case 'm':
            tmp = MONSTER;
            break;
        case 'r':
            tmp = EMPTY;
            break;
        case 't':
            tmp = MERCHANT;
            break;
        default:
            tmp = EMPTY;
            break;
    }
    pmap->setAtLocation(csr->y, csr->x, MapObject(csr->y, csr->x, tmp));
    refreshmap();
}
Example #2
0
void ObjectsLayer::addObject(const std::string &name, const int type,
                             const unsigned x, const unsigned y,
                             unsigned dx, unsigned dy)
{
    if (!mTiles)
        return;

    if (x + dx > mWidth)
        dx = mWidth - x;
    if (y + dy > mHeight)
        dy = mHeight - y;

    for (unsigned y1 = y; y1 < y + dy; y1 ++)
    {
        const unsigned idx1 = x + y1 * mWidth;
        const unsigned idx2 = idx1 + dx;

        for (unsigned i = idx1; i < idx2; i ++)
        {
            if (!mTiles[i])
                mTiles[i] = new MapObjectList();
            mTiles[i]->objects.push_back(MapObject(type, name));
        }
    }
}
void MapEditor::autowall() {
    int y1 = csr->y;
    int x1 = csr->x;
    int y2, x2, c;
    
    printwdlg("auto wall mode on, press 'a' again to confirm wall location");
    
    while ((c = getch()) != 'a') {
        // allow cursor movement
        switch (c) {
            case KEY_LEFT:
            case KEY_RIGHT:
            case KEY_UP:
            case KEY_DOWN:
                refreshmap();
                mvcsr(c);
                y2 = csr->y;
                x2 = csr->x;
                // create walls preview
                for (int i = y1; i <= y2; i++) {
                    mvwprintw(stdscr, i, x1, "#");
                    mvwprintw(stdscr, i, x2, "#");
                }
                for (int i = x1; i <= x2; i++) {
                    mvwprintw(stdscr, y1, i, "#");
                    mvwprintw(stdscr, y2, i, "#");
                }
                refresh();
                break;
            default:
                printwdlg("error: only arrow keys are accepted");
                break;
        }
    }
    // confirm placement of the walls
    // destroying all previous data's
    for (int i = y1; i <= y2; i++) {
        pmap->setAtLocation(i, x1, MapObject(i, x1, WALL));
        pmap->setAtLocation(i, x2, MapObject(i, x1, WALL));
    }            
    for (int i = x1; i <= x2; i++) {
        pmap->setAtLocation(y1, i, MapObject(y1, i, WALL));
        pmap->setAtLocation(y2, i, MapObject(y2, i, WALL));
    }
    refreshmap();
    printwdlg("auto wall mode completed");
}
FArchive& FLinkerSave::operator<<( UObject*& Obj )
{
	FPackageIndex Save;
	if (Obj)
	{
		Save = MapObject(Obj);
	}
	return *this << Save;
}
Example #5
0
void Map::createStatics()
{
	std::string path("Levels/");
	path += _campaign;
	path += "/";
	path += _level;
	path += "/statics.dat";

	std::ifstream file(path, std::ifstream::in);

	if (file.good() && file.peek() != file.eof()){
		while (!file.eof()){
			int t_sizeX = 0,
				t_sizeY = 0,
				t_posX = 0,
				t_posY = 0,
				t_aSizeX = 0,
				t_aSizeY = 0,
				t_startX = 0,
				t_startY = 0,
				t_interval = 60,
				t_frames = 1;
			unsigned int t_data = 0;

			float t_bBoxModX = 0, t_bBoxModY = 0;
			bool hasPhys = true, t_loop = false;
			std::string t_textureDir;

			file >> t_sizeX;
			file >> t_sizeY;
			file >> t_posX;
			file >> t_posY;
			file >> t_bBoxModX;
			file >> t_bBoxModY;
			file >> t_textureDir;
			file >> hasPhys;

			if (file.peek() != '\n'){
				file >> t_aSizeX;
				file >> t_aSizeY;
				file >> t_startX;
				file >> t_startY;
				file >> t_interval;
				file >> t_frames;
				if (file.peek() != '\n'){
					file >> t_data;
					file >> t_loop;
				}
			}

			_mapObject.emplace_back(MapObject());
			_mapObject.back().load(_world, t_sizeX, t_sizeY, t_posX, t_posY, hasPhys, t_textureDir, _esettings->smoothTextures, t_aSizeX, t_aSizeY, t_startX, t_startY, t_interval, t_frames, t_bBoxModX, t_bBoxModY);
			_mapObject.back()._trigData = t_data;
			_mapObject.back()._loop = t_loop;
		}
Example #6
0
int main ()
{


	struct
	{
		int screenWidth;
		int screenHeight;
		bool fullScreen;

	} screenSettings;

	screenSettings.screenWidth = 800;
	screenSettings.screenHeight = 600;
	screenSettings.fullScreen = false;

	sf::RenderWindow screen;
	sf::Music music;

	if (screenSettings.fullScreen)
	{
		screen.create(sf::VideoMode(screenSettings.screenWidth, screenSettings.screenHeight, 32), "Test Window", sf::Style::Fullscreen);
	}
	else
	{
		screen.create(sf::VideoMode(screenSettings.screenWidth, screenSettings.screenHeight, 32), "Test Fullscreen Window");
	}
	screen.setFramerateLimit(30);

	//sf::Texture texture;
	//texture.loadFromFile("img/testjpg.jpg");
	//sf::Sprite sprite(texture);


	sf::Font font;
	font.loadFromFile("font/Amano.ttf");
	sf::Text text("holy shit, text!", font, 50);
	text.setPosition(0,400);

	ScreenObject guiFrame(550, 0, 250, 600);
	guiFrame.loadTexture("img/sideGuiBackground.gif");

	music.openFromFile("music/Minima.ogg"); //From incompetech
	music.setLoop(true);
	//music.play();
	
	//DungeonLevel testLevel;

	GameWorld * game;
	std::cout << "&game is: " << &game << '\n';
	game = new GameWorld();
	//update loop
	MapObject testSquare;
	testSquare = MapObject(1,1,0,0,0);
	/*while (true)
	{
		screen.clear();
		testSquare.drawSelf(&screen);
		screen.display();
	}*/

	int code;
	
	std::cout << "Screen adress in main: " << &screen << '\n';
	
	code = game->gameLoop(&screen);

	if (1 == code)
	{
		std::cout << "successful exit";
	}
		

	//	testLevel.drawDungeon(&screen);

	//	screen.draw(sprite);

	//	screen.draw(text);

		
	
	return 0;

}
Example #7
0
WorldMap::WorldMap() : MAP_SIZE(20,20), MAP_DIMS(MAP_SIZE.x*MapObject::OBJECT_SIZE.x,MAP_SIZE.y*MapObject::OBJECT_SIZE.y)
{
	for (int row=0; row<MAP_SIZE.y; ++row)
	{
		std::vector<std::pair<sf::Vector2f, MapObject> > rowVec;
		for (int col=0; col<MAP_SIZE.x; ++col)
		{
			rowVec.emplace_back(sf::Vector2f(MapObject::OBJECT_SIZE.x*(col + .5f), MapObject::OBJECT_SIZE.y*(row + .5f)), MapObject(MapObject::ObjectType::wall));
			rowVec[col].second.SetPosition(rowVec[col].first);
		}
		mapGrid.push_back(rowVec);
	}
}