so player should bonuce right back on ground.
i comment code line by line but if can understant statnd let me know. and ill explain more.
variable info:
playerX = player x postion
playerY = player y postion
playerH = player height
playerW = player width
x = platform x postion
y = platform y postion
width = platform width
height = platform height
p.setY() = set player y postion
if(playerX + playerW >= x && playerX <= x + width)
{
if(playerY+playerH >= y && playerY <= y+height) //basic collsion between player and platform
{
if (playerX <= x && playerY+playerH >= y) //player on left - cant go though platform
{
p.setX(x - playerW); //stop player from going right
}
else if(playerX >= x && playerY+playerH >= y) //player on right -cant go thought it
{
p.setX(x + width); //stop player from going left
}
else if(playerY+playerH <= y) //player on top -cant go though it
{
p.setJUMP(false);
p.setY(y - playerH); //stop player from going down
}
else if(playerY <= y+height) //player on top -cant go though it
{
//stop player from going down
p.setY(y + playerH);
}
}
}
if player jump from bottom of platform than i want to go inside this if statment.
else if(playerY <= y+height) //player on top -cant go though it p.setY(y + playerH);
1st problem is that if player is bottom of platform than it go inside this if statment. which is wrong
else if(playerX >= x && playerY+playerH >= y) //player on right -cant go thought it
2nd problem is logic question. how can i make my player bounce back on ground. here is what i am thinking
p.setY(playerY+1); //but it go though platform

New Topic/Question
Reply


MultiQuote

|