Hi, I made a small smash bros game like and ran into a problem, i made a code for making the platform solid, but it only work when my character come from the side. When it come from under, it just get stuck in the platform. If anyone could help me and explain what is the matter I would appreciate it.
public class ButlerStanding extends Character
{
int v = 0;
int t = 10;
int u = 0;
int attack = 0;
int pos = 0;
int cd = 0;
public void act()
{
int y = getY();
int x = getX();
Hitboxattack h = new Hitboxattack();
if(isTouching(water.class)){
Greenfoot.setWorld(new MyWorld());
}
if (isTouching(platform.class)){
v = 0;
if (pos==0){
setImage(new GreenfootImage("Bstanding.png"));
}
if (pos==1){
setImage(new GreenfootImage("Bstandingright.png"));
}
if (pos==2){
setImage(new GreenfootImage("Bstandingleft.png"));
}
if (Greenfoot.isKeyDown("right")){
u=u+2;
if (t==0){
t=10;
}
else if(t<=10 && t>5){
setImage(new GreenfootImage("Walkingright12.png"));
}
else{
setImage(new GreenfootImage("Walkingright22.png"));
}
t=t-1;
pos=1;
}
if (Greenfoot.isKeyDown("left")){
u=u-2;
if (t==0){
t=10;
}
else if(t<=10 && t>5){
setImage(new GreenfootImage("Walkingleft12.png"));
}
else{
setImage(new GreenfootImage("Walkingleft22.png"));
}
t=t-1;
pos=2;
}
if (Greenfoot.isKeyDown("up")){
v=v-15;
}
if (!Greenfoot.isKeyDown("right") && !Greenfoot.isKeyDown("left")){
if (u>0){
u=u-1;
}
if (u<0){
u=u+1;
}
}
}
else{
v=v+1;
if (Greenfoot.isKeyDown("left")){
u=u-3;
}
if (Greenfoot.isKeyDown("right")){
u=u+3;
}
}
if (u>5){
u=5;
}
if (u<-5){
u=-5;
}
if (getWorld().getObjectsAt(x+u+16,y+v,platform.class).size()==0){
setLocation(x+u,y+v);
}
else if (getWorld().getObjectsAt(x+u,y+v,platform.class).size()==0){
setLocation(x,y+v);
}
