First commit
This commit is contained in:
26
src/main/java/se/urmo/my2dgame/object/SuperObject.java
Normal file
26
src/main/java/se/urmo/my2dgame/object/SuperObject.java
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user