Hey,
My English is not so good - I come from Germany - sorry =))
I have a little problem. Maybe someone could help me:
I have code a program. It´s a game and it´s a sort of a mario-game. But the "Mario" is a snake and it has to find bananas in the jugle =)). The snake can jump onto blocks to achieve the bananas. When the snake don´t "land" on a platform it will fall down. -> it will land on the bottom of the jungle.
Now there´s my problem:
I have code the "falling snake" with a acceleration- so it looks a little bit more realistical. So , when the snake starts to fall , it will accelerats with one pixel. In the first stap it fall 1 pixel , then 2 pixel, then 3 pixel ...
I use this code for it:
public void onGroundEins()
{
Block block =(Block) getOneIntersectingObject(Block.class);
if (block !=null) {
acceleration = 0;
vSpeed = 0;
dx=block.dx;
dy=block.dy;
if (Greenfoot.isKeyDown("up"))
{
jump();
}
}
else acceleration = 1;
}
So the snake stops falling when it fall onto the ground. But mostly the snake falls a little bit to long an it hides behind the bottom. I know the problem - but I don´t know who to discribe it in English. I can try it:
I think the problem is the acceleration , because when the snake knows that there is a block under it, it will stop to acceleration. But it could be that the value of the acceleration is (for example) 13, so the snake will move 13 pixel, because it will stop. Do anybody knows who I can make it correct? So the snake has to stop when it knows that there is a block under it ?
Thank you =))