Strike Force Heroes 2
The explosive sequel to the hit game Strike Force Heroes!
3.95 / 5.00 11,777 ViewsObsolescence
Defeat the enormous mechanical beasts--and become one of them.
4.04 / 5.00 51,201 ViewsPLATFORMERS FROM THE GROUND UP
A LITTL…CAUGHT MYSELF THERE, A FRICKIN HUGE TUTORIAL
BY THE MUSICIAN
I dunno why everything that isn’t actionscript is in notation…I just started doing it this way and kept at it.
IF YOU READ ANYTHING READ THIS FIRST
If you have finished algebra 1 then actionscript will be soooooo much easier to get. And if you have finished trigonometry well then the sine cosine and atan commands will be easier to learn (but im not gonna be covering any trig this time)
I had an idea for a tutorial, and was bored enough to do it. I centers on a rather advanced FLA file that I wrote. Or at least a glitchy one from a backup file. I’ve taken the liberty of using the glitchy one from the backup file simply because I’d rather not have someone try (keyword being try) to copy and paste this into the flash action script window. A lot of this code has been modified in word rather than in flash and it’s been broken apart many times so I don’t know if it will work anymore at all in flash. But just because it can’t be read by a computer doesn’t mean it can’t be read by humans (I can’t believe I typed this up). The idea is that I would type notes around the source code that were so dumbed down a n00b could understand it. And when I say n00b I mean n00b to actionscript not flash. If you don’t know how to do the visual bits of flash then it will be difficult to understand what I’m talking about even with a coding background. That all typed, if you don’t know the basic timeline control commands then the following content explains them. Otherwise you should skip it or have your intelligence insulted. ONCE AGAIN this code is fricked up from being edited outside of flash. If you find an error whoop dee frickin doo you can post it but don’t be surprised if I reply by repeating this to you unless of course you solve a real glitch that I havn’t found yet in the collision code that makes it so that hits to a wall to the left of you are not detected. Also I may typo once or twice during this…freaking large tutorial, please understand that you’d be brain-dead too if you’d been typing this all day.
If anyone learns anything from this please say so, it would be nice to know I didn’t waste a day of my life for nothing.
ESSENTIAL ACTIONSCRIPT FOR THE COMPLETE N00B
Not everything I’ve listed here is relevant to this tutorial but you might as well learn it now.
stop(); – what do you think it does…CMON!...it pauses whichever timeline you specify (i.e. _root. stop(); to stop the main timeline. I f you don’t specify which timeline then it assumes you are referring to the timeline of the frame or movie clip it’s posted in.
play(); - just like stop only the opposite…did that make sense?
gotoAndStop(); - like stop() only it goes somewhere first…infact it’s pretty self explanatory doncha think.
gotoAndPlay(); - like play() only goes somewhere first… ALSO very self explanatory.
nextFrame(); - move to the next frame
nextScene(); - move to the next scene
prevFrame(); - move to the previous frame
prevScene(); - If I need to explain this then you have no business reading this tutorial…or being alive.
_root. - putting this in front of an instance will tell the game to look for it on the main timeline as opposed to some timeline inside of a movieclip. You don’t have to this all the time if you create a variable for you mc like MC = _root.MC.
._x - the x coordinate of an MC or a button (I dunno about graphics)
._y – ditto only for going up and down rather than left and right. Also not that the greater the y coordinate the lower you go and the lower the y coordinate the higher you go.
._alpha – how see-through an object is for lack of a better term. Its also refered to as opacity in photoshop if that rings a bell. Will return a value and value can be set to between 1 and 100 (if its over 100 then its auto set to one hundred and vice versa for less than 0)
THIS CODE IS IN THE PLATFORMS
I would like to note that this can be used for a tile based system as well with a little tweaking and ingenuity. However im too lazy to do that for you and I still don’t fully understand everything about TBG’s.
onClipEvent (enterFrame) {
leeway = 10;
leeway2 = 30;
leeway3 = 10;
leeway is different for each platform it shows it’s detect ranges. In the if statements below the conditions depend on these variables to make a radar range. (Just try and understand that this is crucial for my form of ground collision).
grip = false;
you can’t grab on to the top of this platform. The code to allow you to grip onto a platform (like if you fall off you can catch yourself) was uncomplete at this time.
walljump = true;
you can jump off the side of this. The wall jump code wasn’t complete at this time
sideA = this._x+_root.groundy._x;
sideB = this._x+this._width+_root.groundy._x;
groundTop = this._y+_root.groundy._y;
measures the coordinates and values of the platform it’s in
if (_root.man._x>sideA && _root.man._x<sideB && _root.man._y<groundTop+leeway && _root.man._y>groundTop-leeway/2) {
_root.ground = groundTop;
}
This is the code for ground collision, if the man is within the platforms detect range then the y coordinate of the top of this platform becomes the value of the variable ground which is in the code on the main timeline. In the main timeline there is a line of code defining landing as if the character’s y is greater than the ground’s value (y coordinates are the reverse of x coordinates, if you raise an object y coordinate it goes down instead of up.), then it will set the mans y to ground’s value. The detect range for the ground collision is determined by the variable “leeway 1”
if (_root.man._x+_root.widthholder>sideA-leew
ay2/2 && _root.man._x+_root.widthholder<sideA+leewa
y2 && _root.man._y>groundTop+leeway3) {
rightactive = true;
_root.rightwall = sideA;
} else {
rightactive = false;
}
if (_root.man._x-_root.widthholder<sideB+leew
ay2/2 && _root.man._x-_root.widthholder>sideB-leewa
y2 && _root.man._y>groundTop+leeway3) {
leftactive = true;
_root.leftwall = sideB;
} else {
leftactive = false;
}
}
This code is for wall collision. In concept it’s as simple as doing y axis collisions. However since there are 2 directions, things get complicated quickly.
I'm reposting so that I can remove the constant // do not post until all 6 pages are posted
I have no country to fight for; my country is the earth; I am a citizen of the world
-- Eugene Debs
THIS CODE IS ON THE MAIN TIMELINE IN THE FIRST FRAME
behold my large list of unorganized variables. These are the reason my sources are not for the weak hearted.
if you already know what variables are then move on. If you don’t let me explain. Variables are basically just holders of values. There are several different kinds of variables all of which are determined by the value that the variable has. If the variable’s value is a number then its an int (integer), if it holds quoted material (i.e. myVariable = 20) then it’s a char (character), if the value is a decimal number then its declared a float (float), and finally if it’s a value of true or false then it’s considered a bool (boolean), wait I forgot one if its value is undefined then it’s a void till it’s given a real value (I don’t know if its called a void or an undeclared but there’s a function type called void that isn’t a variable type so I’m just assuming). I’m also not positive of this, but should a variable be declared something at one point in the code and can be declared a value later that is not of the same type as before it will be declared a multiple (I dunno the real name I just call them multiples). A multiple in theory is caused when flash realizes that it can have it’s type changed twice within a reoccurring code. I assume that constantly changing the value type of a variable is taxing on the computers ram (“not noticeably though”) and also many times requires the “===” and “!==” instead of “==” and “!=” to work in if statements correctly (its fickle so I don’t suggest this unless you have a good reason which I have yet to find one). Phew….did I forget anything? Probably, I always do but lets move on. Ooh I just remembered I think since flash 6 both floats and ints are in the number class, they combined em.
maxrunspeed = 26;
the fastest you can run
runspeed = 0;
im using a drift engine so my run speed starts at 0 but if you character only has on speed it should just be the number of how fast your character goes.
jumpHeight = 40;
your initial jump velocity
velocity = 0;
same idea as runspeed
maxVelocity = -20;
same idea as max runspeed
jump = true;
jump is the bool to determine if he’s in the air or not.
man = _root.man;
this is optional, I do this so I don’t have to worry about typing _root before something everytime I want to refer to something on the main timeline. Now I only have to put down man instead of _root man.
LeftKey = Key.LEFT;
RightKey = Key.RIGHT;
JumpKey = Key.UP;
AttackKey = Key.SPACE;
Same idea as man, only if I decide halfway through I don’t like the keys I used for the controls halfway through the production of the game then I can just change these
walking = false;
Sorta self explanatory
dash = false;
I have an attack that I refer to as a dash and need a bool to keep track of whether its happening or not.
attackcounter = 0;
attackcounter is my way of telling the game when the player is done attacking or the attack animation is over. I reset the counter to 0 at the start of every attack. Then in the attacks if statement I have it add 1 to the attackcounter when its value = the number of frames in that attack animation then I declare that the attack is over
white._alpha = 0;
On the stage I have a movie clip called white and im setting its alpha to 0 so everything isn’t white.
man._y = ground;
part of the collision system you saw earlier it just sets his y coordinate to the value of ground.
attacking = false;
attacking tells me whether the character is attacking or not…god you’re dumb;
timer = 5;
a variable that I use to keep track of my delays (more on this later)
groundy = _root.groundy;
I named it groundy because the name ground was already taken by the ground collision variable
groundframe = 1;
lastframe = 3;
these two variables are part of a very effective form of scrolling optimization. All you need to know about these right now is that lastframe is the number of frames inside of the movieclip groundy and that groundframe is the current frame that groundy is set to
rightactive = false;
leftactive = false;
this shows if your within range of any walls
rightwall = undefined;
leftwall = undefined;
these are the wall equivalent of the ground variable I made. They show the x coordinate of the nearest right and left wall or atleast the last one that was active (the last one you were close to).
righthit = false;
lefthit = false;
These are determined by the wallCheck function that I’ve written waaaaay down there. They show whether you are colliding with a wall or not.
widthholder = _root.man._width/2-10;
this variable is equal to half of the man’s width subtract ten.
I’ll get more organized…someday. If I feel like it…moving on
_root.onEnterFrame = function() {
yeah…you know…its like onClipEvent(enterFrame) only different because this code is in a frame and not a movieclip. Because coding in movieclip doesn’t exist outside of flash and I wanna do C++ someday…when I feel like it…
before we move on notice the braces that comes after the string “_root.onEnterFrame.function()” (these are braces {}). Those braces show the beginning and end of statements, loops and so on. So way down at the bottom where you can see the last brace before I state the wallCheck function, that’s where this onEnterFrame function ends. Is this confusing you yet? Too bad because I don’t know how to better explain it.
wallCheck();
a wonderful little function that I made that works just like hitTest…only it detects detects walls and nothing else…and it doesn’t suck.. (btw for those of you who don’t know what hitTest is, it is the built in function to flash that detects a collision between 2 objects. It however is very bad for things like wall collisions and is very taxing on a computers ram. The only good thing about hitTest is that it can detect all of the contours of a shape, but if you want basic box collision you’re better off making your own.)
Page 2 of 6
I have no country to fight for; my country is the earth; I am a citizen of the world
-- Eugene Debs
if (Key.isDown(LeftKey) && jump == false && dash == false && attacking == false && !lefthit == true) {
This is an “if” statement. An if statement is the most essential piece of coding in every logic based code that I know. Simply enough when you are using an if statement you are saying “if this is happening then do this.” An example would be if a bullet hit a man the thing that would happen would be…the bullet would disappear, maybe a blood movie clip would be displayed, his health would be subtracted from, and if his health was below zero (you can have “if” statements inside of “if” statements) then maybe a bool named dead would be given a value of true or the mans movie clip would gotoAndPlay(death animation). Once again “if” statements are crucial if you don’t understand what they are for then please read this again or find some other tutorial to teach you.
Sorry bout this but before we move on I have some more stuff to explain. If you look above to the if statement, then you can see inside the parenthesis (incase you didn’t know this is where the condition for the if statement goes.). All of those are the conditions (if the left arrow key is down and you’re not jumping and your not doing a dash attack and the is not collision detected with the current value of leftwall).Notice the double ampersand between each condition. This is the operator that represents “and”. Other operators that can be used to separate if statement conditions are…
> - greater than
< - less than
== - check to see if is equal to
>= - greater then or equal to
<= - less than or equal to
!= - is not equal to
=== - strictly equal (sorta complex to explain but essentially the same as “==” only the thing its being compared to has to be the same type of variable)
!== - strictly unequal (same as “!=” only it checks the variables type for equality there are booleans, integers, floats, and a lot of other types I really don’t care to know since flash sets the type for you.)
! – not
|| - or
Since all of these can be used in if statements they are also crucial to know (although a lot of them you should have learned in your math class if you were listening)
In this “if” statement, you’ll see everything that’s happening when the character is walking to the left
groundy._x -= runspeed;
I’m moving the ground instead of the man movie clip this way we the land scrolls and we don’t have to worry about the character going off screen.
walking = true;
Walking is true… because you are walking.
if (lefthit == true) {
walking = false;
wallStop();
}
This is the collision system for when you’re walking. It calls on another function that I’ve written called wallStop(). wallStop() is just like the Landing if statement further down only it works for walls (aduh). If the man reaches or passes the walls x then his speed is set to 0 and his x is backed up to where the x started. This way he’s still colliding with the wall and can’t continue in that directs but can back out of it seeing as righthit’s value is still false. This is why it’s crucial that I have right counterpart for every left-based variable.
if (runspeed<=0) {
man.gotoAndStop("walk");
} else if (runspeed>0) {
man.gotoAndStop("skid");
if (righthit == true) {
wallStop();
walking = false;
}
runspeed -= 2;
}
if your skidding you subtract an extra 2 from runspeed. This is also where I put the collision check for skidding so that you cannot skid through walls.
You see here for the first time an else if statement. Just like an if statement only it will only occur if all of its conditions are met and the if statement’s it’s attached to conditions are not met. However since the first if statement in this case condition is runspeed is less than or equal to 0 and the else if statement’s conditions are if runspeed is greater than 0. there should never be a time when the if’s and the else if’s conditions are met at the same time.
if (runspeed>-maxrunspeed) {
runspeed -= 2;
}
This decreases the variable runspeed’s value by 2 so long as runspeed is greater than negative max runspeed. maxrunspeed has to be negative because the man is heading, left and if he was going by being less than positive maxrunspeed like when the man is heading right then there technically wouldn’t be a maxrunspeed because it would always be less.
if (man._xscale>0) {
man._xscale = man._xscale*-1;
}
a new property of movie clips is introduced. _xscale is like the width of an object only put into a percent like form. _xscale always starts at 100 and at -100 the object is completely flipped (facing the opposite direction). This is perfect for making an opposite direction for every animation you’ve made, however maybe it’s a personal glitch of mine or something that happens to everyone using flash but when I try to do this with more than one object then the width of at least one of them goes crazy. So you have to improvise. Since the original direction you are facing when you’re spawned is “right” then the negative version of whatever your _xscale is must be a perfectly flipped version of you movie clip. Therefore when you turning left you first check to see if your movie clips _xscale is not already what you want it somehow using an if statement (I always check if its positive or negative by asking if the xscale is greater or less than 0). And then you multiply it by negative one, swapping it from positive to negative or vice versa.
} else if (Key.isDown(RightKey) && jump == false && dash == false && attacking == false && !righthit == true) {
Same as I did for walking left only with some changes to make it work for moving right and its an else if statement so that you cant walk right and left at the same time.
groundy._x -= runspeed;
Remember that if the man would move to the right if there was not scrolling, then the platform would move to the left if there was. If the ground is moving instead of the movieclip then it moves in the opposite direction.
walking = true;
walking = true if your walking aduh(again)
if (righthit == true) {
walking = false;
wallStop();
}
Page 3 of 6
I have no country to fight for; my country is the earth; I am a citizen of the world
-- Eugene Debs
wallStop();
I call once again on my wallStop function again since it also has code to turn jump speed to zero along with run speed. (My wallStop function PWNS XD).
if (velocity>maxVelocity) {
velocity -= 10;
}
it will subtract a certain amount from the velocity. Some people like to have a variable called gravity which is subtracted from velocity at this point, but I think that’s sort of pointless since I’d only be using it once and I have like, 20 variables already…wait, do I have 20 variables…I know I have a lot but I’m too lazy to count them.
if (velocity>=0) {
man.gotoAndStop("jump");
} else if (velocity<0) {
man.gotoAndStop("fall");
}
}
And at the end a small bit of code to determine whether to play the jump or fall animation based on the velocity. You don’t have to have a fall animation (you can get away with only having one for jump). But I think it makes it look better for some reason.
if (man._y>ground && groundy.hitTest(man._x, man._y, true) && jump == true) {
man._y = ground;
jump = false;
if (runspeed != 0) {
man.gotoAndStop("walk");
} else {
man.gotoAndStop("stand");
}
}
This bit of code governs the landing sequence (the sequence that lets the movie clip that it’s landed and can stop falling but hopefully you already got that). Again I use hitTest as a backup because you can land if you’re not hitting anything. And lastly I put some animation control code to set it to walk or run depending on the jump speed upon landing because the animations were glitching quite a lot while the man movie clip was landing for reasons unknown.
if (dash == false && jump == false && walking == true && Key.isDown(AttackKey) && (runspeed>=maxrunspeed || runspeed<=-maxrunspeed)) {
This is like the initial jump and fall sequences only for the dash attack. Take note that you must be at full speed to use the attack.
dash = true;
dashspeed = runspeed;
walking = false;
tells the game that you are using the dash attack, that dashspeed is equal to runspeed, and that since obviously since you need to be at full speed to use the attack you are most likely walking.
} else if (dash == true) {
the dash sequence
man.gotoAndStop("dash");
play the dash animation
if (dashspeed<0) {
dashspeed += 2;
} else if (dashspeed>0) {
dashspeed -= 2;
}
this is basically the same as the other if statement waaaaaaay up at the top that lowers the runspeed if you’re not running. Also if you look at that if statement you will see that one of its conditions is not if dash == false. That is simply so that while this attack is occurring, your runspeed will be reset to 0. This makes perfect sense seeing as you will be exiting the attack with a dashspeed of zero and it would look stupid if you went from standing still to running full speed 26 pixels a frame. When making a game always look for ways of changing your old if statements or variables to fit the need of the program before creating new ones (admittedly I didn’t follow that rule very well with this game but do as I say not as I do!).
groundy._x -= dashspeed;
sorta like every other thing we’ve done you’re moving the character in some direction at some speed. Or I guess the ground this time since, I’m doing scrolling
if (dashspeed<3 && dashspeed>-3) {
dashspeed = 0;
dash = false;
}
Like that if statement at the beginning that sets the runspeed to zero if its in between 2 numbers, this if statement ends the dash attack.
} else if (attacking == false && timer<=0 && Key.isDown(AttackKey) && jump == false) {
if (runspeed<maxrunspeed || runspeed>-maxrunspeed) {
attacking = true;
walking = false;
man.gotoAndPlay("slash");
attackcounter = 0;
}
}
another initial sequence only this time for the normal ground attack…BUT WAIT! Whats this? It requires the variable timer to be less than or equal to 0 (really it just has to be 0 but I set it like that as a precaution if for some extremely complicated and technical reason it jumps over 0 and into the negatives).Why have I done this? Simple! To delay the character from attacking at hyper fast rate. Making him wait for a split second or 2 so that the speed of the characters swings don’t look
if (attacking == true) {
attackcounter++;
if (attackcounter>=5) {
attacking = false;
timer = 5;
}
}
the attack sequence uses a counter to count up to 5 (5 being the number of frames in the attack animation) and then ending the attack sequence while setting the variable timer to 5 so that the if statement I showed you earlier will take effect and start subtracting from it. When the timer reaches 0 you’ll be able to attack again. This way the loop of attacking not attacking will be delayed and won’t look like attacking, attacking, still attacking, I must have some violent media influence, attacking, and attacking.
};
if a braces is followed by a semi-colon then it usually means that you’re ending a clip event function like the onEnterFrame function that I stated at the waaaaay beginning. Why do braces that end clip events have semi-colons after them….nobody knows…well actually its more like nobody cares. Below are the two functions that you saw me use before in the code. Before some n00b asks, let me say than “No” these functions are not programmed into flash like hitTest(). These are custom made functions that I programmed for my convenience. What’s this you ask? I can make my own functions. Why yes! You can and let me tell you how…
function wallCheck() {
declaring a function is similar to declaring an if statement. Only instead of being constantly looped through, they happen when you call upon them. This way I don’t have to continuously rewrite the same code over and over again. This is the way I use functions anyways, I we were programming outside of flash this kind of function would be called a void. However if you were to use the command return it would be something else. Void is the title a function gets when it does not return a value. If it returns a number value its an integer, if it returns true or false it’s a boolean, if it returns something that is in the decimals it’s a float, and if it returns a word value like “stuff”, “wordhere”, or “something” then it’s a character.
Page 4 of 6
I have no country to fight for; my country is the earth; I am a citizen of the world
-- Eugene Debs
In C++ you would have to say what type of function it was at the beginning like (i.e.void function imaVoidFunction()) or (int function imaIntFunction). However flash reads through your function and detects what the return value is if there is one to automatically name it one of these things. There is one more class that exists only in flash though that you should know about. I dunno its real name so I just call it multiple. If you have more than one return value (which means at least 1 return value is in an if statement because a function breaks once it runs into a return value) and the 2 return values aren’t in the same class then flash will declare it a multiple. Multiples (although I’m not positive about this) I would assume are taxing on a computers ram and I would recommend just making 2 functions and linking them some other way.
for (i=1; i<Number.POSITIVE_INFINITY; i++) {
Whoo! the first “for” loop (these drove me crazy when I was but a n00b for I have no frickin Idea what the i’s were for). However, haven’t experienced the worst of learning pains (I still have scars) I’m sure I can explain these perfectly…
Think of a for loop like an if statement.
for( set the value of the variable (most people use “i” as their variable but it can be anything…even pizza) ; condition ; event that happens at the end of every loop).
So it’s like an if statement only instead of being run through until its conditions are met, it’s the opposite, it starts with its conditions met and loops till they aren’t. then it resets its conditions and loops again. In the third part of the example listed above it says “event that happens at the end of every loop”, this must be an event that will eventually cause the middle condition to not be met. The one exception to this is if you use the break; command to end the loop then you wont have to do that, however if your going to do that (which I do, as seen above) then I suggest you just say i < Number.POSITIVE_INFINITY or i < 99999999999999999999999999999999999 seeing as flash auto-defines numbers that high as infinity. Listen cause this is important, if you for statement has been rigged to infinently loop and you do not have a way for it to break and try and test your movie AND you choose not to cancel even though flash warns you that a part of the source is creating a massive loss in speed AND your computer is as weak as mine. You WILL spend the next five minutes waiting for your computer to kick in and automatically stop the process or pull the plug because that for statement will **** your computer up bad.
if (_root.groundy["platform"+i].rightactive == true) {
at first glance you may not think there is any more to learn from this is statement. However upon looking close into the conditions you’ll notice that “platform” + i is inside of brackets. If you’ve ever done dynamic text scripting then you’ll probably already know what is going on here but just incase… the brackets signify a building area in which you can piece together an instance name. this of course is ideal for using in for statements (although you can also use them outside of them to to put together a name or something like _root[“half of name” + “other half of name”] only I’m sure you’d find a more practical use than that.) A good example would be a bullet hitting one of 20 enemies. You don’t want to wright an if statement for every enemy. So just put the if statement inside a for loop like this one…
for (i=1;i<20;i++){
if(_root[“enemy” + i].hitTest (_root.bullet,true))
I DON’T APRROVE OF USING HITTEST! (it’s only an example so it doesn’t matter this time)
}
this way you can have one if statement work for all of the 20 enemies. Not to mention you can also check to see if the enemies are attacking you. Mixed with the duplicateMovieClip() function a for statement can also be great for spawning or clouds for scenery or whatever. Be creative I needn’t list everything I’ve used for statements to do.
rightactive = true;
break;
Just incase you’re wondering there are 2 kinds of rightactive variables, the kind that are in the platforms and the one that’s in this chunk of code. Just thought you might wanna know to avoid confusion.
} else {
rightactive = false;
otherwise rightactive is given a value of false…you should know this by know if you’ve been reading my notes up to this point….have you been skipping GO BACK UP THERE AND READ IT…If anyone has the right to be lazy it’s me because I had to type this. Wait…have we run into an else statement yet?... huh. Well its exactly the same as an else if statement only it doesn’t have it’s own conditions which mean that it will loop so long as the conditions of the if statement it’s attached to are not met. Be careful when you use these because they are easily my greatest source of glitches for obvious reasons…well I guess hitTest actually. Else statements take second place.
}
if(_root.groundy[“platform”+i]._groundTop == undefined){
break;
}
}
the whole purpose of this for statement is to check to see if your within range of a wall so if even on of the platforms variable of rightdetect is true then this codes version of rightdetect is true but if none of the platforms detect the MC then he must not be near any walls. But if this was true then I couldn’t break right there seeing as it would sabotage the who concept for this “for” loop. So I wrote some code that would detect if there was another platform like if there’s 4 platforms then it would go to five and find that groundTop (which is defined in every existing platform) is undefined and break the for loop.
for (i=1; i<infinity; i++) {
if (_root.groundy["platform"+i].leftactive == true) {
leftactive = true;
break;
} else {
leftactive = false;
}
}
if (man._x+widthholder>=rightwall-widthholder && rightactive == true) {
righthit = true;
} else {
righthit = false;
}
if (man._x-widthholder<=leftwall+widthholder && leftactive == true) {
lefthit = true;
} else {
lefthit = false;
}
}
the exact same thing only for the left side
function wallStop() {
This is a function I made to set the man movieclip’s x to where the was this way he’d never sink into the wall any more than I told it to let him.
Page 5 of 6
if (righthit == true) {
man._x = rightwall-widthholder;
runspeed = 0;
jumpspeed = 0;
} else if (lefthit == true) {
man._x = leftwall+widthholder;
runspeed = 0;
jumpspeed = 0;
}
}
If you look back up at the beginning where the onEnterFrame clip event was stated. You will see the first thing that is listed is the function wallCheck since it is in the clip event it is looped through every frame which continuously updates the right and left hit variables. With this code finished and written I only have to put wallStop whenever I want his x to be set back to where the wall starts (right and left hit work sorta like hit test in the way that they detect the hit, this is just the code I’m using that makes it better than hitTest)
FINAL NOTES
Admittedly I have not covered 100% of all the coding knowledge you need to go from n00b to pro in one sitting (no such thing), however if you did read and understand a good deal of what I said, then at least I’ve set you on that path. Its better that you discover the rest on your own so that you can have your own style. Also if you are new to actionscript don’t go making things the easy way (like making shooter games using buttons) because it will only make it harder to relearn AS the right way. With that all said and done I’m going to go have surgery performed on my fingers and I will personally rip off the testicles of the man who say I didn’t include detailed enough instructions.
I’m really tired if you haven’t noticed by the increasingly frequent typos…
Please delete the other thread and why does the "S" in the title keep going lowercase, thats annoying.
PLEASE FEEL FREE TO POST NOW
Page 6 of 6
That looks awesome and well-explained but... Would you mind posting a sample?
just so you people know in whichever post this was in when I said (i.e. myVariable = 20) I meant (i.e. myVariable = "wordz")
I think I must have mixed up the backup files a bit... this one has everything the source shows except wall collisions which I was doing when this was the up to date backupfile. I can't any later tho because it contains spoilerz of something that are crucial you don't know when I actually release the game.
Im almost out of posts so im only gonna answer the best question. If you really are stuck on some part of this tutorial I can offer a better explanation over AIM. (my screen name is "MusicianMX")
nice, that is a lot of writing.
At 8/18/05 03:27 AM, dieEVILsanta wrote: nice, that is a lot of writing.
hahaha funny to hear someone say that.
W00t! hahaha I really should go to bed.
I have no country to fight for; my country is the earth; I am a citizen of the world
-- Eugene Debs
just one more thing before bed to prevent any confusion. the swf I linked to is not the result of the source code in the tutorial. it is the result of a source thats even older than this one. since this code thats been posted is practically useless now that it's covered with notes and the original backup file that used the source I've lost (the one I posted was being saved in a word document, I have alot of backup files...)not to mention im really to lazy to get one of the older files up to date with this one, you'll have to deal with that SWF as an example for now (I am using this in a game and although I have no techniques I care to hide the new one has all sorts of new moves that use techniques that im not going to share just yet...)
NOW THAT THIS TUTORIAL IS POSTED THERE IS NOT EXCUSE FOR A N00B TO SUBMIT A CRAPPILY PROGRAMMED GAME AND HAVE IT SURVIVE
(I've seen several make the front page...scary)
G'night
I have no country to fight for; my country is the earth; I am a citizen of the world
-- Eugene Debs
Heh, on the demo thing you posted you can got through the walls.. thought I'd mention that.
And that was a lot of writing.
Sup, bitches :)
At 8/18/05 04:04 AM, MusicianEXE wrote: some stuff i dont care about.
um, do you compose music for flash?
for free??
At 8/18/05 06:11 AM, -liam- wrote: Heh, on the demo thing you posted you can got through the walls.. thought I'd mention that.
And that was a lot of writing.
yeah I sorta said that in my last post. its old demo...old enough anyhow. the wall collisions weren't even programmed at that point. read the ladt thing I posted the one more thing before I go to bed thing only I didn't go to bed.
I have no country to fight for; my country is the earth; I am a citizen of the world
-- Eugene Debs
At 8/18/05 06:27 AM, MusicianEXE wrote: yeah I sorta said that in my last post. its old demo...old enough anyhow. the wall collisions weren't even programmed at that point. read the ladt thing I posted the one more thing before I go to bed thing only I didn't go to bed.
Yeah I saw that, just thought I'd say it anyway.
Any chance someone could post what the tutorial makes?
Sup, bitches :)
the whole tute looks alot more intimidating than it is. the reason it's size is so beefy is because of all the extra detail I use in explaining this crap (The tute assumes you are a n00b). So if you really new to actionscript you'll need to read all of it. otherwise feel free to skim through till you reach something you dont know. Or just use it as a reference while making a game. I just wanted it to be used. I don't wanna have replies like.
"Thats alot of text and despite the fact I didn't read it I am thoroughly convinced that you are an expert"
best just to learn it all at once then read 20 small crappy tutorials that are so indescriptive that all it's good for is copy and paste. No offence to the people that made them it's just the truth.
I have no country to fight for; my country is the earth; I am a citizen of the world
-- Eugene Debs
At 8/18/05 06:29 AM, -liam- wrote:At 8/18/05 06:27 AM, MusicianEXE wrote: yeah I sorta said that in my last post. its old demo...old enough anyhow. the wall collisions weren't even programmed at that point. read the ladt thing I posted the one more thing before I go to bed thing only I didn't go to bed.Yeah I saw that, just thought I'd say it anyway.
Any chance someone could post what the tutorial makes?
tommorow Ill take a my current fla and cut out all the stuff that shouldn't be there and create a swf that shows what what the tutorial makes. btw Im sure that you know this but the actual amount of text that is source code could make up like 1 post. So I REALLY put alot of notation on it. The idea is not to copy and paste. It's to learn how it works so that you can do it in a way that fits your FLA (I have a really uniques style which puts most of the code for a game in one frame. Since little to no people code this way, my code is even more anti- copy and paste.)
pardon my typos
I have no country to fight for; my country is the earth; I am a citizen of the world
-- Eugene Debs
You know I already made 2 tutorials about this and I even covered shooting. Plus you could have done it much better
(you could have used for loops on the down and uphill that way you can use slopes and stuff AND automatically incorporate walls
- Matt, Rustyarcade.com
what you mean the source could've been better? is anyone even fucking reading it. I posted the source from a backup file thats been dismantled and explain. A BACKUP FILE. why the hell would I give out my real source in a way that any n00b could come along and copy and paste... GOD DAMMIT, I know I've said this like fucking twice already.
rubber chicken - All I would need to do to create some extra code to put in a platform that would use a percentage equation to make the ground variavle higher depending on how close you were to the center. I'm also not 100% sure of what the hell you said in your post :\, So why don't you actually read the tutorial and try and figure out the theory behind it rather than automatically assuming that your way is better. kk kootchie?
I have no country to fight for; my country is the earth; I am a citizen of the world
-- Eugene Debs
At 8/18/05 07:02 AM, MusicianEXE wrote: what you mean the source could've been better? is anyone even fucking reading it. I posted the source from a backup file thats been dismantled and explain. A BACKUP FILE. why the hell would I give out my real source in a way that any n00b could come along and copy and paste... GOD DAMMIT, I know I've said this like fucking twice already.
rubber chicken - All I would need to do to create some extra code to put in a platform that would use a percentage equation to make the ground variavle higher depending on how close you were to the center. I'm also not 100% sure of what the hell you said in your post :\, So why don't you actually read the tutorial and try and figure out the theory behind it rather than automatically assuming that your way is better. kk kootchie?
Oh i wouldn't worry about Ninja-Chicken, he thinks he's better than everyone else.
^^
just ignore him and he'll say he didn't know what got into him, and he'd be a good little boy.
At 8/18/05 07:02 AM, MusicianEXE wrote: what you mean the source could've been better? is anyone even fucking reading it. I posted the source from a backup file thats been dismantled and explain. A BACKUP FILE. why the hell would I give out my real source in a way that any n00b could come along and copy and paste... GOD DAMMIT, I know I've said this like fucking twice already.
rubber chicken - All I would need to do to create some extra code to put in a platform that would use a percentage equation to make the ground variavle higher depending on how close you were to the center. I'm also not 100% sure of what the hell you said in your post :\, So why don't you actually read the tutorial and try and figure out the theory behind it rather than automatically assuming that your way is better. kk kootchie?
WOW
Why the hell are you getting so emo
Dude I didnt say MY way was better (though my tutorials have a better engine they are not explained as well - though I think you over-explained) and also it doesnt matter if you post the source of not you still could have used loops to determin going uphill and downhill so that way you could have done slopes instead of shitty flat land AND walls would have been automatically incorporated that way so all you have to do is draw it. Calm down and stop being a defensive little worm just because your method sucked
And ignore rebuilt he thinks hes really cool because he can hold a sarcy little grudge and cant accept apologies
(he'll grow up sooner or later though)
- Matt, Rustyarcade.com
:you still could have used loops to determin going uphill and downhill
uphill and downhill using for loops...why do I have such doubt in your teaching abilities
:Calm down and stop being a defensive little worm just because your method sucked
This wasn't my method, I learned it from RiftMaster, whom learned it from TomFulp himself. So what are you suggesting?
And if you're wondering why im pissed then maybe you should try typing up 15 pages of tutorial and posting it only to have some n00b who obviously didn't even try to understand it say that it would have been better his way, which you did say even if I don't understand what the hell you mean by uphill and downhill.
okay for starts dont call me a n00b when I signed up before you
also that method is good but ONLY FOR FLAT GROUND.
I will explain this slowly because its obviously hard for you to understand
you can use shapeflag hitTests and for loops to test wether he hits the ground in time if not then he falls. Then you can use it to test if he will be hitting the ground and if the loops doesnt end where he isnt hitting ground then you can make that place a wall automatically...
I'll even post a script because I know how you n00bs like to copy and paste code
for (i=0; i<11; i++) {
if (this._parent.floor.hitTest(_x, _y-i, 1)) {
grav = 0;
jumping = false;
falling = false;
this._y--;
}
}
do you see what I mean?
and then on my moving I tested for walls
I think you dont even know what a loop is and how to use it
- Matt, Rustyarcade.com
At 8/18/05 07:26 AM, Ninja-Chicken:
flamed a user
lol, you suck.
go to the naughty corner.
At 8/18/05 07:28 AM, Rebuilt wrote: At 8/18/05 07:26 AM, Ninja-Chicken:
flamed a userlol, you suck.
go to the naughty corner.
HA thats the thing I didnt flame anyone
he flamed me because I gave him advice???
Dude noone even cares about you or your posts (we just ignore you) so shhhh and go learn something that can contribute to NG
- Matt, Rustyarcade.com
At 8/18/05 07:26 AM, Ninja-Chicken wrote:
for (i=0; i<11; i++) {
if (this._parent.floor.hitTest(_x, _y+i, 1)) {
grav = 0;
jumping = false;
falling = false;
this._y++;
}
}
did you mean to make it like this? haha what a cock, it's a decent idea I'll give you that with a little tweaking it could work fairly (still would be a nightmare for 56k people tho).
But before you go off and say that the flat grounds and strait slopes are limited you should think about the tiled based games games that Nintendo makes. incase you havn't noticed every piece ground is perfectly strait and yet it they all kick more ass than any game you could make.
Also realize that hitTest is only in flash, you have to make your own collision sytem like I did if you ever plan on moving on to another language.
I think you dont even know what a loop is and how to use it
More proof that you didn't reas the tute, maybe you should read it n00b, you could learn how to do quality programming.
:)
At 8/18/05 07:31 AM, Ninja-Chicken wrote:At 8/18/05 07:28 AM, Rebuilt wrote: At 8/18/05 07:26 AM, Ninja-Chicken:HA thats the thing I didnt flame anyone
flamed a userlol, you suck.
go to the naughty corner.
he flamed me because I gave him advice???
Dude noone even cares about you or your posts (we just ignore you) so shhhh and go learn something that can contribute to NG
i couldn't really care less what people think about me over the internet ^^
i know people ignore me cos i get on peoples nerves.
Learn something valuable to contribute to NG, I', getting a Wacom in the next week so yeah, I think i'll do that.
thanx for the bumps rubber chicken but if you don't have anything better to do than to flame and repeat the same suggestion over and over again dont bother to post XD. No one likes a flammer.
At 8/18/05 08:05 AM, MusicianMX wrote: thanx for the bumps rubber chicken but if you don't have anything better to do than to flame and repeat the same suggestion over and over again dont bother to post XD. No one likes a flammer.
okay get your head out of your ass for 1 second and listen
I havnt flamed you I have used the only language you understand
Stop calling me a n00b because though Ive only been scripting for 3 months I still PWN you
also if you think that that method I showed you was bad then please dont hesitate to show a better method
finally HOW THE FUCK do you know how good a game I can make?
I could easily PWN those shitty nintendo games and how would you know otherwise?
Seriously you need to stop being jerks and saying im flaming when I clearly retaliated to you starting it.
Rebuilt FUCK OFF I dont know when the hell you decided to start posting gay things about me on the BBS but stop it because your being a complete dick head
Stop ganging up on me just because I pointed out a method to improve that is what the BBS is all about
- Matt, Rustyarcade.com