- Timestamp:
- 2013-06-26 14:53:06 (10 years ago)
- Location:
- 2013/26/WilleK/Ensimmäinen Peli/Ensimmäinen Peli
- Files:
-
- 16 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
2013/26/WilleK/Ensimmäinen Peli/Ensimmäinen Peli/Ensimmäinen Peli/Ensimmäinen_Peli.cs
r4214 r4237 9 9 public class Ensimmäinen_Peli : PhysicsGame 10 10 { 11 IntMeter nopeus = new IntMeter(200);12 IntMeter hyppyNopeus = new IntMeter(700);11 IntMeter nopeus; 12 IntMeter hyppyNopeus; 13 13 const int RUUDUN_KOKO = 40; 14 14 15 Vector alkupiste; 15 Vector alkupiste; 16 16 17 17 PlatformCharacter pelaaja1; … … 22 22 Image LisäVoima = LoadImage("Voima"); 23 23 Image Ruoho = LoadImage("GrassTexture"); 24 Image Palikka2 = LoadImage("alkuun"); 25 Image tyyppiLyoKuva = LoadImage("TyyppiLyo"); 26 Image nyrkkikuva = LoadImage("Nyrkki"); 24 27 25 28 SoundEffect maaliAani = LoadSoundEffect("maali"); 26 27 29 DoubleMeter elamaLaskuri; 28 30 … … 34 36 public void AloitaPeli() 35 37 { 38 nopeus = new IntMeter(200); 39 hyppyNopeus = new IntMeter(700); 40 36 41 ClearAll(); 37 42 Gravity = new Vector(0, -1000); … … 43 48 Camera.ZoomFactor = 1.2; 44 49 Camera.StayInLevel = true; 50 MediaPlayer.Play("GroundTheme"); 51 MediaPlayer.IsRepeating = true; 52 MediaPlayer.Volume = 0.2; 45 53 } 46 54 … … 54 62 kentta.SetTileMethod("FF0000", LisaaVihu); 55 63 kentta.SetTileMethod("B6FF00", LisaaRuoho); 64 kentta.SetTileMethod("404040", Palikka3); 65 //kentta.SetTileMethod("") 56 66 kentta.Execute(RUUDUN_KOKO, RUUDUN_KOKO); 57 67 Level.Background.CreateGradient(Color.White, Color.SkyBlue); 68 } 69 70 void Palikka3(Vector paikka, double leveys, double korkeus) 71 { 72 PhysicsObject Palikka3 = PhysicsObject.CreateStaticObject(leveys, korkeus); 73 Palikka3.Image = Palikka2; 74 Palikka3.Position = paikka; 75 Add(Palikka3); 58 76 } 59 77 … … 147 165 Keyboard.Listen(Key.Right, ButtonState.Down, Liikuta, "Liikkuu vasemmalle", pelaaja1, nopeus, 1); 148 166 Keyboard.Listen(Key.Up, ButtonState.Pressed, Hyppaa, "Pelaaja hyppää", pelaaja1, hyppyNopeus); 167 Keyboard.Listen(Key.Space, ButtonState.Pressed, Lyo, "Pelaaja Lyö", pelaaja1); 168 149 169 150 170 ControllerOne.Listen(Button.Back, ButtonState.Pressed, Exit, "Poistu pelistä"); … … 155 175 156 176 PhoneBackButton.Listen(ConfirmExit, "Lopeta peli"); 177 } 178 179 void Lyo(PlatformCharacter hahmo) 180 { 181 hahmo.Image = tyyppiLyoKuva; 182 GameObject nyrkki = new GameObject(hahmo.Width, hahmo.Height); 183 nyrkki.Image = nyrkkikuva; 184 hahmo.Add(nyrkki); 185 int suunta = hahmo.FacingDirection == Direction.Right ? 1 : -1; 186 if (hahmo.FacingDirection == Direction.Left) nyrkki.Image = Image.Mirror(nyrkki.Image); 187 nyrkki.Position = new Vector(suunta * hahmo.Width, 0); 188 //nyrkki.Position = hahmo.Position + new Vector(hahmo.Width, 0); 189 //Add(nyrkki); 190 191 List<GameObject> vihutLahella = GetObjectsAt(hahmo.Position + nyrkki.Position, "pahis", nyrkki.Width); 192 vihutLahella.ForEach(x => x.Destroy()); 193 194 Timer.SingleShot(0.2, delegate 195 { 196 hahmo.Image = pelaajanKuva; 197 nyrkki.Destroy(); 198 }); 157 199 } 158 200 -
2013/26/WilleK/Ensimmäinen Peli/Ensimmäinen Peli/Ensimmäinen PeliContent/Ensimmäinen PeliContent.contentproj
r4214 r4237 90 90 </Compile> 91 91 </ItemGroup> 92 <ItemGroup> 93 <Compile Include="alkuun.png"> 94 <Name>alkuun</Name> 95 <Importer>TextureImporter</Importer> 96 <Processor>TextureProcessor</Processor> 97 </Compile> 98 </ItemGroup> 99 <ItemGroup> 100 <Compile Include="TyyppiLyo.png"> 101 <Name>TyyppiLyo</Name> 102 <Importer>TextureImporter</Importer> 103 <Processor>TextureProcessor</Processor> 104 </Compile> 105 </ItemGroup> 106 <ItemGroup> 107 <Compile Include="Nyrkki.png"> 108 <Name>Nyrkki</Name> 109 <Importer>TextureImporter</Importer> 110 <Processor>TextureProcessor</Processor> 111 </Compile> 112 </ItemGroup> 113 <ItemGroup> 114 <Compile Include="GroundTheme.mp3"> 115 <Name>GroundTheme</Name> 116 <Importer>Mp3Importer</Importer> 117 <Processor>SongProcessor</Processor> 118 </Compile> 119 </ItemGroup> 92 120 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 93 121 <!-- 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.