Gamestudio Links
Zorro Links
Newest Posts
Executing Trades on Next Bar Open
by vicknick. 06/13/24 08:51
Zorro Beta 2.61: PyTorch
by jcl. 06/10/24 14:42
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
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (ozgur, Ayumi, VHX, monarch), 1,161 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19059 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Count every 360 degrees rotate #275118
06/30/09 07:31
06/30/09 07:31
Joined: Jun 2009
Posts: 18
3
3DGSDutch Offline OP
Newbie
3DGSDutch  Offline OP
Newbie
3

Joined: Jun 2009
Posts: 18
Hello.

I would like to count every 360 degree rotate. So if my objects has turned 3 times, a variable must be set to 3. Every full round must be +1 on that variable.

But i don't know how to count every round. I tried some things but that won't work pretty well.

Thanks,
3DGS Dutch

Re: Count every 360 degrees rotate [Re: 3DGSDutch] #275126
06/30/09 08:35
06/30/09 08:35
Joined: Feb 2009
Posts: 38
Germany
P
Phonech Offline
Newbie
Phonech  Offline
Newbie
P

Joined: Feb 2009
Posts: 38
Germany
Hi there... take a look at this

Code:
var counter;

action hand_spin()
{
	player = my; //you may take an other entity
	
	while(1)
	{
		my.tilt += 5*time_step; //spins the entity
		if(player.tilt > 360){player.tilt = 0; counter ++;} 
                //if its tilt is above 360 set it 0 again and increase the counter var
		wait(1);
	}
}

PANEL* clockhand_pan = //shows the tilt and counter var on screen
{
	digits(5,5,"TILT: %.0f",("Arial#20"),1,player.tilt);
	digits(5,25,"COUNTER: %.0f",("Arial#20"),1,counter);
	flags = VISIBLE;
}



I hope that helps.

Re: Count every 360 degrees rotate [Re: Phonech] #275131
06/30/09 08:59
06/30/09 08:59
Joined: Jun 2009
Posts: 18
3
3DGSDutch Offline OP
Newbie
3DGSDutch  Offline OP
Newbie
3

Joined: Jun 2009
Posts: 18
Thanks Phonech! It works perfect smile

Re: Count every 360 degrees rotate [Re: 3DGSDutch] #275132
06/30/09 09:04
06/30/09 09:04
Joined: Jul 2007
Posts: 959
nl
F
flits Offline
User
flits  Offline
User
F

Joined: Jul 2007
Posts: 959
nl
just for the eye this wil look some what nicer

if(player.tilt > 360){player.tilt -= 360; counter ++;}


"empty"
Re: Count every 360 degrees rotate [Re: flits] #275152
06/30/09 11:08
06/30/09 11:08
Joined: Jun 2009
Posts: 18
3
3DGSDutch Offline OP
Newbie
3DGSDutch  Offline OP
Newbie
3

Joined: Jun 2009
Posts: 18
Is it possible to script it like this:

If it is rotating, and you press a button: That it will slowly rotate to the starting point. So it will stop rotating at 360 degrees?

If yes, how ?

Re: Count every 360 degrees rotate [Re: 3DGSDutch] #275183
06/30/09 14:16
06/30/09 14:16
Joined: Feb 2009
Posts: 38
Germany
P
Phonech Offline
Newbie
Phonech  Offline
Newbie
P

Joined: Feb 2009
Posts: 38
Germany
Hmmm, let's see...

Code:
var counter;
var spin = 1;

function handel_timer()
{
	if (spin) //if var spin = 1
	{
		player.tilt += 5*time_step; //rotate the entity
	}
	else
	{
		while(player.tilt > 0)
		{
			player.tilt -= 0.5*time_step;
			spin = 0;
			wait(1);
		}
	}
}

action hand_spin()
{
	player = my;
	while(1)
	{
		handel_timer();
		if(player.tilt > 360){player.tilt = 0; counter ++;} 
		if(key_space && spin) //if space pressed and spin = 1
		{
			spin = 0;
			while(key_space) wait(1); //wait until space is released
		}
		if(key_space && !spin) //if space pressed and spin = 0
		{
			spin = 1; //set spin = 1
			while(key_space) wait(1);
		}
		wait(1);
	}
}



Re: Count every 360 degrees rotate [Re: Phonech] #275199
06/30/09 14:49
06/30/09 14:49
Joined: Jun 2009
Posts: 18
3
3DGSDutch Offline OP
Newbie
3DGSDutch  Offline OP
Newbie
3

Joined: Jun 2009
Posts: 18
It's working but not as I would. It only may rotate 1 way, not back. And it's going to fast back to 0.

Re: Count every 360 degrees rotate [Re: 3DGSDutch] #275212
06/30/09 15:58
06/30/09 15:58
Joined: Feb 2009
Posts: 38
Germany
P
Phonech Offline
Newbie
Phonech  Offline
Newbie
P

Joined: Feb 2009
Posts: 38
Germany
Okay here we go! Just replace the function an add the new var.

Code:
var back_speed = 1; //play with this var 

function handel_timer()
{
	if (spin) //if var spin = 1
	{
		player.tilt += 5*time_step; //rotate the entity
	}
	else // var spin is 0
	{
		if(player.tilt > 0)
		{
			player.tilt += back_speed*time_step;
			key_space = 0; //don't let them use space until .tilt isn't 0 agian
		}
	}
}



Re: Count every 360 degrees rotate [Re: Phonech] #275222
06/30/09 16:21
06/30/09 16:21
Joined: Jun 2009
Posts: 18
3
3DGSDutch Offline OP
Newbie
3DGSDutch  Offline OP
Newbie
3

Joined: Jun 2009
Posts: 18
That's more better:), but it even stop's to fast, the speed need to go slower and slower, and not at one time. But slowly slower.

Re: Count every 360 degrees rotate [Re: 3DGSDutch] #275228
06/30/09 16:38
06/30/09 16:38
Joined: Feb 2009
Posts: 38
Germany
P
Phonech Offline
Newbie
Phonech  Offline
Newbie
P

Joined: Feb 2009
Posts: 38
Germany
hmm, try player.tilt += back_speed*time_step*(360-player.tilt); or something in the handle_time() function. I'm sure you can figure that out by your own.

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