Results 1 to 5 of 5
- 02-11-2013, 09:03 PM #1
Member
- Join Date
- Feb 2013
- Posts
- 3
- Rep Power
- 0
how can i do this in the java word game i am making similar to battle ship
hi i am making a word game in java. its objectives are similar to battleships. at the start of the game,5 words(or any number really) are randomly placed on locations on a GUI grid of 8 by 8. at first i had wanted to make words vary in length but i will do them of 3 letters each to keep it simple.the player tries to hit the words on the grid. If he hits a letter, a window pops up. in this window there will be the letter he hit and blank spaces for the rest of the letters. a hint about the word will also be displayed. the user has one chance to try and guess the word. if he manages it counts as a point and the word is sunk else the window closes and the game continues but the hit letter remains uncovered. i had no problem up till the later parts of making the game. I have created the grid in GUI and a word vector in another class. the main menu with the options of PLAY, HELP and ADD WORDS is functional and working. however i hit a road block. i cant figure out how to take the words from the vector and place them randomly on the grid :/ also the points methods that will keep track of the players points. how can i do this? also there is an odd number of words on the grid to avoid draws. please help any advice appriciated . one last thing is it possible to make a button uncklicable after it has been hit? thank you
- 02-12-2013, 09:48 AM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,476
- Rep Power
- 16
Re: how can i do this in the java word game i am making similar to battle ship
For deploying words, break it down.
You'll want a method that deploys all the words.
This is the easy bit.
Just loop over the array and call a deployWord(String) method.
Now, you need to write the deployWord method.
You'll need to describe your criteria for legal places to deploy a word.
For example you can't deploy one too close to the right hand side of the grid, since the word wouldn't fit.
As for making a button unclickable, they have a setEnabled method.Please do not ask for code as refusal often offends.
- 02-12-2013, 10:37 AM #3
Member
- Join Date
- Feb 2013
- Posts
- 3
- Rep Power
- 0
- 02-12-2013, 11:01 AM #4
Re: how can i do this in the java word game i am making similar to battle ship
Moved from Advanced Java.
Whatever made you think this is an 'advanced' question?
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 02-12-2013, 12:47 PM #5
Moderator
- Join Date
- Apr 2009
- Posts
- 10,476
- Rep Power
- 16
Re: how can i do this in the java word game i am making similar to battle ship
You need to come up with some rules.
Forget about the buttons, just come up with some rules about checking whether a particular location is valid.
In order to check whether a position is valid it needs a model of the grid to work with. Note this is a model, not the grid of buttons itself. That button grid is simpyl a visual representation of the model.
All this should be doable without any reference to a GUI whatsoever.
Once you're happy that you have the population of this grid working, then you can use that grid to create the grid of buttons.Please do not ask for code as refusal often offends.
Similar Threads
-
Java stringtokenizer- making it reverse word
By katiebear128 in forum New To JavaReplies: 8Last Post: 10-20-2011, 12:15 AM -
How to use JgraphT or other similar graph making libraries?
By ankit1801 in forum New To JavaReplies: 1Last Post: 03-21-2011, 04:12 AM -
BattleShip game ship on top of ship
By linux1man in forum New To JavaReplies: 2Last Post: 06-03-2009, 12:42 PM -
battle Ship game help!!
By linux1man in forum New To JavaReplies: 4Last Post: 06-03-2009, 01:47 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks