This article is about how to create your own character out of a number of sprites. It is very general though, even if the example is just plain from the front view.
Let’s say you got four part; a hat, a face, a shirt and some pants. You want your users to select from a wide range of looks and then combine them together. This theory is working cross all genres, also in RPGs and more. Here is how to do:
You need to have all the sprites to have the same measurements. Like for an example the shirt could be 50 pixels high and the pants 70. Try to figure out what is the realistic length scale. All pants must be 70 if you choose that, and all shirts must be 50 if you choose that. Otherwise you couldn’t possibly exchange the clothes as you wanted to cause they all wouldn’t fit. I couldn’t find any sprites that kept the same dimension though, but if you are making a real game and making it serious this is really important.
Next thing to do is arranging them somehow. One idea is to put all shirts as subimages in sprite, say spr_shirt, and all pants as subimages to spr_pants. Then you need to figure out what dimension to use when drawing the sprite. Then you alter the code below to fit your measurements of the sprites (you might want to overlap your sprites a little):
draw_sprite(spr_hat,img_nr,x,y);
draw_sprite(spr_shirt,img_nr2,x,y+hat_height);
Understand that you will need one such drawing code per clothing and you will have to add +height for each time. Eventually it will look like +hat_height+shirt_height+ etc. You will also have one img_nr variable for each function, so that you can define which one of the subimages to draw. In the button where you want to change image you simply put img_nr+=1.
I include a very old file that I create, I found it on my computer, it’s not good and foremost the sprites have different length width so it looks like crap. Perhaps you can use the code for something anyway:
http://gmtutorials.com/files/mi.gm6
.
Users logged in:
Comments
Loading comments...