here is the plauer stuff
void drawplayer() {
// Clamp cameraX
if(cameraX < cameraXMin)
{
cameraX = cameraXMin;
}
else if(cameraX > cameraXMax)
{
cameraX = cameraXMax;
}
// Clamp cameraY
if(cameraY < cameraYMin)
{
cameraY = cameraYMin;
}
else if(cameraY > cameraYMax)
{
cameraY = cameraYMax;
}
// Check if player is beyond X boundary
if(player_x < playerXMin)
{
cameraX += cameraXSpeed;
if(cameraX > cameraXMin && cameraX < cameraXMax)
{
player_x = playerXMin;
}
}
else if(player_x > playerXMax)
{
cameraX -= cameraXSpeed;
if(cameraX > cameraXMin && cameraX < cameraXMax)
{
player_x = playerXMax;
}
}
// Check if player is beyond Y boundary
if(player_y < playerYMin)
{
cameraY += cameraYSpeed;
if(cameraY > cameraYMin && cameraY < cameraYMax)
{
player_y = playerYMin;
}
}
else if(player_y > playerYMax)
{
cameraY -= cameraYSpeed;
if(cameraY > cameraYMin && cameraY < cameraYMax)
{
player_y = playerYMax;
}
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////Buttons Repeat//////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
if (ButtonUp.update());
if (ButtonDown.update());
if (ButtonLeft.update());
if (ButtonRight.update());
if (ButtonA.update());
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
ButtonUp.rebounce(10);
ButtonDown.rebounce(10);
ButtonLeft.rebounce(10);
ButtonRight.rebounce(10);
// ButtonA.rebounce(10);
///////////////////////////////////////////////////////////////////////////////
////////////////////////////Up/////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
if (ButtonUp.fallingEdge()){
tft.writeRectNBPP(player_x, player_y,16,16,4,paulrearwa,palette);
tft.writeRectNBPP(player_x, player_y,16,16,4,paulrearwb,palette);
player_direction = 1;
player_y -= 4;
if(checkcolision())
{
player_y += 4;}
}
if(player_y <= 16){
player_y = 16;}
//////////////////////////////////////////////////////////////////////////////
///////////////////////////////Down///////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
if (ButtonDown.fallingEdge()){
tft.writeRectNBPP(player_x, player_y,16,16,4,paulfrontwa,palette);
tft.writeRectNBPP(player_x, player_y,16,16,4,paulfrontwb,palette);
player_direction = 2;
player_y += 4;
if(checkcolision())
{
player_y -=4;}
}
if(player_y >= 224){
player_y = 224;}
//////////////////////////////////////////////////////////////////////////////
//////////////////////////Left////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
if (ButtonLeft.fallingEdge()){
tft.writeRectNBPP(player_x, player_y,16,16,4,paulleftw,palette);
tft.writeRectNBPP(player_x, player_y,16,16,4,paulleft,palette);
player_direction = 3;
player_x -= 4;
if(checkcolision())
{
player_x += 4;}
}
if(player_x >= 304){
player_x = 304;}
/////////////////////////////////////////////////////////////////////////////
////////////////////////////Right////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
if (ButtonRight.fallingEdge()){
tft.writeRectNBPP(player_x, player_y,16,16,4,paulrightw,palette);
tft.writeRectNBPP(player_x, player_y,16,16,4,paulright,palette);
player_direction = 4;
player_x += 4;
if(checkcolision())
{
player_x -= 4;}
}
if(player_x <= 16){
player_x = 16;}
///////////////////////////////////////////////////////////////////////////////
//////////////////////////////PLAYER DIRECTION/////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
if (player_direction == 1){
tft.writeRectNBPP(player_x, player_y,16,16,4,paulrear,palette);
}
/////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
else if (player_direction == 2){
tft.writeRectNBPP(player_x, player_y,16,16,4,paulfront,palette);
}
/////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
else if (player_direction == 3){
tft.writeRectNBPP(player_x, player_y,16,16,4,paulleft,palette);
}
/////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
else if (player_direction == 4){
tft.writeRectNBPP(player_x, player_y,16,16,4,paulright,palette);
}
/////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////for use with movey blocks////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
else if (player_direction == 5){
tft.writeRectNBPP(player_x, player_y,16,16,4,paulrearwa,palette);
}
else if (player_direction == 6){
tft.writeRectNBPP(player_x, player_y,16,16,4,paulfrontwa,palette);
}
else if (player_direction == 7){
tft.writeRectNBPP(player_x, player_y,16,16,4,paulleftw,palette);
}
else if (player_direction == 8){
tft.writeRectNBPP(player_x, player_y,16,16,4,paulrightw,palette);
}
};