HEY laugh ES TUTS !!
ich musste doch #define benutzen,
damit der schuss keine leeren were hat

hier der code laugh
Code:
///////////////////////////////
#include <acknex.h>
#include <default.c>

#define enemy_width 51
#define enemy_height 64
#define bullet_width 5 // player's bullets' width and height
#define bullet_height 11

///////////////////////////////
var i = 1;
var score = 0;

function move_background();

function space_ship();
function shoot();

function enemy_event(i);
function enemy_collisions(i);


FONT* arial_font = "Arial#20";


///////////////////


PANEL* score_pan =
{
	layer = 20;
	digits (10, 10, "Score: %.f", arial_font, 1, score);
	flags = visible;
}

PANEL* background1 =
{
 bmap = "back_1.bmp";
 pos_x = 0;
 pos_y = 0;
 flags = SHOW;	
}

PANEL* background2 =
{
 bmap = "back_1.bmp";
 pos_x = 0;
 pos_y = -769;
 flags = SHOW;	
}

PANEL* _ship =
{
 bmap = "ship.bmp";
 pos_x = 100;
 pos_y = 100;
 flags = SHOW | OVERLAY;	
}


	

PANEL* _shoot[50];
PANEL* enemies[50];


function main()
{
  vec_set(screen_size,vector(800,400,0));
  vec_set(screen_color,vector(50,1,1)); // dark blue
  vec_set(sky_color,vector(50,1,1)); // dark blue
  video_window(NULL,NULL,0,"My New Game");
  d3d_antialias = 1;
  shadow_stencil = 3;
  level_load(NULL);

  move_background();
  
  enemy_event(i);
  space_ship();

}

function move_background()
{
	while (1)
	{
		background1.pos_y += 3 * time_step; 
		background2.pos_y = background1.pos_y - 769; 
				if (background1.pos_y > 768)
		{
			background1.pos_y -= 768; 
		}
		wait (1);
	}
}

function space_ship()
{
 while(1)
 {
  //UP	
  if (key_cuu == 1)
  {
  	_ship.pos_y --;
  }
  
  //DOWN
  if (key_cud == 1)
  {
  	_ship.pos_y ++;
  }
 
  //LEFT
  if (key_cul == 1)
  {
  	_ship.pos_x --;
  }
 
  //RIGHT
  if (key_cur == 1)
  {
  	_ship.pos_x ++;
  }
  
//SPACE && SHOOT == 0
  if ((key_space) &&(!_shoot[i]))
  {
   _shoot[i] = pan_create("bmap = shot.bmp;",1);
   _shoot[i].pos_x = _ship.pos_x+30;
   _shoot[i].pos_y = _ship.pos_y;
   _shoot[i].flags = VISIBLE;
  }
  
//SHOOT EVENT
if (_shoot[i])
{
if (_shoot[i].pos_y > 5)
{
_shoot[i].pos_y -= 5;
}
else
{
reset(_shoot[i] , VISIBLE);
_shoot[i] = NULL;
}
}



//COLLISION WITH ENEMY

if ((((_ship.pos_x + 67 >= enemies[i].pos_x) && (_ship.pos_x + 67 <= enemies[i].pos_x + 37)) ||
((enemies[i].pos_x + 37 >= _ship.pos_x) && (enemies[i].pos_x + 37 <= _ship.pos_x + 67)))&&
(((_ship.pos_y + 67 >= enemies[i].pos_y) && (_ship.pos_y + 67 <= enemies[i].pos_y + 37)) ||
((enemies[i].pos_y + 37 >= _ship.pos_y) && (enemies[i].pos_y + 37 <= _ship.pos_y + 67))))
{
 if(score > 1)
 {
  score -= 10;	
 }
reset(enemies[i],SHOW);
enemies[i].pos_x = random(400);
enemies[i].pos_y = random(400);
set(enemies[i],SHOW);
}



wait(1);
}
}


function enemy_event(i)
{
enemies[i] = pan_create("bmap = enemy2.bmp; flags = VISIBLE;", 20);
enemies[i].pos_x = random(650);
enemies[i].pos_y = random(350);
enemy_collisions(i);

}


function enemy_collisions(i)
{
	while (1)
	{
		if (_shoot[i]) 
		{
			if (is (enemies[i], INVISIBLE)) {break;} 
						
				if ((((_shoot[i].pos_x + bullet_width >= enemies[i].pos_x) && (_shoot[i].pos_x + bullet_width <= enemies[i].pos_x + enemy_width)) ||
			((enemies[i].pos_x + enemy_width >= _shoot[i].pos_x) && (enemies[i].pos_x + enemy_width <= _shoot[i].pos_x + bullet_width)))
			&& (((_shoot[i].pos_y + bullet_height >= enemies[i].pos_y) && (_shoot[i].pos_y + bullet_height <= enemies[i].pos_y + enemy_height)) ||
			((enemies[i].pos_y + enemy_height >= _shoot[i].pos_y) && (enemies[i].pos_y + enemy_height <= _shoot[i].pos_y + bullet_height))))
			{
				score += 20; 
				reset(_shoot[i], VISIBLE); 
				_shoot[i] = NULL; 
				reset(enemies[i], VISIBLE); 
				enemy_event(i);
			}
			
	
  
			
		}
		wait (1);
	}
}




Last edited by ratz; 11/06/13 17:27.