Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class collision {
- public static boolean iscolliding(Point p,block b){
- return b.contains(p);
- }
- public class block extends Rectangle {
- private static final long serialVersionUID = 1L;
- public static int blocksize = 40;
- private int id;
- private Image i;
- public static Rectangle r = new Rectangle(Comp.mx, Comp.my, 1, 1);
- public static boolean c = false;
- public block(int x, int y, int id) {
- setBounds(x, y, blocksize, blocksize);
- this.id = id;
- }
- public void render(Graphics g) {
- g.setColor(Color.green);
- if (id == 0) {
- ImageIcon i62 = new ImageIcon("res/tiles/air.png");
- i = i62.getImage();
- g.drawImage(i, x - play.camx, y - play.camy, null);
- }
- if (id == 1) {
- ImageIcon i62 = new ImageIcon("res/tiles/dirt.png");
- i = i62.getImage();
- g.drawImage(i, x - play.camx, y - play.camy, null);
- }
- if (id == 2) {
- ImageIcon i62 = new ImageIcon("res/tiles/roots.png");
- i = i62.getImage();
- g.drawImage(i, x - play.camx, y - play.camy, null);
- }
- if (id == 3) {
- ImageIcon i62 = new ImageIcon("res/tiles/hellgrasses/hellsoil.png");
- i = i62.getImage();
- g.drawImage(i, x - play.camx, y - play.camy, null);
- }
- }
- public void setID(int id) {
- this.id = id;
- }
- public int getID() {
- return id;
- }
- public double x,y;
- public boolean dead;
- public Rectangle r = new Rectangle((int)x, (int)y,20,20);
- public boolean canmove;
- public blob (int x, int y){
- this.x = x;
- this.y = y;
- }
- public void tick(){
- r = new Rectangle((int)x- play.camx, (int)y-play.camy,20,20);
- if(!play.isPaused){
- if(x > play.p.x+ play.camx){
- x-=.2;
- }
- if(x < play.p.x+ play.camx){
- x+=.2;
- }
- if(y > play.p.y+ play.camy){
- y-=.2;
- }
- if(y < play.p.y+ play.camy){
- y+=.2;
- }
- if(r.intersects(play.p.r)){
- play.p.health-=1;
- }
- }
- if(dead){
- if(new Random().nextInt(100) >= 95){
- play.hp.add(new healthPack((int)x,(int)y));
- }
- }
- }
- public void render(Graphics g){
- g.setColor(Color.green);
- g.fillRect((int)x - play.camx, (int)y -play.camy, 20, 20);
- g.setColor(Color.red);
- g.drawRect((int)r.x , (int)r.y, 20, 20);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement