コード例 #1
0
ファイル: draw.cpp プロジェクト: fangelod/Coursework
    virtual void onDraw(GCanvas* canvas) {
        canvas->fillRect(GRect::MakeXYWH(0, 0, 10000, 10000), fBGColor);

        for (int i = 0; i < fList.size(); ++i) {
            fList[i]->draw(canvas);
        }
        if (fShape) {
            draw_hilite(canvas, fShape);
        }
    }
コード例 #2
0
//Draw the world and all objects
void Game::drawScene(){
	static float hlt_rate = 0.01;		// opacity rate for highlights
	static float hlt =  0.4;			// opacity for highlights
	world.display(camera.get_pos());	// Draw the map

	// Draw fish in the water
	glColor3f(0,0.1,0.2);
	glPushMatrix();
		glTranslatef(0,-1,0);
		bird_system[0].display(dt, camera.get_pos());
	glPopMatrix();

	// Draw birds in the sky
	glColor3f(1,1,1);
	bird_system[1].display(dt, camera.get_pos());

	// Draw water
	glColor4ub(89,173,237,200);
	water_system.display(dt);
	draw_still_water();
	
	glDisable(GL_FOG);
	
	glEnable(GL_FOG);

	glDisable(GL_LIGHTING);

	// Draw the highlight around the selected unit
	glPointSize(4);
	if( current.is_traversable() ){
		vector3f p = current.get_wpos();
		glColor4f(0,0,1,hlt);
		draw_hilite(p);
	}

	// Draw the target around the target tile or unit
	if( target.is_traversable() ){
		vector3f p = target.get_wpos();
		glColor4f(1,0,0,hlt);
		draw_target(p);
	}

	// Draw the highlights for the possible movement area
	if( move_area.size() > 0 ){
		glColor4ub(255,0,93,255*hlt);
		for (int i = 0; i < move_area.size(); ++i){
			vector3f p = move_area[i].get_wpos();
			draw_hilite(p);
		}
	}

	// Draw the hilights for the movement path
	if( move_path.size() > 0 ){
		glColor4f(0,0,1,hlt);
		for (int i = 1; i < move_path.size(); ++i){
			vector3f p = move_path[i].get_wpos();
			draw_hilite(p);
		}
	}

	hlt += hlt_rate;
	if( hlt < 0.4 || hlt > 0.75)
		hlt_rate *= -1;

	draw_skybox();

	glEnable(GL_LIGHTING);
	
	// Draw all the units
	for (int i = 0; i < units.size(); ++i){
		if( units[i].get_team() == 0 )
			glColor3f(0.3,0.3,0.3);
		else
			glColor3f(0.7,0.7,0.7);
		units[i].display(dt,camera.get_pos());	
	}

	draw_hud();
}