Discussion about software development for the old-school Gameboys, ranging from the "Gray brick" to Gameboy Color
(Launched in 2008)
You are not logged in.
For some reason I can't get the game to load the sprites properly, the bricks are giving me problems as you can see, the first two work fine, but then the rest of them don't display properly. As I play the game and some bricks get erased (it's a breakout clone btw) the other sprites start loading. How can I fix it? Here's the part of the code that loads the sprites:
void loadSprites(){
SPRITES_8x8;
set_sprite_data(0,2,paddle);
set_sprite_data(2,2,ball);
set_sprite_data(3,4,block);
//paddle
set_sprite_tile(0,0);
set_sprite_tile(1,1);
//ball
set_sprite_tile(2,2);
//sets paddle
move_sprite(0, player, 140);
move_sprite(1, player+8, 140);
//sets ball
move_sprite(2, ballInfo[0], ballInfo[1]);
//ten=0;//each row can contain 10 blocks(160px/16px), so this tell us when to change the row value
//row=2;// idk but works for setting the y, tried with a sum but did not work...
for(i=0;i<8;i++){ // 3 lines
bricks[0][i]=true; //sets it to true
bricks[1][i]=(i*20 + 10);//(ten*20); // sets x
bricks[2][i]=16;//row*8; // sets y
set_sprite_tile(i+3,3);
set_sprite_tile(i+33,4);
move_sprite(i+3, bricks[1][i], bricks[2][i]);
move_sprite(i+33, bricks[1][i] + 8, bricks[2][i]);
//if(ten==4){ ten=0; row++; }else{ ten++; }
}
DISPLAY_ON;
SHOW_SPRITES;
}
Last edited by birucan (2017-07-13 14:57:39)
Offline
That's because the GB has a hard limit of 10 sprites per scanline. If that limit is reached, the GB ignores the "lowest" in the list, in this case the last 5 "right" halves.
Offline