Have I mentioned how much I stinkin love programming? Especially Python man, that's the bee's knees.
So If you look at a lot of the GIFs in this devlog, you'll notice one glaring problem: Dustin is too dark. He get's lost in the background. I'm not an artist so I still don't understand colors very well. This leads me to make like 150+ sprite images with a color that's too dark. So although I like the animations, the colors are off.
So I was looking around some GIMP/Gamemaker forums to see if there was a quick way to change ONE color in a bunch of GameMaker sprites and then import them back in. As far as I could find there wasn't any, so I thought 'HOLY MOLY I'M GOING TO HAVE TO RE-COLOR ALL THESE SPRITES!
IT'S ONLY TWO COLORS!!!!'
Well I expanded my horizon to simply using Python to manipulate images. AND OF COURSE PYTHON CAME THROUGH FOR THE
CAPITAL W WIN!
Props to
Darren@Work for giving me most of the code. Apparently there's this thing called the Python Imaging Library and it's BOSS:
This:
# Austin's Pixel Art Toolkit (APAT)
# SWITCH OLD NORMAL PURPLE
OLD_PATH = r'C:\Users\Lenovo ThinkPad x201\Documents\GameMaker\Projects\Dragons+Friends.gmx\assets\Characters\purple.png'
NEW_PATH = r'C:\Users\Lenovo ThinkPad x201\Documents\GameMaker\Projects\Dragons+Friends.gmx\assets\Characters\purple_new.png'
# establish new/old colors
R_OLD, G_OLD, B_OLD = (40, 8, 24) # old normal purple: 40, 8, 24
R_NEW, G_NEW, B_NEW = (74, 15, 45) # new normal purple: 74, 15, 45
R_OLD1, G_OLD1, B_OLD1 = (26, 5, 16) # old dark purple: 26, 5, 16
R_NEW1, G_NEW1, B_NEW1 = (45, 9, 30) # new dark purple: 45, 9, 30
from PIL import Image # From the Python Imaging Library, import the main module 'Image'
im = Image.open(OLD_PATH) # open the image we want to change and store it in 'im' variable
pixels = im.load() # x.load() is an Image Class method that returns image properties
width, height = im.size # get the pixel width and height
print width # DEBUG, so we know how big this thing is
print height
# Cycle through the image pixel by pixel and look for the color we want to change
for x in range(width): # for each x
for y in range(height): # for each y
r, g, b, a = pixels[x, y] # recieve the rgb color of the current pixel at (x,y)
if (r, g, b) == (R_OLD, G_OLD, B_OLD): # IF the current pixel is the (1st) color we want to change...
pixels[x, y] = (R_NEW, G_NEW, B_NEW, a) # -> change it.
elif (r, g, b) == (R_OLD1, G_OLD1, B_OLD1): # ELSE IF the current pixel is the (2nd) color we want to change...
pixels[x, y] = (R_NEW1, G_NEW1, B_NEW1, a) # -> change it.
im.save(NEW_PATH) # Save the changed image
gave me an easy way to do this:
pRoGrAmMiNg Is StIlL cOoL KIDSIt will still take some time to convert all his sprites but holy cow it won't take nearly as much time