java - Collision works after going to the other side -
i'm making simple pong game, , need make player paddle cannot go out of screen.
it works, if go edge, go , go same edge again, works first time not second. if go top edge, , bottom works fine. cannot figure out, appreciate ;)
game.java:
screen.java
ball.java
player.java
computer.java
what code stops player paddle going outside of screen. instead of posting code show stub you're asking well.
just had , saw check being done in keypress.
try putting check in player.update() method. update parse in height
public void update(int height) { if(y < 0) { y = 0; } else if( y > height ) { y = height } else { y = y + yvelocity; } }
Comments
Post a Comment