Computer Science Canada Using Sprite Sheets. |
Author: | MysticVegeta [ Fri Jul 14, 2006 11:18 am ] |
Post subject: | Using Sprite Sheets. |
Well I have a sprite sheet, which contains leonardo walking, on the next row jumping, on the next row doing something else. But, in order to "animate" it, do I need to cut the sprite sheet into several jpgs (or bmps) and then import them and animate it old style, because it will take too long to cut them.. each sheet has like 50 of them. Or is there a way perhaps I could import the sprite sheet and then somehow "logically" do something with it, so it could be useable. The link to the sprite sheet has been provided: http://www.geocities.com/ohsoinsane/teenagemutantninjaturtlestournamentfighterssheet1.gif |
Author: | Delos [ Fri Jul 14, 2006 12:31 pm ] |
Post subject: | |
!!! This is not going to be easy, Mystic. The main problem with this sprite sheet is that individual frames are not of a regular size. Sure this allows for more impressive animation, but from your point of view it just means more work. You have several work arounds to this. If all sprite sheets follow a similar convention (all charas similarly sized, with same sorts of sequences), then you could determine positions on the map that would correspond to the sprite boundaries and extract the pics directly off the sheet each time. This sounds vaguely like hard-coding, albeit it is. If there is variablility to the sprites, as there likely is, then you could manually chop up the sprites and work from there. A lot of work, yes, but will give you fairly good results. The only thing you'll have to watch for is to ensure that you 'center' your pics correctly when drawing them. For instance, it might not be advantageous to always have the lower left corner as the 'centre' - when Leonardo kicks right, his pic would shift to accomodate this 'centre'...however if you were to use the middle of the pic as 'centre', then you mightn't have this problem (as much!). Another more complex route to take would be to use the white space as a buffer of sorts, and use the change from 'white' to 'colour' to indicate the beginning of a character. This would obviously entail some really tricky calculations and estimates, but it might work. Since it is rather complex, I'll just leave you with the idea and let you broil on it for a while - if I were to try explain my own thoughts, both of us would get quite confused. ![]() It gladens me to see the influx of sprites these days. So much fun they are. |
Author: | [Gandalf] [ Fri Jul 14, 2006 6:17 pm ] |
Post subject: | |
While it would be slow, especially in Turing, you could use whatdotcolour to determine the outer edges of each sprite and create a tight box around each sprite that way. That would make it easier to keep everything nicely centered and manipulable. |
Author: | Clayton [ Fri Jul 14, 2006 7:19 pm ] |
Post subject: | |
hm, interesting idea [Gandalf], although yes, that would be rather slow, plus you would have to look up boundary colors as well, although it would probably go faster than chopping up 200 pics in paint and saving them as bmp files! i like Delos' idea of using a program to get chop up your pics for you using a "box" to chop them and save them from the sheet. I dont see any "easy" way to do this so, its up to you |
Author: | [Gandalf] [ Fri Jul 14, 2006 7:58 pm ] | ||
Post subject: | |||
SuperFreak82 wrote: plus you would have to look up boundary colors as well
Not at all... You have a background colour, white in this case, so...
|
Author: | NikG [ Sat Jul 15, 2006 1:27 am ] |
Post subject: | |
Once you figure out the sizing issue, TheOneTrueGod's Character Map Tutorial might be of use to you. (maybe not exactly the formulas he uses, but you should be able to come up with your own) |
Author: | McKenzie [ Sat Jul 15, 2006 6:52 am ] |
Post subject: | |
Um, not that slow actually. Here is a little something I wrote for students whom I didn't expect to be able the write it themselves but still could do meaningfull things with the sprites. It doesn't always work. If you can't draw a horizontal line accross then you'll have problems but give it a try. |
Author: | Delos [ Sat Jul 15, 2006 12:10 pm ] |
Post subject: | |
Pretty sweet! Do keep in mind that you need the bgcolour to be white for this to work. As a challenge to Mystic, turn this code into a Class that will do the following: - segment a sprite sheet into its various sprites - return an array of pic streams (as opposed to creating files) - any host of other functions that could be associated with this sort of thing...be creative! |
Author: | MysticVegeta [ Sun Jul 16, 2006 1:43 am ] |
Post subject: | |
Thanks for the ideas guys. I am try that, and by the ways, did Mr McKenzie attach something? I cant reallly see it. Anyways, If I run into any problems I will surely ask. Also I will notify, which one will produce interesting and quick results. Thanks. |
Author: | Delos [ Sun Jul 16, 2006 11:40 am ] |
Post subject: | |
You can't see his attachment? Try logging out, deleting cookies, then logging in again. |
Author: | MysticVegeta [ Sun Jul 16, 2006 6:16 pm ] |
Post subject: | |
Yeah... I forgot to log-out before.. got it now Amazing.. Exactly what I was looking for.. perfect.. You are a God Mr Mckenzie! Lifesaver! I was thinking, I would split the 5 sheets up with this and then rename!!! lol. But I got a better way of doing it, as soon as it tries to save the cropped image it asks for the filename so that would do it nicely, shouldnt take more than 2 mins for each sheet. I am trying to work on doing this using dfs just for the heck of it. Thanks again for the help guys. I will let you know if I am able to do it using dfs. |
Author: | MysticVegeta [ Sun Jul 16, 2006 7:18 pm ] |
Post subject: | |
wow the dfs one was easier than I thought... here is the attached file. works like a charm, ofcourse slower than mr mckenzie's by 2 seconds on my comp. but its really accurate, short in code and no extra whitespaces, etc. If there is any way I can make this better, please do tell me. Thanks again for all the help! |
Author: | MysticVegeta [ Sun Jul 16, 2006 7:21 pm ] | ||
Post subject: | |||
I am really sorry, I forgot to post the source code:
|