Permalink
Browse files

Its Cellular Automata on Steroids.

  • Loading branch information...
1 parent 2f03a3b commit e7155e74f7ea6f5f2ffa32d849957a44e5d45138 namaste committed Jun 30, 2008
@@ -0,0 +1,38 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using Microsoft.Xna.Framework;
+using Microsoft.Xna.Framework.Graphics;
+
+namespace Playing_God
+{
+ public class Cell
+ {
+ int element;
+
+ public Cell()
+ {
+ element = 1;
+ UpdateColor();
+ }
+
+ public int Element
+ {
+ get { return element; }
+ set
+ {
+ element = value;
+ UpdateColor();
+ }
+ }
+
+ Vector3 color;
+ public Color Color { get { return new Color(color); } }
+
+ private void UpdateColor()
+ {
+ color = new Vector3(1.0f, 1.0f, 1.0f);
+ }
+
+ }
+}
@@ -0,0 +1,48 @@
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <ProjectGuid>15e9e6ea-7722-40a5-8df0-3ecd10db139e</ProjectGuid>
+ <ProjectTypeGuids>{96E2B04D-8817-42c6-938A-82C39BA4D311};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <XnaFrameworkVersion>v2.0</XnaFrameworkVersion>
+ <PlatformTarget>x86</PlatformTarget>
+ <OutputPath>bin\$(Platform)\$(Configuration)</OutputPath>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
+ <XnaPlatform>Windows</XnaPlatform>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
+ <XnaPlatform>Windows</XnaPlatform>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="Microsoft.Xna.Framework.Content.Pipeline.EffectImporter, Version=2.0.0.0, Culture=neutral, PublicKeyToken=6d5c3888ef60e27d, processorArchitecture=MSIL">
+ <Private>False</Private>
+ </Reference>
+ <Reference Include="Microsoft.Xna.Framework.Content.Pipeline.FBXImporter, Version=2.0.0.0, Culture=neutral, PublicKeyToken=6d5c3888ef60e27d, processorArchitecture=MSIL">
+ <Private>False</Private>
+ </Reference>
+ <Reference Include="Microsoft.Xna.Framework.Content.Pipeline.TextureImporter, Version=2.0.0.0, Culture=neutral, PublicKeyToken=6d5c3888ef60e27d, processorArchitecture=MSIL">
+ <Private>False</Private>
+ </Reference>
+ <Reference Include="Microsoft.Xna.Framework.Content.Pipeline.XImporter, Version=2.0.0.0, Culture=neutral, PublicKeyToken=6d5c3888ef60e27d, processorArchitecture=MSIL">
+ <Private>False</Private>
+ </Reference>
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="point.png">
+ <Name>point</Name>
+ <Importer>TextureImporter</Importer>
+ <Processor>TextureProcessor</Processor>
+ </Compile>
+ </ItemGroup>
+ <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\v2.0\Microsoft.Xna.GameStudio.ContentPipeline.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,97 @@
+using System;
+using System.Collections.Generic;
+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.Net;
+using Microsoft.Xna.Framework.Storage;
+
+namespace Playing_God
+{
+ /// <summary>
+ /// This is the main type for your game
+ /// </summary>
+ public class MainGame : Microsoft.Xna.Framework.Game
+ {
+ GraphicsDeviceManager graphics;
+ SpriteBatch spriteBatch;
+
+ Universe universe;
+
+ Texture2D pointTex;
+ KeyboardState currentKeyState;
+ KeyboardState lastKeyState;
+
+ const int universeW = 40;
+ const int universeH = 30;
+
+ public MainGame()
+ {
+ graphics = new GraphicsDeviceManager(this);
+ Content.RootDirectory = "Content";
+ }
+
+ protected override void Initialize()
+ {
+ base.Initialize();
+ }
+
+ protected override void LoadContent()
+ {
+ spriteBatch = new SpriteBatch(GraphicsDevice);
+ pointTex = Content.Load<Texture2D>("point");
+
+ universe = new Universe(universeW, universeH);
+ }
+
+ protected override void UnloadContent()
+ { }
+
+ protected override void Update(GameTime gameTime)
+ {
+ // Allows the game to exit
+ if ((GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) ||
+ Keyboard.GetState(PlayerIndex.One).IsKeyDown(Keys.Escape))
+ this.Exit();
+
+ CheckInput();
+
+ base.Update(gameTime);
+ }
+
+ private void CheckInput()
+ {
+ lastKeyState = currentKeyState;
+ currentKeyState = Keyboard.GetState(PlayerIndex.One);
+
+ if (currentKeyState.IsKeyDown(Keys.F1) && lastKeyState.IsKeyUp(Keys.F1))
+ {
+ graphics.ToggleFullScreen();
+ }
+ }
+
+ protected override void Draw(GameTime gameTime)
+ {
+ graphics.GraphicsDevice.Clear(Color.Black);
+
+ spriteBatch.Begin(SpriteBlendMode.AlphaBlend);
+ for (int i = 0; i < universe.Width; i++)
+ {
+ for (int j = 0; j < universe.Height; j++)
+ {
+ Cell c = universe.LookUp(i, j);
+ float posx = i * (800.0f / universe.Width);
+ float posy = j * (600.0f / universe.Height);
+ spriteBatch.Draw(pointTex, new Vector2(posx, posy), null,
+ c.Color, 0.0f, new Vector2(), 0.3f, SpriteEffects.None, 0);
+ }
+ }
+ spriteBatch.End();
+
+ base.Draw(gameTime);
+ }
+ }
+}
@@ -0,0 +1,85 @@
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <ProjectGuid>{EAE94A41-781B-4339-A974-022708F54C71}</ProjectGuid>
+ <ProjectTypeGuids>{6D335F3A-9D43-41b4-9D22-F6F17C4BE596};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
+ <OutputType>WinExe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Playing_God</RootNamespace>
+ <AssemblyName>Playing God</AssemblyName>
+ <XnaFrameworkVersion>v2.0</XnaFrameworkVersion>
+ <XnaPlatform>Windows</XnaPlatform>
+ <XnaCrossPlatformGroupID>c213483e-b745-4a28-a5bb-53b8581b826c</XnaCrossPlatformGroupID>
+ <ApplicationIcon>Game.ico</ApplicationIcon>
+ <Thumbnail>GameThumbnail.png</Thumbnail>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\x86\Debug</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <NoStdLib>true</NoStdLib>
+ <UseVSHostingProcess>false</UseVSHostingProcess>
+ <PlatformTarget>x86</PlatformTarget>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\x86\Release</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <NoStdLib>true</NoStdLib>
+ <UseVSHostingProcess>false</UseVSHostingProcess>
+ <PlatformTarget>x86</PlatformTarget>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="Microsoft.Xna.Framework, Version=2.0.0.0, Culture=neutral, PublicKeyToken=6d5c3888ef60e27d, processorArchitecture=x86">
+ <Private>False</Private>
+ <SpecificVersion>True</SpecificVersion>
+ </Reference>
+ <Reference Include="Microsoft.Xna.Framework.Game, Version=2.0.0.0, Culture=neutral, PublicKeyToken=6d5c3888ef60e27d, processorArchitecture=MSIL">
+ <Private>False</Private>
+ <SpecificVersion>True</SpecificVersion>
+ </Reference>
+ <Reference Include="mscorlib">
+ <Private>False</Private>
+ </Reference>
+ <Reference Include="System">
+ <Private>False</Private>
+ </Reference>
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Cell.cs" />
+ <Compile Include="Universe.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Program.cs" />
+ <Compile Include="MainGame.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <Content Include="Game.ico" />
+ <Content Include="GameThumbnail.png" />
+ </ItemGroup>
+ <ItemGroup>
+ <NestedContentProject Include="Content\Content.contentproj">
+ <Project>15e9e6ea-7722-40a5-8df0-3ecd10db139e</Project>
+ <Visible>False</Visible>
+ </NestedContentProject>
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\v2.0\Microsoft.Xna.GameStudio.Common.targets" />
+ <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\v2.0\Microsoft.Xna.GameStudio.NestedContent.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
@@ -0,0 +1,19 @@
+using System;
+
+namespace Playing_God
+{
+ static class Program
+ {
+ /// <summary>
+ /// The main entry point for the application.
+ /// </summary>
+ static void Main(string[] args)
+ {
+ using (MainGame game = new MainGame())
+ {
+ game.Run();
+ }
+ }
+ }
+}
+
@@ -0,0 +1,33 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Playing God")]
+[assembly: AssemblyProduct("Playing God")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyCompany("")]
+
+[assembly: AssemblyCopyright("Copyright © 2008")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("16732254-9d4d-480c-9d7d-08f28c96a02a")]
+
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+[assembly: AssemblyVersion("1.0.0.0")]
@@ -0,0 +1,36 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Playing_God
+{
+ public class Universe
+ {
+ int width = 100;
+ int height = 100;
+
+ Cell[,] space;
+
+ public Universe(int w, int h)
+ {
+ width = w;
+ height = h;
+ space = new Cell[width, height];
+ for (int i = 0; i < width; i++)
+ {
+ for (int j = 0; j < height; j++)
+ {
+ space[i, j] = new Cell();
+ }
+ }
+ }
+
+ public Cell LookUp(int i, int j)
+ {
+ return space[i, j];
+ }
+
+ public int Width { get { return space.GetLength(0); } }
+ public int Height { get { return space.GetLength(1); } }
+ }
+}

0 comments on commit e7155e7

Please sign in to comment.