First commit

This commit is contained in:
Urban Modig
2025-06-24 20:37:52 +02:00
parent 2490b976ad
commit b3750271c0
55 changed files with 833 additions and 0 deletions

View File

@ -0,0 +1,26 @@
package se.urmo.my2dgame.object;
import se.urmo.my2dgame.main.Screen;
import java.awt.*;
import java.awt.image.BufferedImage;
public class SuperObject {
public String name;
public BufferedImage image;
public boolean collision = false;
public int worldX;
public int worldY;
public void draw(Graphics2D g2d, Screen screen) {
// Only drawImage for tiles within camera
if (worldX + screen.TILE_SIZE > screen.player.worldX - screen.player.SCREEN_X &&
worldX - screen.TILE_SIZE < screen.player.worldX + screen.player.SCREEN_X &&
worldY + screen.TILE_SIZE > screen.player.worldY - screen.player.SCREEN_Y &&
worldY - screen.TILE_SIZE < screen.player.worldY + screen.player.SCREEN_Y) {
int screenX = worldX - screen.player.worldX + screen.player.SCREEN_X;
int screenY = worldY - screen.player.worldY + screen.player.SCREEN_Y;
g2d.drawImage(image, screenX, screenY, screen.TILE_SIZE, screen.TILE_SIZE, null);
}
}
}