当前位置: 首页>>代码示例>>C++>>正文


C++ Area类代码示例

本文整理汇总了C++中Area的典型用法代码示例。如果您正苦于以下问题:C++ Area类的具体用法?C++ Area怎么用?C++ Area使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Area类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Area

Area Area::operator+(Area& rv)
{
	return Area(GetValueUnits("m3").Value + rv.GetValueUnits("m3").Value, "m3");
}
开发者ID:dmitryzy,项目名称:ChemistryModel1,代码行数:4,代码来源:Area.cpp

示例2: clippedSrcDst

void SurfaceT<T>::copyFrom( const SurfaceT<T> &srcSurface, const Area &srcArea, const Vec2i &relativeOffset )
{
	std::pair<Area,Vec2i> srcDst = clippedSrcDst( srcSurface.getBounds(), srcArea, getBounds(), srcArea.getUL() + relativeOffset );
	
	if( getChannelOrder() == srcSurface.getChannelOrder() )
		copyRawSameChannelOrder( srcSurface, srcDst.first, srcDst.second );
	else if( hasAlpha() && srcSurface.hasAlpha() )
		copyRawRgba( srcSurface, srcDst.first, srcDst.second );
	else
		copyRawRgb( srcSurface, srcDst.first, srcDst.second );
}
开发者ID:paulobarcelos,项目名称:Cinder,代码行数:11,代码来源:Surface.cpp

示例3: main

//================================================================
int main()
{
	system("mode con: cols=54 lines=26");
	srand((unsigned)time(0));
	enum {_224=224,up=72,down=80,left=75,right=77,space=32,enter=13};//接收上下左右键第一个需要两个变量,第一个值是224
	int score=0,level=0;
	short M=1;
	double _time=0.5;//下降的时间间隔(秒),其实说CLOCKS_PER_SEC在windows下是1000,这里time的单位才可以说是秒)
	//===========================================
	//场地对象
	Area area;
	area.paint();
	//===========================================
	//启动问候语
	gotoxy(10,5);cout<<"俄罗斯方块";
	gotoxy(8,6);
	system("pause");
	gotoxy(10,5);cout<<"         ";
	gotoxy(8,6);cout<<"                   ";
	//===========================================
	gotoxy(area.area_x+11,8);cout<<score;
	gotoxy(area.area_x+11,10);cout<<level;
	clock_t start,end;
	Cube *cube_one=new Cube;//方块1对象
LOOP:
	Cube *cube_two=new Cube;//下一个方块
	cube_two->paint_next(area);
	start=clock();
	cube_one->drop(area);
	while(1)
	{
		end=clock();
		while(_time*CLOCKS_PER_SEC<=end-start)
		{
			if(!cube_one->drop(area))
			{
				if(cube_one->over(area))
				{
					Gameover(area);
				}
				LOOP2:
				delete cube_one;
				cube_one=cube_two;//用2替换1
				goto LOOP;
			}
			start=clock();
		}
		short m;
		if(m=cube_one->clear(area))
		{
			cout<<"\a";
			SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_BLUE|FOREGROUND_GREEN|FOREGROUND_RED);
			score+=m*10;
			gotoxy(area.area_x+11,8);cout<<score;
			if(score/60>level)
			{
				if(_time>0.1)
				{
					_time-=0.05;
					level=score/60;
					gotoxy(area.area_x+11,10);cout<<level;
				}
				else
				{
					gotoxy(area.area_x+11,10);cout<<"超神级别!";
				}
			}
			goto LOOP2;
		}
		while(kbhit())
		{
			short one,two;
			one=getch();
			switch(one)
			{
			case _224:two=getch();
						switch(two)
						  {
							case up:cube_one->up(area);			break;
							case left:cube_one->left(area);		break;
							case right:cube_one->right(area);	break;
							case down:cube_one->down(area);		break;
							default:							break;
						  }								break;
			case space:cube_one->end(area);				break;//空格到底部
			case enter:getch();							break;//回车是暂停
			default:									break;
			}
		}
		Sleep(1);
	}
	return 0;
}
开发者ID:gaopu,项目名称:mygame,代码行数:94,代码来源:main.cpp

示例4: readYAMLStr

void World::parseZone(YAML::Node fileNode, std::ostream& lerr, TiledLoader* tiledLoader, MobSpawner* mobSpawner) {
    String areaName = readYAMLStr(fileNode, "Area", "nil", "Area expected.", lerr);
    if (areaNameMap.find(areaName) != areaNameMap.end()) {
        String name = readYAMLStr(fileNode, "Name", "nil", "Name expected.", lerr);
        Area* area = areaNameMap[areaName];
        Zone* newZone = NULL;
        if (fileNode["Stack"]) {
            YAML::Node stackNode = fileNode["Stack"];

            String genName = readYAMLStr(fileNode, "Gen", "dungeon");
            GenType gen = GEN_DUNGEON;
            if (genName == "dungeon") gen = GEN_DUNGEON;
            int depth = readYAMLInt(stackNode, "Num_Floors", 10);
            DungeonStack* dungeonStack = new DungeonStack(name, depth, gen);

            String tilesetName = readYAMLStr(stackNode, "Tileset", "nil", "Tileset expected.", lerr);
            if (Tile::hasSet(tilesetName)) {
                dungeonStack->setTileset(Tile::getSet(tilesetName));
            } else lerr << "'" << tilesetName << "' is not an existing tileset.\n";

            dungeonStack->setLight(readYAMLInt(stackNode, "Light", 8), readYAMLNum(stackNode, "LightMod", 0));
            dungeonStack->setNumStairs(readYAMLInt(stackNode, "Stairs", 1), readYAMLNum(stackNode, "StairsMod", 0));
            dungeonStack->setDifficulty(readYAMLInt(stackNode, "Diff", 0), readYAMLNum(stackNode, "DiffMod", 0));

            if (stackNode["Spawn"].IsSequence()) {
                YAML::Node spawnNode = stackNode["Spawn"];
                for (YAML::const_iterator iter = spawnNode.begin(); iter != spawnNode.end(); ++iter) {
                    dungeonStack->addEnvironment(mobSpawner->getEnvironment(iter->as<String>()));
                }
            }
            dungeonStack->createZones();
            newZone = dungeonStack->getZone(0);
            area->addDungeonStack(dungeonStack);
            dunNameMap[name] = dungeonStack;
        } else if (fileNode["File"]) {
            newZone = tiledLoader->loadTileFile(fileNode["File"].as<String>(), name, lerr);
            area->addZone(newZone);
            zoneNameMap[name] = newZone;
        }

        if (newZone && fileNode["Connections"]) {
            YAML::Node cNode = fileNode["Connections"];
            for (YAML::const_iterator iter = cNode.begin(); iter != cNode.end(); ++iter) {
                YAML::Node curNode = *iter;
                if (curNode["From"] && curNode["To"]) {
                    YAML::Node posNode = curNode["From"];
                    Coord pos = Coord(posNode[0].as<int>(), posNode[1].as<int>());
                    String zoneName = curNode["To"].as<String>();
                    if (zoneNameMap.find(zoneName) != zoneNameMap.end()) {
                        area->addConnection(Connection{pos, pos, newZone, zoneNameMap[zoneName]});
                    } else if (dunNameMap.find(zoneName) != dunNameMap.end()) {
                        DungeonStack* ds = dunNameMap[zoneName];
                        area->addConnection(Connection{pos, ds->addEntryStairs(), newZone, ds->getZone(0)});
                    } else lerr << "'" << name << "' is not the name of an existing zone or dungeon stack.\n";
                } else {
                    lerr << "expected From and To in the connection" << std::endl;
                }
            }
        }
    } else lerr << "Area does not exist: " << areaName << "\n";
}
开发者ID:lupuchard,项目名称:ragrelark-ddvmk,代码行数:61,代码来源:World.cpp

示例5: createBuffers

void StereoAutoFocuser::autoFocus( CameraStereo *cam, const Area &area, GLuint buffer )
{
	if( !cam->isStereoEnabled() )
		return;

	// create or resize buffers
	createBuffers( area );

	// blit (multi-sampled) depth buffer to (non-multi-sampled) auto focus fbo	
	// (they need to be the same size for this to work!)
	{
		Area dstArea = mFboLarge->getBounds();

		gl::ScopedFramebuffer readBuffer( GL_READ_FRAMEBUFFER, buffer );
		gl::ScopedFramebuffer drawBuffer( GL_DRAW_FRAMEBUFFER, mFboLarge->getId() );

		glBlitFramebuffer( area.getX1(), area.getY1(), area.getX2(), area.getY2(),
						   dstArea.getX1(), dstArea.getY1(), dstArea.getX2(), dstArea.getY2(), GL_DEPTH_BUFFER_BIT, GL_NEAREST );
	}

	// create a downsampled copy for the auto focus test
	{
		Area srcArea = mFboLarge->getBounds();
		Area dstArea = mFboSmall->getBounds();

		gl::ScopedFramebuffer readBuffer( GL_READ_FRAMEBUFFER, mFboLarge->getId() );
		gl::ScopedFramebuffer drawBuffer( GL_DRAW_FRAMEBUFFER, mFboSmall->getId() );

		glBlitFramebuffer( srcArea.getX1(), srcArea.getY1(), srcArea.getX2(), srcArea.getY2(),
						   dstArea.getX1(), dstArea.getY1(), dstArea.getX2(), dstArea.getY2(), GL_DEPTH_BUFFER_BIT, GL_NEAREST );
	}

	// load depth samples into buffer
	glBindFramebuffer( GL_READ_FRAMEBUFFER, mFboSmall->getId() );
	glReadPixels( 0, 0, AF_WIDTH, AF_HEIGHT, GL_DEPTH_COMPONENT, GL_FLOAT, &mBuffer.front() );
	mFboSmall->unbindFramebuffer();

	// find minimum value 
	std::vector<GLfloat>::const_iterator itr = std::min_element( mBuffer.begin(), mBuffer.end() );

	size_t p = itr - mBuffer.begin();
	mNearest.x = 0.5f + (int) ( ( p % AF_WIDTH ) / (float) AF_WIDTH * mArea.getWidth() );
	mNearest.y = 0.5f + (int) ( ( p / AF_WIDTH ) / (float) AF_HEIGHT * mArea.getHeight() );

	// convert to actual distance from camera
	float nearClip = cam->getNearClip();
	float farClip = cam->getFarClip();
	float depth = 2.0f * ( *itr ) - 1.0f;
	mNearest.z = 2.0f * nearClip * farClip / ( farClip + nearClip - depth * ( farClip - nearClip ) );

	// perform auto focussing
	float z = math<float>::max( nearClip, mNearest.z * mDepth );
	cam->setConvergence( cam->getConvergence() + mSpeed * ( z - cam->getConvergence() ), true );
}
开发者ID:AbdelghaniDr,项目名称:Cinder,代码行数:54,代码来源:StereoAutoFocuser.cpp

示例6: play

void AudioStreamPlayer3D::_notification(int p_what) {

	if (p_what == NOTIFICATION_ENTER_TREE) {

		velocity_tracker->reset(get_global_transform().origin);
		AudioServer::get_singleton()->add_callback(_mix_audios, this);
		if (autoplay && !Engine::get_singleton()->is_editor_hint()) {
			play();
		}
	}

	if (p_what == NOTIFICATION_EXIT_TREE) {

		AudioServer::get_singleton()->remove_callback(_mix_audios, this);
	}
	if (p_what == NOTIFICATION_TRANSFORM_CHANGED) {

		if (doppler_tracking != DOPPLER_TRACKING_DISABLED) {
			velocity_tracker->update_position(get_global_transform().origin);
		}
	}

	if (p_what == NOTIFICATION_INTERNAL_PHYSICS_PROCESS) {

		//update anything related to position first, if possible of course

		if (!output_ready) {

			Vector3 linear_velocity;

			//compute linear velocity for doppler
			if (doppler_tracking != DOPPLER_TRACKING_DISABLED) {
				linear_velocity = velocity_tracker->get_tracked_linear_velocity();
			}

			Ref<World> world = get_world();
			ERR_FAIL_COND(world.is_null());

			int new_output_count = 0;

			Vector3 global_pos = get_global_transform().origin;

			int bus_index = AudioServer::get_singleton()->thread_find_bus_index(bus);

			//check if any area is diverting sound into a bus

			PhysicsDirectSpaceState *space_state = PhysicsServer::get_singleton()->space_get_direct_state(world->get_space());

			PhysicsDirectSpaceState::ShapeResult sr[MAX_INTERSECT_AREAS];

			int areas = space_state->intersect_point(global_pos, sr, MAX_INTERSECT_AREAS, Set<RID>(), area_mask);
			Area *area = NULL;

			for (int i = 0; i < areas; i++) {
				if (!sr[i].collider)
					continue;

				Area *tarea = Object::cast_to<Area>(sr[i].collider);
				if (!tarea)
					continue;

				if (!tarea->is_overriding_audio_bus() && !tarea->is_using_reverb_bus())
					continue;

				area = tarea;
				break;
			}

			List<Camera *> cameras;
			world->get_camera_list(&cameras);

			for (List<Camera *>::Element *E = cameras.front(); E; E = E->next()) {

				Camera *camera = E->get();
				Viewport *vp = camera->get_viewport();
				if (!vp->is_audio_listener())
					continue;

				Vector3 local_pos = camera->get_global_transform().orthonormalized().affine_inverse().xform(global_pos);

				float dist = local_pos.length();

				Vector3 area_sound_pos;
				Vector3 cam_area_pos;

				if (area && area->is_using_reverb_bus() && area->get_reverb_uniformity() > 0) {
					area_sound_pos = space_state->get_closest_point_to_object_volume(area->get_rid(), camera->get_global_transform().origin);
					cam_area_pos = camera->get_global_transform().affine_inverse().xform(area_sound_pos);
				}

				if (max_distance > 0) {

					float total_max = max_distance;

					if (area && area->is_using_reverb_bus() && area->get_reverb_uniformity() > 0) {
						total_max = MAX(total_max, cam_area_pos.length());
					}
					if (total_max > max_distance) {
						continue; //cant hear this sound in this camera
					}
//.........这里部分代码省略.........
开发者ID:MattDBell,项目名称:godot,代码行数:101,代码来源:audio_stream_player_3d.cpp

示例7: doAction

 virtual void doAction() {
     sound->play(L"glasbk2.wav");
     bool restart = false;
     bool newGame = false;
     Font font(L"laudcn2.ttf", 24);
     Font btnFont(L"laudcn2.ttf", 14);
     Area area;
     area.add(gameArea);
     area.add(new Window(220, 240, 360, 140, L"redpattern.bmp", 6));
     area.add(new Label(&font, 250, 230, 300, 100, Label::ALIGN_CENTER,
                 Label::ALIGN_MIDDLE, 255,255,0, msg(L"loose")));
     OkDlgCommand newGameCmd(&area, newGame);
     area.add(new Button(250, 340, 90, 25, &btnFont, 255,255,0, 
                 L"redpattern.bmp", msg(L"startNew"), &newGameCmd));
     OkDlgCommand restartCmd(&area, restart);
     area.add(new Button(350, 340, 90, 25, &btnFont, 255,255,0, 
                 L"redpattern.bmp", msg(L"tryAgain"), &restartCmd));
     ExitCommand exitCmd(area);
     area.add(new Button(450, 340, 90, 25, &btnFont, 255,255,0, 
                 L"redpattern.bmp", msg(L"exit"), &exitCmd));
     area.run();
     if (restart || newGame) {
         if (newGame)
             game->newGame();
         else
             game->restart();
         gameArea->draw();
         gameArea->updateMouse();
     } else
         gameArea->finishEventLoop();
 };
开发者ID:0-wiz-0,项目名称:einstein-puzzle,代码行数:31,代码来源:game.cpp

示例8: defined

void ObjectManager::Draw()
{
    // Render state
#if ! defined(CINDER_GLES)
    m_wireframe ? gl::enableWireframe() : gl::disableWireframe();
#endif

//    m_fbo.bindFramebuffer();

    gl::enableVerticalSync();   // TODO: why can't this be set once at setup?
    gl::enableAlphaBlending();
    gl::enableDepthRead();
    gl::enable(GL_CULL_FACE);
    glCullFace(GL_BACK);
    gl::clear(ColorA(178/255.f,178/255.f,178/255.f,1.0f));

    // Draw Player 1
    gl::pushMatrices();
    gl::setViewport(Area(0, 0, g_pApp->getWindowWidth()*getWindow()->getContentScale()/2, g_pApp->getWindowHeight()*getWindow()->getContentScale()));
    gl::setMatrices(m_pPlayer1->m_cam.GetCamera());

    for (auto i = m_objects.begin(); i != m_objects.end(); i++)
    {
        (*i)->Draw();
    }

    if (m_pWorld)
    {
        m_pWorld->Draw();
    }

    m_pPlayer1->Draw();
    if (m_gameState == PLAYING)
    {
        m_pPlayer1->DrawCursor();
    }
    gl::popMatrices();

    // Draw Player 2
    gl::pushMatrices();
    gl::setViewport(Area(g_pApp->getWindowWidth()*getWindow()->getContentScale()/2, 0, g_pApp->getWindowWidth()*getWindow()->getContentScale(), g_pApp->getWindowHeight()*getWindow()->getContentScale()));
    gl::setMatrices(m_pPlayer2->m_cam.GetCamera());

    for (auto i = m_objects.begin(); i != m_objects.end(); i++)
    {
        (*i)->Draw();
    }

    if (m_pWorld)
    {
        m_pWorld->Draw();
    }

    m_pPlayer2->Draw();
    if (m_gameState == PLAYING)
    {
        m_pPlayer2->DrawCursor();
    }
    gl::popMatrices();
/*
    // Render framebuffer
    m_fbo.unbindFramebuffer();
    gl::enableVerticalSync();   // TODO: why can't this be set once at setup?
    gl::enableAlphaBlending();
    gl::enableDepthRead(false);
    gl::enableDepthWrite(false);
    gl::disable(GL_CULL_FACE);

    // Post process shader on FBO
    gl::color(1.f, 1.f, 1.f, 1.f);
    gl::setMatricesWindow(getWindowSize(), false);
    gl::Texture fboTex = m_fbo.getTexture();

    fboTex.enableAndBind();
    m_shader.bind();
    m_shader.uniform("tex0", 0);
    m_shader.uniform("resolution", Vec2f(fboTex.getWidth(), fboTex.getHeight()));
    m_shader.uniform("timer", static_cast<float>(m_playtime));
    m_shader.uniform("resolutionScale", getWindow()->getContentScale());

    gl::drawSolidRect(getWindowBounds());

    m_shader.unbind();
    fboTex.unbind();
    fboTex.disable();
*/
    // Draw game screens
//    gl::pushMatrices();
     gl::color(1,1,1,1);
    Vec2i windowSize = getWindowSize();

    int dim = windowSize.y < windowSize.x ? windowSize.y : windowSize.x;
    float scale = 1.4f;
    dim *= scale;

    float texRatio = 1.f;   // height / width
    int xoffset = 0;
    int yoffset = 0;
    Area bounds;

//.........这里部分代码省略.........
开发者ID:halogenica,项目名称:Aggrogate,代码行数:101,代码来源:ObjectManager.cpp

示例9: ScanAreaIds

  bool OptimizeAreaWayIdsGenerator::ScanAreaIds(const ImportParameter& parameter,
                                                Progress& progress,
                                                const TypeConfig& typeConfig,
                                                NodeUseMap& nodeUseMap)
  {
    FileScanner scanner;
    uint32_t    dataCount=0;

    progress.SetAction("Scanning ids from 'areas.tmp'");

    if (!scanner.Open(AppendFileToDir(parameter.GetDestinationDirectory(),
                                      "areas.tmp"),
                      FileScanner::Sequential,
                      parameter.GetAreaDataMemoryMaped())) {
      progress.Error(std::string("Cannot open '")+scanner.GetFilename()+"'");
      return false;
    }

    if (!scanner.Read(dataCount)) {
      progress.Error("Error while reading number of data entries in file");
      return false;
    }

    for (size_t current=1; current<=dataCount; current++) {
      uint8_t type;
      Id      id;
      Area    data;

      progress.SetProgress(current,dataCount);

      if (!scanner.Read(type) ||
          !scanner.Read(id) ||
          !data.Read(typeConfig,
                     scanner)) {
        progress.Error(std::string("Error while reading data entry ")+
                       NumberToString(current)+" of "+
                       NumberToString(dataCount)+
                       " in file '"+
                       scanner.GetFilename()+"'");

        return false;
      }

      for (const auto& ring: data.rings) {
        std::unordered_set<Id> nodeIds;

        if (!ring.GetType()->CanRoute()) {
          continue;
        }

        for (const auto id: ring.ids) {
          if (nodeIds.find(id)==nodeIds.end()) {
            nodeUseMap.SetNodeUsed(id);

            nodeIds.insert(id);
          }
        }
      }
    }

    if (!scanner.Close()) {
      progress.Error(std::string("Error while closing file '")+
                     scanner.GetFilename()+"'");
      return false;
    }

    return true;
  }
开发者ID:AQbernhard,项目名称:OSMScout-ubuntu,代码行数:68,代码来源:GenOptimizeAreaWayIds.cpp

示例10: CopyAreas

  bool OptimizeAreaWayIdsGenerator::CopyAreas(const ImportParameter& parameter,
                                              Progress& progress,
                                              const TypeConfig& typeConfig,
                                              NodeUseMap& nodeUseMap)
  {
    FileScanner scanner;
    FileWriter  writer;
    uint32_t    areaCount=0;

    if (!writer.Open(AppendFileToDir(parameter.GetDestinationDirectory(),
                                     "areas2.tmp"))) {
      progress.Error(std::string("Cannot create '")+writer.GetFilename()+"'");
      return false;
    }

    writer.Write(areaCount);

    progress.SetAction("Copy data from 'areas.tmp' to 'areas2.tmp'");

    if (!scanner.Open(AppendFileToDir(parameter.GetDestinationDirectory(),
                                      "areas.tmp"),
                      FileScanner::Sequential,
                      parameter.GetAreaDataMemoryMaped())) {
      progress.Error(std::string("Cannot open '")+scanner.GetFilename()+"'");
      return false;
    }

    if (!scanner.Read(areaCount)) {
      progress.Error("Error while reading number of data entries in file");
      return false;
    }

    for (size_t current=1; current<=areaCount; current++) {
      uint8_t type;
      Id      id;
      Area    data;

      progress.SetProgress(current,areaCount);

      if (!scanner.Read(type) ||
          !scanner.Read(id) ||
          !data.Read(typeConfig,
                     scanner)) {
        progress.Error(std::string("Error while reading data entry ")+
                       NumberToString(current)+" of "+
                       NumberToString(areaCount)+
                       " in file '"+
                       scanner.GetFilename()+"'");

        return false;
      }

      for (auto& ring : data.rings) {
        std::unordered_set<Id> nodeIds;

        for (auto& id : ring.ids) {
          if (!nodeUseMap.IsNodeUsedAtLeastTwice(id)) {
            id=0;
          }
        }
      }

      if (!writer.Write(type) ||
          !writer.Write(id) ||
          !data.Write(typeConfig,
                      writer)) {
        progress.Error(std::string("Error while writing data entry to file '")+
                       writer.GetFilename()+"'");

        return false;
      }
    }

    if (!scanner.Close()) {
      progress.Error(std::string("Error while closing file '")+
                     scanner.GetFilename()+"'");
      return false;
    }

    if (!writer.SetPos(0)) {
      return false;
    }

    if (!writer.Write(areaCount)) {
      return false;
    }

    if (!writer.Close()) {
      progress.Error(std::string("Error while closing file '")+
                     writer.GetFilename()+"'");
      return false;
    }

    return true;
  }
开发者ID:AQbernhard,项目名称:OSMScout-ubuntu,代码行数:95,代码来源:GenOptimizeAreaWayIds.cpp

示例11: if

Area* World::move(Player *player,
                  int clip_x, int clip_y, int clip_w, int clip_h)
{
    Area *result = 0;

    if (!player->is_morphing()) {
        result = player->get_warp();
    }

    player->move(m_map);

    int window_width = clip_w - clip_x;
    if (m_lock_x) {
        m_map->set_x(m_lock_x, window_width);
    }
    else {
        int map_x = player->get_x() - window_width / 2 + m_offset_x;
        if (map_x < 0) {
            map_x = 0;
        }
        m_map->set_x(map_x, window_width);
    }

    int window_height = clip_h - clip_y;
    if (m_lock_y) {
        m_map->set_y(m_lock_y, window_height);
    }
    else {
        int map_y = player->get_y() - window_height / 2 + m_offset_y;
        if (map_y < 0) {
            map_y = 0;
        }
        m_map->set_y(map_y, window_height);
    }

    std::vector<Object*> perished;

    for (std::list<Object*>::iterator it = m_objects.begin();
         it != m_objects.end();
         ++it) {
        Object *object = *it;

        if (object->get_visible(m_map, clip_x, clip_y, clip_w, clip_h)) {
            Object::Type object_type = object->get_type();

            // Handle area objects
            if (object_type == Object::TypeArea) {
                Area *area = (Area *) object;

                if (area->is_over(player)) {

                    if (area->is_locked()) {

                        // Check if the player has the key
                        Status *status = m_db->get_status();
                        Item *item = status->check_item(area->get_data());
                        if (item) {
                            if (area->unlock(this, item)) {
                                status->remove_item(item);
                            }
                        }
                    }
                    else {
                        area->move(m_map);

                        if (area->is_open()) {
                            result = area;
                        }
                    }
                }
            }

            // Handle monster object
            else if (object_type == Object::TypeMonster) {
                Monster *monster = (Monster *) object;

                monster->move(m_map);
                monster->set_reference(player->get_front(), player->get_y());
                if (player->check_collision(monster) ||
                    monster->attack_object(player)) {
                    if (!monster->get_invisible()) {
                        player->set_hit(monster, m_db->get_status());
                    }
                }
                if (player->attack_object(monster)) {
                    monster->set_hit(player, m_db->get_status());
                }
                if (monster->get_action() == Actor::HitPerished) {
                    perished.push_back(monster);
                }
            }

            // Handle item objects
            else if (object_type == Object::TypeItem) {
                Item *item = (Item *) object;

                item->move(m_map);

                // Check if player picked up item
                if (player->check_collision(item)) {
//.........这里部分代码省略.........
开发者ID:baijkal,项目名称:dragonscurse,代码行数:101,代码来源:world.cpp


注:本文中的Area类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。