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:

http://pastebin.com/nfapk339

screen.java

http://pastebin.com/z0bb34sn

ball.java

http://pastebin.com/ydvmtg6e

player.java

http://pastebin.com/rbu0hsd8

computer.java

http://pastebin.com/dra1swze

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

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -