Be a Supporter!

Code help

  • 322 Views
  • 2 Replies
New Topic Respond to this Topic
TheMillz
TheMillz
  • Member since: Jun. 28, 2006
  • Offline.
Forum Stats
Member
Level 23
Blank Slate
Code help 2006-12-19 18:17:51 Reply

Hi, I'm trying to make a game. I got the main mechanics figured out, but here's my problem.

I have 2 movie clips. the first is a solid ball. The second is an open circle.I want to make it so when you control the open circle, the filled circle inside it reacts with gravity. Like a hamster in a ball.

Here's the code for the ball inside:

onClipEvent (load) {
ySpeed = 0;
// starting fall speed of object
gravity = 3;
// how fast the ySpeed rises, should be no higher then 3
bounce = .8;
// how much the speed decreases when for each bounce
ground = 350;
// where to bounce back
}
onClipEvent (enterFrame) {
if (_y<ground) {
ySpeed += gravity;
} else if (ySpeed>gravity*4) {
// change 4 to a higher number if it doesnt work
_y = ground;
ySpeed *= -bounce;
} else {
ySpeed = 0;
_y = ground;
}
_y += ySpeed;
}

Now this actully works, but it thinks the bottom of the browser is the ground. The rims of the circle is what I want it to stop at.I gave the circle the instance name "ground".

Can anyone help me?

TheMillz
TheMillz
  • Member since: Jun. 28, 2006
  • Offline.
Forum Stats
Member
Level 23
Blank Slate
Response to Code help 2006-12-19 19:15:30 Reply

sorry for the double post, but It's kinda urgent. My free flash trial ends in 8 days

InkyBoy
InkyBoy
  • Member since: Aug. 6, 2006
  • Offline.
Forum Stats
Member
Level 21
Blank Slate
Response to Code help 2006-12-19 19:24:18 Reply

At 12/19/06 07:15 PM, TheMillz wrote: sorry for the double post, but It's kinda urgent. My free flash trial ends in 8 days

Then save up and buy it.
And good luck finding the code you need.
:)