#72518 - deltree - Sun Feb 19, 2006 2:23 pm
solution for this problem:
never define an array without specify the size of it. else, it will work weirdly or not at all.
--------------------------------------------------------------
please, help me, I've spent hours on this, and I don't know what's wrong with it:
the resulting rom is here:
http://superdeltree.free.fr/jeux/devgba/test/shmups.gba
it behaves properly untils the 5th missile is launched, and after, everything is fucked up. the missile don't move properly, the plane sprite dissapear, then the plane sprite come in place of one missile sprite. Please someone explain me what's wrong...
Last edited by deltree on Mon Feb 20, 2006 10:17 am; edited 2 times in total
never define an array without specify the size of it. else, it will work weirdly or not at all.
--------------------------------------------------------------
please, help me, I've spent hours on this, and I don't know what's wrong with it:
Code: |
#include <mygba.h>
// Graphics Includes (palette+ship+bullets) #include "gfx/general.pal.c" #include "gfx/tir.raw.c" #include "gfx/vaisseau.raw.c" // sprites u8 player_sprite,bullet_sprite,bullets_sprite[10]; // Sprite object number //positions u16 player_x,player_y,bullets_y[],bullets_x[]; //variables int num_bullets=0,press_A=0,vbl_ok=0,i=0; void vbl_func() { vbl_ok=1; ham_SetObjXY (player_sprite,player_x,player_y); //move bullets for (i=0;i<num_bullets;i++) { if (bullets_y[i]>10) bullets_y[i]--; ham_SetObjXY(bullets_sprite[i],bullets_x[i],bullets_y[i]); } ham_CopyObjToOAM(); } // End of vblFunc() int main() { ham_Init(); ham_SetBgMode(2); // Setup the background mode ham_LoadObjPal((void*)general_Palette,256); //create the player player_x=50; player_y=60; player_sprite = ham_CreateObj((void*)vaisseau_Bitmap,OBJ_SIZE_16X16,OBJ_MODE_NORMAL,1,0,0,0,0,0,0,player_x,player_y); //create the bullet sprite bullet_sprite=ham_CreateObj((void*)tir_Bitmap,OBJ_SIZE_8X8,OBJ_MODE_NORMAL,1,0,0,0,0,0,0,240,10); ham_StartIntHandler(INT_TYPE_VBL,(void*)&vbl_func); while(1) { if (vbl_ok==1) { vbl_ok=0; //control the player if(F_CTRLINPUT_LEFT_PRESSED && player_x > 0) player_x--; if(F_CTRLINPUT_UP_PRESSED && player_y > 0) player_y--; if(F_CTRLINPUT_DOWN_PRESSED && player_y < 144) player_y++; if(F_CTRLINPUT_RIGHT_PRESSED && player_x < 224) player_x++; if(F_CTRLINPUT_A_PRESSED && num_bullets<10 && press_A==0) { press_A=1; bullets_x[num_bullets]=player_x; bullets_y[num_bullets]=player_y; bullets_sprite[num_bullets]=ham_CloneObj(bullet_sprite,bullets_x[num_bullets],bullets_y[num_bullets]); num_bullets++; } else if(!F_CTRLINPUT_A_PRESSED ) press_A=0; } } } // End of main() |
the resulting rom is here:
http://superdeltree.free.fr/jeux/devgba/test/shmups.gba
it behaves properly untils the 5th missile is launched, and after, everything is fucked up. the missile don't move properly, the plane sprite dissapear, then the plane sprite come in place of one missile sprite. Please someone explain me what's wrong...
Last edited by deltree on Mon Feb 20, 2006 10:17 am; edited 2 times in total