- Home /
Counting colors and keeping it in memory (javascript)
Hello, I have a simple color game that im trying to learn unity with.. I built this with help from this site.. Now i got all the things right but i am lost and dont know what to do with the scoring.. The game goes like a memory test. Objects display on screen with random colors out of 8 colors. The user has to choose the right option from 3 given options at the end of a level. I am ready with the code till the following, i am building as i learn so there are few variables that are left unused but the code works fine.
#pragma strict
public var OnScreen : Texture[] = new Texture[8];
public var timeBetweenImages = 0.6;
var level : int = 1;
public var colors = [Color.white, Color.red, Color.blue, Color.green, Color.yellow];
function Start ()
{
// Shuffle Images (special thanks to roberthu)
var temp : Texture;
for (var i = 0; i < OnScreen.Length-1; i++)
{
var j = Random.Range(i, OnScreen.Length);
temp = OnScreen[i];
OnScreen[i] = OnScreen[j];
OnScreen[j] = temp;
}
DisplayImages();
}
function DisplayImages ()
{
//Displaying main random images for 5 seconds
for(var i = 0; i < OnScreen.Length; i++)
{
renderer.material.mainTexture = OnScreen[i];
renderer.material.color = colors[Random.Range(0, colors.Length)];
yield WaitForSeconds(timeBetweenImages);
}
//Loading the level where the user has to guess the right option.
yield WaitForSeconds(1);
Application.LoadLevel("Guess");
}
Comment
Your answer
Follow this Question
Related Questions
Material doesn't have a color property '_Color' 4 Answers
Changing two different objects renderer colour 1 Answer
Issues with changing light colour 2 Answers
Highlighting objects with colours. 1 Answer