Gamemaker palette swap12/8/2022 #Gamemaker palette swap codeYou'd complain that the variable names were nonsensical and you couldn't understand the code because none of the variables made sense. It wouldn't make any difference it'd just change the excuse from being, "That's not what those variables are used for," to, "Those variables don't make any sense." If you think that example is bad, then how about this example: Go through my code and make the following substitutions: Look at it this way: The only real issue you can cite against me using arguments and alarms is that you and the rest of the GMC have preconceived notions of what arguments and alarms are for. The way I see it, alarms and arguments are recognized by GM so using them as temporary or local variables (although when used outside of a script arguments are global variables) makes them get highlighted so they stand out in the code that makes it a lot easier to read the code for me. It's not efficient, maybe, but some alarms I end up memorizing just like i have RAM offsets memorized. yeah I have a database of what each alarm actually corresponds to. Nowadays I can look at a code I typed up using arguments and it not only makes sense right away, it also looks aesthetically pleasing (to me at least). Palette-swapping a PNG file would be faster than workign with GMSPR files.Īs I said in the readme, if you're getting confused by arguments (btw, argument0 is used as a normal script-pass argument) and alarms without events, then you need to expand your mind and stop thinking inside the box, which is what it means when you get confused in that way. I took one look at the data and said, "Fuck it". As I said in the Game Information, a GMSPR file is a seriously compressed file. I would hope GM decompiles its sprites before the game runs, but if it doesn't, that'd explain why sprite reading functions are so slow. Then the script would need to be altered such that on each iteration you'd check if palette>0 and swap out accordingly. Palette=$B5B7B9BABBDADB //leave 1 empty for transparency So like, in this demo if a palette was referred to as $2C1808 (since the transparent color would be ignored), that refers to palette entries $2C and $18 and $08 (out of a max palette of $3F).įor a 32-color palette, you'd need 4 variables to hold the palette if you use the same method. You'd probably want to use an array so you could just use a for loop to handle it. So 16 colors and 32 colors would be doable, but would require additional variables. Using the method I did in this demo, you can only store 8 palette entries in a variable at a time. GM only allows 8 bytes per variable (at which point it becomes signed, but that's unimportant here). I said 15 colors should be easy, but it's not that simple. I just tested and what I said in the game info was actually incorrect. If you read the Game Information's entry on pal_swap_gif(), it covers multiple colors. Working with text, GM has to translate everything, but binary is as binary does. Working with binary files is considerably faster, or should be. Just something to think about.ĭon't use text files. This would require a palette swap every time the sprite changes, but would drastically reduce RAM at an unknown cost to CPU load. So you don't need any more than 34 sprites total (give or take). For games like Castlevania, there are only ever 34 or so instances in the room at any one time (can reduce that even further - you can make it so there can only be one type of subweapon at a time, so all three subweapon instances could be set to the same sprite). I thought about it some more today and the more I think about it, the better the idea seems: Rather than having one sprite allocated for each sprite (meaning clicking the New Sprite icon for each sprite), it would be better for an NES-style game to have one sprite for each instance. There is one other aspect I touched upon in the Information but didn't implement in the demo. Still, it's there for anyone that wants to use it. The script hasn't been tested because I have my doubts that it's even feasible. Included in the demo is a script I wrote up quickly last night for simulating attribute tables and nametables (how backgrounds were handled on the NES). There is also a Bone Pillar to demonstrate using multiple palettes for enemies. This will demonstrate a per-step palette swap. #Gamemaker palette swap upgradeThere are three candles which will drop a whip upgrade (which does nothing, so you can pick it up 3 times). Of course I used CV3 as a backdrop for the demo. This demo shows that palette swapping is pretty fast when used with proper programming techniques. #Gamemaker palette swap softwareYou could potentially use it in other game design software as long as they allowed bitwise file editing. Here's my palette swapping demo/tutorial for use in Game Maker.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |