|
|
Particles / effect crash
#238354
11/26/08 20:51
11/26/08 20:51
|
Joined: Nov 2008
Posts: 7
dos
OP
Newbie
|
OP
Newbie
Joined: Nov 2008
Posts: 7
|
Hi: I tied the script in the online manual about particle effects:
// 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.htmAny Idea? Thanks for any help in advance!
|
|
|
Re: Particles / effect crash
[Re: heinekenbottle]
#238422
11/27/08 07:35
11/27/08 07:35
|
Joined: Nov 2008
Posts: 7
dos
OP
Newbie
|
OP
Newbie
Joined: Nov 2008
Posts: 7
|
Yesterday was not my day  I've implemented the code into an Action. Now I got the error message: Invalid arguments in aPlayer
#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
dos
OP
Newbie
|
OP
Newbie
Joined: Nov 2008
Posts: 7
|
effect(effect_explo,0,my.x,normal);
I forgot to set the amount of the particles. It works!
|
|
|
|