#23225 - Darmstadium - Wed Jul 07, 2004 10:19 pm
i'm having a very very weird problem. First I will explain a little about what's going on in my demo. In it you move along the level and there are various objects that your character can collide with, that is he can't walk through them. There is a struct called mobj, which holds information about an object that you can collide with and the sprite that is the object's visual representation. In this struct are the x and y coords of the sprite and the number of the sprite (0-127). Anyway, the collsion system isn't really important in my problem. The point is I need to update the actual sprite's coords with the ones in it's mobj struct. I have an array of 128 mobj structs called mobjs. I try to loop through them all like this:
But that doesn't work. In my demo, I have a mobj for testing and a sprite, but the sprite's coords are totally unaffected. The test mobj is mobjs[0]. I tried replacing the loop in my code with this
and the coordinates are updated correctly. I have no idea how this could be possible.
Thanks for helping!
Code: |
for (int loop = 0; loop < 128; loop++) { sprites[mobjs[loop].sprite_number].attribute0 &= 0xFE00; sprites[mobjs[loop].sprite_number].attribute0 |= mobjs[loop].y; sprites[mobjs[loop].sprite_number].attribute1 &= 0xFF00; sprites[mobjs[loop].sprite_number].attribute1 |= mobjs[loop].x; } |
But that doesn't work. In my demo, I have a mobj for testing and a sprite, but the sprite's coords are totally unaffected. The test mobj is mobjs[0]. I tried replacing the loop in my code with this
Code: |
sprites[mobjs[0].sprite_number].attribute0 &= 0xFE00; sprites[mobjs[0].sprite_number].attribute0 |= mobjs[0].y; sprites[mobjs[0].sprite_number].attribute1 &= 0xFF00; sprites[mobjs[0].sprite_number].attribute1 |= mobjs[0].x; |
and the coordinates are updated correctly. I have no idea how this could be possible.
Thanks for helping!