Add a block to set X or O with blocks
@Horizon, @Faraz_Firoz means that add the ability to customize the TicTacToe board, X, O letters. Because always that style will not fit the app
Btw great extension
and happy saraswati puja!
Actually I have talked to Faraz and he said that he want a feature to return the index of the place where the x or o is placed so that it is possible to make online game
Yes you can change the color of all these things along with winning line but you cannot change the characters of X or O because i am not using "X" or "O" instead i am making it using programming
If you know java then go through the source code you'll get how exactly i am doing
And i have made it open source for this only so that new learners can understand it
Thank you
If I will make a little bit change in your code then we can use any letters
Yes you can try and also I would recommend you to give pull request to the GitHub repo
But i guess it's not possible as you can draw that thing but you cannot change the text size and all
Just change this in TicTacToeBoard.java
private void drawX(Canvas canvas, int row, int col) {
paint.setColor(XColor);
canvas.drawLine((float) ((col + 1) * cellSize - cellSize * 0.2),
(float) (row * cellSize + cellSize * 0.2),
(float) (col * cellSize + cellSize * 0.2),
(float) ((row + 1) * cellSize - cellSize * 0.2),
paint);
canvas.drawLine((float) (col * cellSize + cellSize * 0.2),
(float) (row * cellSize + cellSize * 0.2),
(float) ((col + 1) * cellSize - cellSize * 0.2),
(float) ((row + 1) * cellSize - cellSize * 0.2),
paint);
}
private void drawO(Canvas canvas, int row, int col) {
paint.setColor(OColor);
canvas.drawOval((float) (col * cellSize + cellSize * 0.2),
(float) (row * cellSize + cellSize * 0.2),
(float) ((col * cellSize + cellSize) - cellSize * 0.2),
(float) ((row * cellSize + cellSize) - cellSize * 0.2),
paint);
}
You can create your own letter by changing these code. As you do in Canvas component.
@Horizon may I know from where onDraw is getting canvas in TicTacToeBoard.java
I am talking about this code
@Override
protected void onDraw(Canvas canvas) {
paint.setStyle(Paint.Style.STROKE);
paint.setAntiAlias(true);
drawGameBoard(canvas);
drawMarkers(canvas);
if (winningLine == true && game.checkDraw == false) {
paint.setColor(winningLineColor);
drawWinningLine(canvas);
if(mlistener != null){
mlistener.gameWinner(game.getWinner());
}
}
}
Also may I know how can I change your code
The view which is created using TicTacToeBoard.java sets up a canvas only and the canvas of onDraw() is returning the canvas which in which you can make changes
You might learn about this(canvas)
Just fork it and clone your repo
Thank You
See I have made this view therefore i know that which code needs to change to change X and O
But it is not possible for me if you can then try
Tomorrow I will give you some code. You need to add those in your code and compile extension
I think for adding custom letters it can be done through a image of letter. @Horizon you can take help from -
Well i have exams mostly soon so i dont have time to make extensions for a month or more
Then I'll try making it
#Off topic
BTW All the best for your exams
@Horizon I tried this extension but get the error that says the project was saved in a newer version of MIT App Inventor. I would very much like to use this and don't understand the error.
Just click on ok and wait for 1 min it will be loaded
I did that but it would not run in IDE
You can remove this label one click and you can add a new button and say it as reset game and whenever that button will be clicked then you can say that TicTacToe.reset
Which IDE you are talking about