Exemple #1
0
void Game::renderPass(uint64_t frame)
{	
	const Rect cameraRect(mCameraPosition - (mScreenSize / 2), mScreenSize);
	
	Renderables renderables = Renderable::all();
	
	for (Renderables::iterator iter = renderables.begin(); iter != renderables.end(); ++iter)
	{
		Renderable& object = **iter;
		Rect boundingRect = object.boundingRect();
		
		if (!object.hidden() && cameraRect.overlaps(boundingRect))
		{
			// Motion blur
			Color::push();
			int max = 1;
			Color::translate(Color(1.0, 1.0, 1.0, 1.0 / max));
			for (int i = 0; i < max; ++i)
			{
				glMatrixMode(GL_MODELVIEW);
				glPushMatrix();
				object.render(frame - i);
				glMatrixMode(GL_MODELVIEW);
				glPopMatrix();
			}
			Color::pop();
		}
	}
}
Exemple #2
0
void Game::update()
{
	Renderables renderables = Renderable::all();
	for (Renderables::iterator iter = renderables.begin(); iter != renderables.end(); ++iter)
	{
		(*iter)->update();
	}
}
Exemple #3
0
Renderables SceneData::getLights() const
{
    Renderables lights;
    
    for ( size_t index : m_lightIndices ) {
        lights.push_back( m_renderables[ index ] );
    }
    return lights;
}
Exemple #4
0
void LootManager::getRenders(Renderables &dest) {
	for (LootList::const_iterator it = lootList.begin(); it != lootList.end(); ++it) {
		const LootDef &loot = **it;

		Renderable r;
		r.map_pos = loot.pos;
		r.src.x = (loot.frame / LootDef::anim_loot_duration) * 64;
		r.src.y = 0;
		r.src.w = 64;
		r.src.h = 128;
		r.offset = Point(32, 112);
		r.object_layer = true;
		r.tile = Point(0, 0);
		// Right now the animation settings (number of frames, speed, frame size)
		// are hard coded.  At least move these to consts in the header.
		if (loot.stack.item) {
			// item
			for (int i=0; i<animation_count; i++) {
				if (loot.stack.item->loot == animation_id[i])
					r.sprite = flying_loot[i];
			}
		}
		else if (loot.gold > 0) {
			// gold
			if (loot.gold <= 9)
				r.sprite = flying_gold[0];
			else if (loot.gold <= 25)
				r.sprite = flying_gold[1];
			else
				r.sprite = flying_gold[2];
		}

		dest.push_back(r);
	}
}
Exemple #5
0
void Game::render()
{
	glPushMatrix();
	// Camera.
	
	glTranslatef(-(mCameraPosition.x - (mScreenSize.width / 2)), -(mCameraPosition.y - (mScreenSize.height / 2)), 0.0);
	
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	renderPass(frames);
	
	if (drawBoundingBoxes)
	{
		Renderables rs = Renderable::all();
		for (Renderables::const_iterator iter = rs.begin(); iter != rs.end(); ++iter)
		{
			Rect boundingRect = (*iter)->boundingRect();
			
			glMatrixMode(GL_MODELVIEW);
			glPushMatrix();
			
			glTranslatef(boundingRect.origin.x, boundingRect.origin.y, 0.0);

			glHint(GL_LINE_SMOOTH_HINT, GL_FASTEST);
			glBegin(GL_LINE_LOOP);
			{
				glLineWidth(1.0);
				Color(1.0, 1.0, 1.0, 0.5).set();
				glVertex2f(0.0, 0.0);
				glVertex2f(boundingRect.size.width, 0.0);
				glVertex2f(boundingRect.size.width, boundingRect.size.height);
				glVertex2f(0.0, boundingRect.size.height);
			}
			glEnd();
			
			glPopMatrix();
		}
	}
	
	glPopMatrix();
	
	// TODO: Draw widgets here instead of compensating for the translation in the widget drawing code.
	// ^ would also ensure that widgets are always on top of content.
	
	SDL_GL_SwapBuffers();
}
Exemple #6
0
		const_iterator end() const { return m_children.end(); }
Exemple #7
0
		const_iterator begin() const { return m_children.begin(); }