Have you actually implemented an event system like this in games? It seems like a good idea, but for some reason I always thought this approach would introduce unnecessary latency, but now I'm not sure why!
-Scott On 12/13/06, Pete Miller <[EMAIL PROTECTED]> wrote:
Another possible strategy is for the ball to fire off an event every time it crosses certain vertical location thresholds. The target objects could then listen for the event which matches their vertical location to test for a collision. For example, when the ball descends to the row containing the paddle, it fires that event, and the paddle, receiving it, tests for collision. When the ball ascends to the first row of bricks, those bricks each test for collsion. This might be a performance improvement over testing every object in the system all the time. P. >> -----Original Message----- >> From: [EMAIL PROTECTED] [mailto:flashcoders- >> [EMAIL PROTECTED] On Behalf Of Holth, Daniel C. >> Sent: Wednesday, December 13, 2006 9:43 AM >> To: Flashcoders mailing list >> Subject: RE: [Flashcoders] AS2 OOP Class Structure for simple pong type >> game >> >> >> That would be one way. Although it is rather limiting. I'm assuming >> that the ball will bounce whenever it hits an object. >> >> Perhaps create an array of bounceObjects[]; >> >> function addBounceObject(obj:Object):Number{ >> return bounceObjects.push(obj); >> } >> >> Then you could create your hit tracker. >> >> function checkCollisions(){ >> var len:Number = bounceObjects.length; >> // Loop through and check all objects hitting the ball >> for(var i:Number = 0; i < len; i++){ >> // Check each object hit ball >> if(this.hitTest(bounceObjects[i])){ >> >> this.bounce(); // Bounce the ball >> bounceObject[i].onHitByBall(); >> } >> } >> } >> >> Have your onEnterFrame functions run checkCollisions every time. That >> way you check for hits against the paddle, bricks etc. >> >> >> The bounceObject[i].onHitByBall() would execute a function in that >> objects code that would say what to do when it was hit by a ball. In the >> instance of a paddele do nothing, a brick - destory it! >> >> >> -Dan >> >> -----Original Message----- >> From: [EMAIL PROTECTED] >> [mailto:[EMAIL PROTECTED] Behalf Of Paul >> Steven >> Sent: Wednesday, December 13, 2006 8:26 AM >> To: 'Flashcoders mailing list' >> Subject: RE: [Flashcoders] AS2 OOP Class Structure for simple pong type >> game >> >> >> Thanks for the reply Dan >> >> Not quite sure how the Ball references the Paddle or alternatively the >> CollisionController references the ball and paddle. >> >> My Game class creates the Ball and Paddle as follows: >> >> mcPaddle = new Paddle(mcReference, "paddle_mc", 50, 100, 289); >> >> var vBall_Object = new Ball(mcReference, "ball_mc", 100, 160, 240); >> arrBallObjects.push(vBall_Object); >> >> If I wanted to give the Ball a reference to the paddle, would I do >> something >> like this? (see last parameter) >> >> var vBall_Object = new Ball(mcReference, "ball_mc", 100, 160, 240, >> mcPaddle); >> >> Thanks >> >> Paul >> >> >> -----Original Message----- >> From: [EMAIL PROTECTED] >> [mailto:[EMAIL PROTECTED] On Behalf Of Holth, >> Daniel C. >> Sent: 13 December 2006 14:14 >> To: Flashcoders mailing list >> Subject: RE: [Flashcoders] AS2 OOP Class Structure for simple pong type >> game >> >> >> I would make the ball responsible for checking if it collides with the >> paddle because the ball's behavior/state will change - not the paddle's, >> nor >> does the state of the 'game' really change. >> >> An alternative would be to create a CollissionControler.as that does all >> your hit testing for you. This may become useful when you add the bricks >> or >> other objects that need to check for collisions. >> >> -Dan >> >> -----Original Message----- >> From: [EMAIL PROTECTED] >> [mailto:[EMAIL PROTECTED] Behalf Of Paul >> Steven >> Sent: Wednesday, December 13, 2006 8:02 AM >> To: 'Flashcoders mailing list' >> Subject: [Flashcoders] AS2 OOP Class Structure for simple pong type game >> >> >> I am creating a simple pong / breakout / arkanoid game in AS2 and not >> sure >> how best to deal with the classes. >> >> So far I have a Game.as class, a Paddle.as class and a Ball.as class. >> >> I need to detect when the ball (or balls) collide with the Paddle. >> >> My question is, which class should check for this collision? >> >> Should the Game class do this or should I pass a reference to the Paddle >> into the Ball class so the Ball is able to check this collision itself? >> >> If it is the Game class, then I guess it is a case of giving both the >> Paddle >> and Ball classes a method to return their current position and then >> letting >> the Game class compare these positions to determine if a collision has >> occurred? >> >> If the Ball class needs to have a reference to the Paddle passed to it, I >> am >> not sure how this is done. So I would appreciate any advice on this. >> >> I appreciate there are probably a lot of different solutions to this, but >> I >> am trying to get off on the right footing with this OOP programming. >> >> Many thanks >> >> Paul >> >> _______________________________________________ >> [email protected] >> To change your subscription options or search the archive: >> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders >> >> Brought to you by Fig Leaf Software >> Premier Authorized Adobe Consulting and Training >> http://www.figleaf.com >> http://training.figleaf.com >> >> This e-mail and its attachments are intended only for the use of the >> addressee(s) and may contain privileged, confidential or proprietary >> information. If you are not the intended recipient, or the employee or >> agent >> responsible for delivering the message to the intended recipient, you are >> hereby notified that any dissemination, distribution, displaying, >> copying, >> or use of this information is strictly prohibited. If you have received >> this >> communication in error, please inform the sender immediately and delete >> and >> destroy any record of this message. Thank you. >> _______________________________________________ >> [email protected] >> To change your subscription options or search the archive: >> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders >> >> Brought to you by Fig Leaf Software >> Premier Authorized Adobe Consulting and Training >> http://www.figleaf.com >> http://training.figleaf.com >> >> _______________________________________________ >> [email protected] >> To change your subscription options or search the archive: >> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders >> >> Brought to you by Fig Leaf Software >> Premier Authorized Adobe Consulting and Training >> http://www.figleaf.com >> http://training.figleaf.com >> >> This e-mail and its attachments are intended only for the use of the >> addressee(s) and may contain privileged, confidential or proprietary >> information. If you are not the intended recipient, or the employee or >> agent responsible for delivering the message to the intended recipient, >> you are hereby notified that any dissemination, distribution, displaying, >> copying, or use of this information is strictly prohibited. If you have >> received this communication in error, please inform the sender >> immediately and delete and destroy any record of this message. Thank you. >> _______________________________________________ >> [email protected] >> To change your subscription options or search the archive: >> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders >> >> Brought to you by Fig Leaf Software >> Premier Authorized Adobe Consulting and Training >> http://www.figleaf.com >> http://training.figleaf.com _______________________________________________ [email protected] To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
-- : : ) Scott _______________________________________________ [email protected] To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com

