- Timestamp:
- 2012-07-04 15:00:47 (11 years ago)
- Location:
- 2012/27/LeoL/Marsun matkat/Marsun matkat
- Files:
-
- 8 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
2012/27/LeoL/Marsun matkat/Marsun matkat/Marsun matkat/Marsun_matkat.cs
r3493 r3553 17 17 Image pelaajanKuva = LoadImage("norsu"); 18 18 Image tahtiKuva = LoadImage("tahti"); 19 Image vihunKuva = LoadImage("mulkkis"); 20 Image psyykkisKuva = LoadImage("psyykkis"); 21 Image hyppisKuva = LoadImage("hyppis"); 22 23 IntMeter vihunHp = new IntMeter(3); 19 24 20 25 SoundEffect maaliAani = LoadSoundEffect("maali"); 21 26 27 int kentanNro = 1; 28 22 29 public override void Begin() 23 30 { 24 Gravity = new Vector(0, -1000);31 25 32 26 33 LuoKentta(); 27 LisaaNappaimet();28 34 29 Camera.Follow(pelaaja1);30 Camera.ZoomFactor = 1.2;31 Camera.StayInLevel = true;32 35 } 33 36 34 37 void LuoKentta() 35 38 { 36 TileMap kentta = TileMap.FromLevelAsset("kentta1"); 39 string kenttaNimi = "kentta1"; 40 if (kentanNro == 2) 41 { 42 kenttaNimi = "kentta2"; 43 } 44 if (kentanNro == 3) 45 { 46 kenttaNimi = "kentta3"; 47 } 48 ClearAll(); 49 Gravity = new Vector(0, -1000); 50 TileMap kentta = TileMap.FromLevelAsset(kenttaNimi); 37 51 kentta.SetTileMethod('#', LisaaTaso); 38 52 kentta.SetTileMethod('*', LisaaTahti); 39 53 kentta.SetTileMethod('N', LisaaPelaaja); 54 kentta.SetTileMethod('V', LisaaVihu1); 55 kentta.SetTileMethod('M', LisaaVihu2); 56 kentta.SetTileMethod('S', LisaaVihu3); 40 57 kentta.Execute(RUUDUN_KOKO, RUUDUN_KOKO); 41 58 Level.CreateBorders(); 42 59 Level.Background.CreateGradient(Color.White, Color.SkyBlue); 60 61 LisaaNappaimet(); 62 vihunHp.Value = 3; 63 Camera.Follow(pelaaja1); 64 Camera.ZoomFactor = 1.2; 65 Camera.StayInLevel = true; 66 67 } 68 69 void LisaaVihu1(Vector paikka, double leveys, double korkeus) 70 { 71 PhysicsObject vihu = new PhysicsObject(40, 20); 72 vihu.Shape = Shape.Rectangle; 73 vihu.Mass = 10.0; 74 vihu.Tag = "vihu"; 75 vihu.Image = vihunKuva; 76 Add(vihu); 77 } 78 79 void LisaaVihu2(Vector paikka, double leveys, double korkeus) 80 { 81 PhysicsObject vihu2 = new PhysicsObject(40, 20); 82 vihu2.Shape = Shape.Rectangle; 83 vihu2.Mass = 10.5; 84 vihu2.Tag = "vihu"; 85 vihu2.Image = psyykkisKuva; 86 Add(vihu2); 87 } 88 89 void LisaaVihu3(Vector paikka, double leveys, double korkeus) 90 { 91 PhysicsObject vihu2 = new PhysicsObject(40, 20); 92 vihu2.Shape = Shape.Rectangle; 93 vihu2.Mass = 10.5; 94 vihu2.Tag = "vihu"; 95 vihu2.Image = hyppisKuva; 96 Add(vihu2); 43 97 } 44 98 … … 67 121 pelaaja1.Mass = 4.0; 68 122 pelaaja1.Image = pelaajanKuva; 69 AddCollisionHandler(pelaaja1, "tahti", TormaaTahteen);123 AddCollisionHandler(pelaaja1, Tormaa); 70 124 Add(pelaaja1); 71 125 } … … 100 154 } 101 155 102 void Tormaa Tahteen(PhysicsObject hahmo, PhysicsObject tahti)156 void Tormaa(PhysicsObject hahmo, PhysicsObject kohde) 103 157 { 104 maaliAani.Play(); 105 MessageDisplay.Add("Keräsit tähden!"); 106 tahti.Destroy(); 158 if (kohde.Tag.ToString() == "vihu") 159 { 160 if (hahmo.Bottom >= kohde.Top) 161 { 162 vihunHp.Value--; 163 kohde.Position = RandomGen.NextVector(Level.Left, Level.Bottom, Level.Right, Level.Top); 164 } 165 if (vihunHp.Value <= 0) 166 { 167 kohde.Destroy(); 168 kentanNro++; 169 LuoKentta(); 170 } 171 172 } 173 174 if (kohde.Tag.ToString() == "tahti") 175 { 176 maaliAani.Play(); 177 MessageDisplay.Add("Keräsit tähden!"); 178 kohde.Destroy(); 179 } 107 180 } 181 108 182 } -
2012/27/LeoL/Marsun matkat/Marsun matkat/Marsun matkatContent/Marsun matkatContent.contentproj
r3493 r3553 66 66 </Compile> 67 67 </ItemGroup> 68 <ItemGroup> 69 <Compile Include="mulkkis.png"> 70 <Name>mulkkis</Name> 71 <Importer>TextureImporter</Importer> 72 <Processor>TextureProcessor</Processor> 73 </Compile> 74 </ItemGroup> 75 <ItemGroup> 76 <Compile Include="kentta2.txt"> 77 <Name>kentta2</Name> 78 <Importer>TextFileImporter</Importer> 79 <Processor>TextFileContentProcessor</Processor> 80 </Compile> 81 </ItemGroup> 82 <ItemGroup> 83 <Compile Include="psyykkis.png"> 84 <Name>psyykkis</Name> 85 <Importer>TextureImporter</Importer> 86 <Processor>TextureProcessor</Processor> 87 </Compile> 88 </ItemGroup> 89 <ItemGroup> 90 <Compile Include="hyppis.png"> 91 <Name>hyppis</Name> 92 <Importer>TextureImporter</Importer> 93 <Processor>TextureProcessor</Processor> 94 </Compile> 95 </ItemGroup> 96 <ItemGroup> 97 <Compile Include="kentta3.txt"> 98 <Name>kentta3</Name> 99 <Importer>TextFileImporter</Importer> 100 <Processor>TextFileContentProcessor</Processor> 101 </Compile> 102 </ItemGroup> 103 <ItemGroup> 104 <Compile Include="kentta4.txt"> 105 <Name>kentta4</Name> 106 <Importer>TextFileImporter</Importer> 107 <Processor>TextFileContentProcessor</Processor> 108 </Compile> 109 </ItemGroup> 68 110 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 69 111 <!-- To modify your build process, add your task inside one of the targets below and uncomment it. -
2012/27/LeoL/Marsun matkat/Marsun matkat/Marsun matkatContent/kentta1.txt
r3493 r3553 1 *2 ##1 2 3 3 4 * *5 ## ##4 5 6 6 7 * * 8 ## ## ## 9 10 * * * * 11 ## ## ## ## 12 13 * * * * 14 ## ## ## ## ############ 15 ###### 16 N 17 ###################### 7 8 9 10 11 12 * * * * V * 13 ## ## ## ## ############ ########### 14 # # ************ 15 ####################### 16 # 17 ########### 18 # 19 N 20 ############## ######################## 21 ############ ************ 22 #########################################
Note: See TracChangeset
for help on using the changeset viewer.