Gamestudio Links
Zorro Links
Newest Posts
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 1,454 guests, and 9 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19058 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Probleme mit Events #312432
02/24/10 19:12
02/24/10 19:12
Joined: Jun 2008
Posts: 146
Deutschland
M
M4sterm1nd Offline OP
Member
M4sterm1nd  Offline OP
Member
M

Joined: Jun 2008
Posts: 146
Deutschland
Hallo Gamestudio Com.

Hoffentlich könnt Ihr mir weiterhelfen ich bin schon am verzweifeln.

Bei meinem jetzigen Projekt, ein kleines Fake 2D Spiel, habe ich ein paar Probleme.

Also es Spielt sich alles im Weltraaum ab. Man sieht sein Raumschiff von oben und muss asteroiden ausweichen und gegner abschießen. kein sidescroller, ist ne offene welt. also wo man hinfliegen kann wo man will.

Meine Probleme:
- Manche Asteroiden explodieren einfach nicht
- Laser und Raketen ziehen nicht die richtigen schadenswerte vom healthwert der getroffenen Entity ab

Ich glaube es liegt an den Events.

Ich muss leider meinen ganzen Code posten da sonnst der zusammenhang schwer erkennbar ist.

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
}



Danke fürs lesen.

Bitte helft mir.

Re: Probleme mit Events [Re: M4sterm1nd] #312452
02/24/10 21:11
02/24/10 21:11
Joined: Jun 2008
Posts: 146
Deutschland
M
M4sterm1nd Offline OP
Member
M4sterm1nd  Offline OP
Member
M

Joined: Jun 2008
Posts: 146
Deutschland
in English:

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.

Thanks for reading.

Please help me.

And Sorry is google translate

Last edited by M4sterm1nd; 02/24/10 21:12.
Re: Probleme mit Events [Re: M4sterm1nd] #312457
02/24/10 21:49
02/24/10 21:49
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Das liest sich niemand durch, geschweige denn bearbeitet den Code.

Fang doch mal mit einem kleinen Test-Projekt an, wo du event-Techniken ausprobierst und erfolgreiches dann auf dein Spiel überträgst (oder so den Fehler findest). Oder du reduzierst es auf ein Minimum, also fast alles auskommentieren und dann der Sache auf den Grund gehen.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: Probleme mit Events [Re: Superku] #312459
02/24/10 22:14
02/24/10 22:14
Joined: Jun 2008
Posts: 146
Deutschland
M
M4sterm1nd Offline OP
Member
M4sterm1nd  Offline OP
Member
M

Joined: Jun 2008
Posts: 146
Deutschland
es geht ja nur darum ob vielleicht jemand ne idee hat was falsch sein kann

aber du hast schon recht über 500 zeilen code ist schon ne menge

Re: Probleme mit Events [Re: M4sterm1nd] #312477
02/24/10 23:57
02/24/10 23:57
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Ok, bei konkreten Minimalproblemen einfach melden oder bitte Lösung posten, um anderen mit ähnlichen Problemen zu helfen.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: Probleme mit Events [Re: Superku] #312505
02/25/10 09:10
02/25/10 09:10
Joined: Jun 2008
Posts: 146
Deutschland
M
M4sterm1nd Offline OP
Member
M4sterm1nd  Offline OP
Member
M

Joined: Jun 2008
Posts: 146
Deutschland

so hier mal nur die event wichtigen codeteile
Code:
action player1() // attach this action to the ship model
{
		
	#define schaden skill51
	#define health skill52
	
	my.health = 100;
	my.schaden = 10;
	
	while (1)
	{
			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
		

		if(my.health <= 0)
		{
			asteroid_destroy();
		}
		
		wait (1);
	}
}

action gegner()
{
		
	#define schaden skill51
	#define health skill52
	
	my.health = 100;
	my.schaden = 10;
	
	while(1)
	{
		
		my.emask |= (ENABLE_BLOCK | ENABLE_IMPACT); 
		my.event = gegner_event; 
		
				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);
			
					}
		
		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 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()
{

	
	while(1)
	{
		on_mouse_left = players_laser;
		on_mouse_right = players_rocket;
		
		
		wait(1);
	}
		
}

