class Walker { float x; float y; float vx; float vy; float angle; boolean bulletShot = false; float speed; float health = 100; PImage img; public Walker(float x_, float y_, float speed_) { x = x_; y = y_; speed = speed_; img = loadImage("debug-hero.gif"); } void update(int weaponType) { detectKeys(); if(keyUp) { y -= speed; } if(keyDown) { y += speed; } if(keyLeft) { x -= speed; } if(keyRight) { x += speed; } angle = atan2(mouseY - y, mouseX - x); if (mousePressed && (mouseButton == LEFT)) { if (bulletShot == false || weaponType < 3) //fargun has press trigger not hold { bullets[bulletsCount] = new BasicBullet(new Vector2D(x, y), angle, weaponType); bulletsCount ++; bulletShot = true; } } else { bulletShot = false; } collideWithPlantBullets(); if (health < 0) health = 100; if (x > 500) x = 0; if (y > 400) y = 0; if (x < 0) x = 500; if (y < 0) y = 400; } void draw() { pushMatrix(); translate(x, y); rotate(angle); noFill(); /*stroke(color(240, 230, 150)); rect(-5, -5, 10, 10); rect(-9, -4, 3, 3); rect(6, -4, 3, 3);*/ smooth(); image(img, -6, -10); noSmooth(); popMatrix(); fill(40); rect(10, 380, 100, 10); fill(0, 230, 0); rect(10, 380, health, 10); } void collideWithPlantBullets() { //check for collisions with bullets and react on it for (int ib=0; ib