- Timestamp:
- 2017-07-04 11:56:03 (6 years ago)
- Location:
- 2017/27/EeliN/Selviytyja
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
2017/27/EeliN/Selviytyja/Selviytyja/Selviytyja/Selviytyja.cs
r8842 r8864 11 11 int Speed = 100; 12 12 public Image idleRight = LoadImage("PlayerIdleRight_0"); 13 public Image puuimg = LoadImage("Tree_0"); 14 public Image stoneimg = LoadImage("Stone_0"); 13 15 private Image[] playerWalkR = LoadImages("PlayerWalkRight_0","PlayerWalkRight_1"); 14 16 Image idleLeft; 15 17 private Image[] playerWalkL; 18 Image Bg = LoadImage("grass"); 19 List<PhysicsObject> objektilista = new List<PhysicsObject>(); 16 20 public override void Begin() 17 21 { … … 19 23 SmoothTextures = false; 20 24 Player ukko = new Player(50, 50); 25 //ukko.MakeStatic(); 21 26 ukko.Image = idleRight; 27 ukko.CanRotate = false; 28 ukko.PlayerImageRight = idleRight; 29 ukko.PlayerImageLeft = Image.Mirror(idleRight.Clone()); 30 ukko.PlayerImage = ukko.PlayerImageRight; 22 31 //idleLeft = Image.Mirror(idleRight); 23 32 //playerWalkL = playerWalkR; … … 25 34 //playerWalkL[0] = Image.Mirror(playerWalkR[0]).Clone(); 26 35 ukko.PlayerWalkR = new Animation(playerWalkR); 27 //ukko.PlayerWalkL = Animation.Mirror(ukko.PlayerWalkR); 36 //ukko.PlayerWalkL = Animation.Mirror(ukko.PlayerWalkR.cl); 37 ukko.Restitution = 0; 28 38 Level.Background.Color = Color.Black; 29 39 Add(ukko); 40 Level.Background.Image = Bg; 41 Level.Background.TileToLevel(); 42 Camera.ZoomToLevel(); 43 LuoKiviRndm(); 44 LuoPuuRndm(); 45 30 46 31 47 … … 41 57 42 58 59 43 60 PhoneBackButton.Listen(ConfirmExit, "Lopeta peli"); 44 61 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 62 63 45 64 } 46 65 void MoveSideways(Player pelaaja, Vector direction) 47 66 { 48 67 pelaaja.Velocity = new Vector(direction.X, pelaaja.Velocity.Y); 49 PlayerAnimation(pelaaja, direction .X);68 PlayerAnimation(pelaaja, direction); 50 69 } 51 70 … … 53 72 { 54 73 pelaaja.Velocity = new Vector(pelaaja.Velocity.X, direction.Y); 55 //PlayerAnimation(pelaaja, direction.X); 56 } 57 58 public void PlayerAnimation(Player player, double direction) 59 { 60 player.PlayerAnimation(direction); 74 75 PlayerAnimation(pelaaja, direction); 76 } 77 78 public void PlayerAnimation(Player player, Vector direction) 79 { 80 MessageDisplay.Clear(); 81 MessageDisplay.Add("PlayerRight = " + player.PlayerRight + ", direction = " + direction); 82 if (direction.X != 0) 83 { 84 player.PlayerAnimation(direction.X); 85 return; 86 } 87 if (direction.Y != 0) 88 { 89 if (player.PlayerRight) player.Animation = player.PlayerWalkR; 90 else player.Animation = Animation.Mirror(player.PlayerWalkR); 91 92 } 93 else player.PlayerAnimation(0); 94 61 95 //if (direction == 0) player.Animation.Stop(); 62 96 //else 63 97 // player.Animation.Start(); 64 98 99 } 100 101 void LuoKivi(double x,double y) 102 { 103 PhysicsObject stone = PhysicsObject.CreateStaticObject(40, 40); 104 stone.Image = stoneimg; 105 stone.Shape = Shape.Circle; 106 stone.X = x; 107 stone.Restitution = 0; 108 stone.Y = y; 109 Add(stone); 110 objektilista.Add(stone); 111 for (int i = 0; i < objektilista.Count-1; i++) 112 { 113 if ((stone.Position - objektilista[i].Position).Magnitude < 90 ) 114 { 115 objektilista.Remove(stone); 116 stone.Destroy(); 117 } 118 } 119 } 120 121 void LuoKiviRndm() 122 { 123 for (int i = 0; i < 20; i++) 124 { 125 126 double x = RandomGen.NextDouble(Level.Left,Level.Right); 127 double y = RandomGen.NextDouble(Level.Bottom, Level.Top); 128 LuoKivi(x, y); 129 } 130 } 131 void LuoPuu(double x, double y) 132 { 133 PhysicsObject puu = PhysicsObject.CreateStaticObject(100, 100); 134 puu.Image = puuimg; 135 puu.X = x; 136 puu.Y = y; 137 Add(puu); 138 objektilista.Add(puu); 139 for (int i = 0; i < objektilista.Count - 1; i++) 140 { 141 if ((puu.Position - objektilista[i].Position).Magnitude < 90) 142 { 143 objektilista.Remove(puu); 144 puu.Destroy(); 145 } 146 } 147 } 148 149 void LuoPuuRndm() 150 { 151 for (int i = 0; i < 20; i++) 152 { 153 154 double x = RandomGen.NextDouble(Level.Left, Level.Right); 155 double y = RandomGen.NextDouble(Level.Bottom, Level.Top); 156 LuoPuu(x, y); 157 } 65 158 } 66 159 } … … 71 164 public Animation PlayerWalkL; 72 165 public Image PlayerImage; 166 public Image PlayerImageRight; 167 public Image PlayerImageLeft; 73 168 74 169 public Player(double leveys, double korkeus) … … 76 171 { 77 172 //idleRight = Selviytyja.Move(); 78 173 } 79 174 public void PlayerAnimation(double direction) 80 175 { 176 177 if (direction == 0 && PlayerImage == PlayerImageLeft) 178 { 179 this.Animation = null; 180 if (PlayerRight) 181 { 182 PlayerRight = true; 183 PlayerImage = (PlayerImageRight); 184 } 185 this.Image = (PlayerImage); 186 187 return; 188 } 189 else if (direction == 0 && PlayerImage == PlayerImageRight) 190 { 191 this.Animation = null; 192 if (PlayerRight == false) 193 { 194 PlayerRight = false; 195 PlayerImage = (PlayerImageLeft); 196 } 197 this.Image = (PlayerImage); 198 199 return; 200 } 201 81 202 if (direction < 0) 82 203 { 83 this.Animation = Animation.Mirror(PlayerWalkR); 84 this.Animation.Start(); 204 PlayerRight = false; 205 if (this.Animation.IsPlaying == false) 206 { 207 this.Animation = Animation.Mirror(PlayerWalkR); 208 this.Animation.Start(); 209 } 85 210 } 86 211 else if (direction > 0) 87 212 { 88 this.Animation = PlayerWalkR;89 this.Animation.Start();90 }91 92 93 if (PlayerRight == true)94 {95 PlayerImage = Image.Mirror(this.Image);96 this.Image = Image.Mirror(this.Image);97 PlayerRight = false;98 }99 else if (PlayerRight == false)100 {101 PlayerImage = Image.Mirror(this.Image);102 this.Image = Image.Mirror(this.Image);103 213 PlayerRight = true; 104 } 105 106 107 108 if (direction == 0) 109 { 110 //this.Animation = this.Image; 111 this.Animation = null; 112 this.Image = PlayerImage; 113 //return; 214 if (this.Animation.IsPlaying == false) 215 { 216 this.Animation = PlayerWalkR; 217 this.Animation.Start(); 218 } 114 219 } 115 220 if (this.Animation != null) this.Animation.FPS = 3; 116 } 221 222 223 224 225 226 227 } 228 117 229 } -
2017/27/EeliN/Selviytyja/Selviytyja/Selviytyja/Selviytyja.csproj.Debug.cachefile
r8842 r8864 2 2 Content\PlayerWalkRight_0.xnb 3 3 Content\PlayerWalkRight_1.xnb 4 Content\grass.xnb 5 Content\Tree_0.xnb 6 Content\Stone_0.xnb -
2017/27/EeliN/Selviytyja/Selviytyja/Selviytyja/obj/x86/Debug/ContentPipeline-{3B3FCF0A-DF81-4674-AF8D-360E80F14224}.xml
r8842 r8864 9 9 <Options>None</Options> 10 10 <Output>C:\MyTemp\EeliN\Selviytyja\Selviytyja\Selviytyja\bin\x86\Debug\Content\PlayerIdleRight_0.xnb</Output> 11 <Time>2017-07-0 3T13:04:51.8943462+03:00</Time>11 <Time>2017-07-04T11:52:16.3512078+03:00</Time> 12 12 </Item> 13 13 <Item> … … 18 18 <Options>None</Options> 19 19 <Output>C:\MyTemp\EeliN\Selviytyja\Selviytyja\Selviytyja\bin\x86\Debug\Content\PlayerWalkRight_0.xnb</Output> 20 <Time>2017-07-0 3T13:59:50.743235+03:00</Time>20 <Time>2017-07-04T11:53:34.9508947+03:00</Time> 21 21 </Item> 22 22 <Item> … … 27 27 <Options>None</Options> 28 28 <Output>C:\MyTemp\EeliN\Selviytyja\Selviytyja\Selviytyja\bin\x86\Debug\Content\PlayerWalkRight_1.xnb</Output> 29 <Time>2017-07-03T13:59:58.305269+03:00</Time> 29 <Time>2017-07-04T11:54:05.9596768+03:00</Time> 30 </Item> 31 <Item> 32 <Source>grass.png</Source> 33 <Name>grass</Name> 34 <Importer>TextureImporter</Importer> 35 <Processor>TextureProcessor</Processor> 36 <Options>None</Options> 37 <Output>C:\MyTemp\EeliN\Selviytyja\Selviytyja\Selviytyja\bin\x86\Debug\Content\grass.xnb</Output> 38 <Time>2017-07-04T10:32:44.2025662+03:00</Time> 39 </Item> 40 <Item> 41 <Source>Tree_0.png</Source> 42 <Name>Tree_0</Name> 43 <Importer>TextureImporter</Importer> 44 <Processor>TextureProcessor</Processor> 45 <Options>None</Options> 46 <Output>C:\MyTemp\EeliN\Selviytyja\Selviytyja\Selviytyja\bin\x86\Debug\Content\Tree_0.xnb</Output> 47 <Time>2017-07-04T11:55:15.7842714+03:00</Time> 48 </Item> 49 <Item> 50 <Source>Stone_0.png</Source> 51 <Name>Stone_0</Name> 52 <Importer>TextureImporter</Importer> 53 <Processor>TextureProcessor</Processor> 54 <Options>None</Options> 55 <Output>C:\MyTemp\EeliN\Selviytyja\Selviytyja\Selviytyja\bin\x86\Debug\Content\Stone_0.xnb</Output> 56 <Time>2017-07-04T11:54:41.2164752+03:00</Time> 30 57 </Item> 31 58 <BuildSuccessful>true</BuildSuccessful> -
2017/27/EeliN/Selviytyja/Selviytyja/Selviytyja/obj/x86/Debug/Selviytyja.csproj.FileListAbsolute.txt
r8842 r8864 10 10 C:\MyTemp\EeliN\Selviytyja\Selviytyja\Selviytyja\bin\x86\Debug\Content\PlayerWalkRight_0.xnb 11 11 C:\MyTemp\EeliN\Selviytyja\Selviytyja\Selviytyja\bin\x86\Debug\Content\PlayerWalkRight_1.xnb 12 C:\MyTemp\EeliN\Selviytyja\Selviytyja\Selviytyja\bin\x86\Debug\Content\grass.xnb 13 C:\MyTemp\EeliN\Selviytyja\Selviytyja\Selviytyja\bin\x86\Debug\Content\Tree_0.xnb 14 C:\MyTemp\EeliN\Selviytyja\Selviytyja\Selviytyja\bin\x86\Debug\Content\Stone_0.xnb -
2017/27/EeliN/Selviytyja/Selviytyja/Selviytyja/obj/x86/Debug/cachefile-{3B3FCF0A-DF81-4674-AF8D-360E80F14224}-targetpath.txt
r8842 r8864 2 2 Content\PlayerWalkRight_0.xnb 3 3 Content\PlayerWalkRight_1.xnb 4 Content\grass.xnb 5 Content\Tree_0.xnb 6 Content\Stone_0.xnb -
2017/27/EeliN/Selviytyja/Selviytyja/SelviytyjaContent/SelviytyjaContent.contentproj
r8842 r8864 66 66 </Compile> 67 67 </ItemGroup> 68 <ItemGroup> 69 <Compile Include="grass.png"> 70 <Name>grass</Name> 71 <Importer>TextureImporter</Importer> 72 <Processor>TextureProcessor</Processor> 73 </Compile> 74 </ItemGroup> 75 <ItemGroup> 76 <Compile Include="Tree_0.png"> 77 <Name>Tree_0</Name> 78 <Importer>TextureImporter</Importer> 79 <Processor>TextureProcessor</Processor> 80 </Compile> 81 </ItemGroup> 82 <ItemGroup> 83 <Compile Include="Stone_0.png"> 84 <Name>Stone_0</Name> 85 <Importer>TextureImporter</Importer> 86 <Processor>TextureProcessor</Processor> 87 </Compile> 88 </ItemGroup> 68 89 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 69 90 <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Note: See TracChangeset
for help on using the changeset viewer.