Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Drawing;
- using System.Drawing.Color;
- using System.Collections.Generic;
- using System.Linq;
- using Microsoft.Xna.Framework;
- using Microsoft.Xna.Framework.Audio;
- using Microsoft.Xna.Framework.Content;
- using Microsoft.Xna.Framework.GamerServices;
- using Microsoft.Xna.Framework.Graphics;
- using Microsoft.Xna.Framework.Input;
- using Microsoft.Xna.Framework.Media;
- namespace Collision
- {
- /// <summary>
- /// This is the main type for your game
- /// </summary>
- public class Game1 : Microsoft.Xna.Framework.Game
- {
- GraphicsDeviceManager graphics;
- SpriteBatch spriteBatch;
- Texture2D texture;
- Texture2D textureTransparent;
- Texture2D piecealive;
- Texture2D piecedead;
- Texture2D whatever;
- SpriteFont testFont;
- Microsoft.Xna.Framework.Color colour;
- Array KnownColor;
- string value;
- List<string> colors = new List<string>();
- Vector2 pos;
- public Game1()
- {
- graphics = new GraphicsDeviceManager(this);
- Content.RootDirectory = "Content";
- }
- protected override void Initialize()
- {
- base.Initialize();
- }
- protected override void LoadContent()
- {
- // Create a new SpriteBatch, which can be used to draw textures.
- spriteBatch = new SpriteBatch(GraphicsDevice);
- texture = Content.Load<Texture2D>(@"Images/logo");
- textureTransparent = Content.Load<Texture2D>(@"Images/logo_trans");
- piecealive = Content.Load<Texture2D>(@"Images/piece_alive");
- piecedead = Content.Load<Texture2D>(@"Images/piece_dead");
- testFont = Content.Load<SpriteFont>(@"Fonts/Test");
- whatever = Content.Load<Texture2D>(@"Images/Bitmap1");
- GetColors();
- }
- protected override void UnloadContent()
- {
- }
- protected override void Update(GameTime gameTime)
- {
- // Allows the game to exit
- if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
- this.Exit();
- Random rand = new Random();
- CreateRandomColour();
- base.Update(gameTime);
- }
- protected override void Draw(GameTime gameTime)
- {
- GraphicsDevice.Clear(Microsoft.Xna.Framework.Color.White);
- spriteBatch.Begin(SpriteSortMode.FrontToBack, BlendState.AlphaBlend);
- for (int i = 0; i < 256; i++)
- {
- pos.Y = i * 2;
- for (int j = 0; j < 256; j++)
- {
- System.Drawing.Color SColor = System.Drawing.Color.FromName(value);
- colour = new Microsoft.Xna.Framework.Color(SColor.R, SColor.G, SColor.B, SColor.A);
- pos.X = j * 2;
- Microsoft.Xna.Framework.Graphics.SpriteBatch.Draw(whatever,
- pos,
- colour);
- }
- }
- spriteBatch.End();
- base.Draw(gameTime);
- }
- private String CreateRandomColour()
- {
- Random random = new Random();
- int index = random.Next(0, colors.Count); // list.Count for List<T>
- value = colors[index]; // where array is string[]
- return value;
- }
- private List<string> GetColors()
- {
- string[] colorNames = Enum.GetNames(typeof(KnownColor));
- foreach (string colorName in colorNames)
- {
- KnownColor knownColor = (KnownColor)Enum.Parse(typeof(KnownColor), colorName);
- colors.Add(colorName);
- }
- return colors;
- }
- }
- }
Add Comment
Please, Sign In to add comment