Esempio n. 1
0
// updateBullets
// updates the entire list of bullets
void updateBullets()
{
  byte id;
  
  for(id=0; id<BULLET_MAX; id++)
  {
    updateBullet(bullets[id]);
  }
}
Esempio n. 2
0
void gameLoop(){
  while(lives>0){
  updateGeese();
  updateBullet();
  updateGun();
  globalHitTest();
  paintFrame();
  updateLED(lives);
  curGeeseSpeed=geeseSpeed[getPot()/2];
  }
}
Esempio n. 3
0
void MainGame::gameLoop(){

	NeroEngine::FpsLimter _fpsLimter;
	_fpsLimter.setMaxFps(60.0f);

	const float CAMERA_SCALA = 2.0f;
	_camera.setScale(CAMERA_SCALA);
	
	const int  MAX_PHYSISC_STEPS = 1.0f;
	const float DESIREO_FPS = 60.0f;
	const float MS_PER_SECOND = 1000;
	const float MAX_DETLA_TIME = 1.0f;
	const float DESIREO_FRAMETIME = MS_PER_SECOND / DESIREO_FPS;
	float previousTicks = SDL_GetTicks();
	while (_gameState==GameState::PLAY){
		_fpsLimter.begin();
		float newTicks = SDL_GetTicks();
		float frameTime = newTicks - previousTicks;
		previousTicks = newTicks;

		float totalDeltaTime = frameTime / DESIREO_FRAMETIME;

		checkVictory();

		processInput();
		int i = 0;
		while (totalDeltaTime>=0.0f && i<MAX_PHYSISC_STEPS)
		{
			_deltaTime = 1.0f;// std::min(totalDeltaTime, MAX_DETLA_TIME);
			updateAgent(_deltaTime);
			updateBullet(_deltaTime);
			
			//_miniMap.update([=](std::vector<Zombie*> zombies, std::vector<Human*> humans)->void{
				
			//});

			totalDeltaTime += _deltaTime;
			i++;
		}
		
		_particleEngine.update(_deltaTime);

		_camera.setPosition(_player->getAgentPos());

		_camera.update();
		
		drawGame();

		_fps = _fpsLimter.end();
	}
}
Esempio n. 4
0
void update(int value)
{
	updateAnimations();
	updatePointer();
	updatePlayer();
	updateBullet();
	updateCubes();
	updateExplosions();
	updateScore();

	// comunica cata cuburi mai sunt
	sprintf_s(_windowTitle, 39, "JakCube - %d cubes left", _evilCubes.size());
	_windowTitle[39] = NULL;
	glutSetWindowTitle(_windowTitle);

	glutPostRedisplay();
	glutTimerFunc(25, update, 0);
}
//prototype
int main(void){

	bool done = false;
	bool redraw = true;
	const int FPS = 60;
	bool isGameOver = false;
	
	//object variables
	spaceShip ship;
	Bullet bullets[NUM_BULLETS];
	Comet comets[NUM_COMETS];

	ALLEGRO_DISPLAY *display = NULL;
	ALLEGRO_EVENT_QUEUE *eventQueue = NULL;
	ALLEGRO_TIMER *timer = NULL;
	ALLEGRO_FONT *font18 = NULL;

	

	
	//check if allegro is initialised <allegro_native_dialog.h>
	if(!al_init()){ 
		return -1;
	}

	display = al_create_display(WIDTH,HEIGHT);
	

	//check if display was created
	if(!display){
		return -1;
	}

	al_init_primitives_addon();
	al_install_keyboard();
	al_init_font_addon();
	al_init_ttf_addon();

	eventQueue = al_create_event_queue();
	timer= al_create_timer(1.0/FPS);

	srand(time(NULL)); // gives the rand() some value
	initShip(ship);
	initBullet(bullets, NUM_BULLETS);
	initComet(comets, NUM_COMETS);

	font18 = al_load_font("arial.ttf",18,0);
	
	al_register_event_source(eventQueue, al_get_keyboard_event_source());
	al_register_event_source(eventQueue, al_get_timer_event_source(timer));
	al_register_event_source(eventQueue, al_get_display_event_source(display)); //event os display resize closing, moving

	al_start_timer(timer);

	while(!done){
	
		ALLEGRO_EVENT ev;
		al_wait_for_event(eventQueue, &ev);

		if (ev.type==ALLEGRO_EVENT_TIMER){
			redraw=true;
			if(keys[UP]){
				moveShipUp(ship);
			}
			if(keys[DOWN]){
				moveShipDown(ship);
			}
			if(keys[LEFT]){
				moveShipLeft(ship);
			}
			if(keys[RIGHT]){
				moveShipRight(ship);
			}

			if(!isGameOver){
				updateBullet(bullets,NUM_BULLETS);
				startComet(comets, NUM_COMETS);
				updateComet(comets, NUM_COMETS);
				collideBullet(bullets,NUM_BULLETS, comets, NUM_BULLETS, ship);
				collideComet(comets, NUM_COMETS, ship);
			
				if (ship.lives <= 0){
					isGameOver = true;
				}
			}

			
		}
		// when clicling on red X icon to close the game
		else if(ev.type == ALLEGRO_EVENT_DISPLAY_CLOSE){
			done=true;
		
		}
		else if (ev.type==ALLEGRO_EVENT_KEY_DOWN){
			switch(ev.keyboard.keycode){
				case ALLEGRO_KEY_ESCAPE:
					done=true;
					break;
				case ALLEGRO_KEY_UP:
					keys[UP]=true;
					break;
				case ALLEGRO_KEY_DOWN:
					keys[DOWN]=true;
					break;
				case ALLEGRO_KEY_LEFT:
					keys[LEFT]=true;
					break;
				case ALLEGRO_KEY_RIGHT:
					keys[RIGHT]=true;
					break;
				case ALLEGRO_KEY_SPACE:
					keys[SPACE]=true;
					fireBullet(bullets, NUM_BULLETS, ship);
					break;
			}
		}
		else if (ev.type==ALLEGRO_EVENT_KEY_UP){
			switch(ev.keyboard.keycode){
				//make sure when exiting the program exit with esc button
				case ALLEGRO_KEY_ESCAPE:
					done=true;
					break;
				case ALLEGRO_KEY_UP:
					keys[UP]=false;
					break;
				case ALLEGRO_KEY_DOWN:
					keys[DOWN]=false;
					break;
				case ALLEGRO_KEY_LEFT:
					keys[LEFT]=false;
					break;
				case ALLEGRO_KEY_RIGHT:
					keys[RIGHT]=false;
					break;
				case ALLEGRO_KEY_SPACE:
					keys[SPACE]=false;
					break;
			}
		}
		if (redraw && al_is_event_queue_empty(eventQueue)){ // I only draw the screen if there no more event
			redraw=false;

			if(!isGameOver){			
				drawShip(ship);
				drawBullet(bullets,NUM_BULLETS);
				drawComet(comets, NUM_COMETS);

				al_draw_textf(font18, al_map_rgb(255,0,255), 5, 5, 0, "Player has %i lives left. Player has destroyed %i objects", ship.lives, ship.score);
			}
			else{
				al_draw_textf(font18, al_map_rgb(0,255,255),WIDTH / 2, HEIGHT / 2, ALLEGRO_ALIGN_CENTRE, "Game Over, Pal. Final Score: %i", ship.score);
			}

			al_flip_display();
			al_clear_to_color(al_map_rgb(0,0,0)); //that prevents the filled rectangle draw imga just like snake style	
	
		}
		
		//make sure when exiting the program exit with esc button
		
		// when clicling on red X icon to close the game
		}

	//al_rest(5.0);
	al_destroy_display(display);
//hadouken

return 0;
}
//prototype
int main(void){

	bool done = false;
	bool redraw = true;
	const int FPS = 60;

	//object variables
	spaceShip ship;
	Bullet bullets[5];

	ALLEGRO_DISPLAY *display = NULL;
	ALLEGRO_EVENT_QUEUE *eventQueue = NULL;
	ALLEGRO_TIMER *timer = NULL;

	
	//check if allegro is initialised <allegro_native_dialog.h>
	if(!al_init()){ 
		return -1;
	}

	display = al_create_display(WIDTH,HEIGHT);
	

	//check if display was created
	if(!display){
		return -1;
	}

	al_init_primitives_addon();
	al_install_keyboard();
	//to capture keyboard events
	eventQueue = al_create_event_queue();
	timer = al_create_timer(1.0 / FPS);


	initShip(ship);
	initBullet(bullets,NUM_BULLETS);

	//register the keyboard to eventQueue
	al_register_event_source(eventQueue,al_get_keyboard_event_source());
	al_register_event_source(eventQueue,al_get_timer_event_source(timer));
	al_register_event_source(eventQueue,al_get_display_event_source(display));

	al_start_timer(timer);

	while(!done){
		ALLEGRO_EVENT ev;
		al_wait_for_event(eventQueue,&ev);
		if(ev.type == ALLEGRO_EVENT_TIMER){
			redraw=true;

			if(keys[UP]){
				moveShipUp(ship);
			}
			if(keys[DOWN]){
				moveShipDown(ship);
			}
			if(keys[LEFT]){
				moveShipLeft(ship);
			}
			if(keys[RIGHT]){
				moveShipRight(ship);
			}

			updateBullet(bullets,NUM_BULLETS);
		
		}
		else if(ev.type  == ALLEGRO_EVENT_DISPLAY_CLOSE){
			done=true;
		}
		else if(ev.type == ALLEGRO_EVENT_KEY_DOWN){
			switch(ev.keyboard.keycode){
			case ALLEGRO_KEY_ESCAPE:
				done = true;
				break;
			case ALLEGRO_KEY_UP:
				keys[UP] = true;
				break;
			case ALLEGRO_KEY_DOWN:
				keys[DOWN] = true;
				break;
			case ALLEGRO_KEY_LEFT:
				keys[LEFT] = true;
				break;
			case ALLEGRO_KEY_RIGHT:
				keys[RIGHT] = true;
				break;
			case ALLEGRO_KEY_SPACE:
				keys[SPACE] = true;
				fireBullet(bullets, NUM_BULLETS, ship);
				break;

			}
		}

		else if(ev.type == ALLEGRO_EVENT_KEY_UP){
			switch(ev.keyboard.keycode){
			case ALLEGRO_KEY_ESCAPE:
				done = true;
				break;
			case ALLEGRO_KEY_UP:
				keys[UP] = false;
				break;
			case ALLEGRO_KEY_DOWN:
				keys[DOWN] = false;
				break;
			case ALLEGRO_KEY_LEFT:
				keys[LEFT] = false;
				break;
			case ALLEGRO_KEY_RIGHT:
				keys[RIGHT] = false;
				break;
			case ALLEGRO_KEY_SPACE:
				keys[SPACE] = false;
				break;
			}
		}

		if(redraw && al_is_event_queue_empty(eventQueue)){
			redraw = false;
			drawShip(ship);
			//without updating the bullets they will be only create a static spot in the screen, limited to n number of bullets
			drawBullet(bullets,NUM_BULLETS);
			// when clicling on red X icon to close the game
			al_flip_display();
			al_clear_to_color(al_map_rgb(0,0,0)); //that prevents the filled rectangle draw imga just like snake style	
		}
		//make sure when exiting the program exit with esc button
		
		}

	//al_rest(5.0);
	al_destroy_display(display);
//hadouken

return 0;
}
Esempio n. 7
0
	__declspec(dllexport) void ServerProcess(unsigned int deltaTime)
	{
		updateBullet(deltaTime);
	}
Esempio n. 8
0
void  BWSlot::update(float dt)
{
    updatePos(dt);
    updateBullet(dt);
}