class Walker { float x; float y; float vx; float vy; float angle; boolean bulletShot = false; float speed; float health = 100; PImage img; public Walker() { img = loadImage("debug-hero.gif"); } void update() { if (keyPressed) { if(key == 'w') { y -= speed; } if(key == 's') { y += speed; } if(key == 'a') { x -= speed; } if(key == 'd') { x += speed; } } angle = atan2(mouseY - y, mouseX - x); if (mousePressed && (mouseButton == LEFT)) { if (true)//bulletShot) { bullets[bulletsCount] = new BasicBullet(); bullets[bulletsCount].x = x; bullets[bulletsCount].y = y; bullets[bulletsCount].angle = angle + random(-0.2, 0.2); bulletsCount ++; bulletShot = true; } } else { bulletShot = false; } 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); } }