The Daily Click ::. Forums ::. Klik Coding Help ::. Array File Sizes...
 

Post Reply  Post Oekaki 
 

Posted By Message

viva/volt

Awesome Sauce

Registered
  26/08/2006
Points
  1694

Game of the Week WinnerSilverNova MemberKlikCast StarVIP Member
5th April, 2007 at 04:46:02 -

Second question of the day

How do I make my arrays smaller... I'm using a 16x16 grid based system for editing and saving levels. And say I want a frame that's 3000 x 3000 then 3000 / 16 = array dimensions right. But my arrays in this case are around half a mega byte. I know why this is (saving all gridspaces as 0 etc) but is there a way to get around huuuuuge level files? Like how the hell does pod do it in TU?

 
Image
http://bfollington.tumblr.com

Assault Andy

Administrator
I make other people create vaporware

Registered
  29/07/2002
Points
  5686

Game of the Week WinnerVIP Member360 OwnerGOTM JUNE - 2009 - WINNER!GOTM FEB - 2010 - WINNER!	I donated an open source project
5th April, 2007 at 05:14:16 -

There's an example I made which shows you how to make levels with the binary object. The filesizes will be tiny. A map 3000x3000 (with gridsize 16x16) will be 35kb big (according to my calculations ), using my method. Each tile takes up 1 byte of space:

http://www.clickteam.com/epicenter/ubbthreads.php?ubb=showflat&Number=34541&page=4#Post34541

 
Creator of Faerie Solitaire:
http://www.create-games.com/download.asp?id=7792
Also creator of ZDay20 and Dungeon Dash.
http://www.Jigxor.com
http://twitter.com/JigxorAndy

viva/volt

Awesome Sauce

Registered
  26/08/2006
Points
  1694

Game of the Week WinnerSilverNova MemberKlikCast StarVIP Member
5th April, 2007 at 06:27:17 -

Hmmm... I'd prefer to see if there's some way to improve the array... But your method works pretty well

I like how easy the array object is to work with... Maybe I should ask pod, he'd probably be too busy though.

 
Image
http://bfollington.tumblr.com

axel

Crazy?

Registered
  05/02/2005
Points
  4766

Game of the Week WinnerYou've Been Circy'd!
5th April, 2007 at 06:50:56 -

What Assault Andy said. That's what I usually do.

 
n/a

Assault Andy

Administrator
I make other people create vaporware

Registered
  29/07/2002
Points
  5686

Game of the Week WinnerVIP Member360 OwnerGOTM JUNE - 2009 - WINNER!GOTM FEB - 2010 - WINNER!	I donated an open source project
5th April, 2007 at 07:01:19 -

You can't improve the array object because of the way it saves data. It takes up heaps of room for each piece of data you write to it. Open in notepad, you can see there is heaps of wasted space. That's why my method is effective. I have created an array filetype of my own. It's more efficient. 1 byte = 1 piece of information in the array. It's not that complicated if you look at the example and read how it works. It's the same as the array object, it just has different actions and conditions for writing to\retrieving the data. I've already made the code for them, you just have to change them to match your game. Good luck.

 
Creator of Faerie Solitaire:
http://www.create-games.com/download.asp?id=7792
Also creator of ZDay20 and Dungeon Dash.
http://www.Jigxor.com
http://twitter.com/JigxorAndy

DaVince

This fool just HAD to have a custom rating

Registered
  04/09/2004
Points
  7998

Game of the Week WinnerClickzine StaffHas Donated, Thank You!Cardboard BoxDos Rules!
5th April, 2007 at 07:22:27 -

Or alternatively, you could use the ZipIt extension and make it zip/unzip your array whenever necessary. Heh.

 
Old member (~2004-2007).

Del Duio

Born in a Bowling Alley

Registered
  29/07/2005
Points
  1078

GOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!Evil klikerHasslevania 2!The OutlawSanta Boot
5th April, 2007 at 11:11:14 -

If the array object is easier for you to use / understand, just use the thing! It's the end result most people will see, and not how efficient the coding or filesize is. Take all the arrays for maps and whatever- Once you include them in a folder with your finished game, and zip it, it'll reduce the filesize a bunch for downloading ease. And once the end user has it and unzips it? Who cares!? It won't be THAT big in the end, will it? Everybody will have a hard drive that can handle your game unless you plan on making a Morrowind-sized deal ( > 1 GB )

If you're making a game that constantly has to update the array somehow (changes in obstacles, destructable trees, etc- My game Equin Adventures does this A LOT during gameplay) then maybe you should try the binary method above.

 
--

"Del Duio has received 0 trophies. Click here to see them all."

"To be a true ninja you must first pick the most stealthy of our assorted combat suits. Might I suggest the bright neon orange?"

DXF Games, coming next: Hasslevania 2- This Space for Rent!

WillWill

Give me stuff

Registered
  24/07/2006
Points
  552
5th April, 2007 at 12:52:46 -

But what if we want to be able to transfer arrays from server-to-client?

 
http://www.morphboy.newgrounds.com/
^ Free tunes, as long as you contact me.

Andy Hull



Registered
  08/07/2002
