# Badly formed character constant

**URL:** <https://discourse.processing.org/t/badly-formed-character-constant/4832>\
**Category:** Coding Questions\
**Created:** [October 24, 2018, 7:12pm UTC](https://discourse.processing.org/t/badly-formed-character-constant/4832 "2018-10-24T19:12:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![somedude](https://avatars.discourse-cdn.com/v4/letter/s/ecd19e/32.png) [@somedude](https://discourse.processing.org/u/somedude)\
**Post date:** [October 24, 2018, 7:12pm UTC](https://discourse.processing.org/t/badly-formed-character-constant/4832/1 "2018-10-24T19:12:27Z")

</div>

im programming a character that moves on a background with the arrow keys and im having an issue  
i’ll leave the code on the description

```auto
PImage bg, personagem;
int px, py;
boolean cima, baixo, esq, dir;

void setup() {
  size(988, 795);
  bg = loadImage("tela_velho.jpg");
  personagem = loadImage("jogador.png"); 

  px = 500;
  py= 500;

  cima = baixo = dir = esq = false;
}

void draw() {
  background(bg);
  movejogador();
}

void movejogador() {
  if (cima == true) {
    py -= 3;
  } else {
    if (baixo == true) {
      py += 3;
    }
  }
  if (esq == true) {
    px -= 3;
  } else {
    if (dir == true) {
      px += 3;
    }
  }
  image(personagem, px, py);
}

void keyPressed() {
  if (key =='LEFT') {
    esq = true;
  } else {
    if (key == 'RIGHT') {
      dir = true;
    } else {
      if (key == 'DOWN') {
        baixo = true;
      } else {
        if (key == 'UP') {
          cima = true;
        }
      }
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![jb4x](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jb4x/32/789_2.png) [@jb4x](https://discourse.processing.org/u/jb4x)\
**Post date:** [October 24, 2018, 7:17pm UTC](https://discourse.processing.org/t/badly-formed-character-constant/4832/2 "2018-10-24T19:17:00Z")

</div>

Hi someDude,

First, can you please format your code properly. You can read how to do it in this thread: [Guidelines—Tips on Asking Questions](https://discourse.processing.org/t/guidelines-tips-on-asking-questions/2147)

Then you say having an issue but you don’t explain what is the issue… I’m afraid nobody can help you like this.

Lastly, be careful when posting your code, I see that you are using an image in your program. If you want us to be able to run your code, you also need to provide all the resources needed to make it work.

---

<div class="post-metadata">

**Author:** ![somedude](https://avatars.discourse-cdn.com/v4/letter/s/ecd19e/32.png) [@somedude](https://discourse.processing.org/u/somedude)\
**Post date:** [October 24, 2018, 7:28pm UTC](https://discourse.processing.org/t/badly-formed-character-constant/4832/3 "2018-10-24T19:28:48Z")

</div>

i managed to fix it by adding a keyReleased.

---

<div class="post-metadata">

**Author:** ![Lexyth](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/lexyth/32/7403_2.png) [@Lexyth](https://discourse.processing.org/u/Lexyth)\
**Post date:** [October 25, 2018, 10:03am UTC](https://discourse.processing.org/t/badly-formed-character-constant/4832/4 "2018-10-25T10:03:53Z")

</div>

Please don‘t Post questions multiple times.

> [@Help with movement on a background](https://discourse.processing.org/t/help-with-movement-on-a-background/4813):
>
> hello i am making a code for a character that moves on oa background but i keep having the following error "Badly formed character constant(expecting quote, got E) PImage bg, personagem; int px, py; boolean cima, baixo, esq, dir; void setup(){ size(988,795); bg = loadImage(“tela\_velho.jpg”); personagem = loadImage(“jogador.png”); px = 500; py= 500; cima = baixo = dir = esq = false; } void draw(){ background(bg); movejogador(); } void movejogador(){ if(cima == true){ py -= 3; …
