A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Simple pacman style game -- Help required.

  1. #1
    Junior Member
    Join Date
    Mar 2006
    Location
    Gravesend, Kent
    Posts
    13

    Simple pacman style game -- Help required.

    Hi all,

    Im currently in the process of building a hopefully simple pacman game, ive got the player moving around the maze and ive got the maze collsion detection working great and now ive come to the hard part - the player collecting (eating) the balls/counters.

    Ok so ive got a good understanding of actionscript although most of that understanding is through use of javascript which is a similar langauge. The way ive set out to do the balls or counters is ive placed a movie clip instance of the counter about 25 times across the maze (quite spread out!) and i was planning on using instance names and loops to check for player collision thats where im having a hard time getting around the actionscript.

    Ok now that ive got my prob out in the open i need to know is there a simpler way to get my 25 counters displayed across the maze and how should i go about testing for collision on each counter?

    Thanks in advance for any help given and i apologise for the length of first time post :P.

    -*Phoenix*-

  2. #2
    Senior Member SlimSlaby's Avatar
    Join Date
    May 2005
    Posts
    158
    I'd say that with each maze you might want to handplace them. You can pretty much just set their visibility to false to hide them when eaten.

    I'd say you check for collision with a loop that goes through an array of all your balls. If a ball is not active you can either remove it from the array or just don't check it for collision.

    Not sure if this answers your questions. If you are more specific, I can try to help you more.

  3. #3
    Junior Member
    Join Date
    Mar 2006
    Location
    Gravesend, Kent
    Posts
    13
    I understand what your saying about checking for collision using an array and obviously a loop ill give it a go and get back to ya if i need more help.

    Thanks again.
    -------------------------------
    One who will rise from the ashes!
    -------------------------------
    -*Phoenix*-

  4. #4
    Senior Member flashfriend8's Avatar
    Join Date
    Oct 2004
    Posts
    146
    If you have several numbered clips, you can reference them in a loop like this:
    code:

    //if you have clip0 clip1 clip2 clip3 clip4
    for(i=0; i<5; i++)
    {
    _root["clip"+i].doSomething();
    }

    I have no idea where this is going.

  5. #5
    Junior Member
    Join Date
    Mar 2006
    Location
    Gravesend, Kent
    Posts
    13
    Thanks flashfriend ive got that section of code ready to run it was simply the naming of the instances that i needed help with as i didnt want to sit there naming each individual one but hey i might end up doing that now anyway

    Thanks again all.
    -*Phoenix*-
    -------------------------------
    One who will rise from the ashes!
    -------------------------------
    -*Phoenix*-

  6. #6
    Junior Member
    Join Date
    Mar 2006
    Location
    Gravesend, Kent
    Posts
    13
    Hi im back again with another brain teaser.

    Ok so ive got all my little curry counters/balls on the stage ready to be hitested and ive written the following if statement to do so:

    Code:
    if(_root.starbug, hitTest(_root.curry1)) {
    		_root.curry1._y =- 100;
    		_root.curry1._visible = false;
    		_global.score += 1;
    		_root.scoreDisplay += _global.score;
    	}
    Ok so now i need to run that hit test on each of the 56 counters numbered from 1 to 56 as you would expect. Now i was thinking about using a for loop but that would loop itself to the number specified and then not continue untill all the counters are collected.

    Then i thought that a while loop might do it since the score variable only goes up by one i could say while score is below 56 then run this but how could i implement this as i would need to specify in the if within the while loop which curry counter/ball i needed to make disappear??

    All help is appeciated.
    Thanks
    -*Phoenix*-
    -------------------------------
    One who will rise from the ashes!
    -------------------------------
    -*Phoenix*-

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