Changeset 5693


Ignore:
Timestamp:
2014-07-25 12:35:58 (9 years ago)
Author:
mijoilmo
Message:
 
Location:
2014/30/MikkoI
Files:
17 added
4 deleted
37 edited

Legend:

Unmodified
Added
Removed
  • 2014/30/MikkoI/WindowsGame1/WindowsGame1.sln

    r5558 r5693  
    22Microsoft Visual Studio Solution File, Format Version 11.00 
    33# Visual Studio 2010 
    4 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WindowsGame1", "WindowsGame1\WindowsGame1\WindowsGame1.csproj", "{ADEF2337-A726-4041-B783-51541FEF022B}" 
     4Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "shadowSimulator2014", "WindowsGame1\WindowsGame1\shadowSimulator2014.csproj", "{ADEF2337-A726-4041-B783-51541FEF022B}" 
    55EndProject 
    6 Project("{96E2B04D-8817-42C6-938A-82C39BA4D311}") = "WindowsGame1Content", "WindowsGame1\WindowsGame1Content\WindowsGame1Content.contentproj", "{97A5BC4F-C40A-4D52-BF03-8923DFD60CA0}" 
     6Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WindowsGame1Content", "WindowsGame1\WindowsGame1Content\WindowsGame1Content.contentproj", "{97A5BC4F-C40A-4D52-BF03-8923DFD60CA0}" 
    77EndProject 
    88Global 
  • 2014/30/MikkoI/WindowsGame1/WindowsGame1/WindowsGame1/Camera/Camera.cs

    r5626 r5693  
    66using Microsoft.Xna.Framework.Graphics; 
    77 
    8 namespace WindowsGame1 
     8namespace ShadowSimulator2014 
    99{ 
    1010    public class Camera 
     
    2121        public Matrix getMatrix(Vector2 gridSize, Vector2 mapSize) 
    2222        { 
    23             //viewPortBounds(); 
     23            viewPortBounds(); 
    2424 
    2525            Vector3 pixelMapSize = new Vector3((gridSize.X * mapSize.X / 2), (gridSize.Y * mapSize.Y / 2), 0); 
  • 2014/30/MikkoI/WindowsGame1/WindowsGame1/WindowsGame1/Game1.cs

    r5626 r5693  
    1010using Microsoft.Xna.Framework.Media; 
    1111 
    12 namespace WindowsGame1 
     12namespace ShadowSimulator2014 
    1313{ 
    1414    /// <summary> 
    1515    /// This is the main type for your game 
    1616    /// </summary> 
    17     public class Pikseli : Microsoft.Xna.Framework.Game 
     17    public class shadowSimulator : Microsoft.Xna.Framework.Game 
    1818    { 
    1919        GraphicsDeviceManager graphics; 
     
    3636        BasicEffect effect; 
    3737 
    38         public static Pikseli Instance; 
     38        public static shadowSimulator Instance; 
    3939        public GameTime gameTime; 
    4040 
    41         public Pikseli() 
     41        public shadowSimulator() 
    4242        { 
    4343            Instance = this; 
     
    101101            spriteBatch = new SpriteBatch(GraphicsDevice); 
    102102 
    103             allMaps.Add(new Map(new Texture2D(GraphicsDevice, 1, 1), 20, 20)); 
     103            allMaps.Add(new Map(new Texture2D(GraphicsDevice, 1, 1), 50, 50)); 
    104104 
    105105            masterRenderer = new MasterRenderer(spriteBatch, allMaps[currentMapIndex], camera); 
  • 2014/30/MikkoI/WindowsGame1/WindowsGame1/WindowsGame1/Map/Map.cs

    r5626 r5693  
    1010using Microsoft.Xna.Framework.Media; 
    1111 
    12 namespace WindowsGame1 
     12namespace ShadowSimulator2014 
    1313{ 
    1414    public class Map 
     
    4141                { 
    4242                    Tiles[x, y] = new Tile("testitile");//jotain shittiä myöhemmin 
    43                     if (Pikseli.Instance.random.NextDouble() > 0.1) { continue; } 
     43                    if (shadowSimulator.Instance.random.NextDouble() > 0.1) { continue; } 
    4444 
    4545                    string textureId = ""; float shadowOffset = 0; 
    46                     switch ((int)Math.Floor((double)(Pikseli.Instance.random.NextDouble() * 4))) 
     46                    switch ((int)Math.Floor((double)(shadowSimulator.Instance.random.NextDouble() * 4))) 
    4747                    { 
    4848                        case 0: 
  • 2014/30/MikkoI/WindowsGame1/WindowsGame1/WindowsGame1/Map/MapObject.cs

    r5626 r5693  
    66using Microsoft.Xna.Framework.Graphics; 
    77 
    8 namespace WindowsGame1 
     8namespace ShadowSimulator2014 
    99{ 
    1010    public class MapObject 
  • 2014/30/MikkoI/WindowsGame1/WindowsGame1/WindowsGame1/Map/Tile.cs

    r5581 r5693  
    66using Microsoft.Xna.Framework.Graphics; 
    77 
    8 namespace WindowsGame1 
     8namespace ShadowSimulator2014 
    99{ 
    1010    public class Tile 
  • 2014/30/MikkoI/WindowsGame1/WindowsGame1/WindowsGame1/Map/Unit.cs

    r5607 r5693  
    66using Microsoft.Xna.Framework.Graphics; 
    77 
    8 namespace WindowsGame1 
     8namespace ShadowSimulator2014 
    99{ 
    1010    //olento 
  • 2014/30/MikkoI/WindowsGame1/WindowsGame1/WindowsGame1/Program.cs

    r5558 r5693  
    11using System; 
    22 
    3 namespace WindowsGame1 
     3namespace ShadowSimulator2014 
    44{ 
    55#if WINDOWS || XBOX 
     
    1111        static void Main(string[] args) 
    1212        { 
    13             using (Pikseli game = new Pikseli()) 
     13            using (shadowSimulator game = new shadowSimulator()) 
    1414            { 
    1515                game.Run(); 
  • 2014/30/MikkoI/WindowsGame1/WindowsGame1/WindowsGame1/Render/GuiRenderer.cs

    r5626 r5693  
    66using Microsoft.Xna.Framework.Graphics; 
    77 
    8 namespace WindowsGame1 
     8namespace ShadowSimulator2014 
    99{ 
    1010    public class GuiRenderer 
     
    3939            r.spriteBatch.End();*/ 
    4040            r.spriteBatch.Begin(); 
    41             r.spriteBatch.Draw(Pikseli.Instance.textures["gui/cursor"], Pikseli.Instance.mousePos, Color.White); 
     41            r.spriteBatch.Draw(shadowSimulator.Instance.textures["gui/cursor"], shadowSimulator.Instance.mousePos, Color.White); 
    4242            r.spriteBatch.End(); 
    4343        } 
  • 2014/30/MikkoI/WindowsGame1/WindowsGame1/WindowsGame1/Render/MapRenderer.cs

    r5626 r5693  
    66using Microsoft.Xna.Framework.Graphics; 
    77 
    8 namespace WindowsGame1 
     8namespace ShadowSimulator2014 
    99{ 
    1010    class MapRenderer 
     
    1717 
    1818        float sunAngle = 24; 
    19         Vector3 sunPosition = Vector3.Zero; 
     19        Vector3 sunPosition = new Vector3(-100, -100, 40); 
    2020 
    2121        public MapRenderer(RendererBase r, Map map, Camera camera) 
     
    2727        } 
    2828 
    29         void renderGroundObjects(Matrix matrix) { 
     29        void renderGroundObjects(Matrix matrix) 
     30        { 
    3031            //renderöi kaikki maassa olevat dynaamiset objektit, eli puut, olennot ym. 
    3132            r.spriteBatch.Begin(SpriteSortMode.FrontToBack, null, null, null, null, null, matrix); 
     
    3435            foreach (MapObject obj in map.Objects) 
    3536            { 
    36                 Texture2D texture = Pikseli.Instance.textures[obj.textureId]; 
     37                Texture2D texture = shadowSimulator.Instance.textures[obj.textureId]; 
    3738                Vector2 size = new Vector2(texture.Width, texture.Height) * camera.zoomFactor;//ditto 
    3839 
     
    5758            foreach (MapObject obj in map.Objects) 
    5859            { 
    59                 Texture2D texture = Pikseli.Instance.textures[obj.textureId]; 
     60                Texture2D texture = shadowSimulator.Instance.textures[obj.textureId]; 
    6061                Vector2 size = new Vector2(texture.Width, texture.Height) * camera.zoomFactor;//ditto 
    6162                r.renderGroundObject(texture, (int)obj.position.X, (int)obj.position.Y, size, matrix, camera); 
    6263            } 
     64            sunAngle += 1 / 3000.0f;//auringon pyörimisnopeus 
     65 
     66            if (sunPosition.X < 30) 
     67            { 
     68                sunPosition.X += 0.2f; 
     69                sunPosition.Y += 0.2f; 
     70            } 
     71            else 
     72            { 
     73                if (sunPosition.Z > 5) 
     74                { 
     75                    sunPosition.Z -= 0.2f; 
     76                } 
     77 
     78            } 
     79 
     80            Vector3 fixedSun = sunPosition; 
     81            fixedSun.Z *= -1.0f; 
     82 
     83            Texture2D sunTexture = shadowSimulator.Instance.textures["taivas/aurinko"]; 
     84            r.renderDistantSprite(sunTexture, fixedSun, new Vector2(sunTexture.Width * camera.zoomFactor * 5, sunTexture.Height * camera.zoomFactor * 5), matrix, camera); 
    6385 
    6486            r.spriteBatch.End(); 
    6587        } 
    6688 
    67         void renderSky(Matrix matrix) { 
     89        void renderSky(Matrix matrix) 
     90        { 
    6891            r.spriteBatch.Begin(SpriteSortMode.FrontToBack, BlendState.AlphaBlend); 
    6992 
    70             Texture2D starBackground = Pikseli.Instance.textures["taivas/tähdet"]; 
     93            Texture2D starBackground = shadowSimulator.Instance.textures["taivas/tähdet"]; 
    7194 
    72             r.renderBackground(starBackground, new Vector2(starBackground.Width, starBackground.Height)); 
     95            //r.renderBackground(starBackground, new Vector2(starBackground.Width, starBackground.Height)); 
    7396 
    7497            r.spriteBatch.End(); 
     
    84107                for (var y = 0; y < map.Size.Y; y++) 
    85108                { 
    86                     r.renderGroundTile(Pikseli.Instance.textures[map.Tiles[x, y].textureId], x, y); 
     109                    r.renderGroundTile(shadowSimulator.Instance.textures[map.Tiles[x, y].textureId], x, y); 
    87110                } 
    88111            } 
     
    90113 
    91114            renderGroundObjects(matrix); 
    92  
    93             r.spriteBatch.Begin(); 
    94  
    95             sunAngle += 1 / 3000.0f;//auringon pyörimisnopeus 
    96  
    97             sunPosition = baseSunPosition + new Vector3((float)Math.Sin(sunAngle), (float)Math.Cos(sunAngle), 0) * 100; 
    98  
    99             Vector3 fixedSun = sunPosition; 
    100             fixedSun.Z *= -1.0f; 
    101             fixedSun.Z += 22;//alaspäin että näkyy pelissä 
    102  
    103             Texture2D sunTexture = Pikseli.Instance.textures["taivas/aurinko"]; 
    104  
    105             r.renderDistantSprite(sunTexture, fixedSun, new Vector2(sunTexture.Width * camera.zoomFactor * 5, sunTexture.Height * camera.zoomFactor * 5), matrix); 
    106             r.spriteBatch.End(); 
    107115        } 
    108116    } 
  • 2014/30/MikkoI/WindowsGame1/WindowsGame1/WindowsGame1/Render/MasterRenderer.cs

    r5626 r5693  
    66using Microsoft.Xna.Framework.Graphics; 
    77 
    8 namespace WindowsGame1 
     8namespace ShadowSimulator2014 
    99{ 
    1010    public class MasterRenderer 
  • 2014/30/MikkoI/WindowsGame1/WindowsGame1/WindowsGame1/Render/RendererBase.cs

    r5626 r5693  
    66using Microsoft.Xna.Framework.Graphics; 
    77 
    8 namespace WindowsGame1 
     8namespace ShadowSimulator2014 
    99{ 
    1010    public class RendererBase 
     
    2424            spriteBatch.Draw(texture, new Rectangle((int)position.X, (int)position.Y, (int)size.X, (int)size.Y), null, Color.White, 0, Vector2.Zero, SpriteEffects.None, (position.Y + size.Y) / (camera.size.Y + 256*camera.zoomFactor/*128 on suurimman objektin korkeus*/)); 
    2525        } 
    26         public void renderDistantSprite(Texture2D texture, Vector3 position, Vector2 size, Matrix matrix) 
     26        public void renderDistantSprite(Texture2D texture, Vector3 position, Vector2 size, Matrix matrix, Camera camera) 
    2727        {//Renderöi kaukaisia juttuja kuten auringon ja tähdet 
    2828            Vector3 calcPosition = Vector3.Transform(position * 64.0f, matrix); 
    29             spriteBatch.Draw(texture, new Rectangle((int)(calcPosition.X), (int)(calcPosition.Y), (int)size.X, (int)size.Y), null, Color.White, 0f, new Vector2(texture.Width / 2, texture.Height / 2), SpriteEffects.None, 1f); 
     29            spriteBatch.Draw(texture, new Rectangle((int)(calcPosition.X), (int)(calcPosition.Y), (int)size.X, (int)size.Y), null, Color.White, 0f, new Vector2(texture.Width / 2, texture.Height / 2), SpriteEffects.None, (calcPosition.Y + size.Y) / (camera.size.Y + 256 * camera.zoomFactor/*128 on suurimman objektin korkeus*/)); 
    3030        } 
    3131        public void renderBackground(Texture2D texture, Vector2 size) 
  • 2014/30/MikkoI/frakt/frakt.sln

    r5558 r5693  
    44Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "frakt", "frakt\frakt\frakt.csproj", "{F9E4E698-C16A-4607-A0C5-F26305364268}" 
    55EndProject 
    6 Project("{96E2B04D-8817-42C6-938A-82C39BA4D311}") = "fraktContent", "frakt\fraktContent\fraktContent.contentproj", "{223295BE-ACF3-44C6-B8A3-41C3A9AB2E31}" 
     6Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "fraktContent", "frakt\fraktContent\fraktContent.contentproj", "{223295BE-ACF3-44C6-B8A3-41C3A9AB2E31}" 
    77EndProject 
    88Global 
  • 2014/30/MikkoI/frakt/frakt/frakt/Game1.cs

    r5656 r5693  
    1010using Microsoft.Xna.Framework.Input; 
    1111using Microsoft.Xna.Framework.Media; 
     12using System.IO; 
    1213 
    1314namespace frakt 
     
    2829        SpriteFont command; 
    2930 
     31        Vector2 imageSize = Vector2.Zero; 
     32 
    3033        Texture2D pixel; 
    31         Texture2D image; 
     34        System.Drawing.Bitmap image; 
     35        Texture2D referenceImage; 
    3236 
    3337        string commandStr = ""; 
    3438        bool infoHide = false; 
     39        string errorMessage = ""; 
    3540 
    3641        decimal[,][] pointData; 
     
    6570            pixel.SetData(new UInt32[] { UInt32.MaxValue }); 
    6671 
    67             image = new Texture2D(GraphicsDevice, 1, 1); 
    68  
    6972            base.Initialize(); 
    7073 
     
    7679            GraphicsDevice.Textures[0] = null; 
    7780 
    78             image = new Texture2D(GraphicsDevice, (int)calcResolution[0], (int)calcResolution[1]); 
     81            //if (calcResolution[0] > 2048) { calcResolution[0] = 2048; } 
     82            //if (calcResolution[1] > 2048) { calcResolution[1] = 2048; } 
     83 
     84            int threads = 1; 
     85 
     86            imageSize = new Vector2(calcResolution[0], calcResolution[1]); 
     87            if (image!=null) image.Dispose(); 
     88            System.Drawing.Bitmap[] images = new System.Drawing.Bitmap[threads]; 
    7989 
    8090            //alusta fraktaalin numeerinen data 
    81             this.pointData = new decimal[image.Width, image.Height][]; 
    82  
    83             int threads = 4; 
     91            this.pointData = new decimal[(int)imageSize.X, (int)imageSize.Y][]; 
     92 
     93            image = new System.Drawing.Bitmap((int)imageSize.X, (int)imageSize.Y); 
     94 
     95             
    8496            Thread[] apurit = new Thread[threads]; 
    8597 
    86             this.data = new Color[image.Width * image.Height]; 
    87             image.GetData(data); 
     98            this.data = new Color[(int)imageSize.X * (int)imageSize.Y]; 
    8899 
    89100            for (int y = 0; y < threads; y++) 
     
    92103                apurit[y] = new Thread(delegate(object o) 
    93104                { 
    94                     int alku = (image.Height / threads) * yy; 
    95                     int loppu = (image.Height / threads) * (yy + 1); 
    96                     if (yy == threads - 1) { loppu = image.Height; } 
     105                    int alku = ((int)imageSize.Y / threads) * yy; 
     106                    int loppu = ((int)imageSize.Y / threads) * (yy + 1); 
     107                    if (yy == threads - 1) { loppu = (int)imageSize.Y; } 
     108                     
    97109                    Test(alku, loppu); 
    98110                }); 
     
    106118            } 
    107119 
    108             image.SetData(data); 
     120            /*//yhdistä threadien omat imaget 
     121            int totalHeight = 0; 
     122            for (var g = 0; g < threads; g++) { totalHeight += images[g].Height; } 
     123 
     124            image = new System.Drawing.Bitmap((int)imageSize.X, (int)totalHeight); 
     125 
     126            */ 
     127 
     128            Vector2 refSize = new Vector2(Math.Min(image.Width, 2048), Math.Min(image.Height, 2048)); 
     129 
     130            Color[] pixels = new Color[(int)(refSize.X * refSize.Y)]; 
     131            for (int y = 0; y < refSize.Y; y++) 
     132            { 
     133                for (int x = 0; x < refSize.X; x++) 
     134                { 
     135                    System.Drawing.Color c = image.GetPixel(x, y); 
     136                    pixels[(y * (int)refSize.X) + x] = new Color(c.R, c.G, c.B, c.A); 
     137                } 
     138            } 
     139 
     140            referenceImage = new Texture2D(GraphicsDevice, (int)refSize.X, (int)refSize.Y); 
     141            referenceImage.SetData<Color>(pixels); 
    109142        } 
    110143 
     
    112145        { 
    113146            Random random = new Random(); 
     147 
     148            System.Drawing.Bitmap thisImage = new System.Drawing.Bitmap((int)imageSize.X, loppu - alku); 
     149 
    114150            for (int y = alku; y < loppu; y++) 
    115151            { 
    116                 for (int x = 0; x < image.Width; x++) 
    117                 { 
    118                     decimal VectorX = (gridScale[0] / image.Width) * x - (gridScale[0] / 2M) + gridOffset[0]; 
    119                     decimal VectorY = (gridScale[1] / image.Height) * y - (gridScale[1] / 2M) + gridOffset[1]; 
     152                for (int x = 0; x < imageSize.X; x++) 
     153                { 
     154                    decimal VectorX = (gridScale[0] / (int)imageSize.X) * x - (gridScale[0] / 2M) + gridOffset[0]; 
     155                    decimal VectorY = (gridScale[1] / (int)imageSize.Y) * y - (gridScale[1] / 2M) + gridOffset[1]; 
    120156                    pointData[x, y] = new decimal[4] { VectorX, VectorY, VectorX, VectorY }; 
    121157                    for (int iterations = 0; iterations < calcIterations; iterations++) 
     
    123159                        if (doesPointEscape(this.pointData[x, y])) 
    124160                        { 
    125                             this.data[x + y * image.Width] = getColor(iterations, calcIterations + 1); 
     161                            image.SetPixel(x, y, getColor(iterations, calcIterations + 1)); 
    126162                            break; 
    127163                        } 
     
    144180        { 
    145181            decimal[] nvec = new decimal[4]; 
     182            decimal branchLevel = 2M; 
    146183            nvec[0] = 
    147                 //1M * vec[0] - vec[1] * vec[1] - 1M * vec[1] * vec[0] * vec[0]; // branch 
    148                 vec[0] * vec[0] - vec[1] * vec[1] + vec[2]; // mandelbrot 
     184                branchLevel * vec[0] - vec[1] * vec[1] - branchLevel * vec[1] * vec[0] * vec[0]; // branch 
     185            //vec[0] * vec[0] - vec[1] * vec[1] + vec[2]; // mandelbrot 
    149186            nvec[1] = 
    150                 //1M * vec[1] - vec[0] * vec[0] - 1M * vec[0] * vec[1] * vec[1]; // branch 
    151                 2M * vec[0] * vec[1] + vec[3]; // mandelbrot 
     187                branchLevel * vec[1] - vec[0] * vec[0] - branchLevel * vec[0] * vec[1] * vec[1]; // branch 
     188            //2M * vec[0] * vec[1] + vec[3]; // mandelbrot 
    152189            nvec[2] = vec[2]; 
    153190            nvec[3] = vec[3]; 
     
    197234                switch (commandSplit[0]) 
    198235                { 
    199                     case "I": 
     236                    case "I"://set iterations 
    200237                        calcIterations = Convert.ToInt32(commandSplit[1]); 
    201238                        break; 
    202                     case "R": 
     239                    case "R"://set resolution 
    203240                        switch (commandSplit[1]) 
    204241                        { 
     
    213250                                calcResolution[1] = Window.ClientBounds.Height; 
    214251                                break; 
     252                            case "A": 
     253                                calcResolution[0] = Math.Max(calcResolution[0], calcResolution[1]); 
     254                                calcResolution[1] = Math.Max(calcResolution[0], calcResolution[1]); 
     255                                break; 
     256                            case "I": 
     257                                calcResolution[0] = Math.Min(calcResolution[0], calcResolution[1]); 
     258                                calcResolution[1] = Math.Min(calcResolution[0], calcResolution[1]); 
     259                                break; 
    215260                            default: 
    216261                                calcResolution[0] = Convert.ToInt32(commandSplit[1]); 
     
    219264                        } 
    220265                        break; 
    221                     case "P": 
     266                    case "P"://set position 
    222267                        switch (commandSplit[1]) 
    223268                        { 
     
    238283                        } 
    239284                        break; 
    240                     case "H": 
     285                    case "H"://hide / show hud 
    241286                        infoHide = !infoHide; 
    242287                        break; 
    243                     case "RUN": 
     288                    case "W"://set window size 
     289                        graphics.IsFullScreen = false; 
     290                        switch (commandSplit[1]) 
     291                        { 
     292                            case "X": 
     293                                graphics.PreferredBackBufferWidth = Convert.ToInt32(commandSplit[2]); 
     294                                break; 
     295                            case "Y": 
     296                                graphics.PreferredBackBufferHeight = Convert.ToInt32(commandSplit[2]); 
     297                                break; 
     298                            case "F": 
     299                                graphics.PreferredBackBufferWidth = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width; 
     300                                graphics.PreferredBackBufferHeight = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height; 
     301                                graphics.IsFullScreen = true; 
     302                                break; 
     303                            default: 
     304                                graphics.PreferredBackBufferWidth = Convert.ToInt32(commandSplit[1]); 
     305                                graphics.PreferredBackBufferHeight = Convert.ToInt32(commandSplit[1]); 
     306                                break; 
     307                        } 
     308                        graphics.ApplyChanges(); 
     309                        break; 
     310                    case "S"://Save image 
     311                        string filePath = ""; 
     312                        if (commandSplit.Length == 1) 
     313                        { 
     314                            filePath = DateTime.Now.ToString("MM-dd-yy H;mm;ss") + ".png"; 
     315                        } 
     316                        else 
     317                        { 
     318                            filePath = commandSplit[1] + ".png"; 
     319                        } 
     320                        //Stream stream = File.Create(filePath); 
     321                        image.Save(filePath); 
     322                        //stream.Dispose(); 
     323                        break; 
     324                    case "RUN"://render 
    244325                        renderImage(); 
    245326                        break; 
    246                 } 
    247             } 
    248             catch (System.Exception) {} 
     327                    case "EXIT"://exit 
     328                        Exit(); 
     329                        break; 
     330                } 
     331            } 
     332            catch (System.Exception e) 
     333            { 
     334                errorMessage = e.Message; 
     335            } 
    249336        } 
    250337 
     
    427514        /// </summary> 
    428515        /// <param name="gameTime">Provides a snapshot of timing values.</param> 
    429         Color getColor(float index, float size) 
     516        System.Drawing.Color getColor(float index, float size) 
    430517        { 
    431518            Color[] palette = { new Color(0, 0, 0), new Color(255, 0, 0), new Color(255, 255, 0), new Color(0, 255, 0), new Color(0, 255, 255), new Color(0, 0, 255), new Color(0, 0, 0) }; 
     
    437524            Color col2 = palette[(int)Math.Ceiling(realIndex)]; 
    438525            float rel = realIndex - (float)Math.Floor(realIndex); 
    439             return Color.Lerp(col1, col2, rel); 
     526            return convertColor(Color.Lerp(col1, col2, rel)); 
     527        } 
     528        System.Drawing.Color convertColor(Color color) 
     529        { 
     530            return System.Drawing.Color.FromArgb(color.R, color.G, color.B); 
    440531        } 
    441532        protected override void Draw(GameTime gameTime) 
     
    445536 
    446537            spriteBatch.Begin(); 
    447             spriteBatch.Draw(image, new Rectangle(0, 0, Window.ClientBounds.Width, Window.ClientBounds.Height), Color.White); 
     538            spriteBatch.Draw(referenceImage, new Rectangle(0, 0, Window.ClientBounds.Width, Window.ClientBounds.Height), Color.White); 
    448539            spriteBatch.DrawString(command, commandStr, new Vector2(0, 0), Color.Gray); 
    449540            if (!infoHide) 
    450             spriteBatch.DrawString(command, 
    451                 "i:" + calcIterations + " r:(" + calcResolution[0] + "," + calcResolution[1] + 
    452                 ")\nP:(" + gridOffset[0] + 
    453                 ",\n" + gridOffset[1] + 
    454                 ")\ns:" + gridScale[0] 
    455                 , new Vector2(0, Window.ClientBounds.Height - command.LineSpacing * 4), Color.Red); 
     541            { 
     542                spriteBatch.DrawString(command, 
     543                    "i:" + calcIterations + " r:(" + calcResolution[0] + "," + calcResolution[1] + 
     544                    ")\nP:(" + gridOffset[0] + 
     545                    ",\n" + gridOffset[1] + 
     546                    ")\ns:" + gridScale[0] 
     547                    , new Vector2(0, Window.ClientBounds.Height - command.LineSpacing * 4), Color.HotPink); 
     548                spriteBatch.DrawString(command, errorMessage, new Vector2(Window.ClientBounds.Width - command.MeasureString(errorMessage).X, 0), Color.Red); 
     549            } 
    456550            spriteBatch.End(); 
    457551 
  • 2014/30/MikkoI/frakt/frakt/frakt/frakt.csproj

    r5650 r5693  
    6767    <Reference Include="mscorlib" /> 
    6868    <Reference Include="System" /> 
     69    <Reference Include="System.Drawing" /> 
     70    <Reference Include="System.Windows.Forms" /> 
    6971    <Reference Include="System.Xml" /> 
    7072    <Reference Include="System.Core" /> 
  • 2014/30/MikkoI/rainbowSimulator/frakt.sln

    r5650 r5693  
    22Microsoft Visual Studio Solution File, Format Version 11.00 
    33# Visual Studio 2010 
    4 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "frakt", "frakt\frakt\frakt.csproj", "{F9E4E698-C16A-4607-A0C5-F26305364268}" 
     4Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "rainbowSimulator2014", "frakt\frakt\rainbowSimulator2014.csproj", "{F9E4E698-C16A-4607-A0C5-F26305364268}" 
    55EndProject 
    6 Project("{96E2B04D-8817-42C6-938A-82C39BA4D311}") = "fraktContent", "frakt\fraktContent\fraktContent.contentproj", "{223295BE-ACF3-44C6-B8A3-41C3A9AB2E31}" 
     6Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "fraktContent", "frakt\fraktContent\fraktContent.contentproj", "{223295BE-ACF3-44C6-B8A3-41C3A9AB2E31}" 
    77EndProject 
    88Global 
  • 2014/30/MikkoI/rainbowSimulator/frakt/frakt/Game1.cs

    r5650 r5693  
    1111using System.Threading; 
    1212 
    13 namespace frakt 
     13namespace rainbowSimulator 
    1414{ 
    1515    /// <summary> 
    1616    /// This is the main type for your game 
    1717    /// </summary> 
    18     public class WooooFract : Microsoft.Xna.Framework.Game 
     18    public class rainbowSimulator2014 : Microsoft.Xna.Framework.Game 
    1919    { 
    2020        GraphicsDeviceManager graphics; 
     
    3232 
    3333 
    34         public WooooFract() 
     34        public rainbowSimulator2014() 
    3535        { 
    3636            graphics = new GraphicsDeviceManager(this); 
    37             graphics.PreferredBackBufferWidth = 800; 
    38             graphics.PreferredBackBufferHeight = 600; 
     37            graphics.PreferredBackBufferWidth = 400; 
     38            graphics.PreferredBackBufferHeight = 300; 
    3939            Content.RootDirectory = "Content"; 
    4040        } 
     
    110110                    for (int x = 0; x < image.Width; x++) 
    111111                    { 
    112                         data[x + y * image.Width] = getColor(x + (float)random.NextDouble() * anim / 100 + anim, y + 2); 
     112                        data[x + y * image.Width] = getColor(x + anim, y+100); 
    113113                    } 
    114114                } 
  • 2014/30/MikkoI/rainbowSimulator/frakt/frakt/Program.cs

    r5650 r5693  
    11using System; 
    22 
    3 namespace frakt 
     3namespace rainbowSimulator 
    44{ 
    55#if WINDOWS || XBOX 
     
    1111        static void Main(string[] args) 
    1212        { 
    13             using (WooooFract game = new WooooFract()) 
     13            using (rainbowSimulator2014 game = new rainbowSimulator2014()) 
    1414            { 
    1515                game.Run(); 
Note: See TracChangeset for help on using the changeset viewer.