just had a look at the camera controls for you if you add this to your code in void loop() the camera should scroll really nice
- Code: Select all
if(player_x > 64 ) {camerax-=2; player_x -=2;} //Y Scrolling right
else if(player_x < 10 ){camerax+=2; player_x +=2;} //Y Scrolling left
if(player_y > 28 ) {cameray-=2; player_y -=2;} //Y Scrolling Down
else if(player_y < 10 ){cameray+=2; player_y +=2;} //Y Scrolling Up
gb.display.drawTilemap(camerax,cameray,tilemap,spritesheet); // draw the tilemap
this line in the above code
- Code: Select all
gb.display.drawTilemap(camerax,cameray,tilemap,spritesheet);
replaces this one in your project
- Code: Select all
gb.display.drawTilemap(x,y,tilemap,spritesheet);
EDIT #1
also i cannot get your Sever sprites to work correctly, it just confuses me with how much grey/black there is (and the fact the emulator doesn't display grey correctly)
why not try something more simple like this
- Sever.png (2.18 KiB) Viewed 87801 times
EDIT #2
you need to be more careful with your coding, i was confused as to why i was getting a weird sprite displayed when going left and right so looked a bit closer at your code
simple mistake i know, but by checking and double checking you could have avoided this (not an error the compiler will pick up, but testing your code definitely showed it)
the mistakes are here
- Code: Select all
else if (player_direction == 3){
gb.display.setColor(BLACK);{
gb.display.drawBitmap(player_x,player_y,sever_left_black);
}
gb.display.setColor(GRAY);{
gb.display.drawBitmap(player_x,player_y,sever_left_grey);
}
}
else if (player_direction == 4){
gb.display.setColor(BLACK);{
gb.display.drawBitmap(player_x,player_y,sever_right_black);
}
gb.display.setColor(GRAY);{
gb.display.drawBitmap(player_x,player_y,sever_right_grey);
}
}
else { gb.display.setColor(BLACK);{
gb.display.drawBitmap(player_x,player_y,sever_front_black);
}
gb.display.setColor(GRAY);{
gb.display.drawBitmap(player_x,player_y,sever_front_grey);
}
}
you had set player_direction above to the following
1 = up
2 = down
3 = right
4 = left
the above code has the left/right sprites mixed up, so its displaying incorrectly
hope this helps
EDIT #3
and in answer to your question you can have your sprites separate from the other code
in the top right of Arduino IDE there is a drop down arrow that lets you open a new tab, this can then be used to store your sprites, BUT you would need to make your other code read from that second tab or it will mot know where the code is
you would do this using the code
- Code: Select all
extern const byte sever_front_black[];
extern const byte sever_front_grey[]
... etc
for all your listed sprites