00:00
00:00
Upgrade Your Account!

Hey! To start this decade right, we believe Newgrounds should be ad-free for EVERYONE. For this to work, we need people who have the means to become paying supporters. For just $3 per month or $25 for the year, you can help this happen and get some nice perks!

For the month of February we have disabled ads on all E-M content. We need 224 people to reach our goal of 3,100 active supporters. If we hit that, we'll continue with a new goal in March!

Please check out our Supporter Upgrade and consider coming aboard!

Coding question

1,663 Views | 6 Replies
New Topic Respond to this Topic

Coding question 2007-05-05 18:00:24


I'm planning this game that has button timing sequences like in God of War.

Like for instance, an animation is playing where a charecter is running and he needs to jump a gap.

A symble with the letter "A" is displayed in the top center of the screen.

If they push it in time, the animation plays where he jumps the gap.

If they don't, or push the wrong one, the animation plays where he falls and dies.

I'm just an animator, and I've spent a great deal of time trying to learn code, but I just can't grasp it. If someone gives me a model code, something I can use interchangeably, changing instance names where ever needed and such, I will gladly credit you as programer for my game.

This is not a collab or anything like that, but if you wish to see some of my work to see if I'm for real or not, here are a few links of mine:

http://www.newgrounds.com/portal/view/361332

http://www.newgrounds.com/portal/view/352216

http://www.newgrounds.com/portal/view/346283

Response to Coding question 2007-05-05 18:35:56


ok i got it set up for you, was kinda fun making it :)

first, on the frames with the time limit, such as the 10-30 frames you have to react and press the button put this,

jumpGap = 0;
onEnterFrame = function () {
if (Key.isDown(65)) {
jumpGap += 1;
}
};

thats just a variable that goes greater then 1 if you have pressed the button in time, make sure to NOT have that code after the reaction time to press the button.

Next have you make a frame BEFORE the "you didnt press it in time and you fell in this ditch, or something" frame. so its goes, reaction frames, this frame, we'll call it the checking frame, then the dieing frames. on the CHECK frame put this,

onEnterFrame = function () {
if (jumpGap>0) {
gotoAndPlay(45);
}
};

thats saying to skip from where it is, to the frame past where he would have died, because you pressed the button the character will jump instead of going to the dieing frame.

lastly, you have to reset the variable to 0 so you can use it again for the next jump

onEnterFrame = function () {
jumpGap = 0;
};

put that on a frame after you jump and havent died to reset the variable to 0

You can use that code and change it to make ducking or pretty much anything you want for the type of game your making, let me know if you need more help/ if it worked for you or not.
:)

Response to Coding question 2007-05-05 18:39:35


At first glance it looks informative and great. Thanks alot man, I will definetly ask you if I have an issue. I'll also inform you when it goes public and credit you as promised. It will be a while though, I'm planning it to be a "summer long" project to keep me occupied and make it great.

Response to Coding question 2007-05-05 18:57:12


Sounds good to me, have fun with it.

Response to Coding question 2007-05-05 19:22:11


Ok, so heres the situation:

The animation's total length is 165 frames with a fps at 30.

I tweaked the first code from this:

jumpGap = 0;
onEnterFrame = function () {
if (Key.isDown(65)) {
jumpGap += 1;
}
};

To this:

jumpGap = 0;
onEnterFrame = function () { if (Key.isDown(65)) {gotoAndPlay(135);
}};

The keyframe for this code is on frame #75 going to frame # 90.

If you hold the A button down between these 2 frames, you will jump the gap, but if you hold it, the animation will stop with the guy right at the ledge.Heres the link to the demo to show you what I mean:

http://denvish.net/ulf/060507/70718_GAME.php

It will go to the dead screen no matter what, just for the demo you know.

I need it so if your still holding the A button down, it will not effect the animation ( ie, freezing it until you release it. Thanks again for the help.

Response to Coding question 2007-05-05 21:20:36


thats just a variable that goes greater then 1 if you have pressed the button in time, make sure to NOT have that code after the reaction time to press the button.

you have to make sure that the code that says,

if(jumpGap>0){
go play stuff,
}

is NOT on ANY of the frames where you actually do the jumping, because what its saying is yes jumping is greater so im gonna go play frame 130, or whichever it is, so if you dont press it, and it goes to frame 135, then press it, that code is still there so it goes BACK to 130, thats why you have to get rid of that piece of code once you start the jump, and while your in the jump. only use the code up until you have no more time to jump, then get rid of it until the next jump.

Response to Coding question 2007-05-05 21:36:55


Got it to work now, Thanks. :D