java - collision detection not working? -
im quite new java. trying make can control ball arrow keys , if collide ball, print line in console saying "you lost" or somthing. i have done moving, struggling bit how can 2 balls collide. far have tried (i think put rectangle around ball, don't know really!): public void collision() { rectangle rectp = new rectangle(player.x, player.y, player.width, player.height); rectangle recte = new rectangle(enemy.ex, enemy.ey, enemy.width, enemy.height); if(rectp.intersects(recte)) { system.out.println("game over"); } } could me out , explain have done wrong. ps. please don't give me code, want try , learn!!!. thanks. public void actionperformed(actionevent e) { repaint(); x += velx; y += vely; } public void up() { vely = -1.5; velx = 0; } public void down() { vely = 1.5; velx = 0; } public void left() { vely = 0; velx = -1.5; } public void right() { vely = 0; velx = 1.5...