// 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;
	
	

	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); 
		
		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);


	
	#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);
}



Re: Probleme mit Events [Re: M4sterm1nd] #312514
02/25/10 10:47
02/25/10 10:47
Joined: Jan 2003
Posts: 4,615
Cambridge
Joey Offline
Expert
Joey  Offline
Expert

Joined: Jan 2003
Posts: 4,615
Cambridge
immer noch zu lang. wenn du solchen code schreiben kannst, warum kannst du ihn dann nicht debuggen?

Re: Probleme mit Events [Re: Joey] #312515
02/25/10 11:00
02/25/10 11:00
Joined: Jun 2008
Posts: 146
Deutschland
M
M4sterm1nd Offline OP
Member
M4sterm1nd  Offline OP
Member
M

Joined: Jun 2008
Posts: 146
Deutschland
na dann hier erstmal nur die events
Code:
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 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 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);
}


function schusstreffer_event() // Event vom Asteroiden
{
	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() // wenn health <= 0
{
	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);
}



@ Joey den debug hab ich bis jetzt noch nie verwendet immer nur selbst durch den code gekuckt aber das ist auch nebensächlich schließlich hohlt sich auch ein fußballprofi tipps von anderen spielern also ich wär bei jeder hilfe dankbar

Re: Probleme mit Events [Re: M4sterm1nd] #312521
02/25/10 12:05
02/25/10 12:05
Joined: Jul 2008
Posts: 894
T
TechMuc Offline
User
TechMuc  Offline
User
T

Joined: Jul 2008
Posts: 894
Quote:
schließlich hohlt sich auch ein fußballprofi tipps von anderen spielern also ich wär bei jeder hilfe dankbar


grin grin
da fällt mir fast nur ein... legendär... grin
Der "Profi" weiß halt leider nicht wie man einen debugger benutzt. Da fehlen den Fußballprofi ja schon fast beide beine um das vergleichen zu können in dem fall. LERNE zu debuggen. Programmierung ohne debuggen ist nicht möglich.

Was ich dir übrigens sagen kann, ist dass die Funktion blink() nicht gescheit funktionieren kann - um irgendwas konstruktives zu schreiben laugh

PS: schau dir mal den unterschied zwischen EVENT_IMPACT & EVENT_ENTITY an..

PS2: kann mir vorstellen, dass es mit dem passable flag von rocket öfter probleme gibt ( "The entity must not be PASSABLE and it's push value must be 0 or less. ")

Last edited by TechMuc; 02/25/10 12:09.
Re: Probleme mit Events [Re: TechMuc] #312539
02/25/10 14:05
02/25/10 14:05
Joined: Jun 2008
Posts: 146
Deutschland
M
M4sterm1nd Offline OP
Member
M4sterm1nd  Offline OP
Member
M

Joined: Jun 2008
Posts: 146
Deutschland
naja war ein schlechtes beispiel
sagen wir ich hab früher nur als abwehrspieler gespielt und steh jetzt im tor wink

ja das debugging werd ich mir ankucken müssen.

zu blink: Das ist eigentlich die einzige funktion die wirklich immer das tut was sie auch soll also immer wenn etwas getroffen wird blinkt es auch auf.

zu PS: ich weiß EVENT_IMPACT da muss der pushwert genauso groß oder kleiner sein als von der stoßenden Entity.
Event_ENTITY ist eigentlich nur das der pushwert größer ist.
push werte hab ich nicht vergeben müßten also auf null stehen

ODER hab ich da was falsch verstanden?

zu PS2:
der PASSABLE flag der Rocket wird nach einer bestimmten flugstrecke wieder abgeschaltet. das mache ich damit ich nicht das eigene Raumschiff kaputtschieße wink

war aber ein guter ansatz Danke

Last edited by M4sterm1nd; 02/25/10 14:07.
Page 1 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1