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
2 registered members (dr_panther, 1 invisible), 620 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
variable speed changes #432726
11/13/13 13:45
11/13/13 13:45
Joined: Dec 2009
Posts: 361
R
rtsgamer706 Offline OP
Senior Member
rtsgamer706  Offline OP
Senior Member
R

Joined: Dec 2009
Posts: 361
Hi, I am working on a project in which I have an entity and every few frames it fires our another entity.
What I want this other entity to do is to move forward for 50 frames and then reverse direction.
here's the action that I am using:
Code:
action pulse()
{
	var dist_test = 0;
	var move_dir = 85;
	my.pan = you.direction;
	set(my, PASSABLE);
	while (my)
	{
		c_move (me, vector(move_dir*time_step, 0, 0), nullvector, IGNORE_PASSABLE);
		dist_test ++;
		if (dist_test == 50)
		{
			move_dir = -85;
			wait(-1);
		}
		wait(1);
	}
}



it does exactly what I want it to the first time
but every subsequent time it reverses direction much faster than the first.
I'm not 100% sure, but I think it's because the "dist_test" var is changes faster, but I have no idea why that would be happening.
I don't have any global variables that could be effecting them, so I don't know how they can act differently.
Thanks

Re: variable speed changes [Re: rtsgamer706] #432727
11/13/13 14:14
11/13/13 14:14
Joined: Oct 2011
Posts: 1,082
Germany
C
Ch40zzC0d3r Offline
Serious User
Ch40zzC0d3r  Offline
Serious User
C

Joined: Oct 2011
Posts: 1,082
Germany
You should use time_step instead of dist_test++ wink
And dont use == for these kind oft thinhs use >=

Last edited by Ch40zzC0d3r; 11/13/13 14:14.
Re: variable speed changes [Re: Ch40zzC0d3r] #432730
11/13/13 14:39
11/13/13 14:39
Joined: Dec 2009
Posts: 361
R
rtsgamer706 Offline OP
Senior Member
rtsgamer706  Offline OP
Senior Member
R

Joined: Dec 2009
Posts: 361
The >= thing is fine
but what do you mean by use time_step?
I'm using dist_test as a counter, isn't time_step a constant?

Re: variable speed changes [Re: rtsgamer706] #432733
11/13/13 15:04
11/13/13 15:04
Joined: Oct 2011
Posts: 1,082
Germany
C
Ch40zzC0d3r Offline
Serious User
Ch40zzC0d3r  Offline
Serious User
C

Joined: Oct 2011
Posts: 1,082
Germany
instead of increasing dist_test every frame by 1 (dist_test ++;)
use dist_test += time_step.

Re: variable speed changes [Re: Ch40zzC0d3r] #432737
11/13/13 15:09
11/13/13 15:09
Joined: Dec 2009
Posts: 361
R
rtsgamer706 Offline OP
Senior Member
rtsgamer706  Offline OP
Senior Member
R

Joined: Dec 2009
Posts: 361
time_step fixed it
good to know, thanks


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