Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Game;
- import Core.GameResource;
- import java.awt.*;
- public class PhysicsEngine implements GameResource{
- Box b1, b2;
- public PhysicsEngine(Box b1, Box b2) {
- this.b1 = b1;
- this.b2 = b2;
- }
- @Override
- public void update(float tpf, Graphics2D g) {
- g.drawString(checkCollision() ? "Collision Detected" : "No Collision",0, 10);
- }
- boolean checkCollision(){
- if(!(b1.locX+b1.width >= b2.locX && b1.locX <= b2.locX+b2.width))
- return false;
- if(!(b1.locY+b1.height >= b2.locY && b1.locY < b2.locY+b2.height))
- return false;
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement