Guest User

Enemy.java

a guest
Oct 2nd, 2019
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. package com.game.src.main;
  2.  
  3. import java.awt.Graphics;
  4. import java.awt.image.BufferedImage;
  5. import java.io.IOException;
  6.  
  7.  
  8. import javax.imageio.ImageIO;
  9.  
  10. class Enemy {
  11.  
  12. private double x, y;
  13. static final int BOUND = 100;
  14.  
  15.  
  16. private int speedX , speedY;
  17.  
  18. private BufferedImage img;
  19.  
  20. private com.game.src.main.Game game;
  21.  
  22.  
  23. Enemy(double x, double y, com.game.src.main.Game game) {
  24. this.x = x;
  25. this.y = y;
  26. this.game = game;
  27.  
  28. try {
  29. img = ImageIO.read(getClass().getResource("/boss.png"));
  30. } catch (IOException e) {
  31. // TODO Auto-generated catch block
  32. e.printStackTrace();
  33. }
  34. }
  35.  
  36. void tick() {
  37.  
  38. }
  39.  
  40. void render(Graphics g) {
  41. g.drawImage(img, (int)x, (int)y, null);
  42. // System.out.println("X = " + x + " Y = " + y);
  43. }
  44.  
  45. double getX() {
  46. return x;
  47. }
  48.  
  49. void setX(double x) {
  50. this.x = x;
  51. }
  52.  
  53. double getY() {
  54. return y;
  55. }
  56.  
  57. void setY(double y) {
  58. this.y = y;
  59. }
  60.  
  61.  
  62. }
Add Comment
Please, Sign In to add comment