Changeset 2373
- Timestamp:
- 2011-06-30 14:58:08 (12 years ago)
- Location:
- 2011/26/VilleK/Tasohyppelypeli1/Tasohyppelypeli1
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
2011/26/VilleK/Tasohyppelypeli1/Tasohyppelypeli1/Tasohyppelypeli1/Peli.cs
r2309 r2373 10 10 { 11 11 const double nopeus = 200; 12 const double hyppyNopeus = 900;12 const double hyppyNopeus = 900; 13 13 const int RUUDUN_KOKO = 50; 14 14 15 15 PlatformCharacter pelaaja1; 16 16 17 IntMeter tolkkiLaskuri; 17 18 Image pelaajanKuva = LoadImage("juoppo"); 19 Image pelaajankuva2 = LoadImage("juoppo2"); 18 20 Image tollkinkuva = LoadImage("tolkki"); 19 21 Image ammo1a = LoadImage("ammo1a"); 22 20 23 SoundEffect maaliAani = LoadSoundEffect("maali"); 21 24 public override void Begin() … … 25 28 luoKentta(); 26 29 lisaaNappaimet(); 27 30 LuoLaskuri(); 31 LuoTolkkiLaskuri(); 28 32 Camera.Follow(pelaaja1); 29 33 Camera.ZoomFactor = 1.2; 30 34 Camera.StayInLevel = true; 35 } 36 37 void LuoTolkkiLaskuri() 38 { 39 tolkkiLaskuri = new IntMeter(0); 40 41 Label tolkkiNaytto = new Label(); 42 tolkkiNaytto.BindTo(tolkkiLaskuri); 43 tolkkiNaytto.X = Screen.Left + 50; 44 Add(tolkkiNaytto); 45 } 46 47 void LuoLaskuri() 48 { 49 Label pisteNaytto = new Label(); 50 pisteNaytto.X = Screen.Left + 50; 51 pisteNaytto.TextColor = Color.Red; 52 53 pisteNaytto.BindTo(pelaaja1.Weapon.Ammo); 54 Add(pisteNaytto); 55 56 Label pisteTeksti = new Label("ammukset"); 57 pisteTeksti.X = Screen.Left +130; 58 pisteTeksti.TextColor = Color.Red; 59 Add(pisteTeksti); 31 60 } 32 61 … … 37 66 kentta['*'] = lisaaTahti; 38 67 kentta['N'] = lisaaPelaaja; 68 kentta['a'] = lisaammo; 39 69 kentta.Insert(RUUDUN_KOKO, RUUDUN_KOKO); 40 70 Level.CreateBorders(); … … 48 78 return taso; 49 79 } 50 80 PhysicsObject lisaammo() 81 { 82 PhysicsObject ammo1 = PhysicsObject.CreateStaticObject(50, 40); 83 ammo1.Image = ammo1a; 84 ammo1.Tag = "ammo"; 85 return ammo1; 86 } 51 87 PhysicsObject lisaaTahti() 52 88 { 53 PhysicsObject tahti = PhysicsObject.CreateStaticObject( RUUDUN_KOKO, RUUDUN_KOKO);89 PhysicsObject tahti = PhysicsObject.CreateStaticObject(20, 30); 54 90 tahti.Image = tollkinkuva; 55 91 tahti.Tag = "tolkki"; … … 59 95 PlatformCharacter lisaaPelaaja() 60 96 { 61 pelaaja1 = new PlatformCharacter(40, 40);97 pelaaja1 = new PlatformCharacter(40, 80); 62 98 pelaaja1.Mass = 5.0; 63 99 //pelaaja1.Image = pelaajanKuva; 64 pelaaja1.Right IdleAnimation = new Animation(pelaajanKuva);100 pelaaja1.RightWalkingAnimation = new Animation(pelaajanKuva); 65 101 //juoppo2.image = pelaajankuva 66 pelaaja1.LeftIdleAnimation = new Animation(juoppo); 67 AddCollisionHandler(pelaaja1, osuTahteen); 102 pelaaja1.LeftWalkingAnimation = new Animation(pelaajankuva2); 103 pelaaja1.Weapon = new AssaultRifle(80, 20); 104 pelaaja1.Weapon.Ammo.Value = 10; 105 AddCollisionHandler(pelaaja1, pelaaja1törmäsi); 68 106 return pelaaja1; 107 108 } 109 void AmmusOsui(PhysicsObject ammus, PhysicsObject kohde) 110 { 111 ammus.Destroy(); 112 Explosion rajahdys = new Explosion(10); 113 rajahdys.Position = ammus.Position; 114 Add(rajahdys); 69 115 } 70 116 … … 77 123 Keyboard.Listen(Key.Right, ButtonState.Down, liikuta, "Liikkuu vasemmalle", pelaaja1, nopeus); 78 124 Keyboard.Listen(Key.Up, ButtonState.Pressed, hyppaa, "Pelaaja hyppää", pelaaja1, hyppyNopeus); 125 Keyboard.Listen(Key.Space, ButtonState.Down, AmmuAseella, "Ammu"); 79 126 80 127 ControllerOne.Listen(Button.Back, ButtonState.Pressed, Exit, "Poistu pelistä"); … … 83 130 ControllerOne.Listen(Button.DPadRight, ButtonState.Down, liikuta, "Pelaaja liikkuu oikealle", pelaaja1, nopeus); 84 131 ControllerOne.Listen(Button.A, ButtonState.Pressed, hyppaa, "Pelaaja hyppää", pelaaja1, hyppyNopeus); 132 } 133 void AmmuAseella() 134 { 135 PhysicsObject ammus = pelaaja1.Weapon.Shoot(); 136 137 if (ammus != null) 138 { 139 ammus.Size *= 1; 140 pelaaja1.Weapon.ProjectileCollision = AmmusOsui; 141 142 143 } 85 144 } 86 145 … … 95 154 } 96 155 97 void osuTahteen(PhysicsObject hahmo, PhysicsObject kohde)156 void pelaaja1törmäsi(PhysicsObject hahmo, PhysicsObject kohde) 98 157 { 99 158 if (kohde.Tag.ToString() == "tolkki") … … 101 160 maaliAani.Play(); 102 161 MessageDisplay.Add("Keräsit tölkin hurraa!"); 162 tolkkiLaskuri.Value++; 103 163 kohde.Destroy(); 104 164 } 105 } 165 if (kohde.Tag.ToString() == "ammo") 166 { 167 maaliAani.Play(); 168 MessageDisplay.Add("sait panoksia"); 169 pelaaja1.Weapon.Ammo.Value += 10; 170 kohde.Destroy(); 171 } 172 } 106 173 } 174 -
2011/26/VilleK/Tasohyppelypeli1/Tasohyppelypeli1/Tasohyppelypeli1/Tasohyppelypeli1.csproj.Debug.cachefile
r2299 r2373 5 5 Content\tolkki.xnb 6 6 Content\juoppo2.xnb 7 Content\ammo1a.xnb 7 8 kentta1.txt -
2011/26/VilleK/Tasohyppelypeli1/Tasohyppelypeli1/Tasohyppelypeli1/kentta1.txt
r2299 r2373 1 *#2 ## **#3 ###### # ##4 * *## #1 # 2 ## # 3 ###### # # 4 ## # 5 5 ## ## ## # 6 # ###7 * *#8 ####### ### #### ### ### ### ####### #6 # ## # 7 # 8 ####### ### #### ###a ### ### ####### # 9 9 # 10 * * * * 10 * * * * aaaa # # 11 11 ## ## ## ############################################################################################################# 12 12 # -
2011/26/VilleK/Tasohyppelypeli1/Tasohyppelypeli1/Tasohyppelypeli1Content/Tasohyppelypeli1Content.contentproj
r2299 r2373 80 80 </Compile> 81 81 </ItemGroup> 82 <ItemGroup> 83 <Compile Include="ammo1a.png"> 84 <Name>ammo1a</Name> 85 <Importer>TextureImporter</Importer> 86 <Processor>TextureProcessor</Processor> 87 </Compile> 88 </ItemGroup> 82 89 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 83 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.