[Solved] Lunar run SD Code
Posted: Sun May 10, 2015 7:43 am
Hi,
I would like to use the Myndale Code of Lunar run for a new game.
But I don't understand how this work.
First Myndale Use the persistence :
And he load the map ".DAT"
Finally he draw the ship :
All work fine !
When I do the same thing in my game the world is correctly draw, but the Player are persisted in the screen.
the code for load map is same as the Myndale Code
I change the code for draw Player :
Thx for your help
I would like to use the Myndale Code of Lunar run for a new game.
But I don't understand how this work.
First Myndale Use the persistence :
- Code:
gb.display.persistence = true;
And he load the map ".DAT"
- Code:
PFFS.lseek_file(screen_num*(LCDWIDTH*LCDHEIGHT/8));
uint8_t * buffer = gb.display.getBuffer();
for (int row=0; row<LCDHEIGHT/8; row++, buffer+=LCDWIDTH)
PFFS.read_file((char *)buffer, LCDWIDTH, &bytes_read);
Finally he draw the ship :
- Code:
gb.display.setColor(INVERT);
if (grayscale_frame)
drawBitmap(dst_x, dst_y, dst_w, dst_h, src_x, src_y, image1);
else
drawBitmap(dst_x, dst_y, dst_w, dst_h, src_x, src_y, image2);
All work fine !
When I do the same thing in my game the world is correctly draw, but the Player are persisted in the screen.
the code for load map is same as the Myndale Code
I change the code for draw Player :
- Code:
gb.display.drawBitmap((player.x % LCDWIDTH) - 4,(player.y % LCDHEIGHT) - 5, player.sprites[player.currentState].sprite1); //Sprite
/* another test */
gb.display.setColor(INVERT);
gb.display.drawBitmap((player.x % LCDWIDTH) - 4,(player.y % LCDHEIGHT) - 5, player.sprites[player.currentState].sprite1); //Sprite
/* another test */
gb.display.setColor(INVERT,INVERT);
if(gb.frameCount%2 == 0)//grey scale frame
{
gb.display.drawBitmap((player.x % LCDWIDTH) - 4,(player.y % LCDHEIGHT) - 5, player.sprites[player.currentState].sprite1); //Sprite
}
else {
gb.display.drawBitmap((player.x % LCDWIDTH) - 4,(player.y % LCDHEIGHT) - 5, player.sprites[player.currentState].sprite2); //inverse sprite (black are white and white are black)
}
/* and with draw Myndale's bitmap */
gb.display.setColor(INVERT);
if(gb.frameCount%2 == 0)
{
drawBitmap((player.x % LCDWIDTH) - 4,(player.y % LCDHEIGHT) - 5,8,11,0,0, player.sprites[player.currentState].sprite1);
}
else {
drawBitmap((player.x % LCDWIDTH) - 4,(player.y % LCDHEIGHT) - 5,8,11,0,0, player.sprites[player.currentState].sprite2);
}
Thx for your help