Hello GameStudio Com.

I hope you can help me I am already on despair.

On my current project, a little fake 2D game, I have a few problems.

So, it plays everything from the Weltraaum. You can see his spaceship from above and must dodge asteroids, and shoot down opponent. no sidescroll is the world ne open. So where can you fly where you want.

My problems:
- Some asteroids not simply explode
- Lasers and rockets did not hurt to learn the right values of the measures taken by the entity from health value

I think it is up to the event.

I am sorry to post my entire code because else connexion is difficult to detect.

Code:
///////////////////////////////
#include <acknex.h>
#include <default.c>
///////////////////////////////

function starfield(PARTICLE *p);
function fade_stars(PARTICLE *p);
function fire_effect(PARTICLE *p);
function fade_fire(PARTICLE *p);

function players_laser();
function move_plaser();
function remove_plaser();

function players_rocket();
function move_procket();
function remove_procket();

function neuer_asteroid();
function asteroid();
function schusstreffer_event();
function asteroid_destroy();
function asteroid_explodes();

function enemy_explodes();
function enemy_destroy();

function gegner_event();
function kill_player();

function blink();

function player_collisions();

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

var Raketenzaehler = 0;

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

STRING* explosion_pcx = "explo+9.pcx"	; // explosions sprite

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

BMAP* star_tga = "star.tga";
BMAP* fire_tga = "fire.tga";
BMAP* firered_tga = "fire4_red.tga";

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

action player1() // attach this action to the ship model
{
	var init_z;
	player = my; // I'm the player
	init_z = my.z;
	
	#define schaden skill51
	#define health skill52
	
	my.health = 100;
	my.schaden = 10;
	
	
	VECTOR player_speed, star_pos, temp, jet_offset, jet2_offset, jet3_offset, jet4_offset, jet5_offset, jet6_offset;
	var temp_x = 0, temp_y = 0;
	
	while (1)
	{
		// Triebwerkseffekt	
		vec_set(jet_offset.x, vector(-40, 50, 0)); 
		vec_set(jet2_offset.x, vector(-40, -50, 0));
		vec_set(jet3_offset.x, vector(10, 50, 0));
		vec_set(jet4_offset.x, vector(10, -50, 0));
		vec_set(jet5_offset.x, vector(-15, -65, 0));
		vec_set(jet6_offset.x, vector(-15, 65, 0));
		vec_rotate(jet_offset.x, my.pan);
		vec_rotate(jet2_offset.x, my.pan);
		vec_rotate(jet3_offset.x, my.pan);
		vec_rotate(jet4_offset.x, my.pan);
		vec_rotate(jet5_offset.x, my.pan);
		vec_rotate(jet6_offset.x, my.pan);
		vec_add(jet_offset.x, my.x);
		vec_add(jet2_offset.x, my.x);
		vec_add(jet3_offset.x, my.x);
		vec_add(jet4_offset.x, my.x);
		vec_add(jet5_offset.x, my.x);
		vec_add(jet6_offset.x, my.x);
		
		if((!key_a) || (!key_s) || (!key_w) || (!key_d))
		{
			temp_x = 0;
			temp_y = 0;
		}
		

		if(key_w)
		{
			temp_x += 20 * time_step;
			if (key_space)
			{
				temp_x += 20 * time_step;

				effect(fire_effect, 20, jet_offset.x, nullvector); // generate 20 fire particles each frame
				effect(fire_effect, 20, jet2_offset.x, nullvector);
			}
		
			else
			{
			effect(fire_effect, 10, jet_offset.x, nullvector); // generate 10 fire particles each frame
			effect(fire_effect, 10, jet2_offset.x, nullvector);
			}
		}
		
		if(key_s)
		{
			temp_x -= 20 * time_step;
			if (key_space)
			{
				temp_x -= 20 * time_step;

				effect(fire_effect, 20, jet3_offset.x, nullvector); // generate 20 fire particles each frame
				effect(fire_effect, 20, jet4_offset.x, nullvector);
			}
		
			else
			{
				effect(fire_effect, 10, jet3_offset.x, nullvector); // generate 10 fire particles each frame
				effect(fire_effect, 10, jet4_offset.x, nullvector);
			}
		}
		
		if(key_a)
		{
			temp_y += 20 * time_step;
			if (key_space)
			{
				temp_y += 20 * time_step;

				effect(fire_effect, 10, jet5_offset.x, nullvector);
			}
			
			else
			effect(fire_effect, 5, jet5_offset.x, nullvector);
		}
		
		if(key_d)
		{
			temp_y -= 20 * time_step;
			if (key_space)
			{
				temp_y -= 20 * time_step;

				effect(fire_effect, 10, jet6_offset.x, nullvector);
			}
			
			else
			effect(fire_effect, 5, jet6_offset.x, nullvector);
		}
			
		player_speed.x = temp_x;
		player_speed.y = temp_y;
		player_speed.z = 0;
		
		vec_set(temp.x,mouse_pos3d.x);
		vec_sub(temp.x,my.x);
		temp.z = 0;
		
		vec_to_angle(my.pan,temp);
		
		c_move(my,player_speed,NULLVECTOR,IGNORE_PASSABLE | GLIDE);
		
		my.emask |= (ENABLE_IMPACT | ENABLE_SCAN); // the player is sensitive to collisions with level blocks and entities
		my.event = player_collisions; // and runs this event function if it collides with something
		

		star_pos.x = my.x - 800 + random(1600); // x = -800...+1300
		star_pos.y = my.y - 800 + random(1600); // y = -800...+1300
		star_pos.z = 0;
		effect(starfield, 1, star_pos.x, nullvector);
		
		if(my.health <= 0)
		{
			asteroid_destroy();
		}
		
		wait (1);
	}
}

action gegner()
{
	while (!player) {wait (1);}
	my.z = player.z; // align the power source entity at the same height with the player
	my.pan = random(360); // start with a random set of angles
	
	#define schaden skill51
	#define health skill52
	
	my.health = 100;
	my.schaden = 10;
	
	VECTOR temp,gegnergeschwindigkeit,jet_offset;
	
	vec_set(gegnergeschwindigkeit,vector(5,0,0));
	
	c_setminmax(me);
	set(my, POLYGON);
	
	while(1)
	{
		my.z = player.z;
		my.emask |= (ENABLE_BLOCK | ENABLE_IMPACT); 
		my.event = gegner_event; 
		
		// Triebwerkseffekt	
		vec_set(jet_offset.x, vector(-65, 0, 0)); 
		vec_rotate(jet_offset.x, my.pan);
		vec_add(jet_offset.x, my.x);
		
		c_scan(my.x,my.pan,vector(360,20,750),IGNORE_ME | SCAN_LIMIT);
		
		if(you)
		{
			vec_set(temp,your.x);
			vec_sub(temp,my.x);
			vec_to_angle(my.pan,temp);
		}
		
		if(result > 450)
		{
			c_move(me,gegnergeschwindigkeit,NULLVECTOR,IGNORE_PASSABLE);
			
			effect(fire_effect, 10, jet_offset.x, nullvector);
		}
		
		if(my.health <= 0)
		{
			enemy_destroy();
		}
		
		wait(1);
	}
	
}

function gegner_event()
{
	switch (event_type)
	{
		case EVENT_BLOCK:
		{
			my.health -= 10;
			
			blink();
			
			vec_to_angle(my.pan, normal);
			return;
		}
		
		case EVENT_IMPACT:
		{
			my.health -= you.schaden;
			you.health -= my.schaden;
			
			blink();
			return;
		}
	}
}


function blink()
{
	while(EVENT_BLOCK || EVENT_IMPACT)
	{
		my.ambient = 100;
		while(my.ambient > 0)
		{
			my.ambient -= 5;
			wait(1);
		}
		return;
	}
}

function player_collisions() // this is player's event function
{
	switch (event_type)
	{
		case EVENT_BLOCK:
		{
			my.health -= 10;
			
			blink();
			
			vec_to_angle(my.pan, normal);
			return;
		}
		
		case EVENT_IMPACT:
		{
			my.health -= you.schaden;
			you.health -= my.schaden;
			
			blink();
			return;
		}
	}

}


///////////////////////////////
function main()
{
	vec_set(sky_color, vector(1, 1, 1));
	fps_max = 80;
	
	video_screen = 1;
	
	level_load("spaceshooter.WMB");
	wait(5);
	
	random_seed(0);
	
	mouse_mode = 2;
		
	BMAP* Maus_tga = bmap_create("Maus.tga");
	mouse_map = Maus_tga;
	mouse_spot.x = bmap_width(Maus_tga)/2;
	mouse_spot.y = bmap_height(Maus_tga)/2;

	
	while(1)
	{
			
		vec_set(camera.x,player.x);
		vec_add(camera.x,vector(0,0,1200));
		vec_set(camera.pan,vector(0,-90,0));
		
		mouse_pos.x = mouse_cursor.x;
		mouse_pos.y = mouse_cursor.y;
		
		
		on_mouse_left = players_laser;
		on_mouse_right = players_rocket;
		
		// zufalls Asteroiden
		if(total_secs == 10)
		{
			ent_create("asteroid.mdl",vector(random(4000)-2000,random(4000)-2000,1000),neuer_asteroid);
			
			total_secs = 0;
		}
		
		
		wait(1);
	}
		
}

function neuer_asteroid()
{
	while(my.z > player.z)
	{
		c_move(me,NULLVECTOR,vector(0,0,-5),IGNORE_PASSABLE);
		wait(1);
	}
	
	asteroid();
}


function starfield(PARTICLE *p)
{
	p.alpha = 5 + random(50);
	p.bmap = star_tga;
	p.size = 2 + random(1); // generate stars with random sizes
	p.flags |= (BRIGHT | TRANSLUCENT);
	p.event = fade_stars;
}

function fade_stars(PARTICLE *p)
{
	p.alpha -= 0.5 * time_step; // fade out the stars
	if (p.alpha < 0) 
	{
		p.lifespan = 0;
	}
}


// Triebwerk 

function fire_effect(PARTICLE *p)
{
	p->vel_x = (1 - random(2)) / 5; // set a random particle speed on the x and y axis
	p->vel_y = (1 - random(2)) / 5;
	p->vel_z = 0;
	p.alpha = 25 + random(50); // and a random transparency
	p.bmap = fire_tga;
	p.size = 10; // gives the size of the fire particles
	p.flags |= (BRIGHT | MOVE);
	p.event = fade_fire;
}

function rocketfire_effect(PARTICLE *p)
{
	p->vel_x = (1 - random(2)) / 5; // set a random particle speed on the x and y axis
	p->vel_y = (1 - random(2)) / 5;
	p->vel_z = 0;
	p.alpha = 25 + random(50); // and a random transparency
	p.bmap = firered_tga;
	p.size = 10; // gives the size of the fire particles
	p.flags |= (BRIGHT | MOVE);
	p.event = fade_fire;
}


function fade_fire(PARTICLE *p)
{
	p.alpha -= 25 * time_step; // fade out the fire particles quickly
	if (p.alpha < 0) 
		p.lifespan = 0; // and remove them completely when they become invisble
}

// Schießen (Laser)


function players_laser()
{
	
	VECTOR plaser_offset;
	vec_set(plaser_offset.x, vector(20, 0, 0)); 
	vec_rotate(plaser_offset.x, player.pan);
	vec_add(plaser_offset.x, player.x);
	ent_create("laser1.mdl", plaser_offset.x, move_plaser);

	wait (1); 
}

function players_rocket()
{
	Raketenzaehler += 0.5;
	
	VECTOR plaser_offset;
	
	if(fraction(Raketenzaehler))
	vec_set(plaser_offset.x, vector(0, 20, 0));
	
	else
	vec_set(plaser_offset.x, vector(0, -20, 0)); 
	
	vec_rotate(plaser_offset.x, player.pan);
	vec_add(plaser_offset.x, player.x);
	ent_create("rakete.mdl", plaser_offset.x, move_procket);

	wait (1); 
}



function move_plaser()
{
	c_setminmax(me);
	set(my, PASSABLE);
	set(my, POLYGON);
	my.pan = player.pan; 

	my.emask |= (ENABLE_BLOCK | ENABLE_ENTITY); 
	my.event = remove_plaser; 
	
	#define schaden skill51
	#define health skill52
	
	my.schaden = 10;
	my.health = 10;
	
	while (my) 
	{
		if (vec_dist(my.x, player.x) > 70) 
			reset(my, PASSABLE); 
			
		if (vec_dist(my.x, player.x) > 900)
			remove_plaser();	
			
		c_move(my, vector(75 * time_step, 0, 0), nullvector, IGNORE_PASSABLE); 
		wait (1);
	}
}

function move_procket()
{
	c_setminmax(me);
	set(my, PASSABLE);
	set(my, POLYGON);
	my.pan = player.pan; 

	my.emask |= (ENABLE_BLOCK | ENABLE_ENTITY); 
	my.event = remove_procket; 
	
	#define schaden skill51
	#define health skill52
	
	my.schaden = 50;
	my.health = 10;
	
	// Triebwerkseffekt
		VECTOR jet_offset;

	while (my) 
	{
		if (vec_dist(my.x, player.x) > 70) 
			reset(my, PASSABLE); 
			
		if (vec_dist(my.x, player.x) > 900)
			remove_procket();	
			
		c_move(my, vector(50 * time_step, 0, 0), nullvector, IGNORE_PASSABLE); 
		
		vec_set(jet_offset.x, vector(-15, 0, 0)); 
		vec_rotate(jet_offset.x, my.pan);
		vec_add(jet_offset.x, my.x);
		
		effect(rocketfire_effect, 10, jet_offset.x, nullvector); // generate 20 fire particles each frame
		
		wait (1);
	}
}

