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?
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
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.
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.
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.
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
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
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
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 )
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
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)
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.
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
----------------------------------------------------------------------