For a school project I need to make a game in C. However, since I'm much more fond with javascript + js can give a easy visual implementation, I decided to write my game in js before in c, to get my structure right. That's why my code's so weirdly looped.
Now, the issue is that I have a switches[]
array that has the switches being pressed (1/0). I want to compare this to another array, oldArray[]
. Now, when comparing, they are both ALWAYS the same for some reason, and I just can't find it. Here's a full sample on jsfiddle.net. The issue is in the memory()
function. This line isn't working properly:
if (switches[i] == 1 && oldArray[i] == 0 && guessedArray[i] == 8 && i != oldtouch) {...}
because switches[]
always seems to be equal to oldArray[]
.
In the fiddle, press Start
and check the consle output after clicking some buttons.