# Translate mistake in the console

**URL:** <https://discourse.processing.org/t/translate-mistake-in-the-console/17171>\
**Category:** Coding Questions\
**Created:** [January 18, 2020, 11:28pm UTC](https://discourse.processing.org/t/translate-mistake-in-the-console/17171 "2020-01-18T23:28:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alrox](https://avatars.discourse-cdn.com/v4/letter/a/bb73d2/32.png) [@Alrox](https://discourse.processing.org/u/Alrox)\
**Post date:** [January 18, 2020, 11:28pm UTC](https://discourse.processing.org/t/translate-mistake-in-the-console/17171/1 "2020-01-18T23:28:13Z")

</div>

Dear friends, I’m working on a code for my college and I’ve made a game with processing. Unfortunately there is a mistake in the console: “translate(), or this particular variation of it, is not available with this renderer.” I’m wondering about it, because I haven’t even used the translate() function. Anyway, the game I’ve made works without any issues, but I’m wondering what can be the reason for this line in the console. I commented the code lines in german, I hope it doesn’t disturb.  
Here is the code except the variables:

> **Code**
>
> ```auto
> void setup()
> {
> loaded = false;
> frameRate(60); // Anzahl an Frames (processing.org default Wert = 60), um die Geschwindigkeit der Bewegung von Objekten zu aendern.
> size(600,600);
> rectMode(RADIUS); //Schaltflaechen mit Beschriftung werden nach dem Radius gesetzt
>   
> counter = 0;
> spawnTime = 30; //Alle 30 Frames wird ein neuer Feind erzeugt
>   
> maxVelocity = 5; //Max Geschwindigkeit abhaengig vom Level
>   
> paused = false;
> menu = true;
> playMusic = true;
>   
> enemiesx = new ArrayList<Integer>(); //Generieren neuer Array Liste mit Variablen vom Typ Interger fuer X-Koordinaten der Feinde
> enemiesy = new ArrayList<Integer>(); // --...-- fuer Y-Koordinaten
>   
> v_enemiesx = new ArrayList<Integer>(); //Geschwindigkeit X
> v_enemiesy = new ArrayList<Integer>(); //Geschwindigkeit Y
>   
> //Laden von Bildern bzw. der Sound Datei
> player = loadImage("player.png");
> enemy = loadImage("mine.png");
>   
> file = new SoundFile(this, "music.mp3"); //Neue Sound Datei wird erstellt bzw. geladen
> file.loop();
> }
> 
> void draw()
> {
> background(109, 104, 170);
> textAlign(CENTER);
> textSize(20);
> //Menue Funktion
> if(menu){
> textSize(30);
> fill(254,185,95);
> if(titleText == "Game Over!"){
> fill(255,30,30);
> }
> text(titleText, 300, 100);
> textSize(20);
> fill(254,185,95);
> if(credits){ //Zeige credits an
> text("Made by: SK", 300,450);
> }else{
> text("Dodge the enemies with your mouse!\nPress p to pause", 300, 450);
> }
> drawUI(m_text, m_buttons); //Zeige Menue mit Schaltflaechen
> }
> else if(paused){
> drawUI(p_text, p_buttons); //Zeige den Pause Bildschirm
> }else{
> fill(254,185,95);
> text("Press P for Pause", 30, 20);
> counter+=2; //Addiert einen Wert zur Variablen "Counter", counter=counter+2
> //Erzeugen von Feinden
> if(counter > spawnTime){
> score += maxVelocity;
> counter = 0; 
> //Randomisieren der Plazierung von Feinden (Koordinaten)
> int posx = (int)random(100, 500); //Float--> Interger
> int posy = (int)random(100, 500);
>       
> while(abs(posx - mouseX) < 70 && abs(posy - mouseY) < 70){ // Absoluter Wert der Position. Stellt sicher, dass die Feinde nicht innerhalb von 70px rund um den Spieler erzeugt werden
> posx += -(posx - 100) + random(50, 80);
> posy += -(posy - 100) + random(50, 80);
> 
> }
>       
> enemiesx.add(posx); //Hinzufuegen von Werten (X) in die Array Liste
> enemiesy.add(posy);
>       
> //Unterschiedliche Geschwindigkeit der Feinde wird hiermit generiert
> v_enemiesx.add((int)random(-maxVelocity, maxVelocity)); //X Werte in die Array Liste
> v_enemiesy.add((int)random(-maxVelocity, maxVelocity)); //Y Werte in die Array Liste
> }
> //Zeichne Spieler
> image(player,mouseX, mouseY, playerSize+15, playerSize+15);  
>     
> //Verarbeitung der Bewegung von Feinden
> for(int i = 0; i < enemiesx.size(); i++){
> //Feinde bewegen sich nach der gegebenen Geschwindigkeit
> enemiesx.set(i, v_enemiesx.get(i) + enemiesx.get(i));
> enemiesy.set(i, v_enemiesy.get(i) + enemiesy.get(i));
>       
> //Sicherstellen, dass dies innerhalb der Groesse des Fensters geschieht, falls nicht - loeschen.
> if(enemiesx.get(i) > 600 || enemiesx.get(i) < 0 || enemiesy.get(i) > 600 || enemiesy.get(i) < 0){
> enemiesx.remove(i);
> enemiesy.remove(i);
> v_enemiesx.remove(i);
> v_enemiesy.remove(i);
>         
> }
>        
> //Zeichne Feinde (Position + Groesse)
> image(enemy, enemiesx.get(i), enemiesy.get(i), enemySize+15, enemySize+15);
>       
> //Pruefe auf Kollisionen (Spieler||Feind)
> if(enemiesx.get(i) - enemySize < mouseX + playerSize && enemiesx.get(i) + enemySize > mouseX- playerSize && enemiesy.get(i) + enemySize > mouseY - playerSize && enemiesy.get(i) - enemySize < mouseY + playerSize){
> menu = true;
> cursor(ARROW);
> titleText = "Game Over!";
> }
> }
> }
> text("SCORE: " + score, 300, 550, 300);
> 
> loaded = true;
> }
> 
> void keyPressed(){ // P Taste wird gedrueckt
> if(key == 'p'){
> cursor(ARROW);
> paused = !paused;
> }
> }
> 
> // Loesche den Spielestand bzw. Neustarten
> void clearGame(){
> score = 0;
> enemiesx.clear();
> enemiesy.clear();
> v_enemiesx.clear();
> v_enemiesy.clear();
> menu = true;
> }
> 
> // Spiel starten
> void startGame(){
> clearGame();
> menu = false;
> paused = false;
> noCursor();
> }
> // Musik aus- bzw. einschalten
> void toggleMusic(){
> playMusic = !playMusic;
> if(playMusic){
> file.loop();
> }else{
> file.pause();
> }
> }
> 
> void mouseClicked(){
> if(menu && loaded){
> //0,1,2 - Level inkl. max. Geschwindigkeit, 3 - Credits zum Anzeigen, wenn angeklickt, 4 - Musik aus- einschalten
> switch(indexOfClickedButton(m_buttons)){
> case 0:
> maxVelocity = 3;
> startGame();
> break;
> case 1:
> maxVelocity = 5;
> startGame();
> break;
> case 2:
> maxVelocity = 7;
> startGame();
> break;
> case 3:
> credits = !credits;
> break;
> case 4:
> toggleMusic();
> }
> }else if(paused){
> //Welche Schaltflaeche ist angeklickt: 0 - Fortsetzen, 1 - Neustarten, 2 - Musik an- ausmachen
> switch(indexOfClickedButton(p_buttons)){
> case 0:
> paused = false;
> break;
> case 1:
> clearGame();
> paused = false;
> menu = false;
> noCursor();
> break;
> case 2:
> toggleMusic();
> break;
> }
> }
> }
> 
> //Mit der Mausposition wird geprueft, welche Schaltflaeche innerhalb vom definierten Array angeklickt ist. Dann wird der Index der Schaltflaeche zurueckgegeben.
> int indexOfClickedButton(int[] yposArray){
> for(int i = 0; i < yposArray.length; i++){
> 
> if(mouseX > uix - button_sx && mouseX < uix + button_sx && mouseY > yposArray[i] - button_sy && mouseY < yposArray[i] + button_sy){
> return i;
> }
> }
> return -1;
> }
> 
> void drawUI(String[] stringArray, int[] yposArray){
> //Zeichne Schaltflaeche "Fortsetzen"
> for(int i = 0; i < yposArray.length; i++){
> //Rechteckige Schaltflaeche 
> fill(254, 185, 95); //0,185,95
> rect(uix, yposArray[i], button_sx, button_sy);
> //Text
> fill(255);
> textSize(20);
> textAlign(CENTER);
> text(stringArray[i], uix, yposArray[i]);
> fill(254, 185, 95);
> }
> }
> 
> ```

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [January 19, 2020, 1:45am UTC](https://discourse.processing.org/t/translate-mistake-in-the-console/17171/2 "2020-01-19T01:45:03Z")

</div>

please format your code posting here at forum  
( topic editor )  
by pasting it into the

```auto
</> code button

```

of the editor header menu ( context name: Preformatted text )  
it looks like  
```  
type or paste code here  
```

also can use the ``` manually above and below your code.  
or select the already pasted “code” and use [ctrl][shift][c]

thank you.

* * *

also we recommend that the code from processing IDE ( PDE )  
is formatted there first, like with /Edit/Auto Format/ or [ctrl][t]

* * *

now we need you to REPAIR your above CODE POSTING,  
not make a new / better post.  
( just think about the hundred people opening your topic in the future )

* * *

also you need to post a full running code ( but possibly reduced to the question )  
and not use any files, or if using files provide them too.

what you think posting code without the variable declaration?

* * *

after posting the code i ask you to test copy paste back to PDE  
for verify.

---

<div class="post-metadata">

**Author:** ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)\
**Post date:** [January 19, 2020, 10:38am UTC](https://discourse.processing.org/t/translate-mistake-in-the-console/17171/3 "2020-01-19T10:38:50Z")

</div>

> [@Alrox](#):
>
> text("SCORE: " + score, 300, 550, 300);

This statement says draw the text at position  
x = 300  
y = 550  
z = 300  
Processing will probably attempt to translate in the Z direction which is not allowed with a 2D renderer.  
Check the reference for [text](https://processing.org/reference/text_.html)

There may be other examp[les where you have tried to use Processing functions with 3D coordinates, I have not looked at every line of your code

---

<div class="post-metadata">

**Author:** ![Alrox](https://avatars.discourse-cdn.com/v4/letter/a/bb73d2/32.png) [@Alrox](https://discourse.processing.org/u/Alrox)\
**Post date:** [January 19, 2020, 3:28pm UTC](https://discourse.processing.org/t/translate-mistake-in-the-console/17171/4 "2020-01-19T15:28:05Z")

</div>

That was exactly my problem! Thank you!! After deleting the Z coordinate, the console mistake disappeared 🙂
