Professors, like Internet Explorer, are notoriously slow to respond. I've been waiting for around a week for him to get back to me on whether or not the data I sent him is what he needs. While waiting, I decided to use my class time well, and learn a new language.
Javascript has been something that I've wanted to learn since Zoli showed me it. His effusive praise made it sound like the best language, period. So, over the summer, I completed a brief tutorial through Codecademy. However, I lacked a project to learn the language. I've always felt that knowing a language without having a project was like having a paperweight. Sure, its nice, but its completely useless.
I got my inspiration for the project from Etienne, who had been making Javascript games since last year. I asked him how he got started, and he said Snake. So I started trying that out. However, I quickly grew disenchanted with the idea. When I heard that the GameHost team needed a game, I decided to try making Tic-Tac-Toe. It was perfect. A simple game, easy to code, and mildly interesting.
I started by drawing nine squares on the page. Whenever someone clicked somewhere, the code would check whether or not the click was in a box. If it was, it colored the box and marked it as filled. Then, it would change the fill color, so that the next click would color the box differently.
I ended up with a nice visual representation of a tic-tac-toe game. It doesn't calculate win conditions yet, and I need to use more objects in my code. Here are some ideas for moving forwards--make a class that represents a box, then create functions inside that class. The first function checks whether or not a point is inside the box, another colors it, etc. Then, to get the tic-tac-toe grid, we need a 2D array of square objects.
The only problem is that today, I got an email from my professor today, giving us ideas to work forwards on. Rest in pieces, Tic-Tac-Toe game. I'll get back to you someday.
No comments:
Post a Comment