Personal Project 2: Tic Tac Toe
Tic Tac Toe
I needed to make an alternative controller, so I made one for tic tac toe that is run in unity. I went with tic ta toe because I have the pieces to make it and the knowledge to do it. I went with unity due to past experience in the program.
Initial Setups
This is the initial build i used to test my buttons. This resistor ladder is just like the one used in project 7.
This was the code I used to get the initial reads and make sure that I am still getting the same results as the project 7.
This is what my unity sketch looks like. I made no real changes to it, just got rid of the circle in the top spot. I was using it to determine where the pieces were going to go.
This is my final setup and parts list. The double resistor ladder on each side of the board was nice and can be used with further coding for other things.
Final Coding
Arduino:
There is a lot of coding, but it is mostly just simple stuff of just checking if the value is what we want and the printing the data to the serial so that unity can get the data.
Unity:
For unity there was definitely a lot more coding, but this was still just more if checks. The most notable is the DataStream and its reading which we barely dive into it so it is pretty simple. The two codes will send data to each other and when the unity code gets the data it will create the pieces of the tic-tac-toe in the corresponding places.
Final Thoughts
This was a fun project, and I ran out of time to incorporate everything that I wanted to do. I had plans for a menu screen and a win screen and in the code, there is extra data being sent that was going to be used for that. Currently none of that got implemented and the buttons go from 1-9 from top to bottom and the user will have to run it in the unity editor and when player wins reset the game manually. I also learned that if unity tries to open and read the data, but you have sent nothing it will crash so always send empty which seems like nothing but prevents the crashes.
Comments
Post a Comment