Updated the project configuration to use Java 21 and run the game from the correct directory, resolving previous Java version conflicts and ensuring proper execution. Replit-Commit-Author: Agent Replit-Commit-Session-Id: f6819c21-e85d-45ac-acde-604db2cfa4fe Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: ed832e25-fc86-4753-8cfc-80cfabc64a02 Replit-Helium-Checkpoint-Created: true
31 lines
638 B
Java
31 lines
638 B
Java
import java.awt.Graphics;
|
|
import java.awt.Rectangle;
|
|
import javax.swing.ImageIcon;
|
|
|
|
public class Collidable extends Sprite {
|
|
int x, y, width, height;
|
|
Rectangle rect;
|
|
|
|
public Collidable(int x1, int y1, int w, int h, ImageIcon icon) {
|
|
super(icon);
|
|
x = x1;
|
|
y = y1;
|
|
width = w;
|
|
height = h;
|
|
rect = new Rectangle(x1, y1, w, h);
|
|
}
|
|
|
|
public void draw(Graphics g) {
|
|
sprite = icon.getImage();
|
|
g.drawImage(sprite, x, y, width, height, null);
|
|
}
|
|
|
|
public boolean collidesWith(Collidable other) {
|
|
return this.rect.intersects(other.rect);
|
|
}
|
|
|
|
public void onCollide(Collidable other) {
|
|
return;
|
|
}
|
|
}
|