List Info

Thread: AS 3.0 organizational question




AS 3.0 organizational question
user name
2007-08-27 12:48:33
Hey, Flashnewbies.

So here's my situation: Longtime Director guy looking to
make the transition
to Flash and AS3.0. I've got a basic understanding of the
language (thanks
to the Moock book), but am having trouble figuring out where
to start on a
"real" project. Here's my semi-hypothetical
example...

Let's say I'm trying to make a very simple pinball game.
I've got a ball and
some bumpers and maybe a scoreboard. (We'll ignore the
flippers for now.)
I'm going to have to take care of a few basic tasks...
making sure the ball
has some basic physics, and making sure the bumpers push the
ball away when
they come into contact.

No doubt my game will include a "Ball" object and
a few "Bumper" objects
(that will probably be a subclass of an abstract TableThing
object). The
question I'm having trouble with is deciding where and how
they should
interact.

The way that I think makes sense to me is to have the ball,
on an
ENTER_FRAME listener, try to move itself based on some
internal calculations
(It's got a sense of gravity, an internal velocity, etc.).
At the end of
this listener, it generates a custom "BALL_IS_AT"
event. This event would
contain the ball's current position and velocity, and a
reference to the
ball itself.

The bumpers would then have some BALL_IS_AT event listener
that would check
to see if the ball has made collision with the bumper, and
if so, would call
some sort of "e.ballRef.OhNoYouDidnt" method,
giving the ball an updated
location and velocity. At this point it would probably
generate some sorta
custom "SCORE_INCREMENT" event, which our game's
scoreboard could listen for
and then update itself when appropriate.

Does that seem like the right way to go? I was first
thinking of creating
some kind of master "PinballTablePhysics" object
that would do all the
underlying calculations and collision detection, and in some
ways that seems
cleaner, but it also didn't seem object-oriented-y enough.
But the whole
idea of generating a custom event every frame seems a little
weird to me, as
well.

Anyway, if you guys (and gals) have any advice on how to
proceed, let me
know. I'd love to hear it. Thanks!


--Todd
_______________________________________________
Flashnewbiechattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashnewb
ie

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.c
om

Re: AS 3.0 organizational question
user name
2007-08-29 17:08:51
> Does that seem like the right way to go? I was first
thinking of creating
> some kind of master "PinballTablePhysics"
object that would do all the
> underlying calculations and collision detection, and in
some ways that seems
> cleaner, but it also didn't seem object-oriented-y
enough. But the whole
> idea of generating a custom event every frame seems a
little weird to me, as
> well.

A PinballTablePhysics object seems like the preferable
solution to me.
Don't overdesign the thing. It's difficult enough as it is.

The most difficult part will be hit detection. You're
dealing with a
potentially fast moving ball and arbitrary shapes. Imagine
the
situation where a fast ball is on one side of a thin wall in
one
frame, and on the other side in the next, without ever
overlapping.

There's a good (but very advanced and AS2) hit test
tutorial:
<http://www.harveycartel.org/metanet/tutorials.html>

It might be overkill, but maybe it's interesting for you.

Mark


On 8/27/07, Todd Kerpelman <toddkerp.net> wrote:
> Hey, Flashnewbies.
>
> So here's my situation: Longtime Director guy looking
to make the transition
> to Flash and AS3.0. I've got a basic understanding of
the language (thanks
> to the Moock book), but am having trouble figuring out
where to start on a
> "real" project. Here's my semi-hypothetical
example...
>
> Let's say I'm trying to make a very simple pinball
game. I've got a ball and
> some bumpers and maybe a scoreboard. (We'll ignore the
flippers for now.)
> I'm going to have to take care of a few basic tasks...
making sure the ball
> has some basic physics, and making sure the bumpers
push the ball away when
> they come into contact.
>
> No doubt my game will include a "Ball" object
and a few "Bumper" objects
> (that will probably be a subclass of an abstract
TableThing object). The
> question I'm having trouble with is deciding where and
how they should
> interact.
>
> The way that I think makes sense to me is to have the
ball, on an
> ENTER_FRAME listener, try to move itself based on some
internal calculations
> (It's got a sense of gravity, an internal velocity,
etc.). At the end of
> this listener, it generates a custom
"BALL_IS_AT" event. This event would
> contain the ball's current position and velocity, and a
reference to the
> ball itself.
>
> The bumpers would then have some BALL_IS_AT event
listener that would check
> to see if the ball has made collision with the bumper,
and if so, would call
> some sort of "e.ballRef.OhNoYouDidnt" method,
giving the ball an updated
> location and velocity. At this point it would probably
generate some sorta
> custom "SCORE_INCREMENT" event, which our
game's scoreboard could listen for
> and then update itself when appropriate.
>
> Does that seem like the right way to go? I was first
thinking of creating
> some kind of master "PinballTablePhysics"
object that would do all the
> underlying calculations and collision detection, and in
some ways that seems
> cleaner, but it also didn't seem object-oriented-y
enough. But the whole
> idea of generating a custom event every frame seems a
little weird to me, as
> well.
>
> Anyway, if you guys (and gals) have any advice on how
to proceed, let me
> know. I'd love to hear it. Thanks!
>
>
> --Todd
> _______________________________________________
> Flashnewbiechattyfig.figleaf.com
> To change your subscription options or search the
archive:
> http://chattyfig.figleaf.com/mailman/listinfo/flashnewb
ie
>
> Brought to you by Fig Leaf Software
> Premier Authorized Adobe Consulting and Training
> http://www.figleaf.com
> http://training.figleaf.c
om
>
_______________________________________________
Flashnewbiechattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashnewb
ie

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.c
om

RE: AS 3.0 organizational question
country flaguser name
Switzerland
2007-08-30 12:26:58
Your approach sound well thought out to me - but then I'm
not an OOP guru. 
For discussing the finer details of OOP-design,
design-patterns and the like
I recommend you try the 'flashcoders' list for more
response.

hth
-------------
Andreas Weber


-----Original Message-----
From: flashnewbie-bounceschattyfig.figleaf.com
[mailto:flashnewbie-bounceschattyfig.figleaf.com] On
Behalf Of Todd
Kerpelman
Sent: Monday, August 27, 2007 7:49 PM
To: flashnewbiechattyfig.figleaf.com
Subject: [Flashnewbie] AS 3.0 organizational question


Hey, Flashnewbies.

So here's my situation: Longtime Director guy looking to
make the transition
to Flash and AS3.0. I've got a basic understanding of the
language (thanks
to the Moock book), but am having trouble figuring out where
to start on a
"real" project. Here's my semi-hypothetical
example...

Let's say I'm trying to make a very simple pinball game.
I've got a ball and
some bumpers and maybe a scoreboard. (We'll ignore the
flippers for now.)
I'm going to have to take care of a few basic tasks...
making sure the ball
has some basic physics, and making sure the bumpers push the
ball away when
they come into contact.

No doubt my game will include a "Ball" object and
a few "Bumper" objects
(that will probably be a subclass of an abstract TableThing
object). The
question I'm having trouble with is deciding where and how
they should
interact.

The way that I think makes sense to me is to have the ball,
on an
ENTER_FRAME listener, try to move itself based on some
internal calculations
(It's got a sense of gravity, an internal velocity, etc.).
At the end of
this listener, it generates a custom "BALL_IS_AT"
event. This event would
contain the ball's current position and velocity, and a
reference to the
ball itself.

The bumpers would then have some BALL_IS_AT event listener
that would check
to see if the ball has made collision with the bumper, and
if so, would call
some sort of "e.ballRef.OhNoYouDidnt" method,
giving the ball an updated
location and velocity. At this point it would probably
generate some sorta
custom "SCORE_INCREMENT" event, which our game's
scoreboard could listen for
and then update itself when appropriate.

Does that seem like the right way to go? I was first
thinking of creating
some kind of master "PinballTablePhysics" object
that would do all the
underlying calculations and collision detection, and in some
ways that seems
cleaner, but it also didn't seem object-oriented-y enough.
But the whole
idea of generating a custom event every frame seems a little
weird to me, as
well.

Anyway, if you guys (and gals) have any advice on how to
proceed, let me
know. I'd love to hear it. Thanks!


--Todd
_______________________________________________
Flashnewbiechattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashnewb
ie

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training http://www.figleaf.com
http://training.figleaf.c
om

_______________________________________________
Flashnewbiechattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashnewb
ie

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.c
om

[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )