SlideShare a Scribd company logo
1 of 5
Download to read offline
What's wrong with my code?
I am coding a battleship game that uses a dpad using C on an arduino mega which is connected
to a screen. I noticed that something is missing from my code but I can't figure out what it is and
why battleship is not running. For context, we have two buttons: one for select and one for
deselect. I need that incorporated as well.
#include <TFT_eSPI.h>
// Define the TFT display object
TFT_eSPI tft = TFT_eSPI();
// Define the dpad pins
#define UP_PIN 2
#define DOWN_PIN 3
#define LEFT_PIN 4
#define RIGHT_PIN 5
#define CONFIRM_PIN 6
#define SELECT_PIN 7
#define DESELECT_PIN 8
// Define the grid size
const int GRID_SIZE = 10;
// Define the ship lengths
const int SHIP_LENGTHS[] = {1, 2, 3, 4};
// Define the player grids
int player1Grid[GRID_SIZE][GRID_SIZE];
int player2Grid[GRID_SIZE][GRID_SIZE];
// Define the current player and ship length
int currentPlayer = 1;
int currentShipLength = 1;
// Define the ship placement position
int shipRow = 0;
int shipCol = 0;
int shipDirection = 0; // 0 = horizontal, 1 = vertical
// Function to initialize the game
void initializeGame() {
// Clear the player grids
memset(player1Grid, 0, sizeof(player1Grid));
memset(player2Grid, 0, sizeof(player2Grid));
// Set the current player and ship length
currentPlayer = 1;
currentShipLength = 1;
// Set the initial ship placement position
shipRow = 0;
shipCol = 0;
shipDirection = 0;
// Draw the player grids
tft.fillScreen(TFT_BLACK);
tft.drawRect(0, 0, tft.width() / 2 - 1, tft.height() - 1, TFT_WHITE);
tft.drawRect(tft.width() / 2, 0, tft.width() / 2 - 1, tft.height() - 1, TFT_WHITE);
// Draw the current ship
tft.drawRect(tft.width() / 2 + shipCol * 20, shipRow * 20, currentShipLength * 20 - 1, 19,
TFT_WHITE);
}
// Function to update the ship placement position
void updateShipPosition(int direction) {
// Calculate the new ship position
int newRow = shipRow;
int newCol = shipCol;
if (direction == 0) { // up
newRow--;
} else if (direction == 1) { // down
newRow++;
} else if (direction == 2) { // left
newCol--;
} else if (direction == 3) { // right
newCol++;
}
// Check if the new position is valid
if (newRow >= 0 && newRow < GRID_SIZE && newCol >= 0 && newCol < GRID_SIZE -
currentShipLength + 1) {
// Erase the current ship
tft.drawRect(tft.width() / 2 + shipCol * 20, shipRow * 20, currentShipLength * 20 - 1, 19,
TFT_BLACK);
// Update the ship position
shipRow = newRow;
shipCol = newCol;
// Draw the current ship
tft.drawRect(tft.width() / 2 + shipCol * 20, shipRow * 20, currentShipLength * 20 - 1, 19,
TFT_WHITE);
}
}
// Function to update the ship placement direction
void updateShipDirection() {
// check if the "right" button is pressed
if (digitalRead(RIGHT_BUTTON_PIN) == LOW) {
// increment the ship direction
shipDirection++;
// wrap the direction around if it goes past 3
if (shipDirection > 3) {
shipDirection = 0;
}
// draw the ship in the new direction
drawShip(shipX, shipY, shipLength, shipDirection);
}
// check if the "left" button is pressed
else if (digitalRead(LEFT_BUTTON_PIN) == LOW) {
// decrement the ship direction
shipDirection--;
// wrap the direction around if it goes below 0
if (shipDirection < 0) {
shipDirection = 3;
}
// draw the ship in the new direction
drawShip(shipX, shipY, shipLength, shipDirection);
}
}

More Related Content

Similar to What's wrong with my code- I am coding a battleship game that uses a d (1).pdf

i have a code that runs, but it only lets the player to guess where .pdf
i have a code that runs, but it only lets the player to guess where .pdfi have a code that runs, but it only lets the player to guess where .pdf
i have a code that runs, but it only lets the player to guess where .pdf
poblettesedanoree498
 
The following code, is a one player battleship game in JAVA. Im tryi.pdf
The following code, is a one player battleship game in JAVA. Im tryi.pdfThe following code, is a one player battleship game in JAVA. Im tryi.pdf
The following code, is a one player battleship game in JAVA. Im tryi.pdf
fonecomp
 
How do I draw the Labview code for pneumatic cylinder(air pistion). .pdf
How do I draw the Labview code for pneumatic cylinder(air pistion). .pdfHow do I draw the Labview code for pneumatic cylinder(air pistion). .pdf
How do I draw the Labview code for pneumatic cylinder(air pistion). .pdf
footstatus
 
Runtime Code Generation and Data Management for Heterogeneous Computing in Java
Runtime Code Generation and Data Management for Heterogeneous Computing in JavaRuntime Code Generation and Data Management for Heterogeneous Computing in Java
Runtime Code Generation and Data Management for Heterogeneous Computing in Java
Juan Fumero
 
write the TODO part of the program.docx
write the TODO part of the program.docxwrite the TODO part of the program.docx
write the TODO part of the program.docx
annetnash8266
 
Combine the keypad and LCD codes in compliance to the following requ.pdf
Combine the keypad and LCD codes in compliance to the following requ.pdfCombine the keypad and LCD codes in compliance to the following requ.pdf
Combine the keypad and LCD codes in compliance to the following requ.pdf
forwardcom41
 
Embedded Systems Project 3rd Year
Embedded Systems Project 3rd YearEmbedded Systems Project 3rd Year
Embedded Systems Project 3rd Year
Andrew Kozik
 
Can you finish and write the int main for the code according to the in.pdf
Can you finish and write the int main for the code according to the in.pdfCan you finish and write the int main for the code according to the in.pdf
Can you finish and write the int main for the code according to the in.pdf
aksachdevahosymills
 
Mdp plus 2.1
Mdp plus 2.1Mdp plus 2.1
Mdp plus 2.1
boedax
 

Similar to What's wrong with my code- I am coding a battleship game that uses a d (1).pdf (20)

i have a code that runs, but it only lets the player to guess where .pdf
i have a code that runs, but it only lets the player to guess where .pdfi have a code that runs, but it only lets the player to guess where .pdf
i have a code that runs, but it only lets the player to guess where .pdf
 
Dam gate open close lpc prog
Dam gate open close lpc progDam gate open close lpc prog
Dam gate open close lpc prog
 
The following code, is a one player battleship game in JAVA. Im tryi.pdf
The following code, is a one player battleship game in JAVA. Im tryi.pdfThe following code, is a one player battleship game in JAVA. Im tryi.pdf
The following code, is a one player battleship game in JAVA. Im tryi.pdf
 
How do I draw the Labview code for pneumatic cylinder(air pistion). .pdf
How do I draw the Labview code for pneumatic cylinder(air pistion). .pdfHow do I draw the Labview code for pneumatic cylinder(air pistion). .pdf
How do I draw the Labview code for pneumatic cylinder(air pistion). .pdf
 
Cvim half precision floating point
Cvim half precision floating pointCvim half precision floating point
Cvim half precision floating point
 
Runtime Code Generation and Data Management for Heterogeneous Computing in Java
Runtime Code Generation and Data Management for Heterogeneous Computing in JavaRuntime Code Generation and Data Management for Heterogeneous Computing in Java
Runtime Code Generation and Data Management for Heterogeneous Computing in Java
 
Creating an Uber Clone - Part III.pdf
Creating an Uber Clone - Part III.pdfCreating an Uber Clone - Part III.pdf
Creating an Uber Clone - Part III.pdf
 
write the TODO part of the program.docx
write the TODO part of the program.docxwrite the TODO part of the program.docx
write the TODO part of the program.docx
 
Combine the keypad and LCD codes in compliance to the following requ.pdf
Combine the keypad and LCD codes in compliance to the following requ.pdfCombine the keypad and LCD codes in compliance to the following requ.pdf
Combine the keypad and LCD codes in compliance to the following requ.pdf
 
Embedded Systems Project 3rd Year
Embedded Systems Project 3rd YearEmbedded Systems Project 3rd Year
Embedded Systems Project 3rd Year
 
Box2D with SIMD in JavaScript
Box2D with SIMD in JavaScriptBox2D with SIMD in JavaScript
Box2D with SIMD in JavaScript
 
2011.02.18 marco parenzan - modelli di programmazione per le gpu
2011.02.18   marco parenzan - modelli di programmazione per le gpu2011.02.18   marco parenzan - modelli di programmazione per le gpu
2011.02.18 marco parenzan - modelli di programmazione per le gpu
 
Can you finish and write the int main for the code according to the in.pdf
Can you finish and write the int main for the code according to the in.pdfCan you finish and write the int main for the code according to the in.pdf
Can you finish and write the int main for the code according to the in.pdf
 
Xiicsmonth
XiicsmonthXiicsmonth
Xiicsmonth
 
Code
CodeCode
Code
 
Functions for Nano 5 Card
Functions for Nano 5 CardFunctions for Nano 5 Card
Functions for Nano 5 Card
 
The Ring programming language version 1.5 book - Part 2 of 31
The Ring programming language version 1.5 book - Part 2 of 31The Ring programming language version 1.5 book - Part 2 of 31
The Ring programming language version 1.5 book - Part 2 of 31
 
JVM code reading -- C2
JVM code reading -- C2JVM code reading -- C2
JVM code reading -- C2
 
Mdp plus 2.1
Mdp plus 2.1Mdp plus 2.1
Mdp plus 2.1
 
My bitmap
My bitmapMy bitmap
My bitmap
 

More from atexgarments

More from atexgarments (20)

When I input the number 3- my output is -Ready! 0 Go!----- what gives-.pdf
When I input the number 3- my output is -Ready! 0 Go!----- what gives-.pdfWhen I input the number 3- my output is -Ready! 0 Go!----- what gives-.pdf
When I input the number 3- my output is -Ready! 0 Go!----- what gives-.pdf
 
When is it appropriate to use a one-sample Z-test instead of a one-sam.pdf
When is it appropriate to use a one-sample Z-test instead of a one-sam.pdfWhen is it appropriate to use a one-sample Z-test instead of a one-sam.pdf
When is it appropriate to use a one-sample Z-test instead of a one-sam.pdf
 
When planning for the scope of a project- the following are created- P.pdf
When planning for the scope of a project- the following are created- P.pdfWhen planning for the scope of a project- the following are created- P.pdf
When planning for the scope of a project- the following are created- P.pdf
 
When do think it would be advantageous to have background images- Word.pdf
When do think it would be advantageous to have background images- Word.pdfWhen do think it would be advantageous to have background images- Word.pdf
When do think it would be advantageous to have background images- Word.pdf
 
When Griffin cultured the blood from the mice injected with R cells an.pdf
When Griffin cultured the blood from the mice injected with R cells an.pdfWhen Griffin cultured the blood from the mice injected with R cells an.pdf
When Griffin cultured the blood from the mice injected with R cells an.pdf
 
What's the best explanation of a level of significance- Select one- a-.pdf
What's the best explanation of a level of significance- Select one- a-.pdfWhat's the best explanation of a level of significance- Select one- a-.pdf
What's the best explanation of a level of significance- Select one- a-.pdf
 
When configuring an 802-1X-EAP solution- what must be configured on th.pdf
When configuring an 802-1X-EAP solution- what must be configured on th.pdfWhen configuring an 802-1X-EAP solution- what must be configured on th.pdf
When configuring an 802-1X-EAP solution- what must be configured on th.pdf
 
