# So I need some help lol EDIT: Answered!

**URL:** https://discourse.processing.org/t/so-i-need-some-help-lol-edit-answered/7361
**Category:** Coding Questions
**Created:** [January 9, 2019, 5:07pm UTC](https://discourse.processing.org/t/so-i-need-some-help-lol-edit-answered/7361 "2019-01-09T17:07:19Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Typhoon](https://avatars.discourse-cdn.com/v4/letter/t/ed8c4c/32.png) [@Typhoon](https://discourse.processing.org/u/Typhoon)
#### Post date: [January 9, 2019, 5:07pm UTC](https://discourse.processing.org/t/so-i-need-some-help-lol-edit-answered/7361/1 "2019-01-09T17:07:20Z")

</div>

Hey,  
So Im trying to make my animation only run through once, it is repeating. Im trying to make it only go through once and be done. (Im making a castlevaniaesk game) (Its also for my grade 12 final project)

class Alucard {  
float x = width/2;  
float y = height/2;  
float xspeed = 0;  
float yspeed = 0;  
PImage[] alwalk = new PImage[16];  
int currentwa = 0;  
PImage alidle = new PImage();  
PImage[] alatt = new PImage[17];  
int currentat = 0;

Alucard() {  
walking();  
//jumping();  
//running();  
attack();  
idle();  
}

void idle() {  
if (action == 0) {  
alidle = loadImage(“idle.png”);  
image(alidle, x, y);  
}  
}

void walking() {  
alwalk[0] = loadImage(“walking15.png”);  
alwalk[1] = loadImage(“walking16.png”);  
alwalk[2] = loadImage(“walking17.png”);  
alwalk[3] = loadImage(“walking18.png”);  
alwalk[4] = loadImage(“walking19.png”);  
alwalk[5] = loadImage(“walking20.png”);  
alwalk[6] = loadImage(“walking21.png”);  
alwalk[7] = loadImage(“walking22.png”);  
alwalk[8] = loadImage(“walking23.png”);  
alwalk[9] = loadImage(“walking24.png”);  
alwalk[10] = loadImage(“walking25.png”);  
alwalk[11] = loadImage(“walking26.png”);  
alwalk[12] = loadImage(“walking27.png”);  
alwalk[13] = loadImage(“walking28.png”);  
alwalk[14] = loadImage(“walking29.png”);  
alwalk[15] = loadImage(“walking30.png”);

if (key == ‘d’) {  
action = 2;  
if (action == 2) {  
image(alwalk[currentwa], x, y);  
currentwa++;  
if (currentwa \> 15)currentwa = 0;  
}  
}  
}

void attack() {  
alatt[0] = loadImage(“attack0.png”);  
alatt[1] = loadImage(“attack1.png”);  
alatt[2] = loadImage(“attack2.png”);  
alatt[3] = loadImage(“attack3.png”);  
alatt[4] = loadImage(“attack4.png”);  
alatt[5] = loadImage(“attack5.png”);  
alatt[6] = loadImage(“attack6.png”);  
alatt[7] = loadImage(“attack7.png”);  
alatt[8] = loadImage(“attack8.png”);  
alatt[9] = loadImage(“attack9.png”);  
alatt[10] = loadImage(“attack10.png”);  
alatt[11] = loadImage(“attack11.png”);  
alatt[12] = loadImage(“attack12.png”);  
alatt[13] = loadImage(“attack13.png”);  
alatt[14] = loadImage(“attack14.png”);  
alatt[15] = loadImage(“attack15.png”);  
alatt[16] = loadImage(“attack16.png”);

if (key == ‘z’) {  
action = 3;  
if (action == 3) {  
image(alatt[currentat], x, y);  
currentat++;  
if (currentat == 16) {  
action = 0;  
background(255);  
}  
}  
println(action);  
}  
}  
}

---

<div class="post-metadata">

### Author: ![Sky](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/sky/32/3013_2.png) [@Sky](https://discourse.processing.org/u/Sky)
#### Post date: [January 9, 2019, 5:14pm UTC](https://discourse.processing.org/t/so-i-need-some-help-lol-edit-answered/7361/2 "2019-01-09T17:14:37Z")

</div>

1 ) I get error: action doesnt exist  
2 ) We dont have your .png files, so we cant run your code

---

<div class="post-metadata">

### Author: ![BennyHacker](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/bennyhacker/32/2969_2.png) [@BennyHacker](https://discourse.processing.org/u/BennyHacker)
#### Post date: [January 9, 2019, 5:16pm UTC](https://discourse.processing.org/t/so-i-need-some-help-lol-edit-answered/7361/3 "2019-01-09T17:16:04Z")

</div>

First and foremost I’d move all of your loadImage() calls to the Alucard constructor or setup() to avoid tons of lag

Also you should control the player behaviors with booleans, so you can set attack=false when the player is done looping through its attack animation. So far it seems like your player can only iterate through the attack animation frames while the key is pressed, when it should loop through the whole animation after just one press…
