Changeset 6680
- Timestamp:
- 2015-07-01 14:52:02 (7 years ago)
- Location:
- 2015/27/LukaP
- Files:
-
- 10 added
- 1 deleted
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
2015/27/LukaP/LukanPeli/LukanPeli/LukanPeli/LukanPeli.cs
r6603 r6680 10 10 { 11 11 const double nopeus = 200; 12 const double hyppyNopeus = 750;12 const double hyppyNopeus = 850; 13 13 const int RUUDUN_KOKO = 40; 14 14 … … 17 17 Image pelaajanKuva = LoadImage("Ukko"); 18 18 Image tahtiKuva = LoadImage("Kolikko"); 19 19 Image Vihunkuva = LoadImage("Vihu"); 20 Image Maalinkuva = LoadImage("Maali"); 21 22 23 PhysicsObject Vihu; 24 IntMeter pistelaskuri; 25 int kenttaNro = 1; 26 27 28 29 20 30 21 31 … … 24 34 public override void Begin() 25 35 { 26 Gravity = new Vector(0, -1000);27 28 LuoKentta();29 LisaaNappaimet();30 36 31 37 32 Camera.Follow(pelaaja1); 33 Camera.ZoomFactor = 1.2; 34 Camera.StayInLevel = true; 35 } 36 37 void LuoKentta() 38 { 39 TileMap kentta = TileMap.FromLevelAsset("kentta1"); 38 SeuraavaKentta(); 39 40 } 41 42 void LuoKentta(string kentannimi) 43 { 44 TileMap kentta = TileMap.FromLevelAsset(kentannimi); 40 45 kentta.SetTileMethod('#', LisaaTaso); 41 46 kentta.SetTileMethod('*', LisaaTahti); 42 47 kentta.SetTileMethod('N', LisaaPelaaja); 43 48 kentta.SetTileMethod('1', LisaaKolo); 49 kentta.SetTileMethod('V', LisaaVihu); 50 kentta.SetTileMethod('M',LisaaMaali); 44 51 kentta.Execute(RUUDUN_KOKO, RUUDUN_KOKO); 45 52 Level.Background.CreateGradient(Color.White, Color.SkyBlue); 53 46 54 } 47 55 … … 73 81 } 74 82 83 void LisaaMaali(Vector paikka, double leveys, double korkeus) 84 { 85 PhysicsObject maali = PhysicsObject.CreateStaticObject(leveys, korkeus); 86 maali.Tag = "maali"; 87 maali.Position = paikka; 88 Add(maali); 89 maali.Image = Maalinkuva; 90 } 91 75 92 void LisaaPelaaja(Vector paikka, double leveys, double korkeus) 76 93 { … … 79 96 pelaaja1.Mass = 4.0; 80 97 pelaaja1.Image = pelaajanKuva; 81 AddCollisionHandler(pelaaja1, "tahti", TormaaTahteen); 82 AddCollisionHandler(pelaaja1, "kolo", delegate (PhysicsObject a, PhysicsObject b) { 98 AddCollisionHandler(pelaaja1, "tahti", TormaaKolikkoon); 99 AddCollisionHandler(pelaaja1, "maali", TormaaMaaliin); 100 AddCollisionHandler(pelaaja1, "kolo", delegate(PhysicsObject a, PhysicsObject b) 101 { 102 83 103 a.Destroy(); 84 104 //ClearControls(); 85 105 }); 106 AddCollisionHandler(pelaaja1, "Pahis", PelaajaTormaaPahikseen); 86 107 Add(pelaaja1); 87 108 } … … 91 112 Keyboard.Listen(Key.F1, ButtonState.Pressed, ShowControlHelp, "Näytä ohjeet"); 92 113 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 114 93 115 94 116 Keyboard.Listen(Key.Left, ButtonState.Down, Liikuta, "Liikkuu vasemmalle", pelaaja1, -nopeus); … … 115 137 } 116 138 117 void Tormaa Tahteen(PhysicsObject hahmo, PhysicsObject tahti)139 void TormaaKolikkoon(PhysicsObject hahmo, PhysicsObject tahti) 118 140 { 119 141 maaliAani.Play(); 120 142 MessageDisplay.Add("1X Kolikko Kerätty!"); 121 143 tahti.Destroy(); 144 pistelaskuri.Value += 1; 145 146 147 148 } 149 150 void PelaajaTormaaPahikseen(PhysicsObject pelaaja, PhysicsObject pahis) 151 { 122 152 123 124 125 } 126 127 128 void Kuolema() 129 { 130 131 132 133 } 153 if (pahis.Top - 0.2 * pahis.Height< pelaaja.Bottom) 154 { 155 pahis.Destroy(); 156 (pelaaja as PlatformCharacter).ForceJump(nopeus * 4); 157 } 158 else 159 { 160 pelaaja.Destroy(); 161 } 162 } 163 164 165 void LisaaVihu(Vector paikka, double leveys, double korkeus) 166 { 167 PlatformCharacter Vihu = new PlatformCharacter(40, 30); 168 Vihu.Shape = Shape.Rectangle; 169 Vihu.Mass = 10.0; 170 Add(Vihu); 171 Vihu.Position = paikka; 172 Vihu.Tag = "Pahis"; 173 Vihu.Image = Vihunkuva; 174 175 176 PlatformWandererBrain tasoAivot = new PlatformWandererBrain(); 177 tasoAivot.Speed = 50; 178 Vihu.Brain = tasoAivot; 179 180 181 182 183 184 } 185 186 187 188 189 void Luopistelaskuri() 190 { 191 pistelaskuri = new IntMeter(0); 192 193 Label pisteNaytto = new Label(); 194 pisteNaytto.X = Screen.Left + 10; 195 pisteNaytto.Y = Screen.Top - 10; 196 pisteNaytto.TextColor = Color.Black; 197 pisteNaytto.Color = Color.White; 198 pisteNaytto.Title = "kolikot"; 199 200 pisteNaytto.BindTo(pistelaskuri); 201 Add(pisteNaytto); 202 } 203 204 205 206 207 public void SeuraavaKentta() 208 { 209 ClearAll(); 210 211 if (kenttaNro == 1) LuoKentta("kentta1"); 212 else if (kenttaNro == 2) LuoKentta("kentta2"); 213 else if (kenttaNro == 3) LuoKentta("kentta3"); 214 else if (kenttaNro > 3) Exit(); 215 216 LisaaNappaimet(); 217 Luopistelaskuri(); 218 219 220 221 Camera.Follow(pelaaja1); 222 Camera.ZoomFactor = 1.2; 223 Camera.StayInLevel = true; 224 Gravity = new Vector(0, -1000); 225 226 } 227 134 228 135 229 136 230 void TormaaMaaliin(PhysicsObject pelaaja, PhysicsObject maali) 231 { 232 //Kasvatetaan kenttänumeroa yhdellä ja siirrytään seuraavaan kenttään: 233 kenttaNro++; 234 SeuraavaKentta(); 235 } 236 237 void TormasiPiikkiin(PhysicsObject pelaaja, PhysicsObject piikki) 238 { 239 //Sama kenttä ladataan alusta jos kenttänumeroa ei kasvateta: 240 SeuraavaKentta(); 241 } 242 243 244 245 246 247 248 249 250 251 252 253 254 137 255 } -
2015/27/LukaP/LukanPeli/LukanPeli/LukanPeli/LukanPeli.csproj.Debug.cachefile
r6603 r6680 3 3 Content\Ukko.xnb 4 4 Content\Kolikko.xnb 5 Content\Vihu.xnb 6 Content\Kentta2.xnb 7 Content\kentta3.xnb -
2015/27/LukaP/LukanPeli/LukanPeli/LukanPeli/obj/x86/Debug/ContentPipeline-{2119C4D2-AF14-42FC-976F-6011121F8356}.xml
r6603 r6680 18 18 <Options>None</Options> 19 19 <Output>C:\MyTemp\LukaP\LukanPeli\LukanPeli\LukanPeli\bin\x86\Debug\Content\kentta1.xnb</Output> 20 <Time>2015-0 6-30T14:44:41.2944395+03:00</Time>20 <Time>2015-07-01T14:29:16.3648525+03:00</Time> 21 21 </Item> 22 22 <Item> … … 27 27 <Options>None</Options> 28 28 <Output>C:\MyTemp\LukaP\LukanPeli\LukanPeli\LukanPeli\bin\x86\Debug\Content\Ukko.xnb</Output> 29 <Time>2015-0 6-30T13:59:16.6580977+03:00</Time>29 <Time>2015-07-01T14:30:10.7319793+03:00</Time> 30 30 </Item> 31 31 <Item> … … 36 36 <Options>None</Options> 37 37 <Output>C:\MyTemp\LukaP\LukanPeli\LukanPeli\LukanPeli\bin\x86\Debug\Content\Kolikko.xnb</Output> 38 <Time>2015-06-30T14:14:23.3698276+03:00</Time> 38 <Time>2015-07-01T11:31:26.5138244+03:00</Time> 39 </Item> 40 <Item> 41 <Source>Vihu.png</Source> 42 <Name>Vihu</Name> 43 <Importer>TextureImporter</Importer> 44 <Processor>TextureProcessor</Processor> 45 <Options>None</Options> 46 <Output>C:\MyTemp\LukaP\LukanPeli\LukanPeli\LukanPeli\bin\x86\Debug\Content\Vihu.xnb</Output> 47 <Time>2015-07-01T11:12:45.0189619+03:00</Time> 48 </Item> 49 <Item> 50 <Source>Kentta2.txt</Source> 51 <Name>Kentta2</Name> 52 <Importer>TextFileImporter</Importer> 53 <Processor>TextFileContentProcessor</Processor> 54 <Options>None</Options> 55 <Output>C:\MyTemp\LukaP\LukanPeli\LukanPeli\LukanPeli\bin\x86\Debug\Content\Kentta2.xnb</Output> 56 <Time>2015-07-01T13:59:14.2275241+03:00</Time> 57 </Item> 58 <Item> 59 <Source>kentta3.txt</Source> 60 <Name>kentta3</Name> 61 <Importer>TextFileImporter</Importer> 62 <Processor>TextFileContentProcessor</Processor> 63 <Options>None</Options> 64 <Output>C:\MyTemp\LukaP\LukanPeli\LukanPeli\LukanPeli\bin\x86\Debug\Content\kentta3.xnb</Output> 65 <Time>2015-07-01T14:24:12.7712724+03:00</Time> 39 66 </Item> 40 67 <BuildSuccessful>true</BuildSuccessful> -
2015/27/LukaP/LukanPeli/LukanPeli/LukanPeli/obj/x86/Debug/LukanPeli.csproj.FileListAbsolute.txt
r6603 r6680 11 11 C:\MyTemp\LukaP\LukanPeli\LukanPeli\LukanPeli\bin\x86\Debug\Content\Ukko.xnb 12 12 C:\MyTemp\LukaP\LukanPeli\LukanPeli\LukanPeli\bin\x86\Debug\Content\Kolikko.xnb 13 C:\MyTemp\LukaP\LukanPeli\LukanPeli\LukanPeli\bin\x86\Debug\Content\Vihu.xnb 14 C:\MyTemp\LukaP\LukanPeli\LukanPeli\LukanPeli\bin\x86\Debug\Content\Kentta2.xnb 15 C:\MyTemp\LukaP\LukanPeli\LukanPeli\LukanPeli\bin\x86\Debug\Content\kentta3.xnb -
2015/27/LukaP/LukanPeli/LukanPeli/LukanPeli/obj/x86/Debug/cachefile-{2119C4D2-AF14-42FC-976F-6011121F8356}-targetpath.txt
r6603 r6680 3 3 Content\Ukko.xnb 4 4 Content\Kolikko.xnb 5 Content\Vihu.xnb 6 Content\Kentta2.xnb 7 Content\kentta3.xnb -
2015/27/LukaP/LukanPeli/LukanPeli/LukanPeliContent/LukanPeliContent.contentproj
r6603 r6680 46 46 </ItemGroup> 47 47 <ItemGroup> 48 <Compile Include="maali .wav">49 <Name>maali </Name>48 <Compile Include="maali %28ääni%29.wav"> 49 <Name>maali %28ääni%29</Name> 50 50 <Importer>WavImporter</Importer> 51 51 <Processor>SoundEffectProcessor</Processor> … … 71 71 </Compile> 72 72 </ItemGroup> 73 <ItemGroup> 74 <Compile Include="Vihu.png"> 75 <Name>Vihu</Name> 76 <Importer>TextureImporter</Importer> 77 <Processor>TextureProcessor</Processor> 78 </Compile> 79 </ItemGroup> 80 <ItemGroup> 81 <Compile Include="kentta2.txt"> 82 <Name>kentta2</Name> 83 <Importer>TextFileImporter</Importer> 84 <Processor>TextFileContentProcessor</Processor> 85 </Compile> 86 </ItemGroup> 87 <ItemGroup> 88 <Compile Include="kentta3.txt"> 89 <Name>kentta3</Name> 90 <Importer>TextFileImporter</Importer> 91 <Processor>TextFileContentProcessor</Processor> 92 </Compile> 93 </ItemGroup> 94 <ItemGroup> 95 <Compile Include="Maali.png"> 96 <Name>Maali</Name> 97 <Importer>TextureImporter</Importer> 98 <Processor>TextureProcessor</Processor> 99 </Compile> 100 </ItemGroup> 73 101 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 74 102 <!-- To modify your build process, add your task inside one of the targets below and uncomment it. -
2015/27/LukaP/LukanPeli/LukanPeli/LukanPeliContent/kentta1.txt
r6603 r6680 1 *2 ##3 1 4 * *5 ## ##6 2 7 * *8 ## ## ##9 3 10 * * * *11 ## ## ## ##12 4 13 * * * *14 ## ## ## ## ##15 5 16 N 17 ########################### ######## 18 ###########################1111 6 .............................................................................................................................................................................. 7 ....................................................................................................................................................................................... 8 ...................................................................................................................................................................................................V............M... 9 ...................................*.V..*......*....*.........*.....V.....................................*.................................................................................###################......................... 10 ..................#.#..#..#...#....#....#....#.....#......#.....#....#...:...#.....V........#...................................................#....#.....#....#.....#...#....#....########################## 11 ..............#...#....#......#....#....#....#.....#.......................#......######..........#....................................#....#............................................................. 12 .N........*V........................11111111111111111111111111111111...................................#....#....#...#...#...#....#......................................... 13 #############.................................... 14 #############11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
Note: See TracChangeset
for help on using the changeset viewer.