Question

I have to code a battleship game on processing. Now im at the point that when...

I have to code a battleship game on processing. Now im at the point that when i click that the element beneath if should come out. Like if its a part of the ship than it should show it. But i have been busy trying to slove this little problem for weeks now and im not any further and my assignments are within vew days. I am not allowed to use classes tho.

Homework Answers

Answer #1

I hope this could help you in some way.--

void mouseClicked ()

{

int mouseShipX = mouseY/CELLSIZE ;

int mouseShipY mouseX/CELLSIZE ;

for (int x = 0; x< NUM_COLS; x++)

{

for (int y = 0; y < NUM_ROWS; Y++)

{

if ( shipX [y] == mouseShipX && shipY [x] == mouseShipY)

{

fill (0);

  textSize (CELLSIZE) ;

text ("HIT", (shipHitX [x] * CELLSIZE) , (shipHitY [y] * CELLSIZE) + CELLSIZE/2+textAscent()/2);

shipHitX [x] = shipY [x];

shipHitY [y] = shipX [y];

}

}

}

}

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Microsoft Visual Studio in C#: I have this code and need to loop through each element...
Microsoft Visual Studio in C#: I have this code and need to loop through each element of the patient's array and add to a listbox (lbAccountDisplay) each property of the patient's object. This is the 2nd time to ask this question; it should have all the detail you need to help me. It is a piece of a project and I am trying not to give you the whole project. How do I use a foreach loop to loop through...
Case 13 ✍ It Was Really So Simple Background Information Brenda Galway leaned back in her...
Case 13 ✍ It Was Really So Simple Background Information Brenda Galway leaned back in her chair, sighed heavily, and slowly rubbed her eyes in big circular motions. “I don’t need all this aggravation,” she thought to herself. She had just finished reviewing the report she had requested from her new employee, Bill Stanley. The entire report was incorrect and would have to be redone. Brenda supervised Unit B of the Audit Department. The Unit B team had earned the...
CASE 3.2 Horizon Consulting Patti Smith looked up at the bright blue Carolina sky before she...
CASE 3.2 Horizon Consulting Patti Smith looked up at the bright blue Carolina sky before she entered the offices of Horizon Consulting. Today was Friday, which meant she needed to prepare for the weekly status report meeting. Horizon Consulting is a custom software development company that offers fully integrated mobile application services for iPhonetm, Androidtm, Windows Mobile® and BlackBerry® platforms. Horizon was founded by James Thrasher, a former marketing executive, who quickly saw the potential for digital marketing via smartphones....
PLEASE READ THE ARTICLES ATTACHED AND ANSWER THE FOLLOWING QUESTION. THE ARTICLES ARE BOTH LISTED PLEASE...
PLEASE READ THE ARTICLES ATTACHED AND ANSWER THE FOLLOWING QUESTION. THE ARTICLES ARE BOTH LISTED PLEASE PROVIDE DETAILED EXPLANATIONS. PLEASE WRITE ONE REFLECTION COMBINING BOTH ARTICLES. The purpose of the Article Reflection is to deepen your engagement with the topic of Epidemiology. It will give you the opportunity to reflect on the current real-life epidemiological issues at hand and help to bring meaning to them. ARTICLE 1: A group of students knew they had covid-19. They hosted a party over...
We constantly seem to be pricing ourselves out of some markets and not charging enough in...
We constantly seem to be pricing ourselves out of some markets and not charging enough in others. Our pricing policy is pretty simple: we mark up our full manufacturing cost by 50%. That means a computer that costs us $2,000 to manufacture will sell for $3,000. Until now I thought this was a workable approach, but now I’m not so sure. Steve Works, CEO, Cortland Manufacturing, Inc. (CMI) Steve’s Controller, Sally Nomer, had just told him that she believed the...
Please answer the following Case analysis questions 1-How is New Balance performing compared to its primary...
Please answer the following Case analysis questions 1-How is New Balance performing compared to its primary rivals? How will the acquisition of Reebok by Adidas impact the structure of the athletic shoe industry? Is this likely to be favorable or unfavorable for New Balance? 2- What issues does New Balance management need to address? 3-What recommendations would you make to New Balance Management? What does New Balance need to do to continue to be successful? Should management continue to invest...
What tools could AA leaders have used to increase their awareness of internal and external issues?...
What tools could AA leaders have used to increase their awareness of internal and external issues? ???ALASKA AIRLINES: NAVIGATING CHANGE In the autumn of 2007, Alaska Airlines executives adjourned at the end of a long and stressful day in the midst of a multi-day strategic planning session. Most headed outside to relax, unwind and enjoy a bonfire on the shore of Semiahmoo Spit, outside the meeting venue in Blaine, a seaport town in northwest Washington state. Meanwhile, several members of...
2. SECURING THE WORKFORCE Diversity management in X-tech, a Japanese organisation This case is intended to...
2. SECURING THE WORKFORCE Diversity management in X-tech, a Japanese organisation This case is intended to be used as a basis for class discussion rather than as an illustration of the effective or ineffective handling of an administrative situation. The name of the company is disguised. INTRODUCTION In light of demographic concerns, in 2012, the Japanese government initiated an effort to change the work environment in order to secure the workforce of the future. Japan is world renowned for its...
3 SECURING THE WORKFORCE Diversity management in X-tech, a Japanese organisation This case is intended to...
3 SECURING THE WORKFORCE Diversity management in X-tech, a Japanese organisation This case is intended to be used as a basis for class discussion rather than as an illustration of the effective or ineffective handling of an administrative situation. The name of the company is disguised. INTRODUCTION In light of demographic concerns, in 2012, the Japanese government initiated an effort to change the work environment in order to secure the workforce of the future. Japan is world renowned for its...
The Business Case for Agility “The battle is not always to the strongest, nor the race...
The Business Case for Agility “The battle is not always to the strongest, nor the race to the swiftest, but that’s the way to bet ’em!”  —C. Morgan Cofer In This Chapter This chapter discusses the business case for Agility, presenting six benefits for teams and the enterprise. It also describes a financial model that shows why incremental development works. Takeaways Agility is not just about the team. There are product-management, project-management, and technical issues beyond the team’s control. Lean-Agile provides...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT