예제 #1
0
파일: invaders.c 프로젝트: miloh/f1rmware
void ram(void) {
	while(1) {
		if (!screen_intro()){
      setTextColor(0xff,0x00);
      return;
    }
		game.rokets = 3;
		game.level = 1;
		game.score = 0;
		init_game();
		screen_level();
		while (game.rokets>=0) {
			////checkISP();
			lcdFill(0x00);
			check_end();
			move_ufo();
			move_shot();
			move_shots();
			move_player();
			move_enemy();
			draw_score();
			draw_ufo();
			draw_bunker();
			draw_player();
			draw_enemy();
			draw_shots();
			//        draw_status();
			lcdDisplay();
			delayms(12);
		}
		if (!screen_gameover())
      setTextColor(0xff,0x00);
      return;
	}
}
	void moving(ground& earth, square& another)
	{
		move_left();
		move_right();		
		gravity(earth);
		warp(another);
		collision_check(another);
		set_square_posit();
		move_shots();
	}
예제 #3
0
파일: all.cpp 프로젝트: cxong/apricots
void all(gamedata &g){

  rotate_radars(g.radar);
  animate_smoke(g.smoke);
  animate_flames(g.flame, g.smoke);
  animate_explosions(g.explosion);
  decay_lasers(g.laser);
  clone_planes(g.p, g.dp, g.mission, g.winner);
  plane_collisions(g);
  move_falls(g);
  move_shots(g.shot,g.gamemap.ground,g.images[114],g.images[318],g.drakms);
  fire_guns(g.gun, g.p, g.sound, g.gamemap.b, g.shot, g.xmove, g.ymove);
  if (g.drak) drak_main(g);

}
예제 #4
0
void flyship(void)
{
 double x, y;
 double theta;
 char c;
 int i, go, x1ship, x2ship, y1ship, y2ship;	
 int score[2];
 score[0]=0;
 score[1]=3;
 char str[100];
 go=0;		//will tell drawship function if forward button is held down so flames can display
 int iterate=0;	//counts iterations of loop to determine when to move asteroids
 x=350;
 y=350;		//initial conditions
 theta=0;
 //the 2d array roids will contain 32 elements, one for each potential asteroid
 //and each element will have four numbers for the asteroids' properties
 double astr[32][5];	
 double shots[32][5]; //2d array for the shots out of the ship and its properties
 initialize(astr);
 initialize(shots);
 drawship(x, y, theta, go);
 double speed=0;
 while(1){
        if(gfx_event_waiting()) {
    		
		c=gfx_wait();
                if (score[1]==0 || c=='q') {
          	//this will run when lives are 0 and display the score
			gfx_clear();
			sprintf(str, "Score: %i   Press q to exit game", score[0], score[1]);
        		gfx_text(250, 350, str);
			c=gfx_wait();				
			if(c=='q'){		
				break;
                	}
		}

		if(c=='d'){
      			theta=theta-PI/20;
			  //this will rotate the ship
		} 
		if(c=='a'){
			theta=theta+PI/20;
		}
		if(c=='w'){
			speed=speed+1;			//moves ship forward
			if (speed>5){
				speed=5;
			}
			go=1;			//will tell drawship function that ship is moving
		
		}
		if(c=='o') {
			shoot(shots, theta, x, y);
                }

		if(x>700){
		        x=1;
		} else if(x<0){
        		x=699;
 		} else if(y>700){      //this keeps the ship from flying off the screen
        		y=1;
		} else if(y<0){
        		y=699;
 		}
	}	
	gfx_clear();
	usleep(10000);
	x1ship= x+20*cos(theta+4*PI/3);		//these variables create a sort of box around the ship, which is later used to check the ship's coordinates for collisions
	y1ship= y;
	x2ship= x+20*cos(theta+5*PI/3);
	y2ship= y-20*sin(theta);
	move_shots(shots);
	destroy(astr, shots, score);	//checks whether an asteroid should be destroyed
	move_asteroids(astr, shots, x1ship, y1ship, x2ship, y2ship, &x, &y, &speed, &theta, score);
	x=x+speed*cos(theta+PI/2);	//iterates coordinates of ship based on changes to theta and speed
        y=y-speed*sin(theta+PI/2);
	drawship(x, y, theta, go);
	if(go>=1){
		go=go-1;	//keeps go at 1 so it stops when stop pressing forward button
	}
	if(speed>.025){
                speed=speed-.025;
	
        }
	iterate++; 
 	sprintf(str, "Score: %d Lives: %d", score[0], score[1]);
        gfx_text(20, 680, str);

	}
}