# Why my enemy doesn't work?

**URL:** <https://discourse.processing.org/t/why-my-enemy-doesnt-work/13494>\
**Category:** Coding Questions\
**Created:** [August 20, 2019, 11:06am UTC](https://discourse.processing.org/t/why-my-enemy-doesnt-work/13494 "2019-08-20T11:06:59Z")\
**Posts on this page:** 3\
**Page:** 2

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [September 21, 2019, 6:46pm UTC](https://discourse.processing.org/t/why-my-enemy-doesnt-work/13494/21 "2019-09-21T18:46:09Z")

</div>

> [@carolina\_moreira](#):
>
> but my code is JAVA and not P5js.

I haven’t posted anything about p5js on those 3 links! They’re about Pjs: 😵  
[ProcessingJS.org/reference/](http://ProcessingJS.org/reference/)

---

<div class="post-metadata">

**Author:** ![carolina\_moreira](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/carolina_moreira/32/6196_2.png) [@carolina\_moreira](https://discourse.processing.org/u/carolina_moreira)\
**Post date:** [September 21, 2019, 7:43pm UTC](https://discourse.processing.org/t/why-my-enemy-doesnt-work/13494/22 "2019-09-21T19:43:33Z")

</div>

Sorry @GoToLoop i’m still new to processing 😐

I tried to change the code to this form

> / \* @pjs preload = “myimage.jpg”; \* /
> 
> void setup ()  
> {  
> size (200,200);  
> noLoop ();  
> }
> 
> void draw ()  
> {  
> background (255);  
> PImage im = loadImage (“myimage.jpg”);  
> image (im, 50.50, 100100);  
> }

but I don’t know if I did well

it’s no longer the same error

[here it is](https://www.openprocessing.org/sketch/754572)

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [September 21, 2019, 8:11pm UTC](https://discourse.processing.org/t/why-my-enemy-doesnt-work/13494/23 "2019-09-21T20:11:01Z")

</div>

> [@carolina\_moreira](#):
>
> ```auto
> void draw() {
> background(255);
> PImage im = loadImage(“myimage.jpg”);
> image(im, 50.50, 100100);
> }
> 
> ```

Please, assets are supposed to be loaded before **draw()** starts!  
Loading stuff @ 60 FPS is calamitous!

> [@carolina\_moreira](#):
>
> It’s no longer the same error.

I’ve got this 1: “Uncaught ReferenceError: amarelo is not defined”

Please, always state which error you’ve got and, if possible, where it has occurred!

This is the statement which will throw that error later:  
`PImage im = loadImage("	amarelo1.png ");`

There’s no way this String w/ lotsa spaces and tabs can possibly work: `"	amarelo1.png "`

Also, is everything called _im_ now?!

It doesn’t seem you can figure it out just w/ my lousy clues.

This is what I did to your previous sketch (before your attempt changes now) to make it work online:

Move this [directive](http://processingjs.org/reference/pjs%20directive/) comment to the top of your sketch:  
`/* @pjs preload= "Background.png,caixa3.png,amarelo1.png,plastico2.png"; */`

Change `hist.add(pos.copy());` to `hist.add(pos.get());`

[Previous page](https://discourse.processing.org/t/why-my-enemy-doesnt-work/13494.md?page=1)
