00:00
00:00
Newgrounds Background Image Theme

PalmVoe just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

Foss: Every Other Button

1,389 Views | 3 Replies
New Topic Respond to this Topic

Foss: Every Other Button 2005-11-19 06:53:20


FOSS: Main

Introduction
What this script will do is that first you press the right-button and then the left-button to get more score. You can't press the right-button twice in a row. Do you understand what I'm trying to say? I didn't know what to call it and since my main language isn't english I searched on a dictonary, hope it'll work with the title. Hopefully everyone will understand what it is after I showed the code :P

The Code
Since Foss isn't really a tutorial page as AS:Main I don't think I'll have to explain the code? Well, here it is:

_root.score=0;
onEnterFrame = function(){
if(Key.isDown(Key.LEFT)&&!Key.isDown(Key.R
IGHT)&&_root.turn>=1){
_root.score+=1;
_root.turn=0;
} else if (Key.isDown(Key.RIGHT)&&!Key.isDown(Key.LE
FT)&&_root.turn<=0){
_root.score+=1;
_root.turn=1;
}
};

To show score simply make a text box called "score" without quotes. More on making text boxes you can find here.
You can ofcourse change it as you like and have it in your game or whatever.
If anyone got a better code that does the same maybe you can post it here?

//guywithhiscomp


BBS Signature

Response to Foss: Every Other Button 2005-11-19 07:02:01


Ow, the code got a bit disoriented above, dont know why :S

Well, anyway I hope you can manage to fix it since it's only some extra lines that has to be taken away. Here is the same script but for making the score go down so it's more of a challenge (may be disoriented too):
_root.score=0;
onEnterFrame = function(){
_root.score-=1;
if(_root.score<=0){
_root.score=0;
}
if(Key.isDown(Key.LEFT)&&!Key.isDown(Key.R
IGHT)&&_root.turn>=1){
_root.score+=2;
_root.turn=0;
} else if (Key.isDown(Key.RIGHT)&&!Key.isDown(Key.LE
FT)&&_root.turn<=0){
_root.score+=2;
_root.turn=1;
}
};


BBS Signature

Response to Foss: Every Other Button 2005-11-19 07:38:27


Pretty simple concept. Good if you are trying to make a specific type of game, perhaps, but is it really FOSS material? I don't know.

All I'm saying is, this is a very specific concept which is far from being stand-alone. It would be interesting to see something like iths posted in the AS: Logic (or something like that) page.

I suppose it could be good for something like how fast a character does soething, but even that would require prior knowledge, and a porper understanding of the code which can't be easily gained by a more amateur flashian due to a lack of code notes.

Extend it, maybe?


I'm back! on a temporary basis. No-one can remember who I am! but I don't really mind.

Response to Foss: Every Other Button 2005-11-19 08:16:51


I don't think this is something for the AS: Main since this is a collaboration (?) of different scripts..


BBS Signature