Switch

This was a project that followed on from the Sudoku experiment.
​
It came from the mind set of creating a "simple" puzzle game that could be solved in a few minutes but had a sort of rubiks cube feel to it?
​
The game sees the player move blocks one at a time into a blank space around the bases. They must match all the blocks to their corresponding base colours.
Fancy a poke around?
Download
- Itch.io

So setting up the random bases, I made an algorithm to pull all the base game objects into an array. Then a random number between 1-9 is selected, 1 = red base, 2= blue base e.t.c. is selected. Once a random number is picked, the base game object at the corresponding array location is put into the game. This same technique is used to populate the blocks too.
Once all the blocks and bases are set, the locations of each block and base is stored in a [3,3] array. This can later be used to register which block has been selected by the player and if that block is movable. For example, the first game variation below would have an array formation of;
​
[0,0] = pink1
[0,1] = purple
[0,2] = red
[1,0] = blank
[1,1] = yellow
[1,2] = pink2
[2,0] = green
[2,1] = blue
[2,2] = black
From this we can find out when a player goes to move a block, if it is in-fact movable.
1. Find which block the player has selected.
2. Find the location in the array that this block corresponds to.
3. Look at the (x,y) the players initial click/screen touch happened.
4. Figure out which direction the player has attempted to move the block in.
newPos.x > initalClick.x = plyaer has gestured to move Right
newPos.x < initalClick.x = plyaer has gestured to move Left
newPos.y > initalClick.y = plyaer has gestured to move Up
newPos.y < initalClick.y = plyaer has gestured to move Down
5. If the player has gestured Up and they have clicked the block at [1,2] = pink2 (middle right block). Then we look at the location above this block at [0,2].
6. If [0,2] has "blank" stored in it, then the player is able to move the block up. In this case the value in [0,2] is "red" which means the player is not able to move that "pink2" block up because there is a block blocking his way.
7. Repeat this loop each time the player looks to move a block.

To mix up the gameplay a little I decided to introduce element blocks that would stop the player form completing the game if they weren't dealt with.
​
ICE - This block needs to be smashed on a blank base block.
​
FIRE - This block needs to be extinguished on the blocks corresponding base colour.
​
This means the player can't sit around or leave block off to one side while trying to complete the rest of the puzzle. They will have to remain on their toes.

Another element I was thinking of introducing was 'block value'. This would mean each block worked like a dice and as you moved the blocks around the bases it would roll and the number that remained on top when the puzzle was complete would act like a score multiplier.
​
This is shown below, as the player moves the block to the left it rolls to reveal 4, then as they move the block down it reveals 5. If the player had completed the entire game (all blocks on their correct positions) then the score would go through and then the score for blue would be mulitplied by 5.
​
This element isn't neceasry to do well in to complete the game but means that people who like a challenge can strive for higher scores.


Lastly I was considering adding multiplayer to the game in the form of time trials or in a head to head competitive format. Where players would have to race to finish the puzzles first and the element blocks could be used as hindrances fr each player.
For example, if I had an Ice block and I broke it before my challenger, they would get my ice block so they would then have to remove two Ice blocks from their game, making it harder for them and slowing them down. These small hindrances that the players control could add a little more enjoyment and competition to the multiplayer.
If you made it this far, then thanks for reading. I hope you found something that was of use to you and if you have any questions or want to spit-ball some ideas, drop me an email and we can have a chat.



