Adding tone to player for Cube Inviders

Hi, I’m trying to add a tone for the player every time it moves but I don’t know where to put this code line

(tone, piezo, 523, playerTime);

Any help would be appreciated and here is my code so far.

#include "SPI.h"
#include "Cube.h"

Cube cube;

#include "Wire.h"
#include "WiiChuck.h"

WiiChuck wiichuck = WiiChuck();

unsigned int  joystickReadInterval  = 150;
unsigned long lastJoystickUpdate    = 0;
unsigned long lastEnemyMovement     = 0;
unsigned int  enemyMovementInterval = 600;

int playerX = 1;
int playerY = 0;
int playerZ = 1;

int enemyX;
int enemyY;
int enemyZ;

int piezo = A4;
int notes[] = 
{
 261, 293, 329, 349, 392, 440, 493, 523, 587, 659, 698, 783, 880};

int startTime = 10;
int playerTime = 50;
int enemyTime = 80;
int boomTime = 100;
int shootTime = 30;
int finishTime = 100;


byte lastButtonZState = 0;

void setup(void) {

 cube.begin(0, 115200);
 wiichuck.begin();
 wiichuck.update();
 enemyX = random(0, 4);
 enemyZ = random(0, 4);
 enemyY = 3;
 pinMode(A4, OUTPUT);
}

void loop(void) {
 delay(startTime);
 wiichuck.update();
 cube.all(BLACK);
 checkTrigger();
 updatePlayerPosition();
 updateEnemyPosition();
 cube.set(playerX, playerY, playerZ, BLUE);
 cube.set(enemyX, enemyY, enemyZ, GREEN);
}

void updatePlayerPosition()
{
 if((millis() - lastJoystickUpdate) > joystickReadInterval)
 {    
   int joyX;
   int joyY;

   joyX = wiichuck.readJoyX();
   joyY = wiichuck.readJoyY();

   if(joyX > 50)
     playerX++;

   if(joyX < -50)
     playerX--;

   if(joyY > 50)
     playerZ++;

   if(joyY < -50)
     playerZ--;

   if(playerX > 3)
     playerX = 0;

   if(playerX < 0)
     playerX = 3;

   if(playerZ > 3)
     playerZ = 0;

   if(playerZ < 0)
     playerZ = 3;

   lastJoystickUpdate = millis();
 }
}

void updateEnemyPosition()
{
 if((millis() - lastEnemyMovement) > enemyMovementInterval)
 {
   enemyY--;

   if(enemyY < 0)
   {
     enemyX = random(0, 4);
     enemyZ = random(0, 4);
     enemyY = 3;
   }

   lastEnemyMovement = millis();
   tone(piezo, 261, enemyTime);
 }
}

void checkTrigger()
{
 if((wiichuck.buttonZ) && (lastButtonZState == 0))
 {
   shoot();
 }
 if(wiichuck.buttonZ)
 {
   lastButtonZState = 1;
 } 
 else {
   lastButtonZState = 0;
 } 
}

void shoot()
{
 cube.set(playerX, 1, playerZ, YELLOW);
 tone(piezo, 698, shootTime);
 delay(shootTime);
 cube.set(playerX, 2, playerZ, ORANGE);
 tone(piezo, 783, shootTime);
 delay(shootTime);
 cube.set(playerX, 3, playerZ, RED);
 tone(piezo, 880, shootTime);
 delay(shootTime);

 if((enemyX == playerX) && (enemyZ == playerZ))
   enemyY = -1;

 delay(finishTime);

 if((enemyX == playerX) && (enemyZ == playerZ))
 {
   cube.all(YELLOW);
   tone(piezo, 392, boomTime);
   delay(boomTime);
   cube.all(ORANGE);
   tone(piezo, 440, boomTime);
   delay(boomTime);
   cube.all(RED);
   tone(piezo, 493, boomTime);
   delay(boomTime);
   cube.all(BLACK);
 }
}

I don't know where to put this code line

Put it in the garbage can. It is useless. Try writing a statement that actually calls the tone() function.

I'm trying to add a tone for the player every time it moves

"it" is a pronoun with no referent. Make your statement using nothing but nouns, verbs, adjectives, and adverbs - NO pronouns.

Ok thanks but I'm new to this can you pleas give an example of calling the tone() function.

ShaunCarMan: Ok thanks but I'm new to this can you pleas give an example of calling the tone() function.

No, but the reference page can: https://www.arduino.cc/en/Reference/Tone

Thanks that is a good link, very helpful.