コード例 #1
0
/**
 * \brief here we removed some unwanted borders in Y-direction in case of getting them when using a
 * 		  higher screenspace in Y-direction, than the original used to..
 */
void CMap::changeTileArrayY(Uint16 x, Uint16 y, Uint16 h, Uint16 tile)
{
    SDL_Rect gameres = gVideoDriver.getGameResolution().SDLRect();
	const Uint16 x2 = x+gameres.w/16;
	const Uint16 y2 = y+h;

	for(Uint16 c_y=y ; c_y<y2 ; c_y++)
		for(Uint16 c_x=x ; c_x<x2 ; c_x++)
			changeTile(c_x, c_y, tile);
}
コード例 #2
0
int EditorArea::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: changeTile(); break;
        case 1: saveGame((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 2: saveMap((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
        case 3: addNpcToMap((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
        case 4: addObjectToMap((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
        default: ;
        }
        _id -= 5;
    }
    return _id;
}
コード例 #3
0
ファイル: level.cpp プロジェクト: saurabh1907/2D-RPG-Game
int Level::execute(Player *player, int room_no, sf::RenderWindow* window){
	current_map = load.getMap();
	load.drawMap(window);
	if (isDead(player)){
		player->dead_sound.play();
		dialogue = "DEAD"; game_state = 0;
	}
	interact_state = collision.isInteractionMap(player->characterImage.getPosition(), player->source.y);
	tile_location = collision.tile_location;
	if (interact_state != 13)
		in_contact = false;

	if (interact_state + 1 != 0){
		if (interact_state == 13){
			if (player->is_mattock){
				if (!in_contact){
					clock.restart();
					in_contact = true;
				}
				if (clock.getElapsedTime().asSeconds() > 3.5){
					count++;
					changeTile(player->source.y, sf::Vector2i(16, 0));
					if (count == 2){
						player->is_mattock = false;
						dialogue = "the mattock broke, find another tool to dig";
					}
				}
				if (count == 4){
					dialogue = "Destroy the corpse";
					changeTile(player->source.y, sf::Vector2i(12, 1));
					//game_state = 5; 

				}
			}
			else
				dialogue = "Find some tool to dig and stand still !!";
		}
		else{
			if (sf::Keyboard::isKeyPressed(sf::Keyboard::Return)){
				switch (interact_state){
				case 0:
					player->object_sound.play();
					if (room_no == 3){
						dialogue = "Drawer:\n\tKey found !!\n\n\n\n\n\n\t\t\t\t\t*Press spacebar to dismiss*";
						player->room4_lock = false;
					}
					else if (room_no == 2){
						dialogue = "june 26 1953\n\tA man killed 10 innocent people including\n\twomen and children and then committed suicide.\n\tThe Mansion has never found peace after that !\n\n\tUnfortunate things keep happening.....\n\n\t\t\t\t\t*Press spacebar to dismiss*";
					}
					else
						dialogue = "Drawer : \n\tDrawer is empty.";
					break;
				case 1:
					player->object_sound.play();
					if (room_no == 5){
						player->room6_lock = false;
					}
					if (room_no == 4)
						player->room5_lock = false;
					dialogue = "Chest:\n\tKey found !!";
					changeTile(player->source.y, sf::Vector2i(2, 1));
					break;
				case 2:
					player->object_sound.play();
					break;
				case 3:
					player->object_sound.play();
					if (room_no == 6)
						dialogue = "Police, Priest, Investigator all tried to solve \nthe mystery but none could restore the harmony.\nSome even lost their lives in doing so.\n.\n.\nSome say a Devil lives here !! ";
					break;
				case 4:
					return nextRoom(room_no, 1, player);
					break;
				case 5:
					return nextRoom(room_no, 2, player);
					break;
				case 6:
					return nextRoom(room_no, 3, player);
					break;
				case 7:
					return nextRoom(room_no, 4, player);
					break;
				case 8:
					return nextRoom(room_no, 5, player);
					break;
				case 9:
					return nextRoom(room_no, 6, player);
					break;
				case 10:
					player->object_sound.play();
					if (room_no == 3)
						dialogue = "Diary:\n\tThere are dead souls wandering in the Mansion\n\t.\n\t.\n\tSome force is stopping them to leave the place";
					else if (room_no == 4)
						dialogue = "A hint to open chest.";
					else if (room_no == 7)
						dialogue = "All attempts to save the house has failed.\nThe Devil is strongest in the next room !!\n\nI could either take petrol and burn the \nwhole house down and wish things to be alright.\n\nOr take courage and FIGHT THE DEVIL !!";
					break;
				case 11:
					player->object_sound.play();
					dialogue = "Laltern picked";
					player->is_laltern = true;
					player->room2_lock = false;
					changeTile(player->source.y, sf::Vector2i(-1, -1));
					break;
				case 12:
					player->end_sound.play();
					game_state = 5;
					break;
				case 15:
					player->object_sound.play();
					if (!player->is_mattock){
						dialogue = "Picked Mattock \nUse it to dig the ground!!";
						changeTile(player->source.y, sf::Vector2i(-1, -1));
						player->is_mattock = true;
					}
					else
						dialogue = "Bruce\n\tI already have this tool";
					break;
				case 16:
					player->object_sound.play();
					dialogue = "Picked sword !!";
					changeTile(player->source.y, sf::Vector2i(-1, -1));
					player->room8_lock = false;
					break;
				case 17:
					player->object_sound.play();
					dialogue = "Lever pulled !!";
					for (int i = 0; i < load.map.size(); i++){
						for (int j = 0; j < load.map[i].size(); j++){
							if (load.map[i][j].x == 21){
								load.map[i][j] = sf::Vector2i(21, 0);
							}
						}
					}
					changeTile(player->source.y, sf::Vector2i(17, 2));
					break;
				case 18:
					player->object_sound.play();
					dialogue = "Key Found!!";
					if (room_no == 6)player->room7_lock = false;
					changeTile(player->source.y, sf::Vector2i(-1, -1));
					break;
				case 19:
					player->object_sound.play();
					if (room_no == 7)
						dialogue = "Take your decision wisely as it may result in different endings !!";
					else if (room_no == 8)
						dialogue = "Devil's corpse is burried in the center.\n\nTake the digging tool and stand still to dig.";
					else
						dialogue = "Hint !!";
					changeTile(player->source.y, sf::Vector2i(-1, -1));
					break;
				case 20:
					player->object_sound.play();
					dialogue = "Petrol Picked !!";
					game_state = 6;

					break;
				case 21:
					dialogue = "Dead !!";
					break;
				case 22:
					dialogue = "Dead !!";
					break;
				default:dialogue = "I don't need this.";
					break;
				}
			}
		}
	}
	return room_no;
}