A Flash Developer Resource Site

Results 1 to 19 of 19

Thread: [Flash 8] Destroy ground

  1. #1
    Senior Member tonypa's Avatar
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    8,223

    [Flash 8] Destroy ground

    You know the type of games, Scorched Earth, Worms etc where you can destroy ground by shooting at it. This example allows similar games:

    http://img272.imageshack.us/my.php?image=ground8vt.swf

    Click to create hole.
    Space to reset.
    The red guy in the top middle falls down when he has nothing to stand on.

    The example uses bitmapdata with its draw and getpixel methods.
    Attached Files Attached Files

  2. #2
    Mental Ward Patient Blips's Avatar
    Join Date
    May 2005
    Posts
    482
    wow nice.

  3. #3
    Razor
    Join Date
    Aug 2002
    Location
    Canada
    Posts
    721
    Quote Originally Posted by tonypa
    You know the type of games, Scorched Earth, Worms etc where you can destroy ground by shooting at it. This example allows similar games:

    http://img272.imageshack.us/my.php?image=ground8vt.swf

    Click to create hole.
    Space to reset.
    The red guy in the top middle falls down when he has nothing to stand on.

    The example uses bitmapdata with its draw and getpixel methods.
    Thats really sweet, but the background(white part that you see after clicking) would have to be a solid color wouldnt it?

  4. #4
    M.D. mr_malee's Avatar
    Join Date
    Dec 2002
    Location
    Shelter
    Posts
    4,139
    My bets on Tonypa for first flash 8 game. Nice work again Tony, i'm still messin round with old flash 8 stuff... (well its old on this forum!).

    EDIT: This would be so cool for my game. Smashing enemies through walls, i've always wanted to do that. Thanks again tony for inspiration
    Last edited by mr_malee; 09-17-2005 at 12:27 PM.
    lather yourself up with soap - soap arcade

  5. #5
    Senior Member tonypa's Avatar
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    8,223
    Quote Originally Posted by chuckury
    Thats really sweet, but the background(white part that you see after clicking) would have to be a solid color wouldnt it?
    Uh? I dont understand
    The bitmap is turned into transparent where you click (the white color is background color).

    Sorry, could you explain please.

  6. #6
    Razor
    Join Date
    Aug 2002
    Location
    Canada
    Posts
    721
    Well how does the detection work, sorry still dont know too much about flash 8, does flash re-update the bitmap each time and then it checks for collisions on that, because I thought for some reason that it used some sort of color check, but now I get it so no worries

    EDIT: Ya it was just me being stupid I checked out the .fla all makes perfect sense now nice
    Last edited by chuckury; 09-17-2005 at 01:40 PM.

  7. #7
    \x3a\x6f\x29
    Join Date
    Sep 2005
    Location
    paris
    Posts
    88
    Could be used for (multiplayer) Worms )
    Very nice!

  8. #8
    Senior Member tonypa's Avatar
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    8,223
    I noticed the script creates endless loop when you click near the edge of stage so the hole goes out. You should add check for edges:

    if (myBmp.getPixel (mc._x + i * dir, mc._y + 1) == 0) {
    fall = true;
    }
    var newx:Number=mc._x + i * dir;
    if (myBmp.getPixel (newx, mc._y) != 0 or newx<0 or newx>stageW) {
    break;
    }

  9. #9
    doItLikeThis
    Join Date
    Jan 2004
    Location
    :noitacoL
    Posts
    1,080
    Hmm, I have already done that in flash 6 before, what's the advantage or new about it?
    -Aditya

  10. #10
    doItLikeThis
    Join Date
    Jan 2004
    Location
    :noitacoL
    Posts
    1,080
    ok i guess you're showing draw and getPixel method application.
    -Aditya

  11. #11
    Member
    Join Date
    Aug 2005
    Location
    UK, South East
    Posts
    79
    Quote Originally Posted by adit_ya_sharma
    Hmm, I have already done that in flash 6 before, what's the advantage or new about it?
    Me too (check the Radar Rik game in my sig for starters - play a level with the laserbeam active), but it's complex and akward in MX. In that game, I have three separate versions of the map - one for the radar level, one for the light beam level and one for the minimap. Each time a hole is blown in the landscape I have to add more clips to the three layers and do hittests against them to allow the player to fly into those areas rather than clipping the original landscape that still exists underneath. One big disadvantage of this is that when the amount of broken land starts to build up, it means loads and loads of new clips overlaying the old ones, which hurts the framerate plenty.

    This new method incurs a minor performance hit only when the new bitmap data is drawn to block out some land. After that it's essentially a free effect. It's also a helluva lot easier to understand, and for those two reasons I expect there will be a wave of games using this sort of thing soon.

    Forget "how do I make an RPG" noob questions. It'll be "how do I make Worms" instead
    Try my new game: Radar Rik
    My other Flash crap: Click Here

  12. #12
    Razor
    Join Date
    Aug 2002
    Location
    Canada
    Posts
    721
    Quote Originally Posted by CMU
    Forget "how do I make an RPG" noob questions. It'll be "how do I make Worms" instead
    Then you just tell them that they really dont want to see a Worm made because 1st they'd need a mama and papa worm and then some weird sex ritual

  13. #13
    Official Shoe Shiner thehumanchimp's Avatar
    Join Date
    Jul 2003
    Location
    London
    Posts
    953
    yeh, its hell getting the holes to work, i've done it in MX - but it wasn't easy...
    I really should start working on that game again...
    Message on a gravestone: I finished before you in the human race.

    Using: Flash MX

  14. #14
    *insert clever title* SergeantK's Avatar
    Join Date
    Nov 2004
    Location
    Akron, Ohio
    Posts
    506
    *downloads flash player 8*

    Oh, now it works. Very nice.


  15. #15
    Senior Member TeroLebe's Avatar
    Join Date
    Mar 2003
    Location
    Lahti, Finland
    Posts
    302
    Nice... What next... a Lemmings clone ;D

    I'm very impressed with Flash8 graphical featuers.

  16. #16
    Say hello to Bob Kakihara's Avatar
    Join Date
    Jul 2004
    Location
    kent, England
    Posts
    1,067
    A lemming clone, was actually thinking about making one myself but couldnt figure the making of holes thing out, so yep lemmings clone on the way,'wets go!'.
    If our body is a clock ticking away and if while we experience all that this world has to offer time has still continued to pass, are we living or just experiencing a slow death?

  17. #17
    Senior Member
    Join Date
    Feb 2005
    Posts
    1,834
    Quote Originally Posted by tonypa
    I noticed the script creates endless loop when you click near the edge of stage so the hole goes out. You should add check for edges:

    if (myBmp.getPixel (mc._x + i * dir, mc._y + 1) == 0) {
    fall = true;
    }
    var newx:Number=mc._x + i * dir;
    if (myBmp.getPixel (newx, mc._y) != 0 or newx<0 or newx>stageW) {
    break;
    }
    I can't figure out what to do with this code. Could you fix the fla? This is something that would be really good to have and not just for this.
    .

  18. #18
    Senior Member tonypa's Avatar
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    8,223
    Quote Originally Posted by swak
    I can't figure out what to do with this code. Could you fix the fla? This is something that would be really good to have and not just for this.
    It is suppose to be in checkDir function. I will paste the whole fixed function here:
    Code:
    function checkDir (mc:MovieClip, dir:Number) {
    	var fall:Boolean = false;
    	for (var i:Number = 1; true; i++) {
    		if (myBmp.getPixel (mc._x + i * dir, mc._y + 1) == 0) {
    			fall = true;
    		}
    		var newx:Number=mc._x + i * dir;
    		if (myBmp.getPixel (newx, mc._y) != 0 or newx<0 or newx>stageW) {
    			break;
    		}
    	}
    	if (i > 1 and fall) {
    		return true;
    	} else {
    		return false;
    	}
    }

  19. #19
    Senior Member
    Join Date
    Feb 2005
    Posts
    1,834
    thanks.
    .

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