Gurudas Bhandarkar wrote:@Fred, thank you for starting a new thread.
I understood your codes( written those in very simple manner).
Coming to internal representation, We can have array of 3x3 as 1d array of 9 elements.
and number them serially from 0-8.(or 1-9).
am I making any sense.. please correct me if I am not. more over what about the main class..
Gurudas Bhandarkar wrote:I am new to the swing components.(not that i dont know it but some how, never tried to solve algorithms or create games using swings. just console oriented application, then my friend told me that the gui thing is more impressive than the console applications,I told her that the logic is same, she very well pointed out that looks are what that matter. So I thought to create this game using gui of course with your help.) So it will be better for me to study the code you have written first and then try to write some other.
also one more thing, the test button is not visible if the window is maximized.
Gurudas Bhandarkar wrote:You have done a fantastic job. I hope I am not asking too much from your side.
The question was why the Test button didnt appear when window was maximized,what is the reason. Now even if I maximize it all three buttons are visible.
Moreover, I would like to suggest a thing in this program, that if we are able to put icons for 'X' and 'O'. I have tried to put the icons as
Now I don't know where to put this code or exactly how to make that icon appear. Similarly I am planing for O and grid lines as well. Also if I want to put the image, where should I save this images in order that the program can access them. Later on I want to convert this game to gomoku. Its generally played on 13x13 board. and to connect 5 like tictactoe, hence tried to find some common logic to evaluate the game. to check win in columns, something like
Similarly for rows.
but when it comes to check for diagonals, I am stuck again.
Gurudas Bhandarkar wrote:Here is what I tried.
Still the image didn't appear so I tried to specify the entire path
like
So I got an exception of illegal escape character.
so how can I do it? Once I get this, I would like to change the grid as well to make it appear better, what say?
Gurudas Bhandarkar wrote:I did that when i used jus "X.gif", the file was in same folder as of the program.
I use netbeans for java programs, is there a different way to do it?
Gurudas Bhandarkar wrote:Ya it happens the same thing.
As I run the program, I click on the playing area, no lines are drawn but there is 'X' on that grid.. I may not be able to explain but in short, there is X but not visible.
I ll post the code once again take a look at it.
Gurudas Bhandarkar wrote:no difference.
Am I missing anything very basic?
try {
img = ImageIO.read(new File("X.gif"));
} catch (IOException e) {
}
Ulf Dittmer wrote:I haven't read the whole thread, but this is a bad idea:
try {
img = ImageIO.read(new File("X.gif"));
} catch (IOException e) {
}
In I/O code you simply must handle exceptions; at least print out a warning message that something went wrong, like "System.out.println(e.getMessage())".
Gurudas Bhandarkar wrote:@Ulf&Fred
Thanks for pointing that one.
The error is "Cant read input file"
Gurudas Bhandarkar wrote:But as Fred said, absolute path is not a good idea as when zipped and sent to some one else, he might not have that folder.
More over Netbeans creates a .jar file rather than .class file
while executing.
Fred Hamilton wrote:
Gurudas Bhandarkar wrote:But as Fred said, absolute path is not a good idea as when zipped and sent to some one else, he might not have that folder.
More over Netbeans creates a .jar file rather than .class file
while executing.
I am 99% sure the problem is that the particular version of ImageIO.read() doesn't work with jar files, so as Ulf said you can run the program outside of netbeans without a jar file, or try this...
ImageIO.read( getClass().getResourceAsStream("X.gif") );
I use this with my chess program. But I am not sure it will work in you GameBoard class. You may to create static BufferedImage variables in your GameFrame class, and reference these variables from your drawPiece method.
Gurudas Bhandarkar wrote:I don't know how to compile more than 1 class in command line.
There are 4 different class made for
1.GameFrame.java
2.GameTable.java
3.GameBoard.java
4.Engine.java
when I try to compile the GameFrame.java it says cannot find symbol, GameTable.
Its like we were taught only to compile one class and then onwards we started to use IDEs.
Consider Paul's rocket mass heater. |