#176782 - MisterLogan - Tue Oct 11, 2011 5:51 am
I don't know how to easily phrase this so I'll describe the situation. I have a function that gets run up to 32 times when i load a new map section. It loads sprite data into OAM and does some little index things. This function needs 5 variables that are in a struct called CurrentSprite (an x and y, a pointer to where the visual data is, and two pointers used to index OAM and object memory locations), four of which are loaded from another struct, named after whatever sprite is getting loaded, like this:
initNPCTiles is the function. So my question is, is there any way to give the CurrentSprite struct a sprite structs attributes that doesn't take so much copying and pasting? Some way of giving a function "sadghost" and having it do this for me? I feel like this should be really obvious but my brain is not being very helpful. I guess at this point I would look silly and get past it rather than wait and do nothing.
Thanks
Last edited by MisterLogan on Tue Oct 11, 2011 9:50 pm; edited 1 time in total
| Code: |
|
CurrentSprite.IOAM = &sadghost.IOAM; CurrentSprite.IOBJ = &sadghost.IOBJ; CurrentSprite.X = sadghost.X; CurrentSprite.Y = sadghost.Y; CurrentSprite.Tiles = (u16*) &sadghostTiles; initNPCTiles(OBJMEMCounter, OAMCounter); |
initNPCTiles is the function. So my question is, is there any way to give the CurrentSprite struct a sprite structs attributes that doesn't take so much copying and pasting? Some way of giving a function "sadghost" and having it do this for me? I feel like this should be really obvious but my brain is not being very helpful. I guess at this point I would look silly and get past it rather than wait and do nothing.
Thanks
Last edited by MisterLogan on Tue Oct 11, 2011 9:50 pm; edited 1 time in total