What would you predict if Morrison and Braciale tested their influenza.pdf
What would you predict if Morrison and Braciale tested their influenza.pdfWhat would you predict if Morrison and Braciale tested their influenza.pdf
What would you predict if Morrison and Braciale tested their influenza.pdf
 
What type of unconformity does C represent- nonconformity disconformit.pdf
What type of unconformity does C represent- nonconformity disconformit.pdfWhat type of unconformity does C represent- nonconformity disconformit.pdf
What type of unconformity does C represent- nonconformity disconformit.pdf
 
What would happen to the composition of the interstitial fluid if astr.pdf
What would happen to the composition of the interstitial fluid if astr.pdfWhat would happen to the composition of the interstitial fluid if astr.pdf
What would happen to the composition of the interstitial fluid if astr.pdf
 
What would happen if NAD+ was not generated for the citric acid cycle-.pdf
What would happen if NAD+ was not generated for the citric acid cycle-.pdfWhat would happen if NAD+ was not generated for the citric acid cycle-.pdf
What would happen if NAD+ was not generated for the citric acid cycle-.pdf
 
When constructing a pro forma Balance Sheet- is-are considered as Curr (1).pdf
When constructing a pro forma Balance Sheet- is-are considered as Curr (1).pdfWhen constructing a pro forma Balance Sheet- is-are considered as Curr (1).pdf
When constructing a pro forma Balance Sheet- is-are considered as Curr (1).pdf
 
What type of programming error is an attacker likely to attempt to exp.pdf
What type of programming error is an attacker likely to attempt to exp.pdfWhat type of programming error is an attacker likely to attempt to exp.pdf
What type of programming error is an attacker likely to attempt to exp.pdf
 
what was henry wirtz executed for- what was henry wirtz executed for-.pdf
what was henry wirtz executed for- what was henry wirtz executed for-.pdfwhat was henry wirtz executed for- what was henry wirtz executed for-.pdf
what was henry wirtz executed for- what was henry wirtz executed for-.pdf
 
what would be the standard deciation of Bank B- Ba Bi Cick the ioon to.pdf
what would be the standard deciation of Bank B- Ba Bi Cick the ioon to.pdfwhat would be the standard deciation of Bank B- Ba Bi Cick the ioon to.pdf
what would be the standard deciation of Bank B- Ba Bi Cick the ioon to.pdf
 
When cells release signal molecules (ligands) to send a message- and t (1).pdf
When cells release signal molecules (ligands) to send a message- and t (1).pdfWhen cells release signal molecules (ligands) to send a message- and t (1).pdf
When cells release signal molecules (ligands) to send a message- and t (1).pdf
 
What type of volcano is shown in the ahoto- Glick to view laresimase d.pdf
What type of volcano is shown in the ahoto- Glick to view laresimase d.pdfWhat type of volcano is shown in the ahoto- Glick to view laresimase d.pdf
What type of volcano is shown in the ahoto- Glick to view laresimase d.pdf
 
When award without discussions is not stated in the solicitation and t.pdf
When award without discussions is not stated in the solicitation and t.pdfWhen award without discussions is not stated in the solicitation and t.pdf
When award without discussions is not stated in the solicitation and t.pdf
 
Which Munsell color notation has the lowest chroma- 10YR 1-2 5YR 6-7 2.pdf
Which Munsell color notation has the lowest chroma- 10YR 1-2 5YR 6-7 2.pdfWhich Munsell color notation has the lowest chroma- 10YR 1-2 5YR 6-7 2.pdf
Which Munsell color notation has the lowest chroma- 10YR 1-2 5YR 6-7 2.pdf
 
What type of value is being created by JD-com's digital and online ini.pdf
What type of value is being created by JD-com's digital and online ini.pdfWhat type of value is being created by JD-com's digital and online ini.pdf
What type of value is being created by JD-com's digital and online ini.pdf
 

