Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
5 registered members (AndrewAMD, alibaba, Konsti, 2 invisible), 1,418 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Re: Can you help me with this function? [Re: DiegoFloor] #255950
03/13/09 19:24
03/13/09 19:24
Joined: Aug 2008
Posts: 49
V
Vyse220 Offline OP
Newbie
Vyse220  Offline OP
Newbie
V

Joined: Aug 2008
Posts: 49
yes, actually the function create an object that left a particle trail, so, for example, i should do something like:
my.x = vo * cos(c) * t;
the problem is that it doesn't reach the player.

Re: Can you help me with this function? [Re: Vyse220] #256019
03/14/09 07:20
03/14/09 07:20
Joined: Jan 2009
Posts: 86
Brasil - RS
D
DiegoFloor Offline
Junior Member
DiegoFloor  Offline
Junior Member
D

Joined: Jan 2009
Posts: 86
Brasil - RS
Try something like this:

vec_diff(velocity, player.x, me.x); // Now we have a vector from the particle to the player (right now it doesn't mean anything)
vec_normalize(velocity, magnitude); //whatever the size..
vec_add(velocity, me.x); //now the velocity is in the correct place

After we have the velocity vector, we just use it to change the position as we normally would.

me.x += velocity.x * time_step;
me.y += velocity.y * time_step;

This has to be done every frame.

If you want to do with c_move, you have the option of using 'relative vector', and we don't need the vec_add.

Now, if the particle isn't reaching the player, just increase the magnitude of the velocity vector. Add something like a magnitude += 0.1; (have to experiment with some values)

Re: Can you help me with this function? [Re: DiegoFloor] #256020
03/14/09 07:24
03/14/09 07:24
Joined: Jan 2009
Posts: 86
Brasil - RS
D
DiegoFloor Offline
Junior Member
DiegoFloor  Offline
Junior Member
D

Joined: Jan 2009
Posts: 86
Brasil - RS
This is a working code

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

ENTITY* ball;
ENTITY* ball2;


action action_ball()
{
	VECTOR velocity;
	var magnitude = 0.1;
	while(!key_space){wait(1);} //press space to start the chase!
	while(1)
	{
		vec_diff(velocity, ball2.x, me.x); 
		vec_normalize(velocity, magnitude);
		magnitude +=0.003;
		c_move(me, nullvector, velocity, IGNORE_MAPS);
		wait(1);
	}
}

action action_ball2()
{
	while(!key_space){wait(1);}
	while(1)
	{
		c_move(me,nullvector, vector(10*time_step,0,0),NULL);
		wait(1);
	}
}

function main()
{
	mouse_mode = 1;
	level_load("some_map.wmb");
	wait (2); 
	
 	
 	ball2 = ent_create ("ball.mdl", vector(-100, -200, 0), action_ball2);
 	ball = ent_create ("ball.mdl", vector(100, 100, 0), action_ball);
 	
 	
 	vec_set(camera.x, vector(0,0,600)); 	
 	while(1)
 	{
 		camera.pan -= mouse_force.x * 12 * time_step;
		camera.tilt += mouse_force.y * 8 * time_step;
		wait(1);
 	}	
}


Re: Can you help me with this function? [Re: DiegoFloor] #256212
03/15/09 11:04
03/15/09 11:04
Joined: Aug 2008
Posts: 49
V
Vyse220 Offline OP
Newbie
Vyse220  Offline OP
Newbie
V

Joined: Aug 2008
Posts: 49
thx! you helped me a lot!
the only problem is that the player sometimes get hit by this things and my.passable = on; is set Oo
However, thx laugh

Re: Can you help me with this function? [Re: Vyse220] #256235
03/15/09 14:33
03/15/09 14:33
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
add the IGNORE_PASSABLE flag to the c_move calls in the actions of the entities that are hitting him.
EG: c_move(me, nullvector, velocity, IGNORE_MAPS|IGNORE_PASSABLE);


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Page 2 of 2 1 2

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