Points
  111
5th April, 2007 at 14:34:22 -

Also- you are wasting a ton of space with all the empty spaces that don't contain a tile (or you might be at least). If you have a ton of this, you can save each tile as 3 numbers- (tile, x, y). This adds information, but then the tiles can be saved in any order, and can be any (varying) size for that matter, and you dont worry about any wasted info. Or, if "plaforms" tend to appear all in a row, you can just save uninteruptted rows, with one start position.... ie.. (startx, starty, tile1, tile2, tile3, etc...)

this might help...

-Andy

 
-astro out

www.astrospoon.com

viva/volt

Awesome Sauce

Registered
  26/08/2006
Points
  1694

Game of the Week WinnerSilverNova MemberKlikCast StarVIP Member
5th April, 2007 at 17:44:49 -

Thanks a lot everyone, I'll try out the binary method and see how small zipping makes the arrays

@WillWill: What relevance did that comment have AT ALL?

 
Image
http://bfollington.tumblr.com

WillWill

Give me stuff

Registered
  24/07/2006
Points
  552
5th April, 2007 at 18:32:49 -

DEPENDS if you want this topic to be useful for everyone or just your question. Sorry then.

 
http://www.morphboy.newgrounds.com/
^ Free tunes, as long as you contact me.

Del Duio

Born in a Bowling Alley

Registered
  29/07/2005
Points
  1078

GOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!Evil klikerHasslevania 2!The OutlawSanta Boot
5th April, 2007 at 18:37:33 -

All of my old map arrays contain a single text character for every tile of that map section (which was made up of a double-dimensional array), so that there were never any blank spaces. You would have something like this:

..........
...***....
..*****...
...**O**..
....***...
..........

And when the game loaded these and went to display it, it'd go character by character, line by line from the actual position of the player and show a water tile for every ".", some grass for every "*", a cave for the "O" and etc. Maybe you could do something simple like that?

 
--

"Del Duio has received 0 trophies. Click here to see them all."

"To be a true ninja you must first pick the most stealthy of our assorted combat suits. Might I suggest the bright neon orange?"

DXF Games, coming next: Hasslevania 2- This Space for Rent!

Assault Andy

Administrator
I make other people create vaporware

Registered
  29/07/2002
Points
  5686

Game of the Week WinnerVIP Member360 OwnerGOTM JUNE - 2009 - WINNER!GOTM FEB - 2010 - WINNER!	I donated an open source project
5th April, 2007 at 18:58:51 -

Zipping the maps is a good idea. However there are a few problems with it. Firstly the zip objects are terrible and buggy. People have reported many random crashes from them, and functions that do not work properly. Secondly only one of the objects can extract a single file from a zip, and that doesn't come with working password support (even though you can use your own encryption method.)

 
Creator of Faerie Solitaire:
http://www.create-games.com/download.asp?id=7792
Also creator of ZDay20 and Dungeon Dash.
http://www.Jigxor.com
http://twitter.com/JigxorAndy

Fifth

Quadruped

Registered
  07/05/2003
Points
  5818

VIP MemberGOTW JULY 2010 WINNER!Kliktober Special Award TagGOTW HALLOWEEN 2011 WINNERPicture Me This Round 51 Winner!
5th April, 2007 at 22:26:13 -

If you want to try something strange, you could do something similar to what I had in my dead little Yoshi fangame.

The entire level was made up of pages (each one a screen of 20x15 tiles), and each level would be 16x16 screens across. For every space I stored the tile's visible data (what it looked like), its tile property (if it was empty/ground/platform/slope/etc.), its sprite data (what sprite went there), and the sprite's value (an extra variable to do extra stuff). Thus, I had 16x16x20x15x4 to each map, which ends up being quite a large number.

So what I did was store each page as a string inside one space of a 3-dimensional array. Thus space 0x0x0 would be 300 bytes, the visible data for the upper-left page, and 0x0x1 would be 300 bytes of the upper-left page's tile property data, and so on.

This meant, however, that every level had to be the full 16x16 pages, and would end up with some large files. So I had a system where I could close the unused pages, reducing the bytes it used from 1500 to 1 (or however small it can get in an array). Additionally, I could "block-in" a page with a single tile for solid parts, and save even more space.

If you look at this image of the old Yoshi fangame editor http://www.geocities.com/f4fth/yoshi-editor.jpg you can see on the minimap the pages that were used, closed, and blocked-in, and you can see on the main editing screen how a blocked-in page would only take up one tiles' worth of data. And when you load the level, you just send a fast loop through your array to turn the closed and blocked-in portions into usable data.

So there are certainly ways to shrink level size, you just have to get creative.

 
Go Moon!

WillWill

Give me stuff

Registered
  24/07/2006
Points
  552
6th April, 2007 at 07:16:49 -

Or you could just divide the arrays.

But I'm gonna learn Assault Andy's method someday with the binary object, I mean it would serve me greatly.. Shame I don't know much bout the binary object in the first place.

 
http://www.morphboy.newgrounds.com/
^ Free tunes, as long as you contact me.
   

Post Reply



 



Advertisement

Worth A Click