function remove_plaser() 
{
	wait (1);
	ent_remove(my);
}

function remove_procket() 
{
	wait (1);
	ent_create (explosion_pcx, my.x, asteroid_explodes); // create the explosion sprite	
	ent_remove(my);
}


action asteroid()
{
	c_setminmax(me);
	set(my, POLYGON);

	while (!player) {wait (1);}
	my.z = player.z; // align the power source entity at the same height with the player
	my.pan = random(360); // start with a random set of angles

	
	#define health skill51
	#define schaden skill52

	my.health = 30;
	my.schaden = 10;
	
	my.emask |= (ENABLE_IMPACT | ENABLE_BLOCK);
	my.event = schusstreffer_event;
	
	VECTOR asteroidengeschwindigkeit;
	var i = random(5);
	vec_set(asteroidengeschwindigkeit,vector(i, 0, 0));

	while (my)
	{
		my.z = player.z;
		
		c_move(my,asteroidengeschwindigkeit,NULLVECTOR,IGNORE_PASSABLE);
		
		if(my.health <= 0)
		{
			asteroid_destroy();
		}
		
		wait (1);
	}
}

function schusstreffer_event()
{
	switch (event_type)
	{
		case EVENT_BLOCK:
		{
			vec_to_angle(my.pan, bounce);
			return;
		}
	
		case EVENT_IMPACT:
		{
			my.health -= you.schaden;
			you.health -= my.schaden;
		
			blink();
			return;
		}
	}

}

function asteroid_destroy()
{
	vec_add(my.x, vector(0,0,5));
	ent_create (explosion_pcx, my.x, asteroid_explodes); // create the explosion sprite			
	wait (-0.2);	
	ent_remove(my);
}

function asteroid_explodes() // drives the explosion sprite
{
	set (my, PASSABLE); // the explosion sprite is passable

	my.scale_x = 0.4;
	my.scale_y = my.scale_x;
	my.scale_z = my.scale_x;
	set (my, BRIGHT); // set its bright flag
	my.ambient = 100; // give it an ambient of 100
	set (my, TRANSLUCENT); // and make it transparent
	my.alpha = 100; // but we set it to be completely opaque for now
	my.roll = random(360);
	while (my.frame < 9) // go through all the animation frames
	{
		if (my.frame > 2) // a part of the explosion animation was played?
		{
			if (you) // if the enemy ship hasn't been removed yet
				set(you, INVISIBLE); // then make it invisible (the ship and the explosion sprite have overlapped during the 2 animation frames)
		}
		my.frame += 0.7 * time_step; // 0.7 gives the animation speed
		wait (1);
	}

	while (my.alpha > 0) // now fade the last frame quickly
	{
		my.alpha -= 50 * time_step; // 50 = fading speed
		wait (1);
	}
	ent_remove (my); // time to remove the explosion sprite
}

function enemy_destroy()
{
	vec_add(my.x, vector(0,0,5));
	ent_create (explosion_pcx, my.x, enemy_explodes); // create the explosion sprite			
	wait (-0.2);	
	ent_remove(my);
}

function enemy_explodes() // drives the explosion sprite
{
	set (my, PASSABLE); // the explosion sprite is passable

	my.scale_x = 0.8;
	my.scale_y = my.scale_x;
	my.scale_z = my.scale_x;
	set (my, BRIGHT); // set its bright flag
	my.ambient = 100; // give it an ambient of 100
	set (my, TRANSLUCENT); // and make it transparent
	my.alpha = 100; // but we set it to be completely opaque for now
	my.roll = random(360);
	while (my.frame < 9) // go through all the animation frames
	{
		if (my.frame > 2) // a part of the explosion animation was played?
		{
			if (you) // if the enemy ship hasn't been removed yet
				set(you, INVISIBLE); // then make it invisible (the ship and the explosion sprite have overlapped during the 2 animation frames)
		}
		my.frame += 0.7 * time_step; // 0.7 gives the animation speed
		wait (1);
	}

	while (my.alpha > 0) // now fade the last frame quickly
	{
		my.alpha -= 50 * time_step; // 50 = fading speed
		wait (1);
	}
	ent_remove (my); // time to remove the explosion sprite
}




Thanks for reading.

Please help me.

And Sorry is google translate