Gamestudio Links
Zorro Links
Newest Posts
zorro license, IB connection
by miwok. 12/06/23 16:32
Newbie Questions
by fairtrader. 12/06/23 11:29
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
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
6 registered members (miwok, AndrewAMD, TipmyPip, 3run, Quad, 1 invisible), 645 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Frusterated, guidance please. #242668
12/25/08 02:10
12/25/08 02:10
Joined: Dec 2008
Posts: 12
T
Thordendal Offline OP
Newbie
Thordendal  Offline OP
Newbie
T

Joined: Dec 2008
Posts: 12
I'm doing workshop 18 and the c_move is easy. I'm trying to make the key_space decrease the variable NOS.

I've tied them in, I just can't figure out a way to decrease the value of it when I hit the space button.

Code:
if ((key_space) && (nos >= 1))
c_move (my, vector(15 * time_step, 0, 0), nullvector, GLIDE);

I think I know what to do, but I can't figure out how to do it without crashing the client.

It's got to have something like this right?

Code:
while (key_space) {
energy -= 1;
}


I also believe I need to use while(1), am I right?

Re: Frusterated, guidance please. [Re: Thordendal] #242676
12/25/08 04:27
12/25/08 04:27
Joined: Aug 2008
Posts: 218
U.S.
GamerX Offline
Member
GamerX  Offline
Member

Joined: Aug 2008
Posts: 218
U.S.
Not totally sure what u want but i will give you a few examples.

Code:
while(1)
{
if(key_space)
{
nos -= 1;
}
wait(1);
}


the above code will continue to subtract one from nos while you have the space key down if you want it to just subtract once every time you hit the space bar then you would do something like this.

Code:
var space_hold = 1;
while(1)
{
if(key_space && space_hold == 1)
{
nos -= 1;
space_hold = 0;
}
if(key_space != 1)
{
space_hold = 1;
}
wait(1);
}

That will take 1 from nos every time you hit the space bar even if you hold it down.

Code:
var space_hold = 1;
while(1)
{
if(key_space && space_hold == 1 && nos > 0)
{
nos -= 1;
space_hold = 0;
}
if(key_space != 1)
{
space_hold = 1;
}
wait(1);
}


That will subtract 1 from nos when you hit the space bar only if it is greater than 0.

If you were asking for something else let me know lol.
Or if you get an error because i am kinda half asleep right know just got out of the car.


"You may never know what results come of your action, but if you do nothing there will be no result."
-Mahatma Gandhi
Re: Frusterated, guidance please. [Re: GamerX] #242678
12/25/08 04:43
12/25/08 04:43
Joined: Dec 2008
Posts: 12
T
Thordendal Offline OP
Newbie
Thordendal  Offline OP
Newbie
T

Joined: Dec 2008
Posts: 12
Just got it, what do you think?
Code:
if ((key_space) && (energy > 1)) // press and hold the "Space" key to move the car
			c_move (my, vector(15*time_step, 0, 0), nullvector, GLIDE);
		if(key_space)
			energy-= .12;
		if (energy < 0)
			energy = 0;
		if (energy < 100)
		energy += .02;	
		wait (1);
	}
}
PANEL* nos = {
	digits (50, 50, 3, *, 1,energy);
	flags = VISIBLE;
}


Re: Frusterated, guidance please. [Re: Thordendal] #242679
12/25/08 04:46
12/25/08 04:46
Joined: Aug 2008
Posts: 218
U.S.
GamerX Offline
Member
GamerX  Offline
Member

Joined: Aug 2008
Posts: 218
U.S.
Looks good.


"You may never know what results come of your action, but if you do nothing there will be no result."
-Mahatma Gandhi

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