#67184 - Linkiboy - Mon Jan 16, 2006 3:07 am
Well, I finally got sprites moving, and they detect their collison (yay!), and I got text to show up, but in seperate .nds files. When I try to combine The two scrips, It compiles with no errors, but The text doesn't show up...
Text script:
Here is the combined script:
If you need any other pieces of code ask me.
So what am i doing wrong?
Text script:
Code: |
#include "..\nds.h" #include "..\memory.h" #include "..\screen.h" #include "..\system.h" #include "..\sprtext.h" int main() { int i; powerON(POWER_ALL); videoSetMode(MODE_0_2D | SPR_1D_LAYOUT | SPR_ACTIVE); VRAM_BANK_A(VRAM_SPRITE); SetupText(); Print(0,0,0x01,0); PrintString(8,0,"Hello",1); PrintNum(16,0,0xff,6); } |
Here is the combined script:
Code: |
#include "..\nds.h" #include "..\memory.h" #include "..\screen.h" #include "..\system.h" #include "..\keys.h" #include "..\ipc.h" #include "..\sprtext.h" #include "spr.h" int x,y,spritex,spritey,tempx,tempy,wait,i; void removesprites() //function, outside main, must be called from within main { for(i = 0; i < 128; i++) OAM[i * 4] = ATTR0_DISABLED; } int main() { powerON(POWER_ALL); videoSetMode(MODE_0_2D | SPR_1D_LAYOUT | SPR_ACTIVE); //activates 2d and turns on sprites in 1d mode VRAM_BANK_A(VRAM_SPRITE); //sprite vram SetupText(); Print(0,0,0x01,0); PrintString(8,0,"Hello",1); PrintNum(16,0,0xff,6); SPRITE_PALETTE[1] = RGB(31,0,0); //sprites pallet for(i = 0; i < 256; i++) SPRITE_PALETTE[i] = ((u16*)testPalette)[i]; for(i = 0; i < 32*16; i++) SPRITE_GFX[i] = ((u16*)testData)[i]; for(i = 0; i < 128; i++) removesprites(); //uses function to remove sprites from the screen spritey = 50; spritex = 100; y = 100; x = 200; while(1) { IPC[0] = spritex; IPC[2] = spritey; if(READ_KEYS & KEY_UP) { tempy = y; tempy--; if(tempy>0 & (x<spritex-32 | x>spritex+32 | tempy<spritey-32 | tempy>spritey+32)){y = tempy;} } if(READ_KEYS & KEY_DOWN) { tempy = y; tempy++; if(tempy<184 & (x<spritex-32 | x>spritex+32 | tempy<spritey-32 | tempy>spritey+32)){y = tempy;} } if(READ_KEYS & KEY_LEFT) { tempx = x; tempx--; if(tempx>0 & (tempx<spritex-32 | tempx>spritex+32 | y<spritey-32 | y>spritey+32)){x = tempx;} } if(READ_KEYS & KEY_RIGHT) { tempx = x; tempx++; if(tempx<248 & (tempx<spritex-32 | tempx>spritex+32 | y<spritey-32 | y>spritey+32)){x = tempx;} } tempx = IPC[0]; tempy = IPC[2]; if(IPC[1]){ IPC[1] = 0; if(tempx>0 & (tempx<x-32 | tempx>x+32 | spritey<y-32 | spritey>y+32)){spritex=tempx;} } if(IPC[3]){ IPC[3] = 0; if(tempy>0 & (spritex<x-32 | spritex>x+32 | tempy<y-32 | tempy>y+32)){spritey=tempy;} } if(READ_KEYS & KEY_A) { tempx = spritex; tempx++; if(tempx<248 & (tempx<x-8 | tempx>x+8 | spritey<y-8 | spritey>y+8)){spritex = tempx;} } if(READ_KEYS & KEY_B) { tempy = spritey; tempy++; if(tempy<184 & (spritex<x-8 | spritex>x+8 | tempy<y-8 | tempy>y+8)){spritey = tempy;} } OAM[0] = ATTR0_COLOR_256 | ATTR0_SQUARE | spritey; //ATTR0, atribute which controls sprites colour, shape and x coord OAM[1] = ATTR1_SIZE_32 | spritex; //ATTR1 is size and y coord OAM[2] = 0; //ATTR2 is sprite img no. OAM[4] = ATTR0_COLOR_256 | ATTR0_SQUARE | y; //ATTR0, atribute which controls sprites colour, shape and y coord OAM[5] = ATTR1_SIZE_32 | x; //ATTR1 is size and x coord OAM[6] = 0; //ATTR2 is sprite img no. //oam3 rotates and zooms but is not needed for(wait=0;wait<1000;wait++) wait = wait; WaitForVBlank(); } } |
If you need any other pieces of code ask me.
So what am i doing wrong?