本文整理汇总了C++中Door类的典型用法代码示例。如果您正苦于以下问题:C++ Door类的具体用法?C++ Door怎么用?C++ Door使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Door类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: enter
bool Character::enter(std::string dir) {
Door* exit = location->getExit(dir);
if (exit == NULL) {
return false;
} else {
Room* newLocation = exit->getConnectedRoom(location);
if (newLocation != NULL) {
location->removeActor(this);
location = newLocation;
location->addActor(this);
if (g->player->getLocation() == location) {
addFlag("playerishere");
} else if(checkFlag("playerishere")){
removeFlag("playerishere");
}
triggerEnter(newLocation);
return true;
} else {
g->push(exit->getLockedMessage());
return true;
}
}
}
示例2: if
bool House::getAccessList(uint32_t listId, std::string& list) const
{
if(listId == GUEST_LIST){
guestList.getList(list);
return true;
}
else if(listId == SUBOWNER_LIST){
subOwnerList.getList(list);
return true;
}
else{
Door* door = getDoorByNumber(listId);
if(door){
return door->getAccessList(list);
}
else{
#ifdef __DEBUG_HOUSES__
std::cout << "Failure: [House::getAccessList] door == NULL, listId = " << listId <<std::endl;
#endif
return false;
}
}
return false;
}
示例3: Door
//doors
Door* TileMap::AddDoor(const char *ID, const char* Name, unsigned int Flags,
int ClosedIndex, unsigned short* indices, int count,
Gem_Polygon* open, Gem_Polygon* closed)
{
Door* door = new Door( overlays[0] );
door->Flags = Flags;
door->closedIndex = ClosedIndex;
door->SetTiles( indices, count );
door->SetPolygon( false, closed );
door->SetPolygon( true, open );
door->SetName( ID );
door->SetScriptName( Name );
doors.push_back( door );
return door;
}
示例4: MakeDoor
Door* MazePrototypeFactory::MakeDoor(Room* r1, Room* r2) const{
Door* door = m_pDoor->Clone();
door->Initialize(r1, r2);
return door;
}
示例5: switch
//
// CastThroughIntersections
//
float Raycaster::CastThroughIntersections(float angle, IntersectionDir dir, int *texIndex, float *texelX)
{
float fx, fy;
float dx, dy;
float distance;
float a, b;
int mapX, mapY;
switch(dir)
{
case ID_HORIZONTAL:
if(UP(angle))
{
fy = -(posY - (int)posY);
dy = -1;
}
else
{
fy = (int)posY + 1 - posY;
dy = 1;
}
fx = (float)(ABS(fy)) / (float)(TAN(angle));
dx = (float)(ABS(dy)) / (float)(TAN(angle));
fx = ABS(fx);
dx = ABS(dx);
if(LEFT(angle))
{
dx = -dx;
fx = -fx;
}
fx = posX + fx;
fy = posY + fy;
break;
case ID_VERTICAL:
if(LEFT(angle))
{
fx = -(posX - (int)posX);
dx = -1;
}
else
{
fx = (int)posX + 1 - posX;
dx = 1;
}
fy = (float)(TAN(angle)) * (float)(ABS(fx));
dy = (float)(TAN(angle)) * (float)(ABS(dx));
fy = ABS(fy);
dy = ABS(dy);
if(UP(angle))
{
fy = -fy;
dy = -dy;
}
fx = posX + fx;
fy = posY + fy;
break;
}
while(true)
{
mapY = (int)fy;
mapX = (int)fx;
if(dy == -1 && dir == ID_HORIZONTAL)
mapY -= 1;
else if(dx == -1 && dir == ID_VERTICAL)
mapX -= 1;
if(mapX < 0 || mapY < 0 || mapX >= mapW || mapY >= mapH)
break;
else if(map[mapY][mapX] > 0 && map[mapY][mapX] != DOOR_INDEX && map[mapY][mapX] != LOCKED_DOOR_INDEX)
{
hit:
if(dir == ID_HORIZONTAL)
*texelX = fx - (float)mapX;
else
*texelX = fy - (float)mapY;
*texIndex = map[mapY][mapX] - 1;
break;
}
else if(map[mapY][mapX] == DOOR_INDEX || map[mapY][mapX] == LOCKED_DOOR_INDEX)
{
Door *door = GetDoorAt(mapX, mapY);
//.........这里部分代码省略.........
示例6: main
//.........这里部分代码省略.........
}
case REC_CLOT:
{
Clothing b;
b.load(esm);
if(quiet) break;
cout << " Name: " << b.name << endl;
break;
}
case REC_CONT:
{
Container b;
b.load(esm);
if(quiet) break;
cout << " Name: " << b.name << endl;
break;
}
case REC_CREA:
{
Creature b;
b.load(esm, id);
if(quiet) break;
cout << " Name: " << b.name << endl;
break;
}
case REC_DIAL:
{
Dialogue b;
b.load(esm);
break;
}
case REC_DOOR:
{
Door d;
d.load(esm);
if(quiet) break;
cout << " Name: " << d.name << endl;
cout << " Mesh: " << d.model << endl;
cout << " Script: " << d.script << endl;
cout << " OpenSound: " << d.openSound << endl;
cout << " CloseSound: " << d.closeSound << endl;
break;
}
case REC_ENCH:
{
Enchantment b;
b.load(esm);
break;
}
case REC_GMST:
{
GameSetting b;
b.id = id;
b.load(esm);
if(quiet) break;
cout << " Value: ";
if(b.type == VT_String)
cout << "'" << b.str << "' (string)";
else if(b.type == VT_Float)
cout << b.f << " (float)";
else if(b.type == VT_Int)
cout << b.i << " (int)";
cout << "\n Dirty: " << b.dirty << endl;
break;
}
case REC_INFO:
示例7: actionOpenDoor
void Functions::actionOpenDoor(Aurora::NWScript::FunctionContext &ctx) {
Door *door = Witcher::ObjectContainer::toDoor(getParamObject(ctx, 0));
if (door)
door->open(Witcher::ObjectContainer::toObject(ctx.getCaller()));
}
示例8: activateFunc
static void activateFunc(size_t idx) { sDoors.activate(idx); }
示例9: if
Room *World::getRoom(const std::string &dungeon, int level)
{
Room *room = 0;
DungeonDescriptor dungDesc = worldDescriptor[dungeon];
RoomDescriptor roomDesc = dungDesc.at(level);
std::string parent = roomDesc["parent"];
std::string music = roomDesc["music"];
if (music != "")
music = "music/" + music;
if (roomDesc["method"] == "load")
{
room = RoomLoader::loadRoom("rooms/" + roomDesc["file"]);
// Patch up the doors
if (parent != "")
{
Door *d = room->findUnboundDoor(false);
if (d)
{
d->setTargetDungeon(parent);
d->setTargetLevel(0);
}
}
if (level > 0)
{
Door *d = room->findUnboundDoor(false);
if (d)
{
d->setTargetDungeon(dungeon);
d->setTargetLevel(level - 1);
}
}
if (level < (int)dungDesc.size() - 1)
{
Door *d = room->findUnboundDoor(true);
if (d)
{
d->setTargetDungeon(dungeon);
d->setTargetLevel(level + 1);
}
}
}
else if (roomDesc["method"] == "generate")
{
std::string tileSet = roomDesc["tileset"];
std::string enemies = roomDesc["enemies"];
int algorithm = fromString<int>(roomDesc["algorithm"]);
int width = fromString<int>(roomDesc["width"]);
int height = fromString<int>(roomDesc["height"]);
int chests = fromString<int>(roomDesc["chests"]);
int roomSeed = seed + level * 1000;
for (int i = 0; i < (int)dungeon.size(); i++)
{
roomSeed = (roomSeed + 431) * dungeon[i];
}
Random random(roomSeed);
room = RoomGenerator::generateRoom(width, height, (RoomGenerator::Algorithm)algorithm, "graphics/" + tileSet, enemies, chests, random);
if (parent != "")
{
RoomGenerator::placeDoor(room, parent, 0, false, random);
}
if (level > 0)
{
RoomGenerator::placeDoor(room, dungeon, level - 1, false, random);
}
if (level < (int)dungDesc.size() - 1)
{
RoomGenerator::placeDoor(room, dungeon, level + 1, true, random);
}
}
room->setDungeonName(dungeon);
room->setDungeonLevel(level);
room->setMusic(music);
return room;
}
示例10: ASSERT
void DoorBrush::draw(BaseMap* map, Tile* tile, void* parameter) {
for(ItemVector::iterator item_iter = tile->items.begin();
item_iter != tile->items.end();)
{
Item* item = *item_iter;
if(item->isWall() == false) {
++item_iter;
continue;
}
WallBrush* wb = item->getWallBrush();
if(!wb) {
++item_iter;
continue;
}
BorderType wall_alignment = item->getWallAlignment();
uint16_t discarded_id = 0; // The id of a discarded match
bool close_match = false;
bool perfect_match = false;
bool open = false;
if(parameter) {
open = *reinterpret_cast<bool*>(parameter);
}
if(item->isBrushDoor()) {
open = item->isOpen();
}
WallBrush* test_brush = wb;
do {
for(std::vector<WallBrush::DoorType>::iterator iter = test_brush->door_items[wall_alignment].begin();
iter != test_brush->door_items[wall_alignment].end();
++iter)
{
WallBrush::DoorType& dt = *iter;
if(dt.type == doortype) {
ASSERT(dt.id);
ItemType& it = item_db[dt.id];
ASSERT(it.id != 0);
if(it.isOpen == open) {
item = transformItem(item, dt.id, tile);
perfect_match = true;
break;
} else if(close_match == false) {
discarded_id = dt.id;
close_match = true;
}
if(!close_match && discarded_id == 0) {
discarded_id = dt.id;
}
}
}
test_brush = test_brush->redirect_to;
if(perfect_match) {
break;
}
} while(test_brush != wb && test_brush != nullptr);
// If we've found no perfect match, use a close-to perfect
if(perfect_match == false && discarded_id) {
item = transformItem(item, discarded_id, tile);
}
if(settings.getInteger(Config::AUTO_ASSIGN_DOORID) && tile->isHouseTile()) {
Map* mmap = dynamic_cast<Map*>(map);
Door* door = dynamic_cast<Door*>(item);
if(mmap && door) {
House* house = mmap->houses.getHouse(tile->getHouseID());
ASSERT(house);
Map* real_map = dynamic_cast<Map*>(map);
if(real_map) {
door->setDoorID(house->getEmptyDoorID());
}
}
}
// We need to consider decorations!
while(true) {
// Vector has been modified, before we can use the iterator again we need to find the wall item again
item_iter = tile->items.begin();
while(true) {
if(item_iter == tile->items.end()) {
return;
}
if(*item_iter == item) {
++item_iter;
if(item_iter == tile->items.end()) {
return;
}
break;
}
++item_iter;
}
// Now it points to the correct item!
item = *item_iter;
if(item->isWall()) {
//.........这里部分代码省略.........
示例11: OTSYS_TIME
//.........这里部分代码省略.........
ss << "[x:" << px << ", y:" << py << ", z:" << pz << "] " << "Unknown tile attribute.";
setLastErrorString(ss.str());
return false;
break;
}
}
NODE nodeItem = f.getChildNode(nodeTile, type);
while(nodeItem){
if(type == OTBM_ITEM){
PropStream propStream;
f.getProps(nodeItem, propStream);
Item* item = Item::CreateItem(propStream);
if(!item){
std::stringstream ss;
ss << "[x:" << px << ", y:" << py << ", z:" << pz << "] " << "Failed to create item.";
setLastErrorString(ss.str());
return false;
}
if(item->unserializeItemNode(f, nodeItem, propStream)){
if(isHouseTile && !item->isNotMoveable()){
std::cout << "Warning: [OTBM loader] Moveable item in house id = " << house->getHouseId() << " Item type = " << item->getID() << std::endl;
delete item;
}
else{
tile->__internalAddThing(item);
item->__startDecaying();
// TESTING
if(isHouseTile){
Door* door = item->getDoor();
if(door && door->getDoorId() != 0){
house->addDoor(door);
}
}
//
}
}
else{
std::stringstream ss;
ss << "[x:" << px << ", y:" << py << ", z:" << pz << "] " << "Failed to load item " << item->getID() << ".";
setLastErrorString(ss.str());
delete item;
return false;
}
}
else{
std::stringstream ss;
ss << "[x:" << px << ", y:" << py << ", z:" << pz << "] " << "Unknown node type.";
setLastErrorString(ss.str());
}
nodeItem = f.getNextNode(nodeItem, type);
}
map->setTile(px, py, pz, tile);
}
else{
setLastErrorString("Unknown tile node.");
return false;
}
nodeTile = f.getNextNode(nodeTile, type);
示例12: main
int main(int, char**) {
//initialise SDL system and the video subsystem
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
QuitWithError("SDL_Init Error: ");
}
//Create a Window
SDL_Window *win = SDL_CreateWindow("Hello World!", 100, 100, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN);
if (win == nullptr) {
QuitWithError("SDL_CreateWindow Error: ");
}
//SDL_SetWindowFullscreen(win, SDL_WINDOW_FULLSCREEN);
Mix_Music *music = NULL;
Mix_OpenAudio(22050, MIX_DEFAULT_FORMAT, 2, 4096) == -1;
std::string basepath(SDL_GetBasePath());
music = Mix_LoadMUS((basepath + "background.wav").c_str());
Mix_PlayMusic(music, -1);
Render* renderer = new Render(win);
//Main loop flag
bool quit = false;
b2Vec2 Gravity(0.f, 0.0098f);
b2World World(Gravity);
string bgPath = basepath + "background22.bmp";
SDL_Surface* back = SDL_LoadBMP(bgPath.c_str());
SDL_Rect* backGroundRect = renderer->AddSurfaceToRenderer(back, 0, -600, 1.0f);
Button button = Button(-200, -50, World, renderer);
Door door = Door(600, -100, renderer);
Level level = Level(World, renderer);
Player player = Player(100, 500, World, renderer);
vector<Cannon*> cannons;
cannons.push_back(new Cannon(170, 350, World, renderer, 1));
cannons.push_back(new Cannon(1010, 50, World, renderer, 2));
cannons.push_back(new Cannon(170, 450, World, renderer, 1));
cannons.push_back(new Cannon(1010, 150, World, renderer, 2));
cannons.push_back(new Cannon(170, 550, World, renderer, 1));
cannons.push_back(new Cannon(1010, 250, World, renderer, 2));
MenuScene* menu = new MenuScene(1200, 100, renderer);
SDL_Event e;
//thread t1(&Process::run, Process((*(game)))); //Passing references
//t1.detach(); //detaches from SDL mainline
float prevTicks = SDL_GetTicks();
float currentTicks = SDL_GetTicks();
float FPS = 0;
int fpsTimer = 0;
SDL_Init(0);
//game loop
while (!quit) {
World.Step(1 / 60.f, 6, 2);
while (SDL_PollEvent(&e) != 0) {
if (inputHandler.CheckInput(SDLK_ESCAPE, e)) {
quit = true;
}
}
if (menu->playBool == false && menu->quitBool == false) {
renderer->DrawMenuScene();
menu->Update(renderer);
}
if (menu->playBool == true)
{
//PLAY GAME STATE
int dir = player.Move(inputHandler, e);
for (int i = 0; i < cannons.size(); i++)
{
cannons.at(i)->Update();
}
SDL_Rect rec(player.spriteRect);
rec.y = player.GetY();
for (int j = 0; j < cannons.size(); j++)
{
for (int i = 0; i < cannons.at(j)->fireballs.size(); i++)
{
if (cannons.at(j)->fireballs.at(i)->CheckCollision(&rec) == true)
{
std::cout << "Collision Detected!" << std::endl;
player.Respawn();
button.setOnce(false);
button.buttonBody->SetTransform(b2Vec2(880 / SCALE, 39 / SCALE), 0);
//.........这里部分代码省略.........
示例13: Room
void Level::generate(GameState* state)
{
// Create the starting room.
rooms.push_back(new Room((m_width/2)-10, (m_height/2)-10, 10, 10, nullptr));
// Add it to the list of rooms.
Room* currentRoom = rooms.back();
// Generate the room.
currentRoom->fill(tiles);
// Create other rooms.
while( true )
{
// Get a direction to generate a new room in.
Direction direction = currentRoom->getPossibleDirection();
// Setup variables to generate doors and rooms.
int doorAX, doorAY, roomX, roomY, roomW, roomH;
// Get Width and Height of the room.
roomW = 5 + rand() % 10;
roomH = 5 + rand() % 10;
// Depending on direction, roomX and roomY is altered, as with Doors.
switch((int)direction)
{
case 0:
doorAX = (currentRoom->getX()+1) + rand() % (currentRoom->getWidth()-2);
doorAY = currentRoom->getY();
roomX = doorAX - roomW/2;
roomY = doorAY - roomH + 1;
break;
case 1:
doorAX = (currentRoom->getX()+1) + rand() % (currentRoom->getWidth()-2);
doorAY = currentRoom->getY()+currentRoom->getHeight()-1;
roomX = doorAX - roomW/2;
roomY = doorAY;
break;
case 2:
doorAX = currentRoom->getX();
doorAY = (currentRoom->getY()+1) + rand() % (currentRoom->getHeight()-2);
roomX = doorAX - roomW + 1;
roomY = doorAY - roomH/2;
break;
case 3:
doorAX = currentRoom->getX()+currentRoom->getWidth()-1;
doorAY = (currentRoom->getY()+1) + rand() % (currentRoom->getHeight()-2);
roomX = doorAX;
roomY = doorAY - roomH/2;
break;
default:
break;
}
// Adjust coordinates accordingly, else room placement will freak out.
if( roomY < 0 ) roomY = 0;
if( roomX < 0 ) roomX = 0;
if( roomX >= static_cast<int>(m_width) ) roomX = m_width - 1;
if( roomY >= static_cast<int>(m_height) ) roomX = m_height - 1;
// Make the new room.
Room* newRoom = new Room(roomX, roomY, roomW, roomH, currentRoom);
// Check if it's valid placement.
if(newRoom->validPlacement(tiles, m_width, m_height))
{
// Fill the tiles with the room.
newRoom->fill(tiles);
fillAreaWithFog(newRoom);
// Add the room to the vector.
rooms.push_back(newRoom);
// Remove the succeded Direction, because it's not available again.
//currentRoom->removeDirection(direction);
// Remove the opposite direction of current room.
switch((int)direction)
{
case 0: newRoom->removeDirection(Direction::DOWN); break;
case 1: newRoom->removeDirection(Direction::UPP); break;
case 2: newRoom->removeDirection(Direction::RIGHT); break;
case 3: newRoom->removeDirection(Direction::LEFT); break;
}
// Set the current room to the new room.
currentRoom = newRoom;
// Alter the supposedly connected walls so a pathway is formed.
Door* door = static_cast<Door*>( EntityFactory::get()->createEntity("door") );
//.........这里部分代码省略.........
示例14: deallocateFunc
static void deallocateFunc(size_t idx) { sDoors.deallocate(idx); }
示例15: lua_getglobal
// process all events that are specified in the level file
void Script::processEvents(const vector<World::scriptPos>& scripts){
//vector<World::scriptPos>::iterator it = scripts.begin();
//while (it != scripts.end()){
for (unsigned i = 0; i < scripts.size(); i++){
World::scriptPos sp = scripts[i];
ScriptInfo* si = new ScriptInfo;
//a trap?
if (islower(sp.script[0])){
if (sp.script[0] < 'n')
lua_getglobal(L, "trapScheduler");
else
lua_getglobal(L, "eventScheduler");
si->isTrap = true;
}
else{
lua_getglobal(L, "eventScheduler");
si->isTrap = false;
}
lua_pushstring(L, sp.script);
if (lua_pcall(L, 1, 1, 0) != 0){
cerr << lua_tostring(L, -1);
}
string event = luaL_checkstring(L, -1);
lua_pop(L, 1);
si->pos = sp.pos;
si->script[0] = sp.script[0];
si->script[1] = sp.script[1];
if (event == "OnInit"){
lua_getglobal(L, sp.script);
lua_pushnumber(L, sp.pos.x);
lua_pushnumber(L, sp.pos.y);
if (lua_pcall(L, 2, 0, 0) != 0){
cerr << lua_tostring(L, -1);
}
}
else if (event == "OnTreasure"){
si->event = OnTreasure;
scripts_.push_back(si);
Field& f = wrld.getField(si->pos);
f.script = scripts_.back();
}
else if (event == "OnWalkAt"){
si->event = OnWalkAt;
scripts_.push_back(si);
Field& f = wrld.getField(si->pos);
f.script = scripts_.back();
}
else if (event == "OnOpen"){
si->event = OnOpen;
scripts_.push_back(si);
Door* d = wrld.getDoor(si->pos, TOP);
if (d)
d->setScript(scripts_.back());
d = wrld.getDoor(si->pos, RIGHT);
if (d)
d->setScript(scripts_.back());
d = wrld.getDoor(si->pos, BOTTOM);
if (d)
d->setScript(scripts_.back());
d = wrld.getDoor(si->pos, LEFT);
if (d)
d->setScript(scripts_.back());
}
else{
cerr << "Unknown script event: "+event;
}
//TODO
/*
lua_getglobal(L, sp.script);
lua_pushnumber(L, sp.pos.x);
lua_pushnumber(L, sp.pos.y);
if (lua_pcall(L, 2, 0, 0) != 0){
cerr << lua_tostring(L, -1);
}
*/
//it++;
}
}