View Full Version : system
ownerofbabylon
10-04-2001, 02:14 AM
im working on a system for babylon but i need to know somthing. I want it so it can detect when a player hits a key and it does somthing. So say a player pushes a + up at the same time and i want it to show sprites 2 then 3. How would i make it so it did this in real time? My guess is timeouts but im not sure :(
Enigma_GP6
10-04-2001, 02:30 AM
It is probably something simple like keydown...... for example:
if (keydown(keynumber)&&keydown(keynumber()){
//commands here sor gosh sakes;
}
Like something like that? Or please explain yourself better.
-Rebel95
ownerofbabylon
10-04-2001, 02:40 AM
but i think it needs to constantly check to see if they are pushing it
btedji
10-04-2001, 03:00 AM
Originally posted by ownerofbabylon
but i think it needs to constantly check to see if they are pushing it
if so then just add a timeout loop
Enigma_GP6
10-04-2001, 03:28 AM
oh, okay, well, you have to be more specific, as I remember, if you want it to do that, it would go something like this, but you may revise all you want, because I am making this up as I go.:
while (keydown(keyname)&&(keydown(name)){
if (keydown(name)&&keydown(name)){
//commands here,
//like the sprites and stuff like that, this in
//a loop, but with an 'if' command,
//so only if, beacuse I found that a plain
// 'while' loop seems to not work right on some
//occasions. Just put in stuff like
playersprite=spritename;
}
}
timeout = 0.05;
And that outhgt to do it, although I don't exactly know what you mean, but that is what I am getting out of what you need.
-Rebel95
Cybnext_Design
10-04-2001, 05:56 AM
Originally posted by Enigma_GP6
oh, okay, well, you have to be more specific, as I remember, if you want it to do that, it would go something like this, but you may revise all you want, because I am making this up as I go.:
while (keydown(keyname)&&(keydown(name)){
if (keydown(name)&&keydown(name)){
//commands here,
//like the sprites and stuff like that, this in
//a loop, but with an 'if' command,
//so only if, beacuse I found that a plain
// 'while' loop seems to not work right on some
//occasions. Just put in stuff like
playersprite=spritename;
}
}
timeout = 0.05;
And that outhgt to do it, although I don't exactly know what you mean, but that is what I am getting out of what you need.
-Rebel95
I don't believe you would need a timeout, an if (keydown(#)) should just work without any loop.
And I believe yours would lag a lot.
btedji
10-04-2001, 06:28 AM
Originally posted by Cybnext_Design
I don't believe you would need a timeout, an if (keydown(#)) should just work without any loop.
And I believe yours would lag a lot.
now that i think of it i dont think it needs a timeout either :)
Shard_IceFire
10-04-2001, 06:39 AM
keydowns never really work correctly unless they're in a timeout loop.
btedji
10-04-2001, 07:07 AM
Originally posted by Shard_IceFire
keydowns never really work correctly unless they're in a timeout loop.
they might work more accuratley, but they'll function the same
James
10-04-2001, 08:24 AM
Couldnt you possibly do something different than a timeout? Possibly if (hasweapon) etc?
btedji
10-04-2001, 08:25 AM
Originally posted by James
Couldnt you possibly do something different than a timeout? Possibly if (hasweapon) etc?
dunno but its isweapon and hasweapon(weaponname)
James
10-04-2001, 08:26 AM
Originally posted by btedji
dunno but its isweapon and hasweapon(weaponname)
err i know that, i was just putting it in a short way, thats why I said etc
BocoC
10-04-2001, 08:29 AM
if (created || playerenters) {
this.keys={0,0,0,0,0,0,0,0,0,0,0};
timeout=0.05;
}
if (timeout) {
GetKeys();
DoActions();
timeout=0.05;
}
function GetKeys() {
for (i=0;i<11;i++) {
this.keys[i]=keydown(i);
}
}
function DoActions() {
if (this.keys[0]==1 && this.keys[6]==1) {
DoStuff;
}
}
Try that
btedji
10-04-2001, 07:10 PM
Originally posted by Kaimetsu
Yes it does. Keydown is not an event.
ahhh finally a straight answer!!! :D
vBulletin® v3.8.11, Copyright ©2000-2024, vBulletin Solutions Inc.