Gameboy Development Forum

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.

Ads

#1 2017-07-13 14:57:03

birucan
New member
Registered: 2017-04-25
Posts: 2

Trouble displaying sprites

https://i.imgur.com/hpDfHc4.png
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

 

#2 2017-07-13 15:42:31

ISSOtm
Member
From: Somewhere in Echo RAM
Registered: 2017-04-18
Posts: 160
Website

Re: Trouble displaying sprites

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.


The French Lord Of Laziness.
Legend of Zelda and Undertale fan, I also tend to break Pokémon R/B/Y a little too much.

Twitter | Me on GCL | Discord : ISSOtm#9015 | Skype : isso.tm (I don't login anymore)

Offline

 

#3 2017-07-13 16:25:44

Jonas
Member
From: Frankfurt, Germany
Registered: 2016-06-06
Posts: 112
Website

Re: Trouble displaying sprites

In a game like this, the bricks should be part of the background. wink If you use sprites for the paddle and the ball only, you won't have an issue with the sprite limit.

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson