A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: splitting balls?

  1. #1
    incredibulus-actionscriptum magnetos's Avatar
    Join Date
    May 2001
    Posts
    2,160

    splitting balls?

    hi guys i gotta a question for you
    now immagine the game arkanoid
    my ball hits the multiply the balls bonus
    now i want 5 or more balls on the screen bouncing like crazy

    what is the best way to do this?

    i am stuck with the logic flow

    heeeeelp



    by the way mbenney love your new footer

  2. #2
    Member
    Join Date
    Jan 2003
    Posts
    60
    Personally I'd use the Object.registerClass function to make a ball a component... thus all balls act the same way, but could have random vector values (speed, initial orientation). Then, when the ball hits whatever... use attachMovie to add more ball "components".

    Sorry if that's a bit vague
    Last edited by dotsyntaxJunkie; 08-07-2003 at 08:50 PM.

  3. #3
    Senior Member Mad-Sci's Avatar
    Join Date
    Mar 2000
    Posts
    2,756

    Re: splitting balls?

    Originally posted by magnetos
    hi guys i gotta a question for you
    now immagine the game arkanoid
    my ball hits the multiply the balls bonus
    now i want 5 or more balls on the screen bouncing like crazy

    what is the best way to do this?

    i am stuck with the logic flow

    heeeeelp



    by the way mbenney love your new footer
    this is R rated forum

    ms

    sory I had to say this..I will think about your balls..

  4. #4
    incredibulus-actionscriptum magnetos's Avatar
    Join Date
    May 2001
    Posts
    2,160

    Re: Re: splitting balls?

    Originally posted by Mad-Sci
    this is R rated forum

    ms

    sory I had to say this..I will think about your balls..


    oh well you'll have to excuse my lousy english
    its not my native language you know
    and i think you meant G rated p- and p- again


    and yes dotsyntaxJunkie you were quite vague
    i have no idea what a Object.registerClass function might be
    but it sounds cool

  5. #5
    Senior Member Mad-Sci's Avatar
    Join Date
    Mar 2000
    Posts
    2,756
    Why dont you duplicate your main ball MC 5 times..each ball however will have different speed but will follow the same rules..

    ms

  6. #6
    incredibulus-actionscriptum magnetos's Avatar
    Join Date
    May 2001
    Posts
    2,160
    Originally posted by Mad-Sci
    Why dont you duplicate your main ball MC 5 times..each ball however will have different speed but will follow the same rules..

    ms
    well thats the easy part i am having problem checking when the balls are all out
    i mean if the ball are all out then game is over

    checking one ball its easy
    if this ball_y is below the paddle_y game over

    but how do i check if all the other balls are out?
    maybe i should put a global counter on the ball or something
    which everytime is duplicated increase by 1
    so everytime the ball goes out _root.counter--
    then if _root.counter==0 game is over

    humm now that i am thinking of it
    it could work
    or not....

    thank mad

  7. #7
    DOT-INVADER marmotte's Avatar
    Join Date
    May 2002
    Location
    Dot-Switzerland
    Posts
    2,601
    hey magnetos, long time no see ^^

    well, your problem seems easy to solve. just apply what you just wrote, and that's it...

    instead of having:
    if this ball_y is below the paddle_y game over
    have
    if this ball_y is below the paddle_y counter--
    if counter ==0 game over

    of course, if you duplicated 5times the ball, also counter+=5

    but that's what you just wrote...

    ***EDIT***

    don't forget to remove your ball right after it's below the player, or the counter -- will be calculated each frame
    Last edited by marmotte; 08-07-2003 at 10:35 PM.

  8. #8
    Member
    Join Date
    Jan 2003
    Posts
    60
    Object.registerClass is a really cool feature that attaches a movieclip to a constructor (ie object). In other words you could write just one object that contains all of the props (speed, initial orientation) and functions/callback (like onEnterFrame)...

    then by using Object.registerClass, you could make sure that every instance of a movieclip conforms to the object you built. So every instance of a movieclip also has an instance of that code you wrote attached to it.

    Heh, may seem kind of complicated but I'd recommend looking into it, since it's likely to save you a lot more time in the long run.

  9. #9
    incredibulus-actionscriptum magnetos's Avatar
    Join Date
    May 2001
    Posts
    2,160
    thanks dotsyntaxJunkie i ll try to look for it but me and OOP dont like each other much maybe because i am too lazy to learn

    hey thanks for the tips marmotte long time no see you too
    i am still here... i am watching you guys this is my favorite forum you know

    ciao

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center