Tee Hee . . . I am cheating a bit with this update. I am actually writing this at 2:20 am on Monday 12/2 rather than on Sunday 12/1. And I know that it will keep every single person who reads this, up into the night. Mwuahaha . . .
Anyway. Here we go, week number two. This is the last week of the school semester and I am lucky enough to not have an incredibly stressful final's schedule. Only a couple of test and a few assignments keep me away from the winter break, and more time to work on this project!
For this update I only spent a couple of hours on it. Mainly tonight (whilst playing the incredibly addicting game (Cookie Clicker). With this update I decided upon moving away from a typical object driven work flow. What I mean by that is have a set of main objects that create and track, at runtime, the rest of the objects needed in the game.
I realized that trying to follow this style is working against the grain of how Unity is designed. Unity is a Component-Entity system, and this is a major reason why it such an amazing tool. It only makes sense to write code that continues this style for my objects.
Currently I have four components that I have created:
PositionControl will sit on the object that acts as the head of the snake and listen for the player input, up/down/left/right. As it gets this input it updates the position of the snake.
Head is another component that sits on the snake head object. Right now it doesn't actually do anything but put the head in the center. It originally held the position code, but I decoupled into the above component.
Wall Generator sits on what will be the level objects. It wants the designer to input a width and height for the wall in the inspector, and then on game start, it will construct a wall of that given size based on the Wall prefab sitting in the world.
Wall, like head, does nothing yet.
Next . . .
In the next update I plan to flesh out Head and Wall. I want to make a new component Body that head will inherit from. Body will listen for general collisions, like walls, but the head has to listen for a couple of special ones like food and power ups.
I also plan to add the collisions so that when the snake collides with a wall or a part of itself, the game will end.