示例#1
0
Game::Game(){
	//initialise the invaders
	invader_group = new InvaderGroup(Position(50,450), Scale(20,15),
								15, MoveDistance(0,5,5,5), MoveRange(700,230,10,790), 11, 5, 2); //invader group
	//initialise the tank
    theTank = Tank("image/tank.png", Position(400,60), Scale(25,15), MoveDistance(0,0,10,10), 
								MoveRange(0,0,10,790),3); //tank

    for(int i = 0; i < 4; i++)
	{
		//initialise the shields
		theShield[i] = Shield("image/shield.png", Position(100+i*200,200), Scale(50,30), 10);
	}
    invader_last_time = -1;
    invader_current_time = -1;
    invader_step_time = 300; //300 ms
    bullet_last_time = -1;
    bullet_current_time = -1;
    bullet_step_time = 30; //30 ms
	//Assignment 4
	tank_last_time = -1;
	tank_last_milli = -1;
	tank_current_time = -1;
	tank_current_milli = -1;
	tank_step_time = 500; // 500 ms
    conti = true;
	srand(time(NULL));
	lose = false;
	theTank.readHighScore();
}
task main()
{
	while(true)
	{
		Tank();
		IntakeP();
		Launcher();
		LauncherSub();
 	}
}
void DriveSubsystem::SetTeleoperatedDrive() 
{
	if ( m_isArcade ) 
	{
		Arcade();
	} 
	else 
	{
		Tank();
	}
	PrintEncoders();
}
示例#4
0
//-----------------------------------------------------------------------
Controller::Controller(Importer* pkImporter, Scene* pkScene)
:
m_pkScene(pkScene),
m_iNumTanks(def_iNumTanks), 
m_pkGA(NULL),
m_iTicks(0),
m_iNumMines(def_iNumMines),
m_iGenerations(0)
{
	cout << "Generation number: 0" << endl;

	pkImporter->importResources("../../res/sprite.xml");

	for (int i=0; i<m_iNumTanks; ++i)
	{
		m_kVecTanks.push_back(Tank());
		/*
		pkImporter->createSprite("Tank", &m_kVecTanks[i].m_kTankSprite);
		stringstream kName;
		kName.str("");
		kName << "Tank " << i;
		m_kVecTanks[i].m_kTankSprite.setName(kName.str());
		*/
		pkScene->addEntity(m_kVecTanks[i].m_kTankSprite);
	}

	m_iNumWeightsInNN = m_kVecTanks[0].GetNumberOfWeights();

	m_pkGA = new GeneticAlg(m_iNumTanks, def_dMutationRate, def_dCrossoverRate, m_iNumWeightsInNN);

	m_kVecPopulation = m_pkGA->GetChromos();

	for (int i=0; i<m_iNumTanks; i++)
	{
		m_kVecTanks[i].PutWeights(m_kVecPopulation[i].kVecWeights);
	}

	for (int i=0; i<m_iNumMines; ++i)
	{
		Box* pkBox = new Box();
		pkBox->setPos(RandFloat() * def_WindowWidth, RandFloat() * def_WindowHeight);
		pkBox->setColor(0,0,0);
		pkBox->setDim(def_dMineScale,def_dMineScale);
		pkScene->addEntity(pkBox);
		m_kVecMines.push_back(pkBox);
	}
}
示例#5
0
int main(void) {
	GLFWwindow* window;

	glfwSetErrorCallback(error_callback);

	if (!glfwInit())
		exit(EXIT_FAILURE);

	window = glfwCreateWindow(800, 600, "Simple example", NULL, NULL);
	if (!window) {
		glfwTerminate();
		exit(EXIT_FAILURE);
	}

	glfwMakeContextCurrent(window);

	glfwSetKeyCallback(window, key_callback);

	std::cout << "Drawing a window." << std::endl;

	Tank tan = Tank();
	tan.state.x = 50;
	tan.state.y = 50;

	long curTicks = 0;
	float tps = 25.0f;
	while (!glfwWindowShouldClose(window)) {
		float ratio;
		int width, height;

		for (; curTicks < (float) glfwGetTime() * tps; curTicks++) {
			gameTick(tan);
		}

		glfwGetFramebufferSize(window, &width, &height);
		ratio = width / (float) height;

		glViewport(0, 0, width, height);
		glClear(GL_COLOR_BUFFER_BIT);

		glMatrixMode(GL_PROJECTION);
		glLoadIdentity();
		//glOrtho(-ratio, ratio, -1.f, 1.f, -10, 10);
		glOrtho(0, width/2, 0, height/2, -10, 10);
		glMatrixMode(GL_MODELVIEW);

		glLoadIdentity();
		//glRotatef((float) glfwGetTime() * 10.f, 0.f, 0.f, 1.f);
		//glTranslatef((float) glfwGetTime() * 20.f, 0.f, 0.f);
		//tan.state.h = (float) glfwGetTime() * -10.f;
		//tan.state.turretH = (float) glfwGetTime() * 10.f;

		//drawCube(0, 0, 0);
		//drawTri();
		//glLineWidth(2.f);
		tan.draw();

		glfwSwapBuffers(window);
		glfwPollEvents();
	}

	glfwDestroyWindow(window);

	glfwTerminate();
	std::cout << "Byebye" << std::endl;
	exit(EXIT_SUCCESS);
}
示例#6
0
文件: Tank.hpp 项目: briansan/vcs
 Tank() 
   { Tank( 6.0, 10.0 ); }
示例#7
0
文件: Tank.hpp 项目: briansan/vcs
 Tank( double radius, double height ) 
   { Tank( radius, height, 1.0 ); }