Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by fairtrader. 12/05/23 14:22
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
Combine USD & BTC Pairs In Asset Loop
by TipmyPip. 11/26/23 08:30
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
1 registered members (AndrewAMD), 599 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Particles / effect crash #238354
11/26/08 20:51
11/26/08 20:51
Joined: Nov 2008
Posts: 7
D
dos Offline OP
Newbie
dos  Offline OP
Newbie
D

Joined: Nov 2008
Posts: 7
Hi:

I tied the script in the online manual about particle effects:

Code:
// helper function: sets the vector to random direction and length
function vec_randomize (var* vec, var range)
{
   vec[0] = random(1) - 0.5;
   vec[1] = random(1) - 0.5;
   vec[2] = random(1) - 0.5;
   vec_normalize(vec,random(range));
}

// helper function: fades out a particle
function part_alphafade(PARTICLE *p)
{
   p.alpha -= 2*time_step;
   if (p.alpha <= 0) p.lifespan = 0;
}

// particle function: generates a fading explosion into vel direction
function effect_explo(PARTICLE *p)
{
   var temp[3];
   vec_randomize(temp,10);
   vec_add (p.vel_x, temp);
   p.alpha = 25 + random(25);
   p.bmap = scatter_map;
   p.flags |= (BRIGHT | MOVE);
   p.event = part_alphafade; // change to a shorter, faster function
}

function main()
{
level_load("");
vec_scale(normal,10); // produce an explosion into the normal direction
effect(effect_explo,1000,my.x,normal);
}


Every time I run the code Gamestudio crashes.

http://www.conitec.net/beta/aent-effect.htm

Any Idea?

Thanks for any help in advance!

Re: Particles / effect crash [Re: dos] #238355
11/26/08 21:00
11/26/08 21:00
Joined: Oct 2008
Posts: 218
Nashua NH
heinekenbottle Offline
Member
heinekenbottle  Offline
Member

Joined: Oct 2008
Posts: 218
Nashua NH
Code:
function main()
{
level_load("");
vec_scale(normal,10); // produce an explosion into the normal direction
effect(effect_explo,1000,my.x,normal);
}


Is this the entire main() function? I don't think it knows who "my" is.


I was once Anonymous_Alcoholic.

Code Breakpoint;
Re: Particles / effect crash [Re: heinekenbottle] #238422
11/27/08 07:35
11/27/08 07:35
Joined: Nov 2008
Posts: 7
D
dos Offline OP
Newbie
dos  Offline OP
Newbie
D

Joined: Nov 2008
Posts: 7
Yesterday was not my day smile

I've implemented the code into an Action.

Now I got the error message:

Invalid arguments in aPlayer

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

BMAP* scatter_map = "part.tga";

var punkte = 0;
var speed = 10;
var tot = false;

function vec_randomize (var* vec, var range)
{
   vec[0] = random(1) - 0.5;
   vec[1] = random(1) - 0.5;
   vec[2] = random(1) - 0.5;
   vec_normalize(vec,random(range));
}

// helper function: fades out a particle
function part_alphafade(PARTICLE *p)
{
   p.alpha -= 2*time_step;
   if (p.alpha <= 0) p.lifespan = 0;
}

// particle function: generates a fading explosion into vel direction
function effect_explo(PARTICLE *p)
{
   var temp[3];
   vec_randomize(temp,10);
   vec_add (p.vel_x, temp);
   p.alpha = 25 + random(25);
   p.bmap = scatter_map;
   p.flags |= (BRIGHT | MOVE);
   p.event = part_alphafade; // change to a shorter, faster function
}

function eventHandler()
{
	tot = true;	
}

function eventHandlerTore()
{
	punkte++;
	ptr_remove( me );			// Geht
}

action aPlayer()
{
	player = me;
	c_setminmax(my);
		
	while( 1 )
	{
		if( key_space )
		{
			vec_set(screen_color,vector(255,0,0)); // blau	
			vec_scale(normal,10); // produce an explosion into the normal direction
			effect(effect_explo,0,my.x,normal);
		}
		if( tot )
		{
			ptr_remove( me );
			return;
		}
		c_move( my, vector( ( key_a - key_d ) * time_step * speed, ( key_s - key_w ) * time_step * speed, 0), nullvector, ACTIVATE_PUSH );
		wait( 1 );
	}
}

action aHindernis()
{
	set( my, POLYGON );
	c_setminmax(my);
	my.push = 1;
	my.emask |= ENABLE_PUSH;
	my.event = eventHandler;
	
	while( 1 )
	{
		my.pan += time_step;
		wait( 1 );
	}

}

action aTor()
{
	set( my, POLYGON );
	c_setminmax(my);
	my.push = 1;
	my.emask |= ENABLE_PUSH;
	my.event = eventHandlerTore;
	
	while( 1 )
	{
		if( me == NULL )
		{
			return;
		}
		wait( 1 );
	}
}

function main()
{
	level_load("Map.wmb");
	wait(3);
	
	while( 1 )
	{
		camera.x = player.x;
		camera.y = player.y + 500;
		camera.y += mickey.z;
		wait(1);
	}
}


Re: Particles / effect crash [Re: dos] #238427
11/27/08 09:16
11/27/08 09:16
Joined: Nov 2008
Posts: 7
D
dos Offline OP
Newbie
dos  Offline OP
Newbie
D

Joined: Nov 2008
Posts: 7
Code:
effect(effect_explo,0,my.x,normal);


I forgot to set the amount of the particles.

It works!


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