Recently uploaded

會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
中 央社
 
IATP How-to Foreign Travel May 2024.pdff
IATP How-to Foreign Travel May 2024.pdffIATP How-to Foreign Travel May 2024.pdff
IATP How-to Foreign Travel May 2024.pdff
17thcssbs2
 

Recently uploaded (20)

Behavioral-sciences-dr-mowadat rana (1).pdf
Behavioral-sciences-dr-mowadat rana (1).pdfBehavioral-sciences-dr-mowadat rana (1).pdf
Behavioral-sciences-dr-mowadat rana (1).pdf
 
2024_Student Session 2_ Set Plan Preparation.pptx
2024_Student Session 2_ Set Plan Preparation.pptx2024_Student Session 2_ Set Plan Preparation.pptx
2024_Student Session 2_ Set Plan Preparation.pptx
 
Morse OER Some Benefits and Challenges.pptx
Morse OER Some Benefits and Challenges.pptxMorse OER Some Benefits and Challenges.pptx
Morse OER Some Benefits and Challenges.pptx
 
Discover the Dark Web .pdf InfosecTrain
Discover the Dark Web .pdf  InfosecTrainDiscover the Dark Web .pdf  InfosecTrain
Discover the Dark Web .pdf InfosecTrain
 
factors influencing drug absorption-final-2.pptx
factors influencing drug absorption-final-2.pptxfactors influencing drug absorption-final-2.pptx
factors influencing drug absorption-final-2.pptx
 
How to Analyse Profit of a Sales Order in Odoo 17
How to Analyse Profit of a Sales Order in Odoo 17How to Analyse Profit of a Sales Order in Odoo 17
How to Analyse Profit of a Sales Order in Odoo 17
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
 
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
 
Post Exam Fun(da) Intra UEM General Quiz - Finals.pdf
Post Exam Fun(da) Intra UEM General Quiz - Finals.pdfPost Exam Fun(da) Intra UEM General Quiz - Finals.pdf
Post Exam Fun(da) Intra UEM General Quiz - Finals.pdf
 
....................Muslim-Law notes.pdf
....................Muslim-Law notes.pdf....................Muslim-Law notes.pdf
....................Muslim-Law notes.pdf
 
IATP How-to Foreign Travel May 2024.pdff
IATP How-to Foreign Travel May 2024.pdffIATP How-to Foreign Travel May 2024.pdff
IATP How-to Foreign Travel May 2024.pdff
 
Application of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matricesApplication of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matrices
 
Essential Safety precautions during monsoon season
Essential Safety precautions during monsoon seasonEssential Safety precautions during monsoon season
Essential Safety precautions during monsoon season
 
Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...
Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...
Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...
 
Operations Management - Book1.p - Dr. Abdulfatah A. Salem
Operations Management - Book1.p  - Dr. Abdulfatah A. SalemOperations Management - Book1.p  - Dr. Abdulfatah A. Salem
Operations Management - Book1.p - Dr. Abdulfatah A. Salem
 
An Overview of the Odoo 17 Discuss App.pptx
An Overview of the Odoo 17 Discuss App.pptxAn Overview of the Odoo 17 Discuss App.pptx
An Overview of the Odoo 17 Discuss App.pptx
 
Navigating the Misinformation Minefield: The Role of Higher Education in the ...
Navigating the Misinformation Minefield: The Role of Higher Education in the ...Navigating the Misinformation Minefield: The Role of Higher Education in the ...
Navigating the Misinformation Minefield: The Role of Higher Education in the ...
 
An overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismAn overview of the various scriptures in Hinduism
An overview of the various scriptures in Hinduism
 
Features of Video Calls in the Discuss Module in Odoo 17
Features of Video Calls in the Discuss Module in Odoo 17Features of Video Calls in the Discuss Module in Odoo 17
Features of Video Calls in the Discuss Module in Odoo 17
 
