It is currently Fri Oct 20, 2017 11:14 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 18 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Fri Apr 16, 2010 12:10 am 
Offline

Joined: Sun Mar 29, 2009 4:04 pm
Posts: 36
So I finally got sick of converting bitmaps with a pen and paper and wrote a script to do it for me.

This script takes a bitmap, splits it down into whatever size meta-tiles you want, then outputs it into tile data you can include straight into your source code.

It'll work with any size tiles you specify, the default is 16x16 but you can do 8x8, 16x16, 32x8, it'll even do 10x93 if you want it to. Just make sure your image is actually divisible by the tile size. If you split a 100x100 px image into 8x8 tiles, you'll get weird results.

As always, I don't presume this is the best method of producing these results. This script is linux only and requires imagemagick to be installed. You can probably get it to run under cygwin, but you're on your own for that.

I've included sample input and output if you want to try it out: http://cinematicbazaar.com/?p=111

There is one limitation to the script. If a meta-tile is only used once in the original bitmap, it won't be included in the data file. This was intentional to keep the script from counting the original bitmap as a tile itself. So make sure each tile is used at least twice and you'll be fine.

I'm going to drag linux kicking and screaming into NES development one way or the other... even if I do have to write all my own tools.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 16, 2010 7:36 am 
Offline
User avatar

Joined: Thu Mar 12, 2009 4:09 am
Posts: 6
Location: China
Ohm,Windows could use it?it's for Linux only.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 16, 2010 7:37 am 
Offline
User avatar

Joined: Thu Mar 12, 2009 4:09 am
Posts: 6
Location: China
yeah,maybe at VRT Technology Co.,Ltd homepage,url]http://www.vrt.com.tw/[/url]you could download a nes tile converter ,with compressed tiles used for VT03(NES clone and add 64 colors),but it also can conver 16 colors for nes pal format.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 16, 2010 10:30 am 
Offline
User avatar

Joined: Sun Sep 19, 2004 9:28 pm
Posts: 3192
Location: Mountain View, CA, USA
I took a look at the script... wow. Um, I'm not sure if you realise the implications of using "eval" on all of your execution statements. Yeesh.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 16, 2010 10:49 am 
Offline

Joined: Sun Mar 29, 2009 4:04 pm
Posts: 36
The eval statements are leftovers from the command line options i took out. I'm not aware of any differences between an eval and a straight up command passed to the shell when a variable wasn't in play.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 16, 2010 5:36 pm 
Offline
Site Admin
User avatar

Joined: Mon Sep 20, 2004 6:04 am
Posts: 3470
Location: Indianapolis
Sounds like a decent setup. Is there a good way to edit the screen like that? I imagine there must be some decent tilemap-style editors out there that can output as an image, but I really have no idea.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 16, 2010 7:10 pm 
Offline

Joined: Sun Mar 29, 2009 4:04 pm
Posts: 36
It'll take any non-lossy image file as input, so you can use damn near anything to create the original image. I just happen to use bitmaps for my images.

The artist i'm working with uses photoshop to create the original background design, i use GIMP to edit them. He gives me images that look like this: http://cinematicbazaar.com/images/BioFo ... Level1.bmp

then i convert them into data. The next step will be to add in a hybrid RLE compression so the script's output will be exactly the same as my engine's input.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 16, 2010 8:59 pm 
Offline
Site Admin
User avatar

Joined: Mon Sep 20, 2004 6:04 am
Posts: 3470
Location: Indianapolis
Yeah anything would work, but I tried a google search and it turned up some programs that maybe could make it easier.

I haven't used photoshop, and gimp just a little bit, so maybe it's easier than I think, but it seems like placing tiles in a normal kind of pixel-based editor would have potential for off-by-one errors all over the place. Also seems like it would be a pain to change the character set used (as displayed in the editor), that's something that's useful to do.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 16, 2010 9:42 pm 
Offline
User avatar

Joined: Tue Jun 24, 2008 8:38 pm
Posts: 1517
Location: Fukuoka, Japan
The idea is interesting but the chance of error are high like Memblers is pointing out. A meta-tiled map editor is what would save time for your artist but from experience.. It's a pain to make one that can be generic.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 16, 2010 11:14 pm 
Offline

Joined: Sun Mar 29, 2009 4:04 pm
Posts: 36
I'm sure there are better ways to generate the background composites, but my artist does a kick ass job and I'm not going to ask him to change how he operates. He can draw images using a hex editor for all i care, as long as he keeps making awesome art.

I just needed a tool to take the files he gives me and turn them into data files.

I haven't really run into off-by-one errors working on the files. Turning on a grid and "snap-to-grid" keep most things in line. Basically the process we use is to design the 16x16 meta-tiles, then just copy+paste them into place to assemble the background. The system works pretty well for us, but it may not be for everyone.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 17, 2010 3:09 am 
Offline
User avatar

Joined: Tue Jun 24, 2008 8:38 pm
Posts: 1517
Location: Fukuoka, Japan
To each his own way that works, nothing wrong with that ;) With my editor, I was importing chr files. From that, I could create meta tiles. From the meta tile, I created meta-meta tile. Then with the result I could draw maps. Once all meta-tiles are defined, drawing/prototyping was quite fast. Then once the map was over, I export the data in the format I needed.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 17, 2010 11:22 pm 
Offline
User avatar

Joined: Sun Jun 05, 2005 2:04 pm
Posts: 2131
Location: Minneapolis, Minnesota, United States
I find actually making the bitmaps to be more challenging than entering in the data by hand. But of course, entering the data by hand sucks. That's why I meet half way and make an editor where I can just drop in tiles where I please.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 18, 2010 6:06 am 
Offline
User avatar

Joined: Tue May 05, 2009 2:43 pm
Posts: 11
You are a hero! :D
Here is a tiny contribution, imagemagick can properly pad 0
http://www.imagemagick.org/Usage/files/#write_seq
Code:
# use imagemagick to crop the background into 240 16x16 tiles
convert $1 -crop $TILES output-%03d.bmp

The output will be output-001.bmp output-002.bmp ... output-093.bmp ... output-230.bmp ...

If you need more digits bump %03d to %04d

I tested it (of course removing the 2 for loops that were padding 0), same output of leveldata.

P.S. Zip file for distribution, let's see some tar.gz! ;)


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 18, 2010 7:25 am 
Offline
User avatar

Joined: Mon Sep 27, 2004 8:33 am
Posts: 3715
Location: Central Texas, USA
Banshaku wrote:
The idea is interesting but the chance of error are high like Memblers is pointing out. A meta-tiled map editor is what would save time for your artist but from experience.. It's a pain to make one that can be generic.

Ahhh, so that's what were discussing here. Years and years back when I was trying to make a game I had to write this kind of thing, because I ran into the same issue. It sucked to have to spend so much time on a support tool.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 18, 2010 6:16 pm 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10064
Location: Rio de Janeiro - Brazil
ProgrammingAce wrote:
Turning on a grid and "snap-to-grid" keep most things in line.

That's what I do when editing level maps using GIMP. You can set the grid size to whatever your (meta)tiles' dimensions are.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 18 posts ]  Go to page 1, 2  Next

All times are UTC - 7 hours


Who is online

Users browsing this forum: Google [Bot], keldon and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group