A Flash Developer Resource Site

Results 1 to 14 of 14

Thread: [problem] distorting movieclips?

  1. #1
    flash junk extravagante
    Join Date
    Oct 2003
    Location
    netherlands
    Posts
    105

    [problem] distorting movieclips?

    I just came up with this idea for a game engine earlier this week, did a lot of thinking and drawing and got off to make it. My idea was to make a perspective kind of grid that would be tile-based and would represent an environment that gets smaller and smaller towards the horizon. I figured it would be best to build up the game-area out of square tiles that would be distorted into this kind of shape

    tile
    Code:
    --------
    |      |
    |      |
    |      |
    --------
    distorted
    Code:
       ---
      /   \
     /     \
    /       \
    ---------
    It was only then that I ran into the following problem: it seems impossible to distort an MC in this way in flash MX. After a brief search here on FK (and the flash help) I learned that rotation, skew and scale are controllable through AS, but it still seems impossible to achieve distortion as described above.

    For the sake of my engine: does anyone know of a way to perform (or simulate) distortion like that on an MC?

    all help is really appreciated
    signatures after the show, thank you.

  2. #2
    Ihoss
    Guest
    if u look in the mario kart thread ull see one way. im asuming u want it for 3D.

  3. #3
    flash junk extravagante
    Join Date
    Oct 2003
    Location
    netherlands
    Posts
    105
    Thanks, Ihoss. I've been watching that thread and was really impressed by it.

    BUT... my idea is quite different. I want to use a tile-based engine, whereas the MarioKart Engine uses raycasting (is that the right term? maybe it's raytracing then) and a huge bitmap for the floor-map. I want to build up the game area out of tiles, like this
    Code:
    -------------------
    |     |     |     |
    |     |     |     |
    |     |     |     |
    -------------------
    |     |     |     |
    |     |     |     |
    |     |     |     |
    -------------------
    |     |     |     |
    |     |     |     |
    |     |     |     |
    -------------------
    and then distort it to look like this
    Code:
            ---
           /   \
          -------
         /       \
        /         \
       -------------
      /             \
     /               \
    /                 \
    -------------------
    signatures after the show, thank you.

  4. #4
    Hype over content... Squize's Avatar
    Join Date
    Apr 2001
    Location
    Lost forever in a happy crowd...
    Posts
    5,928
    I've not really played with the mk engine, but converting it to a tile based system shouldn't be too tricky.

    I'm guessing just plotting all your tiles but using the mask/scaling effect as in mk would do it. You may have issues if you make the depth too great, in that you would need a stupid amount of tiles to cover the horizontal line. Perhaps using a bitmap for that to hide it ? ( Depends on your game / movement )

    Andre has posted a tut / source over at www.gotoAndPlay.it which I believe uses tiles.

    Wow, what a vague and pretty useless post. Sorry.

    Squize.

    PS. Great to see the prefix in use btw

  5. #5
    Ihoss
    Guest
    one thing i noticed when working with hte Mario Kart engine was that if u used vector graphics it ran really slow. so u should use only bitmaps. then u can use the same idea.

  6. #6
    Senior Member tonypa's Avatar
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    8,227
    Main problem I ran into, when I tried to do something like this, was how to calculate shape of all the other tiles. I mean its easy to play with only tiles on center, but when you consider the tiles left/right, they all get really complicated.

    Picture attached.

  7. #7
    flash junk extravagante
    Join Date
    Oct 2003
    Location
    netherlands
    Posts
    105
    Thanks for your replies, guys!

    I've been making a start with (thanks to random's tilemap-editor) and have come somewhere. I think I ran into the same problem as you, tonypa. Dynamically creating a grid for the tiles in perspective appeared to be really hard, so I made a pre-defined grid (see attachment). The problem is: the tiles have the shape they should have, and they are set to mask so that the attached tiles are only showing the desired area, but I can't get the attached tiles to be transformed like the holder MC's. When I tested it on a regular (square) grid, it all went well.

    please take a look at the attached picture.

    I also took a look at Andre Michelle's stuff, but couldn't really figure out:
    a) if it was tilebased
    b) if so, how he made the tiles look distorted.

    Anyone with deeper insight on this is really welcome! Else I'll have to stick with just a top-down racing game (and there's already so many of them, so where's the challenge? )

    again, please check the attachment. It might clear up what I'm rambling about here
    Attached Images Attached Images
    signatures after the show, thank you.

  8. #8
    Ihoss
    Guest
    y dont u stuff it in an mc and then use the MK engine to distort tah mc? wouldnt thta work?

  9. #9
    flash junk extravagante
    Join Date
    Oct 2003
    Location
    netherlands
    Posts
    105
    I already have them in an MC, but as I tried to state earlier on, the MK engine uses a different approach, called raycasting. Think of it as this: you have a bitmap (say 1000*1000 px) that you slice up into bars ('rays') by placing a lot of MC's on the stage with masking. You then have a grid like this
    Code:
    -----------------------------------
    
    -----------------------------------
    
    -----------------------------------
    
    -----------------------------------
    
    -----------------------------------
    I.e the screen is built up out of horizontal bars. Inside each bar is the big bitmap, with a specific _rotation and _x- and _yscale. Inside the bars is a mask that makes it show only a little stripe of the bitmap.

    My approach is completely different, as I wish to use tiles. if you'd take a look at the attachment to my previous post, you'd see that my screen is built up out of 9 horizontal blocks (the tiles) and 6 vertical blocks

    Thanks for your reply Ihoss, but I'm really sticking to this tile-based thing 'cause I feel the raycasting isn't what I'm looking for (and I probably wouldn't be able to make it ) and it makes level-editing a lot easier

    P.s: hope that I explained the raycasting thing OK. If not, apologies to the MK-engine people
    signatures after the show, thank you.

  10. #10
    Ihoss
    Guest
    i get the MK engine and what ur doing. im saying that y dont u put ur tile map (with tiles and everything) inside an mc and then stuff that inside the MK engine. that would work (i think )

  11. #11
    flash junk extravagante
    Join Date
    Oct 2003
    Location
    netherlands
    Posts
    105
    Originally posted by tonypa
    Main problem I ran into, when I tried to do something like this, was how to calculate shape of all the other tiles. I mean its easy to play with only tiles on center, but when you consider the tiles left/right, they all get really complicated.
    So you actually figured out how to calculate the shapes of the centered tiles? If so, I'm really interested in how you did that. I think I could come up with a way to do the other tiles
    signatures after the show, thank you.

  12. #12
    Senior Member
    Join Date
    Aug 2001
    Posts
    101

    Howdy

    Howdy, there are basically 2 ways to create your engine (that I can currently think of) 1 way requires a far bit of cpu power and the other way will result in a huge filesize (if you want ur engine to rotate).

    Dont use the mariokart engine as you are right, that wont work with tiles, you will unfortunatly get a big performance hit if you replace the track image with multimple movieclips (tiles)

    You can either look into Lifaros' triangle engine http://www.nomaster.com/flas.php?page=4&cate=1

    and make each tile out of two triangles, which will allow you to give them perspective. However, with lots of triangles on screen you will notice a big performance hit.

    The second way would be to pre-distort the bitmaps that make up your tiles in photoshop. However, if you want to rotate your track like the mariokart engine or the triangle engine will allow. You will have to make a new image of the tile for pretty much each angle you want to rotate the map for.

    ie, you may find you need 360 frames for each tile, so this will have a huge filesize.

    If you arent actually wanting to rotate the track, but make a racing game with a simliar engine to outrun/hangon etc then the 2nd method would be the best as you'd only need 1 frame for each tile.

    Hope that helps

    PercyPea

  13. #13
    Senior Member tonypa's Avatar
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    8,227
    I once made fake 3D engine, that was somehow tile based:
    http://www.hot.ee/tonypa/flash/flas/maze4.html

    You can find fla in the thread too:
    http://www.flashkit.com/board/showth...hreadid=448207

  14. #14
    Senior Member chriserrorplain's Avatar
    Join Date
    Aug 2002
    Location
    london village
    Posts
    623
    am i right in saying that old perspective tile based racing games like Super Hang on et al, used tiles which were already distorted to the correct shape and then moved and scaled them, me and my friend wrote somehting like it in Director ages ago and I'm sure we did it without utilising the Quad distortions.

    I'll have a think on the way home from work and post somehting when i remember how it works


    chris errorplains

    ----------------------------------------------------------------------edit
    Sorry just read that someone already mentioned pre-distorting the tiles silly me
    ----------------------------------------------------------------------

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