- Timestamp:
- 2012-06-13 15:04:53 (11 years ago)
- Location:
- 2012/24/TatuS/Tasohyppelypeli1
- Files:
-
- 8 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
2012/24/TatuS/Tasohyppelypeli1/Tasohyppelypeli1/Tasohyppelypeli1/Stickman Fight.cs
r2961 r3004 20 20 SoundEffect maaliAani = LoadSoundEffect("maali"); 21 21 22 PlatformCharacter pelaaja2; 23 Image pojankuva = LoadImage("poika"); 24 List<Label> valikonKohdat; 22 25 public override void Begin() 23 26 { 27 Valikko(); 28 29 24 30 Gravity = new Vector(0, -1000); 25 31 … … 27 33 lisaaNappaimet(); 28 34 35 29 36 Camera.Follow(pelaaja1); 30 Camera.ZoomFactor = 731 ; 37 Camera.ZoomFactor = 2; 38 32 39 Camera.StayInLevel = true; 33 } 40 41 42 43 } 44 void Valikko() 45 { 46 ClearAll(); 47 48 Level.BackgroundColor = Color.Blue; 49 50 valikonKohdat = new List<Label>(); 51 52 Label kohta1 = new Label("Aloita Uusi Peli"); 53 kohta1.Position = new Vector(0, 40); 54 valikonKohdat.Add(kohta1); 55 56 Label kohta2 = new Label("Lopeta Peli"); 57 kohta2.Position = new Vector(0, -40); 58 valikonKohdat.Add(kohta2); 59 60 foreach (Label valikonKohta in valikonKohdat) 61 { 62 Add(valikonKohta); 63 } 64 65 Mouse.ListenOn(kohta1, MouseButton.Left, ButtonState.Pressed, AloitaPeli, null); 66 Mouse.ListenOn(kohta2, MouseButton.Left, ButtonState.Pressed, Exit, null); 67 68 Mouse.IsCursorVisible = true; 69 Mouse.ListenMovement(1.0, ValikossaLiikkuminen, null); 70 Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, ""); 71 72 73 } 74 75 void ValikossaLiikkuminen(AnalogState hiirenTila) 76 { 77 foreach (Label kohta in valikonKohdat) 78 { 79 if (Mouse.IsCursorOn(kohta)) 80 { 81 kohta.TextColor = Color.Red; 82 } 83 else 84 { 85 kohta.TextColor = Color.Black; 86 } 87 88 } 89 } 90 91 void AloitaPeli() 92 { 93 ClearAll(); 94 Keyboard.Listen(Key.Escape, ButtonState.Pressed, Valikko, "Palaa Valikkoon"); 95 } 96 97 98 99 100 101 102 34 103 35 104 void luoKentta() 36 105 { 37 TileMap kentta = TileMap.From File("kentta1.txt");106 TileMap kentta = TileMap.FromLevelAsset("kentta1"); 38 107 kentta.SetTileMethod('#', lisaaTaso); 39 108 kentta.SetTileMethod('*', lisaaTahti); 40 109 kentta.SetTileMethod('N', lisaaPelaaja); 110 kentta.SetTileMethod('P', lisaapelaaja2); 41 111 kentta.Execute(RUUDUN_KOKO, RUUDUN_KOKO); 42 112 Level.CreateBorders(); 43 113 Level.Background.CreateGradient(Color.White, Color.SkyBlue); 44 114 } 115 116 45 117 46 118 void lisaaTaso(Vector paikka, double leveys, double korkeus) … … 66 138 pelaaja1 = new PlatformCharacter(leveys, korkeus); 67 139 pelaaja1.Position = paikka; 68 pelaaja1.Mass = 4.0;140 pelaaja1.Mass = 10.0; 69 141 pelaaja1.Image = kuva; 70 142 AddCollisionHandler(pelaaja1, kasittelePelaajanTormays); 71 pelaaja1.Weapon = new PlasmaCannon(20, 5);143 pelaaja1.Weapon = new AssaultRifle(18, 5); 72 144 Add(pelaaja1); 73 } ase.Angle += Angle FromDegrees(5); 145 } 146 147 void lisaapelaaja2(Vector Kohde, double leveys, double korkeus) 148 { 149 pelaaja2 = new PlatformCharacter(leveys, korkeus); 150 pelaaja2.Position = Kohde; 151 pelaaja2.Mass = 0.05; 152 pelaaja2.Image = pojankuva; 153 pelaaja2.Tag = "pelaaja2"; 154 pelaaja2.Weapon = new AssaultRifle(18, 5); 155 Add(pelaaja2); 156 157 FollowerBrain seuraajanAivot = new FollowerBrain(); 158 seuraajanAivot.Target = pelaaja1; 159 seuraajanAivot.Speed = 100; 160 seuraajanAivot.StopWhenTargetClose = false; 161 seuraajanAivot.TargetFollowDistance = 50; 162 seuraajanAivot.FollowAlways = true; 163 seuraajanAivot.Active = true; 164 pelaaja2.Brain = seuraajanAivot; 165 166 167 } 168 169 void AmmusOsui(PhysicsObject Ammus, PhysicsObject Kohde) 170 { 171 172 Explosion rajahdys = new Explosion(50); 173 rajahdys.Position = Ammus.Position; 174 Ammus.Destroy(); 175 } 176 177 void kentta() 178 { 179 Camera.Follow(pelaaja1, pelaaja2); 180 Camera.ZoomFactor = 2.0; 181 Camera.StayInLevel = true; 182 } 183 184 74 185 void AmmuAseella() 75 186 { … … 77 188 if (ammus != null) 78 189 { 79 ammus.Size *= 3; 80 } 81 } 190 ammus.Size *= 0.5; 191 } 192 } 193 void TahtaaYlos() 194 { 195 if (pelaaja1.FacingDirection == Direction.Right) 196 { 197 pelaaja1.Weapon.Angle += Angle.FromDegrees(6); 198 } 199 if (pelaaja1.FacingDirection == Direction.Left) 200 { 201 pelaaja1.Weapon.Angle += Angle.FromDegrees(-6); 202 } 203 } 204 205 void TahtaaAlas() 206 { 207 if (pelaaja1.FacingDirection == Direction.Right) 208 { 209 pelaaja1.Weapon.Angle += Angle.FromDegrees(-6); 210 } 211 if (pelaaja1.FacingDirection == Direction.Left) 212 { 213 pelaaja1.Weapon.Angle += Angle.FromDegrees(6); 214 } 215 } 216 217 218 void KasitteleVihollinenKuoli(PhysicsObject Ammus, PhysicsObject kohde) 219 { 220 if (kohde.Tag.ToString() == "pelaaja2") 221 { 222 kohde.Destroy(); 223 } 224 225 } 226 227 void JokuTormasi(PhysicsObject tormaaja, PhysicsObject kohde) 228 { 229 } 230 231 232 82 233 83 234 void lisaaNappaimet() … … 97 248 ControllerOne.Listen(Button.A, ButtonState.Pressed, hyppaa, "Pelaaja hyppää", pelaaja1, hyppyNopeus); 98 249 250 Keyboard.Listen(Key.W, ButtonState.Down, TahtaaYlos, "Tähtää ylös rynnäkkökiväärillä"); 251 Keyboard.Listen(Key.S, ButtonState.Down, TahtaaAlas, "Tähtää alas rynnäkkökiväärillä"); 252 253 99 254 PhoneBackButton.Listen(ConfirmExit, "Lopeta peli"); 100 255 } … … 112 267 void kasittelePelaajanTormays(PhysicsObject hahmo, PhysicsObject kohde) 113 268 { 114 if (kohde.Tag.ToString() == "tahti") 115 { 116 maaliAani.Play(); 117 MessageDisplay.Add("Keräsit tähden!"); 118 kohde.Destroy(); 119 } 120 121 } 269 if (kohde.Tag.ToString() == "pelaaja2") 270 { 271 272 273 } 274 275 } 276 277 278 122 279 } -
2012/24/TatuS/Tasohyppelypeli1/Tasohyppelypeli1/Tasohyppelypeli1/Tasohyppelypeli1.csproj.Debug.cachefile
r2961 r3004 3 3 Content\tahti.xnb 4 4 Content\pelaaja1.xnb 5 Content\kentta1.xnb 6 Content\poika.xnb 7 Content\kentta1.txt 5 8 kentta1.txt -
2012/24/TatuS/Tasohyppelypeli1/Tasohyppelypeli1/Tasohyppelypeli1/obj/x86/Debug/ContentPipeline-{5AB5800E-57D2-49A9-AE03-8CB790FE286B}.xml
r2961 r3004 37 37 <Output>C:\MyTemp\TatuS\Tasohyppelypeli1\Tasohyppelypeli1\Tasohyppelypeli1\bin\x86\Debug\Content\pelaaja1.xnb</Output> 38 38 <Time>2012-06-12T14:03:07.1052195+03:00</Time> 39 </Item> 40 <Item> 41 <Source>kentta1.txt</Source> 42 <Name>kentta1</Name> 43 <Importer>TextFileImporter</Importer> 44 <Processor>TextFileContentProcessor</Processor> 45 <Options>None</Options> 46 <Output>C:\MyTemp\TatuS\Tasohyppelypeli1\Tasohyppelypeli1\Tasohyppelypeli1\bin\x86\Debug\Content\kentta1.xnb</Output> 47 <Time>2012-06-13T13:50:40.9804236+03:00</Time> 48 </Item> 49 <Item> 50 <Source>poika.png</Source> 51 <Name>poika</Name> 52 <Importer>TextureImporter</Importer> 53 <Processor>TextureProcessor</Processor> 54 <Options>None</Options> 55 <Output>C:\MyTemp\TatuS\Tasohyppelypeli1\Tasohyppelypeli1\Tasohyppelypeli1\bin\x86\Debug\Content\poika.xnb</Output> 56 <Time>2012-06-13T12:24:05.6658537+03:00</Time> 39 57 </Item> 40 58 <BuildSuccessful>true</BuildSuccessful> -
2012/24/TatuS/Tasohyppelypeli1/Tasohyppelypeli1/Tasohyppelypeli1/obj/x86/Debug/Tasohyppelypeli1.csproj.FileListAbsolute.txt
r2961 r3004 12 12 C:\MyTemp\TatuS\Tasohyppelypeli1\Tasohyppelypeli1\Tasohyppelypeli1\obj\x86\Debug\Tasohyppelypeli1.pdb 13 13 C:\MyTemp\TatuS\Tasohyppelypeli1\Tasohyppelypeli1\Tasohyppelypeli1\bin\x86\Debug\Content\pelaaja1.xnb 14 C:\MyTemp\TatuS\Tasohyppelypeli1\Tasohyppelypeli1\Tasohyppelypeli1\bin\x86\Debug\Content\kentta1.xnb 15 C:\MyTemp\TatuS\Tasohyppelypeli1\Tasohyppelypeli1\Tasohyppelypeli1\bin\x86\Debug\Content\kentta1.txt 16 C:\MyTemp\TatuS\Tasohyppelypeli1\Tasohyppelypeli1\Tasohyppelypeli1\bin\x86\Debug\Content\poika.xnb -
2012/24/TatuS/Tasohyppelypeli1/Tasohyppelypeli1/Tasohyppelypeli1/obj/x86/Debug/cachefile-{5AB5800E-57D2-49A9-AE03-8CB790FE286B}-targetpath.txt
r2961 r3004 3 3 Content\tahti.xnb 4 4 Content\pelaaja1.xnb 5 Content\kentta1.xnb 6 Content\poika.xnb 7 Content\kentta1.txt -
2012/24/TatuS/Tasohyppelypeli1/Tasohyppelypeli1/Tasohyppelypeli1Content/Tasohyppelypeli1Content.contentproj
r2961 r3004 68 68 </Compile> 69 69 </ItemGroup> 70 <ItemGroup> 71 <Compile Include="kentta1.txt"> 72 <CopyToOutputDirectory>Always</CopyToOutputDirectory> 73 <Name>kentta1</Name> 74 <Importer>TextFileImporter</Importer> 75 <Processor>TextFileContentProcessor</Processor> 76 </Compile> 77 </ItemGroup> 78 <ItemGroup> 79 <Compile Include="poika.png"> 80 <Name>poika</Name> 81 <Importer>TextureImporter</Importer> 82 <Processor>TextureProcessor</Processor> 83 </Compile> 84 </ItemGroup> 70 85 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 71 86 <!-- 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.