View Full Version : [F9/AS3] Scrolling engine
Fall_X
07-07-2006, 12:55 AM
Hi,
I've been working on a scrolling engine in Flash 9 with ActionScript 3.
Here it is : http://gamesquid.com/TileSQUID/TileSQUID.zip
It's still a work in progress and I'll update it regulary.
The features are :
- Multiple layer types supported (at the moment only TileLayer is implemented, but I will add other types)
- Parallax scrolling
- Multiple tile types supported (Tile, SuperTile, BitmapTile)
- Grid-based maps or object based maps supported
- Individual bitmap-caching per layer
- Loading tiles from external swf's and images
Any comments/suggestions? There's probably still some bugs in it, so if you find any, please let me know.
abeall
07-07-2006, 02:19 AM
This is impressive.
I'm confused what is meant by SuperTile type. Are all types of tiles being placed/divided into a screen sized grid that defines visibilty? Or only SuperTiles are placed in that grid?
Incrue
07-07-2006, 03:36 AM
SuperTile...i am not sure, but i think he is talking about this
http://www.strille.net/tutorials/part1_scrolling.php
abeall
07-07-2006, 04:17 AM
Yes, I made one of those back in AS1, actually before Strille popularized it, but the basic concept(unless I'm confusing the term SuperTile) is that rather than calculate the visibilty of every single tile, you divide the map into screen sized regions(the SuperTiles), of which you are never on more than 4 at a time, and that way you only have to check the visibility of the objects in those 4 regions. This also frees you up to put your objects at arbitray positions since it doesn't have to fit into a perfect tile grid. Looking at Fall_X's code it looks like he's using SuperTiles as part of the core engine, so I can't tell what a SuperTile type is referring to. It looks like a SuperTile is an individual object, so that is what's confusing me. However, this code is full of bits and pieces I can't follow yet, but would like to learn, so I'm mostly just probing for insight on the code. :-)
Fall_X
07-07-2006, 07:29 AM
Close, but no cigar.
While the concept you describe - the 4 regions - is a very important part (the most important part if you ask me) of Strille's approach, and my engine as well, it's not what supertiles are.
Supertiles are actually just containers for other tiles. By grouping tiles together, you decrease the amount of calculations needed for checking visibility etc. Off course, you'd probably get even slightly better performance by just making bigger tiles, but that's usually not possible - if the graphical "building blocks" are small, this would mean you have to create a lot of combinations up front, so grouping them together in your map design is the next best thing.
In my engine, supertiles are especially beneficial when you're using the bitmap caching on a layer. This function just caches the layer as one bitmap (cacheAsBitmap), but if the layer is changed a lot, this will probably slow things down. But if you reduce the number of changes on the layer by using supertiles, it will increase the scrolling speed.
Layers that are loaded from a grid have properties that will split the tiles up in supertiles automatically, so if you work with a grid, you don't really have to worry about this except providing a number that indicates how much tiles you want per supertile horizontally, and how much you want vertically. If you're working with a one-dimensional array (ie object-based maps), you'll have to create the supertiles manually in this map.
The fun thing about my supertiles is that they can consist of all types of tiles my engine supports, so they can have normal tiles, other supertiles (not sure if this has any benefits), and bitmap tiles.
The bitmap tiles will need a displayobject (usually a bitmap), and will use a part of that, based on an index and size you provide - ie if you have a tileset in one image with 32x32 tiles, you'd have to specify 32 as size, and index 0 will be the first tile in that tileset, etc.
abeall
07-07-2006, 02:57 PM
I see, so I was thinking of SuperTiles as the actual screens/regions engine, but SuperTile is referring to a group of Tiles in order to minimize the number of objects that need to be checked for visibility(something I never implemented in my old AS1 engine). Cool.
Here's my suggestion for your engine:
When it's done, or at a milestone(I'd say it is at a milestone or near to one right now?) add some basic level documentation on the code so it can be extended.
Great work.
Fall_X
07-07-2006, 11:04 PM
Yeah, I know, at the very least I should add some comments to the source. It's a bad habbit of mine, because I'm used to working with tight deadlines.
BTW, anyone who downloaded it should download again, I fixes some bugs and did some small optimizations.
Fall_X
07-09-2006, 01:53 AM
Hi all,
Could you please check this out? http://www.gamesquid.com/TileSQUID/Game.html (FP9 required)
It runs smoothly on my computer, but could you give me the framerate (number in top left corner) it's running at on your computer?
It's set to run at 120fps, and in the standalone player it does, but in the browser it most likely won't run faster than 65 fps, which is acceptable, if most other computers are able to get a similar framerate.
The map is made in Tiled (www.mapeditor.org), my engine now supports Tiled's XML format. It's a work in progress map for a game I'm making (and now porting to F9).
Thanks a lot, it's really appreciated.
abeall
07-09-2006, 01:59 AM
I got about 60fps. I'm on a P4 3.39 GHz 1.00 GB of RAM.
adi008
07-12-2006, 05:48 PM
nice topic budYYY!... ;)
cparcell
07-12-2006, 10:22 PM
46 is my low and 55 is my high.
Win XP SP2
P4 2.5
512 RAM
flashpipe
08-25-2006, 05:53 PM
Fall_X,
Is your engine still out there somewhere? I'm just starting to play around with game development and would LOVE to take a look at what you've got in AS3...
Thanks!!
Fall_X
08-28-2006, 07:33 AM
Fall_X,
Is your engine still out there somewhere? I'm just starting to play around with game development and would LOVE to take a look at what you've got in AS3...
Thanks!!
Yeah, it's still out there somewhere :)
Just take a look here : http://www.gamesquid.com/?/blog
I would like to say that the simple demo I put up doesn't quite show all the capabilities of this engine.
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.