java - Collisions in breakout game -


so i'm creating breakout game , everything's going well, except collisions bricks. don't know how go detecting if ball hits brick left or right. i'm trying create if statement reads "if ball hits brick left or right, xspeed multiplied -1, else if ball hits brick top or bottom, y multiplied -1." easy do, detecting brick hit has me stumped. i'm using javafx. i'm sure it's easy, i'd figure out how should start.

make collision box around brick , ball , compare position values, this:

        rectangle brickcollision = new rectangle(x, y, w, h);         rectangle playercollision = new rectangle(x, y, w, h);          //example (collision 1 side)         if(playercollision .x + playercollision.w > brickcollision.x && playercollision.x < brickcollision.x + brickcollision.w){            system.out.println("collision");         } 

Comments

Popular posts from this blog

java - Spring Data JPA: Why findOne(id) executing delete query internally? -

python - Mongodb How to add addtional information when aggregating? -

java - Incorrect order of records in M-M relationship in hibernate -