Skip to content

Commit

Permalink
update Entity constructor, convert unit coordinate to real coordinate…
Browse files Browse the repository at this point in the history
… in Canvas
  • Loading branch information
doanthihoaithu committed Nov 5, 2020
1 parent fdf3350 commit a16346f
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/uet/oop/bomberman/entities/Entity.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,23 @@
import uet.oop.bomberman.graphics.Sprite;

public abstract class Entity {
//Tọa độ X tính từ góc trái trên trong Canvas
protected int x;

//Tọa độ Y tính từ góc trái trên trong Canvas
protected int y;

protected Image img;

public Entity( int x, int y, Image img) {
this.x = x;
this.y = y;
//Khởi tạo đối tượng, chuyển từ tọa độ đơn vị sang tọa độ trong canvas
public Entity( int xUnit, int yUnit, Image img) {
this.x = xUnit * Sprite.SCALED_SIZE;
this.y = yUnit * Sprite.SCALED_SIZE;
this.img = img;
}

public void render(GraphicsContext gc) {
// SnapshotParameters params = new SnapshotParameters();
// params.setFill(Color.TRANSPARENT);
//
// ImageView iv = new ImageView(img);
// Image base = iv.snapshot(params, null);

gc.drawImage(img, x * Sprite.SCALED_SIZE, y * Sprite.SCALED_SIZE);
gc.drawImage(img, x, y);
}
public abstract void update();
}

0 comments on commit a16346f

Please sign in to comment.