Example #1
0
int main()
{
    Hondurato car1(20, 0, 20, 25);
    Hondurato car2(7, 20000, 18, 20);
    Hondurato car3(10, 120000, 15, 20);

    std::cout << "-- Car 1 --\nFuel: " << car1.get_fuel() << "/" << car1.get_tank_capacity() << "\n"
              << "Odometer: " << car1.get_odometer() << ", MPG: " << car1.get_mpg() << "\n";
    std::cout << "-- Car 2 --\nFuel: " << car2.get_fuel() << "/" << car2.get_tank_capacity() << "\n"
              << "Odometer: " << car2.get_odometer() << ", MPG: " << car2.get_mpg() << "\n";
    std::cout << "-- Car 3 --\nFuel: " << car3.get_fuel() << "/" << car3.get_tank_capacity() << "\n"
              << "Odometer: " << car3.get_odometer() << ", MPG: " << car3.get_mpg() << "\n";

    std::cout << "\nCar 1 drives at 60mph for 45 minutes to it's destination.\nIt has "
              << car1.drive(60, 45) << " gallons of fuel left.\n";
    std::cout << "Car 2 drives at 80mph for 1 hour and 20 minutes to it's destination.\nIt has "
              << car2.drive(80, 80) << " gallons of fuel left.\n";
    std::cout << "Car 3 drives at 30mph for 30 minutes to it's destination.\nIt has "
              << car3.drive(30, 30) << " gallons of fuel left.\n";

    std::cout << "Car 2 fuels up, it now has " << car2.addFuel(5) << " gallons in it's tank.\n";
    std::cout << "Car 3 fuels up, it now has " << car3.addFuel(0) << " gallons in it's tank.\n";

    return 0;
}
Example #2
0
int main(){


	Car car;
	int gas = car.getGas();

	std::cout << "gas :" << gas << std::endl;

	Car car2(200);
	int gas2 = car2.getGas();

	std::cout << "gas2 :" << gas2 << std::endl;
	return 0;
}
Example #3
0
int main(void)
{
	List<Car> l;
	Car car(MERCEDES_BENZ, 10, 2010, 100, "qwerty");
	Car car2(TOYOTA, 10, 2010, 100, "qwerty2");
	Car car3(MERCEDES_BENZ, 10, 2010, 100, "qwerty3");
	l.PushBack(car);
	l.PushBack(car2);
	l.PushBack(car3);

	l.Print(cout);
	cout<<"\n\n";
	l.Compact();
	l.Print(cout);
	cout<<"\n\n\n";

	l.Diffuse();
	//l.PushBack(car);
	cout << l;

	return 0;
}
Example #4
0
int HSV::start(const std::vector<std::string> &args)
{
    clan::SlotContainer cc;
	DisplayWindow window("ClanLib HSV Sprite", 1024, 768);
	cc.connect(window.sig_window_close(), clan::bind_member(this, &HSV::on_close));
	cc.connect(window.get_ic().get_keyboard().sig_key_up(), clan::bind_member(this, &HSV::on_input_up));
	Canvas canvas(window);
	InputContext ic = window.get_ic();

	clan::Font font(canvas, "Tahoma", -11);

	HSVSpriteBatch sprite_batcher(canvas);
	HSVSprite car1(canvas, &sprite_batcher, "../../Game/SpritesRTS/Gfx/spaceshoot_body_moving1.png");
	HSVSprite car2(canvas, &sprite_batcher, "Resources/ferrari_maranello.png");
	HSVSprite *cars[] = { &car1, &car2 };

	ubyte64 last_fps_update = System::get_time();
	ubyte64 last_time = last_fps_update;

	int fps = 0;
	std::string fps_text;

	float hue_offset = 0.0;
	while (!quit)
	{
		ubyte64 current_time = System::get_time();
		float time_delta_ms = static_cast<float> (current_time - last_time);
		last_time = current_time;

		if (ic.get_keyboard().get_keycode(keycode_left))
			hue_offset += 0.0005f * time_delta_ms;
		else if (ic.get_keyboard().get_keycode(keycode_right))
			hue_offset -= 0.0005f * time_delta_ms;
		if (hue_offset < -1.0f)
			hue_offset += 1.0f;
		if (hue_offset > 1.0f)
			hue_offset -= 1.0f;

		canvas.clear(Colorf::darkslategrey);
		float car_hue = hue_offset;
		for (int y = 0; y < 10; y++)
		{
			for (int x = 0; x < 7; x++)
			{
				cars[(x+y)%2]->draw(canvas, 60+x*128, 60+y*64, car_hue);

				car_hue += 0.02f;
				if (car_hue < -1.0f)
					car_hue += 1.0f;
				if (car_hue > 1.0f)
					car_hue -= 1.0f;
			}
		}

		fps++;
		if (System::get_time() - last_fps_update > 2000)
		{
			fps_text = string_format("%1 fps", fps/2.0f);
			last_fps_update = System::get_time();
			fps = 0;
		}

		Size fps_size = font.get_text_size(canvas, fps_text);
		font.draw_text(canvas, canvas.get_width()-10-fps_size.width, 16, fps_text);
		font.draw_text(canvas, 32, 730, "Use cursor keys left and right");

		window.flip(0);
		KeepAlive::process();
	}

	return 0;
}
Example #5
0
void display(){

	//clear the display
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glClearColor(BLACK, 0);	//color black
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	/********************
	/ set-up camera here
	********************/
	//load the correct matrix -- MODEL-VIEW matrix
	glMatrixMode(GL_MODELVIEW);

	//initialize the matrix
	glLoadIdentity();

	//now give three info
	//1. where is the camera (viewer)?
	//2. where is the camera is looking?
	//3. Which direction is the camera's UP direction?

	//instead of CONSTANT information, we will define a circular path.
	gluLookAt(200*cos(cameraAngle), 200*sin(cameraAngle), 150,		0,0,0,		0,0,1);
	//NOTE: the camera still CONSTANTLY looks at the center
	// cameraAngle is in RADIAN, since you are using inside COS and SIN


	//again select MODEL-VIEW
	glMatrixMode(GL_MODELVIEW);


	/****************************
	/ Add your objects from here
	****************************/

	//border
	glColor3f(1,1,1);
	glBegin(GL_LINES);{
	    glVertex3f(-100, -100, 0);
	    glVertex3f(-100, 100, 0);

	    glVertex3f(-100, 100, 0);
	    glVertex3f(100, 100, 0);

	    glVertex3f(100, 100, 0);
	    glVertex3f(100, -100, 0);

	    glVertex3f(100, -100, 0);
	    glVertex3f(-100, -100, 0);
	}glEnd();

	//roads
	glColor3f(1,1,1);
	glBegin(GL_QUADS);{
	    glVertex3f(-100,-20,0);
	    glVertex3f(-100,20,0);
	    glVertex3f(100,20,0);
	    glVertex3f(100,-20,0);
	}glEnd();

	glColor3f(1,1,1);
	glBegin(GL_QUADS);{
	    glVertex3f(-20,100,0);
	    glVertex3f(20,100,0);
	    glVertex3f(20,-100,0);
	    glVertex3f(-20,-100,0);
	}glEnd();

	//moving car
	pos1 += .1;
	if(pos1>180) pos1 = 0;
	car1(pos1);

    pos2 += .05;
	if(pos2>180) pos2 = 0;
	car2(pos2);

	pos3 += .075;
	if(pos3>180) pos3 = 0;
	car3(pos3);

    //top left buildings 1st row
    drawBuilding(-90, -90, -90, -70, 50);
    drawBuilding(-90, -60, -90, -40, 30);

    //top left buildings 2nd row
    drawBuilding(-60, -90, -60, -70, 60);
    drawBuilding(-55, -60, -55, -40, 40);

    //top right buildings 1st row
    drawBuilding(-90, 90, -90, 70, 70);
    drawBuilding(-90, 60, -90, 40, 50);

    //top right buildings 2nd row
    drawBuilding(-60, 90, -60, 75, 80);
    drawBuilding(-60, 70, -60, 35, 45);

    //middle left buildings
    drawBuilding(40, -90, 40, -70, 40);
    drawBuilding(40, -60, 40, -40, 50);

    //middle right buildings
    drawBuilding(30, 90, 30, 70, 30);
    drawBuilding(30, 60, 30, 40, 50);

    //bottom left buildings
    drawBuilding(70, -90, 70, -70, 30);
    drawBuilding(75, -60, 75, -40, 30);

    //bottom right buildings
    drawBuilding(70, 90, 70, 70, 90);
    drawBuilding(70, 65, 70, 40, 30);

	//ADD this line in the end --- if you use double buffer (i.e. GL_DOUBLE)
	glutSwapBuffers();
}