The Last Leaf, a short story by O. Henry
The Last Leaf, a short story by O. HenryThe Last Leaf, a short story by O. Henry
The Last Leaf, a short story by O. Henry
 

What's wrong with my code- I am coding a battleship game that uses a d (1).pdf

  • 1. What's wrong with my code? I am coding a battleship game that uses a dpad using C on an arduino mega which is connected to a screen. I noticed that something is missing from my code but I can't figure out what it is and why battleship is not running. For context, we have two buttons: one for select and one for deselect. I need that incorporated as well. #include <TFT_eSPI.h> // Define the TFT display object TFT_eSPI tft = TFT_eSPI(); // Define the dpad pins #define UP_PIN 2 #define DOWN_PIN 3 #define LEFT_PIN 4 #define RIGHT_PIN 5 #define CONFIRM_PIN 6 #define SELECT_PIN 7 #define DESELECT_PIN 8 // Define the grid size const int GRID_SIZE = 10; // Define the ship lengths const int SHIP_LENGTHS[] = {1, 2, 3, 4}; // Define the player grids int player1Grid[GRID_SIZE][GRID_SIZE]; int player2Grid[GRID_SIZE][GRID_SIZE]; // Define the current player and ship length int currentPlayer = 1;
  • 2. int currentShipLength = 1; // Define the ship placement position int shipRow = 0; int shipCol = 0; int shipDirection = 0; // 0 = horizontal, 1 = vertical // Function to initialize the game void initializeGame() { // Clear the player grids memset(player1Grid, 0, sizeof(player1Grid)); memset(player2Grid, 0, sizeof(player2Grid)); // Set the current player and ship length currentPlayer = 1; currentShipLength = 1; // Set the initial ship placement position shipRow = 0; shipCol = 0; shipDirection = 0; // Draw the player grids tft.fillScreen(TFT_BLACK); tft.drawRect(0, 0, tft.width() / 2 - 1, tft.height() - 1, TFT_WHITE); tft.drawRect(tft.width() / 2, 0, tft.width() / 2 - 1, tft.height() - 1, TFT_WHITE); // Draw the current ship tft.drawRect(tft.width() / 2 + shipCol * 20, shipRow * 20, currentShipLength * 20 - 1, 19, TFT_WHITE);
  • 3. } // Function to update the ship placement position void updateShipPosition(int direction) { // Calculate the new ship position int newRow = shipRow; int newCol = shipCol; if (direction == 0) { // up newRow--; } else if (direction == 1) { // down newRow++; } else if (direction == 2) { // left newCol--; } else if (direction == 3) { // right newCol++; } // Check if the new position is valid if (newRow >= 0 && newRow < GRID_SIZE && newCol >= 0 && newCol < GRID_SIZE - currentShipLength + 1) { // Erase the current ship tft.drawRect(tft.width() / 2 + shipCol * 20, shipRow * 20, currentShipLength * 20 - 1, 19, TFT_BLACK); // Update the ship position shipRow = newRow; shipCol = newCol;
  • 4. // Draw the current ship tft.drawRect(tft.width() / 2 + shipCol * 20, shipRow * 20, currentShipLength * 20 - 1, 19, TFT_WHITE); } } // Function to update the ship placement direction void updateShipDirection() { // check if the "right" button is pressed if (digitalRead(RIGHT_BUTTON_PIN) == LOW) { // increment the ship direction shipDirection++; // wrap the direction around if it goes past 3 if (shipDirection > 3) { shipDirection = 0; } // draw the ship in the new direction drawShip(shipX, shipY, shipLength, shipDirection); } // check if the "left" button is pressed else if (digitalRead(LEFT_BUTTON_PIN) == LOW) { // decrement the ship direction shipDirection--; // wrap the direction around if it goes below 0 if (shipDirection < 0) {
  • 5. shipDirection = 3; } // draw the ship in the new direction drawShip(shipX, shipY, shipLength, shipDirection); } }