Forum > Using Mood Light to create Simon?

Is it possible using the mood light in the book to restrict the color to 4 rectangles? Meaning I would have 4 rectangles on the screen, a random selector would create yellow, blue, red or green in the appropriate square to simulate the Simon game from years back.

Thanks for any info

Shawn

April 5, 2008 | Unregistered CommenterShawn

Uh, we can ask questions here right?

April 6, 2008 | Unregistered CommenterShawn

One other question, what if I want to associate certain tones to the colors, maybe as a way in the future to create a type of tone recognizer for musicians...like if I wanted the red rectangle to emit a A tone or A note...maybe that will be revealed in the sound chapter, but just thought I would ask.

Thanks,

Shawn

April 6, 2008 | Unregistered CommenterShawn

This is the right place for questions. I check it every couple of days or so.

The answer to your drawing question is that you have to do a little bit of extra work to draw coloured rectangles on the screen.

When you clear the background to a colour you set the entire background to that colour. If you want to have different colours on different parts of the screen you have to have more than one object on the screen and then either have the object a particular colour (say a texture which is green) or illuminate a white object with a partiuclar coloured light

Take a look at using SpriteBatch in the book (page 76) and note that we shine white onto Jake to draw him. If we shine other colours Jake comes up in those instead.

If you can make a white rectangle with Paint, save it in an image file and then load it into your game as a texture you can do this. You can draw the same texture in different places (using different rectangles) and use a different coloured light each time.

XNA won't associate colours with sounds for you, again you have to do the work yourself. What I would do is have a dark red color for the rectangle when it is not playing and then make it "light up" with a bright colour when the "red" tone is playing. The best way to make Simon is to have an array of color items and for each turn you work through the array a certain distance showing the pattern of lights. You then wait for a bunch of presses on buttons (you need to look for edges as described in Chapter 6) and make sure that the buttons are pressed in the right order. If they are you add one to the distance you go down the array and then repeat until the player gets it wrong.

Hope this helps. Let me know how you get on.

April 7, 2008 | Registered CommenterRob

So, a quick update...

Took me a while to free some time up to work on this. I got a start on it today and am kind of running into design issues I guess (or I am making it too hard on myself). Basically I decided to make a PlayBoard class to handle...well, the playboard which is just the 4 squares for now (like in the regular Simon). Here is what I did and I will elaborate on where I am stuck:

Code

What I am stuck on is where to create the Intense colors for when the particular color is "playing" and where I should put the code creating a list and maintaining it. Well, I guess I should also say, how should I switch between, computer is playing colors, or computer is waiting for user input to see if it matches previous colors played? If that makes any sense...

Thanks for any help!

Shawn

April 19, 2008 | Unregistered CommenterShawn

Hmmm. Good start. You need something to keep track of the currently "Active" square. This will have a brighter value when it is displayed. You also need a state value to keep track of what the game is doing at any given instant (computer showing the code or waiting for the user input). You could take a look at the Pelmanism game for some hints on what to do. That has quite a few behaviours that are very similar to what you are doing.

April 22, 2008 | Registered CommenterRob