- Timestamp:
- 2014-07-23 17:40:30 (7 years ago)
- Location:
- 2014/30/MikkoI/WindowsGame1
- Files:
-
- 8 added
- 1 deleted
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
2014/30/MikkoI/WindowsGame1/WindowsGame1/WindowsGame1/Camera/Camera.cs
r5603 r5605 20 20 public Matrix getMatrix(Vector2 gridSize, Vector2 mapSize, Vector2 screenSize) 21 21 { 22 //viewPortBounds();22 viewPortBounds(); 23 23 24 24 Vector3 pixelMapSize = new Vector3((gridSize.X * mapSize.X / 2), (gridSize.Y * mapSize.Y / 2), 0); … … 34 34 35 35 //if (yaw < -70) { yaw = -70; } else if (yaw > 70) { yaw = 70; }//rajoita pyörittämistä (-70 - 70) 36 if (pitch < -8 8) { pitch = -88; } else if (pitch > -45) { pitch = -45; }//rajoittaa ylös-alas-liikettä37 if (zoomFactor < 0. 2f) { zoomFactor = 0.2f; } else if (zoomFactor > 3f) { zoomFactor = 3f; }//rajoittaa zoomia36 if (pitch < -82) { pitch = -82; } else if (pitch > -45) { pitch = -45; }//rajoittaa ylös-alas-liikettä 37 if (zoomFactor < 0.1f) { zoomFactor = 0.1f; } else if (zoomFactor > 3f) { zoomFactor = 3f; }//rajoittaa zoomia 38 38 } 39 39 } -
2014/30/MikkoI/WindowsGame1/WindowsGame1/WindowsGame1/Game1.cs
r5603 r5605 79 79 /*LOAD ALL TEXTURES*/ 80 80 textures.Add("testitile", Content.Load<Texture2D>("Graphics/Test/taso5.1")); 81 textures.Add("testipuu", Content.Load<Texture2D>("Graphics/Test/kuusi")); 82 textures.Add("aurinko", Content.Load<Texture2D>("Graphics/Taivas/Aurinko")); 81 82 //KÄYTETTÄVÄT PUUT 83 textures.Add("puut/kuusi", Content.Load<Texture2D>("Graphics/Puut/kuusi")); 84 textures.Add("puut/mänty", Content.Load<Texture2D>("Graphics/Puut/mänty")); 85 textures.Add("puut/ohut", Content.Load<Texture2D>("Graphics/Puut/ohut")); 86 textures.Add("puut/kuollut", Content.Load<Texture2D>("Graphics/Puut/kuollut")); 87 88 //TAIVAS 89 textures.Add("taivas/aurinko", Content.Load<Texture2D>("Graphics/Taivas/Aurinko")); 90 textures.Add("taivas/tähdet", Content.Load<Texture2D>("Graphics/Taivas/Tähdet")); 83 91 84 92 effect = new BasicEffect(GraphicsDevice); -
2014/30/MikkoI/WindowsGame1/WindowsGame1/WindowsGame1/Map/Map.cs
r5582 r5605 28 28 this.texture = texture;//DEBUG 29 29 30 this.Tiles = new Tile[w, h];30 this.Tiles = new Tile[w, h]; 31 31 32 32 texture.GetData(colorMap); … … 35 35 void buildMap() 36 36 { 37 for (var x = 0; x < Size.X; x++) { 38 for (var y = 0; y < Size.Y; y++) { 39 Tiles[x,y] = new Tile("testitile");//jotain shittiä myöhemmin 40 if (Pikseli.Instance.random.NextDouble()<0.1) 41 Objects.Add(new MapObject("testipuu", x, y)); 37 for (var x = 0; x < Size.X; x++) 38 { 39 for (var y = 0; y < Size.Y; y++) 40 { 41 Tiles[x, y] = new Tile("testitile");//jotain shittiä myöhemmin 42 if (Pikseli.Instance.random.NextDouble() > 0.1) { continue; } 43 44 string textureId = ""; 45 switch ((int)Math.Floor((double)(Pikseli.Instance.random.NextDouble() * 4))) 46 { 47 case 0: 48 textureId = "puut/kuollut"; 49 break; 50 case 1: 51 textureId = "puut/kuusi"; 52 break; 53 case 2: 54 textureId = "puut/mänty"; 55 break; 56 case 3: 57 textureId = "puut/ohut"; 58 break; 59 } 60 Objects.Add(new MapObject(textureId, x, y)); 42 61 } 43 62 } 44 45 63 64 46 65 } 47 66 } -
2014/30/MikkoI/WindowsGame1/WindowsGame1/WindowsGame1/Render/MapRenderer.cs
r5603 r5605 22 22 this.map = map; 23 23 this.screenSize = screenSize; 24 baseSunPosition = new Vector3(map.Size.X /2, map.Size.Y/2, 160);24 baseSunPosition = new Vector3(map.Size.X / 2, map.Size.Y / 2, 40); 25 25 } 26 26 void renderGroundTile(Texture2D texture, int x, int y) … … 35 35 } 36 36 37 void renderDistantSprite(Texture2D texture, Vector3 position, Vector2 size, Matrix matrix) 38 {//Renderöi kaukaisia juttuja kuten auringon ja tähdet 39 Vector3 calcPosition = Vector3.Transform(position * 64.0f, matrix); 40 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); 41 } 42 void renderBackground(Texture2D texture, Vector2 size) 43 { 44 spriteBatch.Draw(texture, new Rectangle(0, 0, (int)size.X, (int)size.Y), Color.White); 45 } 46 37 47 public void RenderMap(Camera camera) 38 48 {//renderöi koko mapin, kutsu ulkopuolelta 39 49 Matrix matrix = camera.getMatrix(new Vector2(64, 64), map.Size, screenSize);//mapin tilen koko 64x64 40 50 41 sunAngle += 1 /3000.0f;//auringon pyörimisnopeus51 sunAngle += 1 / 3000.0f;//auringon pyörimisnopeus 42 52 43 Vector3 sunPosition = baseSunPosition + new Vector3((float)Math.Sin(sunAngle), (float)Math.Cos(sunAngle), 0) * 400;53 Vector3 sunPosition = baseSunPosition + new Vector3((float)Math.Sin(sunAngle), (float)Math.Cos(sunAngle), 0) * 100; 44 54 45 55 spriteBatch.Begin(SpriteSortMode.FrontToBack, BlendState.AlphaBlend); 46 56 Vector3 fixedSun = sunPosition; 47 57 fixedSun.Z *= -1.0f; 48 fixedSun.Z += 162;//alaspäin että näkyy pelissä 49 Vector3 sun = Vector3.Transform(fixedSun * 64.0f, matrix); 50 Texture2D sunTexture = Pikseli.Instance.textures["aurinko"]; 51 spriteBatch.Draw(sunTexture, new Rectangle((int)(sun.X), (int)(sun.Y), sunTexture.Width, (int)(sunTexture.Height)), null, new Color(1f, 1f, 0f, 1f), 0f, new Vector2(sunTexture.Width / 2, sunTexture.Height / 2), SpriteEffects.None, 0f); 58 fixedSun.Z += 22;//alaspäin että näkyy pelissä 59 60 Texture2D sunTexture = Pikseli.Instance.textures["taivas/aurinko"]; 61 Texture2D starBackground = Pikseli.Instance.textures["taivas/tähdet"]; 62 63 renderDistantSprite(sunTexture, fixedSun, new Vector2(sunTexture.Width * camera.zoomFactor * 5, sunTexture.Height * camera.zoomFactor * 5), matrix); 64 renderBackground(starBackground, new Vector2(starBackground.Width, starBackground.Height)); 65 52 66 spriteBatch.End(); 53 67 … … 77 91 78 92 double dot = Vector3.Dot(Vector3.UnitZ, suunta); 79 double testi = 1.0 / dot;80 double shadowHeight = (28000.0 / sunPosition.Z);81 93 82 spriteBatch.Draw(texture, new Rectangle((int)((obj.position.X + 0.5) * 64), (int)((obj.position.Y + 0.5) * 64), texture.Width, (int)( testi* texture.Height - texture.Height)), null, new Color(0f, 0f, 0f, 0.5f), shadowAngle, new Vector2(texture.Width / 2, texture.Height), SpriteEffects.None, 0.5f);94 spriteBatch.Draw(texture, new Rectangle((int)((obj.position.X + 0.5) * 64), (int)((obj.position.Y + 0.5) * 64), texture.Width, (int)((1.0 / dot) * texture.Height - texture.Height)), null, new Color(0f, 0f, 0f, 0.5f), shadowAngle, new Vector2(texture.Width / 2, texture.Height), SpriteEffects.None, 0.5f); 83 95 //spriteBatch.Draw(obj.texture, new Rectangle((int)(obj.position.X + 0.5) * 64, (int)(obj.position.Y + 0.5) * 64, (int)obj.texture.Width, (int)obj.texture.Height), null, Color.Gray, MathHelper.ToRadians(30), new Vector2(obj.texture.Width / 2, obj.texture.Height), SpriteEffects.None, 0f); 84 96 } -
2014/30/MikkoI/WindowsGame1/WindowsGame1/WindowsGame1/WindowsGame1.csproj.Debug.cachefile
r5603 r5605 2 2 Content\Graphics\Test\Kuusi.xnb 3 3 Content\Graphics\Taivas\Aurinko.xnb 4 Content\Graphics\Puut\Kuollut.xnb 5 Content\Graphics\Puut\Kuusi.xnb 6 Content\Graphics\Puut\MÀnty.xnb 7 Content\Graphics\Puut\Ohut.xnb 8 Content\Graphics\Taivas\TÀhdet.xnb -
2014/30/MikkoI/WindowsGame1/WindowsGame1/WindowsGame1/obj/x86/Debug/WindowsGame1.csproj.FileListAbsolute.txt
r5603 r5605 8 8 C:\MyTemp\MikkoI\WindowsGame1\WindowsGame1\WindowsGame1\bin\x86\Debug\Content\Graphics\Test\Kuusi.xnb 9 9 C:\MyTemp\MikkoI\WindowsGame1\WindowsGame1\WindowsGame1\bin\x86\Debug\Content\Graphics\Taivas\Aurinko.xnb 10 D:\Csharp feat jypeli\MikkoI\WindowsGame1\WindowsGame1\WindowsGame1\bin\x86\Debug\Content\Graphics\Test\taso5.1.xnb 11 D:\Csharp feat jypeli\MikkoI\WindowsGame1\WindowsGame1\WindowsGame1\bin\x86\Debug\Content\Graphics\Test\Kuusi.xnb 12 D:\Csharp feat jypeli\MikkoI\WindowsGame1\WindowsGame1\WindowsGame1\bin\x86\Debug\Content\Graphics\Taivas\Aurinko.xnb 13 D:\Csharp feat jypeli\MikkoI\WindowsGame1\WindowsGame1\WindowsGame1\bin\x86\Debug\WindowsGame1.exe 14 D:\Csharp feat jypeli\MikkoI\WindowsGame1\WindowsGame1\WindowsGame1\bin\x86\Debug\WindowsGame1.pdb 15 D:\Csharp feat jypeli\MikkoI\WindowsGame1\WindowsGame1\WindowsGame1\obj\x86\Debug\WindowsGame1.csprojResolveAssemblyReference.cache 16 D:\Csharp feat jypeli\MikkoI\WindowsGame1\WindowsGame1\WindowsGame1\obj\x86\Debug\Microsoft.Xna.Framework.RuntimeProfile.txt 17 D:\Csharp feat jypeli\MikkoI\WindowsGame1\WindowsGame1\WindowsGame1\obj\x86\Debug\WindowsGame1.exe 18 D:\Csharp feat jypeli\MikkoI\WindowsGame1\WindowsGame1\WindowsGame1\obj\x86\Debug\WindowsGame1.pdb 19 D:\Csharp feat jypeli\MikkoI\WindowsGame1\WindowsGame1\WindowsGame1\bin\x86\Debug\Content\Graphics\Puut\Kuollut.xnb 20 D:\Csharp feat jypeli\MikkoI\WindowsGame1\WindowsGame1\WindowsGame1\bin\x86\Debug\Content\Graphics\Puut\Kuusi.xnb 21 D:\Csharp feat jypeli\MikkoI\WindowsGame1\WindowsGame1\WindowsGame1\bin\x86\Debug\Content\Graphics\Puut\MÀnty.xnb 22 D:\Csharp feat jypeli\MikkoI\WindowsGame1\WindowsGame1\WindowsGame1\bin\x86\Debug\Content\Graphics\Puut\Ohut.xnb 23 D:\Csharp feat jypeli\MikkoI\WindowsGame1\WindowsGame1\WindowsGame1\bin\x86\Debug\Content\Graphics\Taivas\TÀhdet.xnb -
2014/30/MikkoI/WindowsGame1/WindowsGame1/WindowsGame1/obj/x86/Debug/cachefile-{97A5BC4F-C40A-4D52-BF03-8923DFD60CA0}-targetpath.txt
r5603 r5605 2 2 Content\Graphics\Test\Kuusi.xnb 3 3 Content\Graphics\Taivas\Aurinko.xnb 4 Content\Graphics\Puut\Kuollut.xnb 5 Content\Graphics\Puut\Kuusi.xnb 6 Content\Graphics\Puut\MÀnty.xnb 7 Content\Graphics\Puut\Ohut.xnb 8 Content\Graphics\Taivas\TÀhdet.xnb -
2014/30/MikkoI/WindowsGame1/WindowsGame1/WindowsGame1Content/WindowsGame1Content.contentproj
r5603 r5605 51 51 </Compile> 52 52 </ItemGroup> 53 <ItemGroup> 54 <Compile Include="Graphics\Puut\Kuollut.png"> 55 <Name>Kuollut</Name> 56 <Importer>TextureImporter</Importer> 57 <Processor>TextureProcessor</Processor> 58 </Compile> 59 <Compile Include="Graphics\Puut\Kuusi.png"> 60 <Name>Kuusi</Name> 61 <Importer>TextureImporter</Importer> 62 <Processor>TextureProcessor</Processor> 63 </Compile> 64 <Compile Include="Graphics\Puut\Mänty.png"> 65 <Name>Mänty</Name> 66 <Importer>TextureImporter</Importer> 67 <Processor>TextureProcessor</Processor> 68 </Compile> 69 <Compile Include="Graphics\Puut\Ohut.png"> 70 <Name>Ohut</Name> 71 <Importer>TextureImporter</Importer> 72 <Processor>TextureProcessor</Processor> 73 </Compile> 74 </ItemGroup> 75 <ItemGroup> 76 <Compile Include="Graphics\Taivas\Tähdet.png"> 77 <Name>Tähdet</Name> 78 <Importer>TextureImporter</Importer> 79 <Processor>TextureProcessor</Processor> 80 </Compile> 81 </ItemGroup> 53 82 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 54 83 <!-- To modify your build process, add your task inside one of the targets below and uncomment it. -
2014/30/MikkoI/WindowsGame1/WindowsGame1/WindowsGame1Content/obj/x86/Debug/WindowsGame1Content.contentproj.FileListAbsolute.txt
r5558 r5605 1 1 C:\MyTemp\MikkoI\WindowsGame1\WindowsGame1\WindowsGame1Content\obj\x86\Debug\WindowsGame1Content.contentprojResolveAssemblyReference.cache 2 D:\Csharp feat jypeli\MikkoI\WindowsGame1\WindowsGame1\WindowsGame1Content\obj\x86\Debug\WindowsGame1Content.contentprojResolveAssemblyReference.cache
Note: See TracChangeset
for help on using the changeset viewer.