For SpartaCodingClub's Game Development Week #4 class, I learned how to create a memory matching game! This lesson also featured some more cute resources of their mascot character and a ticking timer that counts up instead of down this time.
One notable thing I learned from this week's lesson would definitely be how to spawn cards; not by placing them onto their own unique location one by one manually but instead coding it so the engine would do all the work for you.
This was the layout needed for the game.
And this was the result of using this code.
void Start()
{
int[] rtans = { 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7 };
for (int i = 0; i < 16; i++)
{
GameObject newCard = Instantiate(card);
newCard.transform.parent = GameObject.Find("cards").transform;
float x = (i / 4) * 1.4f - 2.1f;
float y = (i % 4) * 1.4f - 3.0f;
newCard.transform.position = new Vector3(x, y, 0);
}
}
The lesson provided all that was needed in order to create a simple memory matching game which resulted in something like this.
Happy with the result. Onto the last class!