- Timestamp:
- 2013-06-06 19:44:36 (10 years ago)
- Location:
- 2013/23/NicoA
- Files:
-
- 45 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
2013/23/NicoA/peli1/peli1/peli1/peli1.cs
r3977 r4000 39 39 public class peli1 : PhysicsGame 40 40 { 41 Image pelaajankuva = LoadImage("pelaaja ");41 Image pelaajankuva = LoadImage("pelaaja1"); 42 42 Image talokuva = LoadImage("talo"); 43 43 Image taustakuva = LoadImage("maa"); … … 48 48 Image elamakuva = LoadImage("elamat"); 49 49 Image elamakuvat = LoadImage("elamat2"); 50 Image metsakuva = LoadImage("metsä"); 51 Image lattiakuva = LoadImage("lattia"); 50 52 51 53 private Image[] palikanliikkuminen = LoadImages("palikka", "palikka2", "palikka3"); 54 private Image[] miekkaisku = LoadImages("miekka1", "miekka2", "miekka3", "miekka4", "miekka5", "miekka6", "miekka7", "miekka8", "miekka9", "miekka10"); 55 private Image[] puuanim = LoadImages("puu1", "puu2", "puu3", "puu4", "puu5"); 52 56 53 57 Vector aloituspaikka; … … 61 65 { 62 66 63 LuoKentta ();67 LuoKentta2(); 64 68 65 69 Camera.Follow(pelaaja1); … … 103 107 pelaaja1ElamaPalkki.BarImage = LoadImage("elamat"); 104 108 Add(pelaaja1ElamaPalkki); 105 106 107 108 109 110 111 112 Widget kuva = new Widget(40, 40); 113 kuva.Color = Color.Red; 114 kuva.Image = LoadImage("ympyra"); 115 kuva.X = Screen.Left + Screen.Width / 20; 116 kuva.Y = Screen.Top - 40; 117 Add(kuva); 109 118 110 119 … … 176 185 kentta.SetTileMethod('S', LisaaVihollinen); 177 186 kentta.SetTileMethod('Y', LisaaYmpyra); 187 kentta.SetTileMethod('U', LisaaPuu); 188 kentta.SetTileMethod('M', LisaaMetsa); 178 189 179 190 kentta.Execute(25, 25); … … 189 200 } 190 201 202 void LuoKentta2() 203 { 204 TileMap kentta2 = TileMap.FromLevelAsset("Taso2"); 205 206 kentta2.SetTileMethod('P', LisaaPelaaja); 207 kentta2.SetTileMethod('T', LisaaTalo); 208 kentta2.SetTileMethod('K', LisaaKolikko); 209 kentta2.SetTileMethod('S', LisaaVihollinen); 210 kentta2.SetTileMethod('Y', LisaaYmpyra); 211 kentta2.SetTileMethod('U', LisaaPuu); 212 kentta2.SetTileMethod('M', LisaaMetsa); 213 214 kentta2.Execute(25, 25); 215 //Level.CreateBorders(); 216 Level.Background.Image = lattiakuva; 217 Level.Background.TileToLevel(); 218 Add(esineet); 219 esineet.IsVisible = false; 220 PushButton button = new PushButton("Close"); 221 button.Clicked += SuljeInventory; 222 esineet.Add(button); 223 //Level.Background.CreateGradient(Color.Green, Color.SkyBlue); 224 } 225 191 226 192 227 void SuljeInventory() … … 199 234 { 200 235 aloituspaikka = paikka; 201 pelaaja1 = new Pelaaja( 75, 75);236 pelaaja1 = new Pelaaja(50, 70); 202 237 pelaaja1.Image = pelaajankuva; 203 238 pelaaja1.Shape = Shape.FromImage(pelaajankuva); … … 225 260 //Add(pelaajan1miekka); 226 261 227 pelaajan1miekka = new AssaultRifle(60, 5); 228 pelaajan1miekka.Image = miekkakuva; 262 pelaajan1miekka = new AssaultRifle(50, 20); 263 //pelaajan1miekka.Image = miekkakuva; 264 265 pelaajan1miekka.Animation = new Animation (miekkaisku); 266 //miekka.Animation = new Animation(miekkaisku); 267 pelaajan1miekka.Animation.FPS = 70; 268 pelaajan1miekka.Animation.Played += delegate { pelaajan1miekka.IsVisible = false; }; 269 229 270 pelaaja1.Add(pelaajan1miekka); 230 271 AddCollisionHandler<IPhysicsObject, IPhysicsObject>(pelaaja1, "vihollinen", vihollinentormaa); … … 274 315 //ajastin.Start(1); 275 316 miekka.IsVisible = true; 276 miekka.Animation.Start(); 277 miekka.Animation.Played += delegate { miekka.IsVisible = false; }; 317 318 miekka.Animation.Start(1); 319 278 320 PhysicsObject ammus = miekka.Shoot(); 279 321 if (ammus == null) return; … … 286 328 void LisaaVihollinen(Vector paikka, double x, double y) 287 329 { 288 Vihu vihollinen = new Vihu( 60, 60);330 Vihu vihollinen = new Vihu(40, 40); 289 331 vihollinen.Position = paikka; 290 332 vihollinen.Tag = "vihollinen"; … … 298 340 vihollinen.Animation.Start(); 299 341 vihollinen.Animation.FPS = 7; 300 vihollinen.ElamaLaskuri.LowerLimit += delegate { vihollinen.Destroy(); }; 342 343 vihollinen.ElamaLaskuri.LowerLimit += delegate { vihollinenkuolee(vihollinen); }; 301 344 302 345 AddCollisionHandler<IPhysicsObject, IPhysicsObject>(vihollinen, "miekka", miekkaosui); … … 305 348 aivot.WanderRadius = 280; 306 349 vihollinen.Brain = aivot; 307 308 350 } 351 352 void vihollinenkuolee(Vihu vihollinen) 353 { 354 vihollinen.Destroy(); 355 Timer.SingleShot(4, delegate { LisaaVihollinen(vihollinen.Position, vihollinen.Width, vihollinen.Height); }); 309 356 } 310 357 … … 353 400 } 354 401 402 void LisaaPuu(Vector paikka, double x, double y) 403 { 404 GameObject puu = new GameObject(90, 150); 405 puu.Position = paikka; 406 //puu.Image = puukuva; 407 puu.Tag = "puu"; 408 Add(puu,1); 409 //puu.CollisionIgnoreGroup = 1; 410 411 PhysicsObject Puu = PhysicsObject.CreateStaticObject(20, 15); 412 Puu.Tag = "Puu"; 413 Puu.X = puu.X; 414 Puu.Y = puu.Y -70; 415 Puu.IsVisible = false; 416 Add(Puu); 417 418 puu.Animation = new Animation(puuanim); 419 puu.Animation.Start(); 420 puu.Animation.FPS = 7; 421 } 422 423 void LisaaMetsa(Vector paikka, double x, double y) 424 { 425 PhysicsObject metsa = PhysicsObject.CreateStaticObject(50, 70); 426 metsa.Position = paikka; 427 metsa.Image = metsakuva; 428 metsa.Tag = "metsa"; 429 Add(metsa); 430 metsa.CollisionIgnoreGroup = 1; 431 432 } 433 355 434 void TormaaKolikkoon(PhysicsObject pelaaja1, PhysicsObject kolikko) 356 435 { … … 360 439 void LisaaYmpyra(Vector paikka, double x, double y) 361 440 { 362 PhysicsObject ympyra = PhysicsObject.CreateStaticObject( 90, 70);441 PhysicsObject ympyra = PhysicsObject.CreateStaticObject(150, 70); 363 442 ympyra.IgnoresCollisionResponse = true; 364 443 ympyra.Position = paikka; -
2013/23/NicoA/peli1/peli1/peli1Content/Taso1.txt
r3974 r4000 1 1 2 S3 S 4 2 MMMMMMMMM 3 S MMMMUMMMM 4 MMMMMMMMM 5 5 S 6 6 S 7 7 8 8 S Y 9 9 U T 10 10 11 11 P -
2013/23/NicoA/peli1/peli1/peli1Content/peli1Content.contentproj
r3977 r4000 136 136 </Compile> 137 137 </ItemGroup> 138 <ItemGroup> 139 <Compile Include="pelaaja1.png"> 140 <Name>pelaaja1</Name> 141 <Importer>TextureImporter</Importer> 142 <Processor>TextureProcessor</Processor> 143 </Compile> 144 </ItemGroup> 145 <ItemGroup> 146 <Compile Include="miekka1.png"> 147 <Name>miekka1</Name> 148 <Importer>TextureImporter</Importer> 149 <Processor>TextureProcessor</Processor> 150 </Compile> 151 </ItemGroup> 152 <ItemGroup> 153 <Compile Include="miekka2.png"> 154 <Name>miekka2</Name> 155 <Importer>TextureImporter</Importer> 156 <Processor>TextureProcessor</Processor> 157 </Compile> 158 </ItemGroup> 159 <ItemGroup> 160 <Compile Include="miekka3.png"> 161 <Name>miekka3</Name> 162 <Importer>TextureImporter</Importer> 163 <Processor>TextureProcessor</Processor> 164 </Compile> 165 </ItemGroup> 166 <ItemGroup> 167 <Compile Include="miekka4.png"> 168 <Name>miekka4</Name> 169 <Importer>TextureImporter</Importer> 170 <Processor>TextureProcessor</Processor> 171 </Compile> 172 </ItemGroup> 173 <ItemGroup> 174 <Compile Include="miekka5.png"> 175 <Name>miekka5</Name> 176 <Importer>TextureImporter</Importer> 177 <Processor>TextureProcessor</Processor> 178 </Compile> 179 </ItemGroup> 180 <ItemGroup> 181 <Compile Include="miekka6.png"> 182 <Name>miekka6</Name> 183 <Importer>TextureImporter</Importer> 184 <Processor>TextureProcessor</Processor> 185 </Compile> 186 </ItemGroup> 187 <ItemGroup> 188 <Compile Include="miekka7.png"> 189 <Name>miekka7</Name> 190 <Importer>TextureImporter</Importer> 191 <Processor>TextureProcessor</Processor> 192 </Compile> 193 </ItemGroup> 194 <ItemGroup> 195 <Compile Include="miekka8.png"> 196 <Name>miekka8</Name> 197 <Importer>TextureImporter</Importer> 198 <Processor>TextureProcessor</Processor> 199 </Compile> 200 </ItemGroup> 201 <ItemGroup> 202 <Compile Include="miekka9.png"> 203 <Name>miekka9</Name> 204 <Importer>TextureImporter</Importer> 205 <Processor>TextureProcessor</Processor> 206 </Compile> 207 </ItemGroup> 208 <ItemGroup> 209 <Compile Include="miekka10.png"> 210 <Name>miekka10</Name> 211 <Importer>TextureImporter</Importer> 212 <Processor>TextureProcessor</Processor> 213 </Compile> 214 </ItemGroup> 215 <ItemGroup> 216 <Compile Include="Taso2.txt"> 217 <Name>Taso2</Name> 218 <Importer>TextFileImporter</Importer> 219 <Processor>TextFileContentProcessor</Processor> 220 </Compile> 221 </ItemGroup> 222 <ItemGroup> 223 <Compile Include="puu1.png"> 224 <Name>puu1</Name> 225 <Importer>TextureImporter</Importer> 226 <Processor>TextureProcessor</Processor> 227 </Compile> 228 </ItemGroup> 229 <ItemGroup> 230 <Compile Include="puu2.png"> 231 <Name>puu2</Name> 232 <Importer>TextureImporter</Importer> 233 <Processor>TextureProcessor</Processor> 234 </Compile> 235 </ItemGroup> 236 <ItemGroup> 237 <Compile Include="puu3.png"> 238 <Name>puu3</Name> 239 <Importer>TextureImporter</Importer> 240 <Processor>TextureProcessor</Processor> 241 </Compile> 242 </ItemGroup> 243 <ItemGroup> 244 <Compile Include="puu4.png"> 245 <Name>puu4</Name> 246 <Importer>TextureImporter</Importer> 247 <Processor>TextureProcessor</Processor> 248 </Compile> 249 </ItemGroup> 250 <ItemGroup> 251 <Compile Include="puu5.png"> 252 <Name>puu5</Name> 253 <Importer>TextureImporter</Importer> 254 <Processor>TextureProcessor</Processor> 255 </Compile> 256 </ItemGroup> 257 <ItemGroup> 258 <Compile Include="metsä.png"> 259 <Name>metsä</Name> 260 <Importer>TextureImporter</Importer> 261 <Processor>TextureProcessor</Processor> 262 </Compile> 263 </ItemGroup> 264 <ItemGroup> 265 <Compile Include="lattia.png"> 266 <Name>lattia</Name> 267 <Importer>TextureImporter</Importer> 268 <Processor>TextureProcessor</Processor> 269 </Compile> 270 </ItemGroup> 138 271 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 139 272 <!-- 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.