예제 #1
0
// ********************************************************************************************** //
//                                                                                                //
// ********************************************************************************************** //
void classMap::drawMap()
{

	if (bg1_surface.width > 0 && game_data.stages[stage_number].maps[number].backgrounds[0].speed == 0.0) {
		for (int i=0; i<mapSurface.width/bg1_surface.width+1; i++) {
			graphLib.copyArea(st_position(i*bg1_surface.width, game_data.stages[stage_number].maps[number].backgrounds[0].adjust_y), &bg1_surface, &mapSurface);
		}
		bg1_surface.freeGraphic();
	}
	if (bg2_surface.width > 0 && game_data.stages[stage_number].maps[number].backgrounds[1].speed == 0.0) {
		std::cout << "classmap::loadMap - showing bg2 as static" << std::endl;
		for (int i=0; i<mapSurface.width/bg2_surface.width+1; i++) {
			graphLib.copyArea(st_position(i*bg2_surface.width, game_data.stages[stage_number].maps[number].backgrounds[1].adjust_y), &bg2_surface, &mapSurface);
		}
		bg2_surface.freeGraphic();
	}
	struct st_position pos_origin;
	struct st_position pos_destiny;
	for (int i=0; i<MAP_W; i++) {
		for (int j=0; j<MAP_H; j++) {
			// level 1
			pos_origin.x = map_tiles.tiles[i][j].tile1.x;
			pos_origin.y = map_tiles.tiles[i][j].tile1.y;
			pos_destiny.x = i*TILESIZE;
			pos_destiny.y = j*TILESIZE;
			graphLib.placeTile(pos_origin, pos_destiny, &mapSurface);
			// level 2
			pos_origin.x = map_tiles.tiles[i][j].tile2.x;
			pos_origin.y = map_tiles.tiles[i][j].tile2.y;
			graphLib.placeTile(pos_origin, pos_destiny, &mapSurface);
		}
	}
}
예제 #2
0
/// @TODO: fix animation. investigate a better way for drawing it (code is way too confusing)
void classMap::redraw_boss_door(bool is_close, int nTiles, int tileX, short player_number) {
	int k, tileCount;
	//is_close = false; // THIS IS A TEMPORARY FIX

	//std::cout << "classMap::redraw_boss_door - is_close: " << is_close << std::endl;

	input.waitTime(10);
	//for (k=0; k<tilePieces; k++) {
	for (k=0; k<nTiles; k++) {
		tileCount = nTiles;
		//if (is_close == false) { std::cout << "classMap::redraw_boss_door - nTiles: " << nTiles << ", tilePieces: " << tilePieces << ", tileCount: " << tileCount << std::endl; }
		// redraw screen
		showMap();
		graphLib.updateScreen();
		int tiles_showed;
		if (is_close == false) {
			tiles_showed = k;
		} else {
			tiles_showed = 0;
		}
		for (int i=0; i<MAP_W; i++) {
			for (int j=0; j<MAP_H; j++) {
				if (map_tiles.tiles[i][j].tile3.x != -1 && map_tiles.tiles[i][j].tile3.y != -1) {
						if (i == tileX && map_tiles.tiles[i][j].locked == TERRAIN_DOOR) {
							//std::cout << "****** redraw_boss_door - k: " << k << ", tiles_showed: " << tiles_showed << ", nTiles: " << nTiles << std::endl;
							if (is_close == false) {
								if (tiles_showed < nTiles) {
									graphLib.placeTile(st_position(map_tiles.tiles[i][j].tile3.x, map_tiles.tiles[i][j].tile3.y), st_position((i*TILESIZE)-scroll.x, (j*TILESIZE)-scroll.y), &graphLib.gameScreen);
									graphLib.updateScreen();
									tiles_showed++;
								}
							} else {
								if (tiles_showed < k) {
									graphLib.placeTile(st_position(map_tiles.tiles[i][j].tile3.x, map_tiles.tiles[i][j].tile3.y), st_position((i*TILESIZE)-scroll.x, (j*TILESIZE)-scroll.y), &graphLib.gameScreen);
									graphLib.updateScreen();
									tiles_showed++;
								}
							}
						} else {
							graphLib.placeTile(st_position(map_tiles.tiles[i][j].tile3.x, map_tiles.tiles[i][j].tile3.y), st_position((i*TILESIZE)+scroll.x, (j*TILESIZE)-scroll.y), &graphLib.gameScreen);
						}
				}
			}
		}
		_player_list.at(0)->show();
		graphLib.draw_hp_bar(_player_list.at(0)->get_current_hp(), player_number, WEAPON_DEFAULT);
		//show_sprite(p1Obj->sprite, game_screen);
		//draw_hp_bar(p1Obj);
		graphLib.updateScreen();
		input.waitTime(100);
	}
	input.waitTime(100);
}
예제 #3
0
// ********************************************************************************************** //
// show the third level of tiles                                                                  //
// ********************************************************************************************** //
void classMap::showAbove()
{
	// draw 3rd tile level
	struct st_position pos_origin;
	struct st_position pos_destiny;
	for (int i=0; i<MAP_W; i++) {
		for (int j=0; j<MAP_H; j++) {
			if (map_tiles.tiles[i][j].tile3.x != -1 && map_tiles.tiles[i][j].tile3.y != -1) {
				pos_origin.x = map_tiles.tiles[i][j].tile3.x;
				pos_origin.y = map_tiles.tiles[i][j].tile3.y;
				pos_destiny.x = (i*TILESIZE)-scroll.x;
				pos_destiny.y = (j*TILESIZE)-scroll.y;
				graphLib.placeTile(pos_origin, pos_destiny, &graphLib.gameScreen);
			}
		}
	}
}