Gamestudio Links
Zorro Links
Newest Posts
Removing outliers from files
by AndrewAMD. 12/02/26 15:26
SGT_FW
by Aku_Aku. 11/30/26 08:19
Experiences with cTrader
by JeyKey II. 11/27/26 09:04
make a complaint
by EW_bytes. 11/26/26 23:00
FXCM => AVA Trade Plugin???
by Martin_HH. 11/25/26 21:59
No connection to MT4
by Martin_HH. 11/23/26 06:38
MinMax function on History t6 file
by LucasJoshua. 11/21/26 14:28
What are you working on?
by rayp. 11/20/26 18:10
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
1 registered members (clint000), 6,287 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EvanTJ, rht, MaliceTheMaker, Haitao_Ren, JimSimons
19250 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Hold down a key to charge #392384
01/22/12 02:29
01/22/12 02:29
Joined: Aug 2009
Posts: 13
W
WoYoSensei Offline OP
Newbie
WoYoSensei  Offline OP
Newbie
W

Joined: Aug 2009
Posts: 13
Hi,
I have a very noob question.
I`m trying to do something like charging skill, but first I would like to learn on something easy. Let`s say I have a variable shift_press = 0 and when I`m holding a key (left shift for example) this variable is growing +1 for every 0.5 second (max 60 fps, so for every 30 fps). When I`m not holding Left Shift anymore, var shift_press is going back to 0.
And here is my question.
I know how it should work, but Lite-C is just completely not logical in this way tongue
Could you assist me with this? How the code should look to work just as I want to?

Re: Hold down a key to charge [Re: WoYoSensei] #392385
01/22/12 02:55
01/22/12 02:55
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
if(!key_shift) charge = 0;
else charge = minv(charge+0.5*time_step, charge_maximum);

What's so illogical about this? wink


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: Hold down a key to charge [Re: WoYoSensei] #392468
01/23/12 00:35
01/23/12 00:35
Joined: Aug 2009
Posts: 13
W
WoYoSensei Offline OP
Newbie
WoYoSensei  Offline OP
Newbie
W

Joined: Aug 2009
Posts: 13
OK, so here is my code

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

var press_shift = 0;
var charge_maximum = 100;

function shift_press()
{
if(!key_shift) press_shift = 0;
else press_shift = minv(press_shift+0.5*time_step, charge_maximum);
}


PANEL* shift_pan = {
	digits (30,10, 4, *, 1, press_shift);
	flags = SHOW;
}
function main()
{
	screen_size.x = 800;
	screen_size.y = 600;
	video_switch(0,0,2);
	screen_color.blue = 150; // dark blue
	shift_press();
}



and it`s not working...
I was trying, but probably Lite-C doesn`t like me so much as I like Lite-C tongue

What this code should do? Well, nothing important. I`m trying to move this charging to variable. When I`m pressing Left Shift, var should growing, but it doesn`t happen.
I was working witch many other languages before, with Lite-C as well, but that was centuries ago and I think I lost my talent tongue
Could you help me with this?
Thank you for any help.

Re: Hold down a key to charge [Re: WoYoSensei] #392470
01/23/12 00:47
01/23/12 00:47
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
The problem is that the function is only executed once, you have to add a loop to shift_press:

Code:
function shift_press()
{
	while(1)
	{
		if(!key_shift) press_shift = 0;
		else press_shift = minv(press_shift+0.5*time_step, charge_maximum);
		wait(1);
	}
}



I suggest you have a look at the tutorial: http://tutorial.3dgamestudio.net/


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: Hold down a key to charge [Re: Superku] #392483
01/23/12 10:41
01/23/12 10:41
Joined: Aug 2009
Posts: 13
W
WoYoSensei Offline OP
Newbie
WoYoSensei  Offline OP
Newbie
W

Joined: Aug 2009
Posts: 13
Ehhh, yes, now it`s working like a dream. Thank you.


Gamestudio download | 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