Newgrounds.com — Everything, By Everyone.

Checking login status…

USERNAME:

PASSWORD:

Logging in…

Logged in as:
.
Logging out…
Inbox My Account Log Out


Forum Topic: Stupid Loops!

(79 views • 6 replies)

This topic is 1 page long.

<< < > >>
Angry

Petwoip

Reply To Post Reply & Quote

Posted at: 5/26/08 11:18 AM

Petwoip LIGHT LEVEL 04

Sign-Up: 01/18/05

Posts: 213

Hey, in this game you can stack any falling ball onto another. I've been trying some code, and this is the closest I have gotten to work. As you can see the game is laggy and some balls disappear. Ignore the "10", those little dots, and the blue. My screwed up game.

So as you can see, if you connect the balls in series, there are no problems. But if you stack three or so in a row and then connect the fourth ball onto the first ball, some others will disappear.

Here's the code:

fallingBall.onEnterFrame = function(){
		for (i=0; i<360; i+=5) {
			X = this._x + (Math.cos(i*(Math.PI/180))*radius)+ _x;
			Y = this._y + (Math.sin(i*(Math.PI/180))*radius)+ _y;
			for(totalhits=0; totalhits<10; totalhits++){
			if (floor.hitTest(X, Y, true) or _root["duplicatedBall" + totalhits].hitTest(X, Y, true)){
				pointstop();
           		break;
			}
			}	
		}
		function pointstop(){
			totalhits+=1
			 _root.attachMovie("duplicatedBall", "duplicatedBall"+totalhits,totalhits,{_x:fallingBall._x, _y:fallingBall._y})
		}

How can I prevent lag and get this to work?!

.

BBS Signature

None

Petwoip

Reply To Post Reply & Quote

Posted at: 5/26/08 11:22 AM

Petwoip LIGHT LEVEL 04

Sign-Up: 01/18/05

Posts: 213

Faster version (but still laggy) Sorry, the other one before is extremely slow!

.

BBS Signature

None

Petwoip

Reply To Post Reply & Quote

Posted at: 5/26/08 12:36 PM

Petwoip LIGHT LEVEL 04

Sign-Up: 01/18/05

Posts: 213

bump

.

BBS Signature

None

Wolfears2

Reply To Post Reply & Quote

Posted at: 5/26/08 12:49 PM

Wolfears2 EVIL LEVEL 08

Sign-Up: 10/20/07

Posts: 688

Try the box 2d flash in AS3. Forgot the link, but it manages balls as well.

not in that way, immature...

Yay, I have a sig again. Go join teh falling egg collab NAOW! www.freewebs.com/wolfears2 is up with some basic stuff on. More coming soon.

BBS Signature

None

Petwoip

Reply To Post Reply & Quote

Posted at: 5/26/08 01:00 PM

Petwoip LIGHT LEVEL 04

Sign-Up: 01/18/05

Posts: 213

At 5/26/08 12:49 PM, Wolfears2 wrote: Try the box 2d flash in AS3. Forgot the link, but it manages balls as well.

1. I'm using AS2
2. Is "box 2d" a tutorial/ game? I looked up your exact phrase and there is a website called box2d.

.

BBS Signature

Happy

Wolfears2

Reply To Post Reply & Quote

Posted at: 5/26/08 01:34 PM

Wolfears2 EVIL LEVEL 08

Sign-Up: 10/20/07

Posts: 688

I'm an AS2 user too. I just found out about box2d by googling it after reading up on it on emanuele's blog

Box2d is a sort of physics engine, allowing circles, rectangles and lines of any size to be combined into a simulator. You can use things like a pully too.

That's what I fgured out.

I'd recommend having all the circles using a shapeflag for the one below it, then using vector code for basic gravity. Maybe drag&drop circles. Then you're on to something =P

Yay, I have a sig again. Go join teh falling egg collab NAOW! www.freewebs.com/wolfears2 is up with some basic stuff on. More coming soon.

BBS Signature

None

Petwoip

Reply To Post Reply & Quote

Posted at: 5/26/08 01:49 PM

Petwoip LIGHT LEVEL 04

Sign-Up: 01/18/05

Posts: 213

I don't think you understand what I'm looking for. I do not want a complicated physics engine, I just want a simple answer to my problem (fix in my code, AS help)

.

BBS Signature

All times are Eastern Daylight Time (GMT -4) | Current Time: 06:38 AM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!