Sun Jan 18, 2015 12:17 am
Sun Jan 18, 2015 12:21 am
Sun Jan 18, 2015 12:22 am
Sun Jan 18, 2015 12:30 am
Sun Jan 18, 2015 12:42 am
Sun Jan 18, 2015 11:44 am
Sun Jan 18, 2015 12:03 pm
Sun Jan 18, 2015 8:50 pm
Sun Jan 18, 2015 10:00 pm
Myndale wrote:Awesome, thanks Marcus! I don't really have much time for graphics or dev utilities so I'll probably just do simple 6x6 sprites on a 2D map. The Tiled map editor is pretty easy to use and exports Json (among other formats), so hopefully that will port over to C quickly and easily.
const byte world[] PROGMEM =
{
98, 8,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x11, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x11, 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00, 0x11, 0x10, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x00, 0x11, 0x00, 0x11, 0x11, 0x11, 0x00, 0x01, 0x10, 0x00, 0x01, 0x11, 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x30, 0x00, 0x00, 0x11, 0x00, 0x11, 0x11, 0x10, 0x00, 0x00, 0x00, 0x11, 0x10, 0x00, 0x00, 0x00, 0x33, 0x30, 0x30, 0x00, 0x00, 0x00, 0x11, 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x01, 0x11, 0x11, 0x11, 0x00, 0x00, 0x00, 0x30, 0x30, 0x00, 0x01, 0x10, 0x01,
0x03, 0x00, 0x00, 0x30, 0x22, 0x23, 0x22, 0x32, 0x20, 0x30, 0x11, 0x03, 0x11, 0x11, 0x10, 0x00, 0x00, 0x00, 0x11, 0x10, 0x30, 0x00, 0x22, 0x33, 0x32, 0x32, 0x20, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x11, 0x11, 0x11, 0x00, 0x00, 0x02, 0x32, 0x32, 0x22, 0x21, 0x10, 0x01,
0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x11, 0x11, 0x11, 0x00, 0x01, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
};
/*
* Made by Jamison Schuster (github.com/Jamish)
* 12/2015
* Do what you will with it, so long as you... remember... me...
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;
namespace MapEncoding
{
class Program
{
[STAThread]
static void Main(string[] args)
{
List<string> output = new List<string>();
String input = System.Windows.Forms.Clipboard.GetText();
Bitmap bitmap = new Bitmap(input.Replace("\"", ""));
for (int y = 0; y < bitmap.Height; y++)
{
for (int x = 0; x < bitmap.Width; x += 2)
{
output.Add(colorToInt(bitmap.GetPixel(x, y)).ToString("x") + colorToInt(bitmap.GetPixel(x+1, y)).ToString("x"));
}
}
String clipboard = "";
clipboard += "const byte world[] PROGMEM =\r\n";
clipboard += "{";
clipboard += "\r\n " + bitmap.Width + ", " + bitmap.Height + ",";
int count = 0;
foreach (var o in output)
{
if (count == 0)
{
clipboard += "\r\n ";
}
clipboard += "0x" + o + ", ";
count++;
if (count == bitmap.Width / 2)
{
count = 0;
}
}
clipboard += "\r\n};";
System.Windows.Forms.Clipboard.SetText(clipboard);
}
static int colorToInt(Color c)
{
string color = c.R.ToString("X2") + c.G.ToString("X2") + c.B.ToString("X2");
int val = 0;
switch (color)
{
case "FFFFFF":
val = 0;
break;
case "000000":
val = 1;
break;
case "FF0000":
val = 2;
break;
case "00FF00":
val = 3;
break;
case "0000FF":
val = 4;
break;
default:
val = 0;
break;
}
return val;
}
}
}
Tue Jan 20, 2015 10:35 am