Changeset 8241
- Timestamp:
- 2016-07-29 11:27:55 (7 years ago)
- Location:
- 2016/30/AapoN/Tasohyppelypeli
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
2016/30/AapoN/Tasohyppelypeli/Tasohyppelypeli/Tasohyppelypeli/Tasohyppelypeli.cs
r8165 r8241 14 14 15 15 PlatformCharacter pelaaja1; 16 int PelaajanTerveys = 3; 17 18 AssaultRifle pelaajan1ase; 16 19 17 20 Image taustakuva = LoadImage("kaivos"); 18 Image pelaajanKuva = LoadImage("norsu");19 21 Image KolikkoKuva = LoadImage("kolikko"); 20 21 SoundEffect maaliAani = LoadSoundEffect("maali"); 22 22 Image HirvionKuva = LoadImage("hirvio"); 23 Image HealthPackKuva = LoadImage("HealthPack"); 24 25 SoundEffect KolikonNappaus = LoadSoundEffect("Pickup_Coin"); 26 SoundEffect OtaOsumaa = LoadSoundEffect("Hit_Hurt2"); 27 SoundEffect Hyppyääni = LoadSoundEffect("Jump2"); 28 29 30 31 int KenttaNro = 1; 23 32 public override void Begin() 24 { 25 Gravity = new Vector(0, -1000); 26 33 { 27 34 LuoKentta(); 28 LisaaNappaimet(); 29 LisaaVihollinen(); 30 31 Camera.Follow(pelaaja1); 32 Camera.ZoomFactor = 1.2; 33 Camera.StayInLevel = true; 34 } 35 36 } 37 35 38 36 39 void LuoKentta() 37 40 { 41 MessageDisplay.Add("Humans have enslaved the blobs to work in their mines. One brave blob has managed to avoid brainwashing. Help it escape!"); 38 42 TileMap kentta = TileMap.FromLevelAsset("kentta1"); 39 43 kentta.SetTileMethod('#', LisaaTaso); 40 44 kentta.SetTileMethod('*', LisaaKolikko); 41 45 kentta.SetTileMethod('N', LisaaPelaaja); 46 kentta.SetTileMethod('V', LisaaVihollinen); 47 kentta.SetTileMethod('P', LisaaPiikit); 48 kentta.SetTileMethod('H', LisaaHealthPack); 49 kentta.SetTileMethod('M', LuoMaali); 42 50 kentta.Execute(RUUDUN_KOKO, RUUDUN_KOKO); 43 51 Level.CreateBorders(); 44 52 Level.Background.CreateGradient(Color.White, Color.SkyBlue); 45 53 Level.Background.Image = taustakuva; 46 } 47 54 Camera.Follow(pelaaja1); 55 Camera.ZoomFactor = 1.2; 56 Camera.StayInLevel = true; 57 LisaaNappaimet(); 58 59 Gravity = new Vector(0, -1000); 60 61 62 } 63 void LuoMaali(Vector paikka, double leveys, double korkeus) 64 { 65 PhysicsObject Maali = new PhysicsObject(40, 60); 66 Maali.MakeStatic(); 67 Maali.Position = paikka; 68 Maali.Tag = "finish"; 69 Maali.Color = Color.Yellow; 70 Add(Maali); 71 } 72 void TormasiMaaliin(PhysicsObject hahmo, PhysicsObject maali) 73 { 74 Exit(); 75 } 48 76 void LisaaTaso(Vector paikka, double leveys, double korkeus) 49 77 { … … 69 97 pelaaja1.Position = paikka; 70 98 pelaaja1.Mass = 4.0; 71 pelaaja1.Image = pelaajanKuva; 99 pelaaja1.Color = Color.Red; 100 pelaaja1.Tag = "pelaaja"; 72 101 AddCollisionHandler(pelaaja1, "kolikko", TormaaKolikkoon); 102 AddCollisionHandler(pelaaja1, "piikki", TormaaPiikkiin); 103 AddCollisionHandler(pelaaja1, "pahis", TormaaPahikseen); 104 AddCollisionHandler(pelaaja1, "health", SaaHealth); 105 AddCollisionHandler(pelaaja1, "finish", TormasiMaaliin); 106 pelaaja1.Weapon = new AssaultRifle(30, 10); 107 pelaaja1.Weapon.Ammo.Value = 100; 108 pelaaja1.Weapon.ProjectileCollision = AmmusOsui; 73 109 Add(pelaaja1); 74 110 } … … 82 118 Keyboard.Listen(Key.Right, ButtonState.Down, Liikuta, "Liikkuu vasemmalle", pelaaja1, nopeus); 83 119 Keyboard.Listen(Key.Up, ButtonState.Pressed, Hyppaa, "Pelaaja hyppää", pelaaja1, hyppyNopeus); 120 Keyboard.Listen(Key.Space, ButtonState.Pressed, AmmuAseella, "Ammu", pelaaja1); 121 Keyboard.Listen(Key.R, ButtonState.Pressed, AloitaAlusta, "Restart"); 84 122 85 123 ControllerOne.Listen(Button.Back, ButtonState.Pressed, Exit, "Poistu pelistä"); … … 87 125 ControllerOne.Listen(Button.DPadLeft, ButtonState.Down, Liikuta, "Pelaaja liikkuu vasemmalle", pelaaja1, -nopeus); 88 126 ControllerOne.Listen(Button.DPadRight, ButtonState.Down, Liikuta, "Pelaaja liikkuu oikealle", pelaaja1, nopeus); 89 ControllerOne.Listen(Button.A, ButtonState.Pressed, Hyppaa, "Pelaaja hyppää", pelaaja1, hyppyNopeus); 90 91 PhoneBackButton.Listen(ConfirmExit, "Lopeta peli"); 127 ControllerOne.Listen(Button.A, ButtonState.Pressed, Hyppaa, "Pelaaja hyppää", pelaaja1, hyppyNopeus); 92 128 } 93 129 … … 100 136 { 101 137 hahmo.Jump(nopeus); 138 Hyppyääni.Play(); 102 139 } 103 140 104 141 void TormaaKolikkoon(PhysicsObject hahmo, PhysicsObject kolikko) 105 142 { 106 maaliAani.Play();107 MessageDisplay.Add("Keräsit kolikon!");143 MessageDisplay.Add("You've found a coin!"); 144 KolikonNappaus.Play(); 108 145 kolikko.Destroy(); 109 146 } 110 void LisaaVihollinen() 111 { 112 PhysicsObject vihollinen = new PhysicsObject(60, 40); 113 vihollinen.Shape = Shape.Rectangle; 114 Add(vihollinen); 147 void LisaaVihollinen(Vector paikka, double leveys, double korkeus) 148 { 149 PhysicsObject vihollinen = new PhysicsObject(40, 40); 150 vihollinen.Shape = Shape.Rectangle; 115 151 vihollinen.Tag = "pahis"; 116 117 118 152 vihollinen.Position = paikka; 153 FollowerBrain SeuraajanAivot = new FollowerBrain("pelaaja"); 154 SeuraajanAivot.Speed = 300; 155 SeuraajanAivot.DistanceFar = 600; 156 SeuraajanAivot.DistanceClose = 300; 157 Add(vihollinen); 158 vihollinen.Image = HirvionKuva; 159 vihollinen.Brain = SeuraajanAivot; 160 161 } 162 void LisaaPiikit(Vector paikka, double leveys, double korkeus) 163 { 164 PhysicsObject piikki = new PhysicsObject(30, 30); 165 piikki.Shape = Shape.Triangle; 166 piikki.Tag = "piikki"; 167 piikki.Position = paikka; 168 piikki.MakeStatic(); 169 Add(piikki); 170 171 } 172 void TormaaPiikkiin(PhysicsObject hahmo, PhysicsObject piikki) 173 { 174 hahmo.Destroy(); 175 OtaOsumaa.Play(); 176 } 177 178 void TormaaPahikseen(PhysicsObject hahmo, PhysicsObject pahis) 179 { 180 PelaajanTerveys--; 181 if (PelaajanTerveys <= 0) 182 hahmo.Destroy(); 183 MessageDisplay.Add("You got hit!"); 184 if (PelaajanTerveys <= 1) 185 MessageDisplay.Add("Health dangerously low!"); 186 OtaOsumaa.Play(); 187 } 188 void LisaaHealthPack(Vector paikka, double leveys, double korkeus) 189 { 190 PhysicsObject Potion = new PhysicsObject(20, 20); 191 Potion.Position = paikka; 192 Potion.Tag = "health"; 193 Potion.Image = HealthPackKuva; 194 Add(Potion); 195 } 196 197 void SaaHealth(PhysicsObject hahmo, PhysicsObject kohde) 198 { 199 PelaajanTerveys++; 200 MessageDisplay.Add("You've been healed!"); 201 } 202 void AmmusOsui(PhysicsObject ammus, PhysicsObject kohde) 203 { 204 ammus.Destroy(); 205 if(kohde.Tag == "pahis") 206 { 207 kohde.Destroy(); 208 MessageDisplay.Add("Hostile blob defeated"); 119 209 } 120 121 122 123 124 125 126 } 210 } 211 void AmmuAseella(PlatformCharacter pelaaja1) 212 { 213 PhysicsObject ammus = pelaaja1.Weapon.Shoot(); 214 if (ammus != null) 215 { 216 ammus.MaximumLifetime = TimeSpan.FromSeconds(1.0); 217 } 218 219 } 220 void AloitaAlusta() 221 { 222 ClearAll(); 223 LuoKentta(); 224 } 225 } -
2016/30/AapoN/Tasohyppelypeli/Tasohyppelypeli/Tasohyppelypeli/Tasohyppelypeli.csproj.Debug.cachefile
r8165 r8241 1 1 Content\maali.xnb 2 Content\norsu.xnb3 2 Content\kentta1.xnb 4 3 Content\kaivos.xnb 5 4 Content\kolikko.xnb 5 Content\Hirvio.xnb 6 Content\Pickup_Coin.xnb 7 Content\Hit_Hurt2.xnb 8 Content\Jump2.xnb 9 Content\HealthPack.xnb -
2016/30/AapoN/Tasohyppelypeli/Tasohyppelypeli/Tasohyppelypeli/obj/x86/Debug/ContentPipeline-{FB1067CC-FEED-45F1-8CB8-8F3DD59AB260}.xml
r8165 r8241 12 12 </Item> 13 13 <Item> 14 <Source>norsu.png</Source>15 <Name>norsu</Name>16 <Importer>TextureImporter</Importer>17 <Processor>TextureProcessor</Processor>18 <Options>None</Options>19 <Output>C:\MyTemp\AapoN\Tasohyppelypeli\Tasohyppelypeli\Tasohyppelypeli\bin\x86\Debug\Content\norsu.xnb</Output>20 <Time>2016-07-27T10:19:03.2800054+03:00</Time>21 </Item>22 <Item>23 14 <Source>kentta1.txt</Source> 24 15 <Name>kentta1</Name> … … 27 18 <Options>None</Options> 28 19 <Output>C:\MyTemp\AapoN\Tasohyppelypeli\Tasohyppelypeli\Tasohyppelypeli\bin\x86\Debug\Content\kentta1.xnb</Output> 29 <Time>2016-07-2 7T14:49:40.7336158+03:00</Time>20 <Time>2016-07-29T10:57:03.1016293+03:00</Time> 30 21 </Item> 31 22 <Item> … … 46 37 <Output>C:\MyTemp\AapoN\Tasohyppelypeli\Tasohyppelypeli\Tasohyppelypeli\bin\x86\Debug\Content\kolikko.xnb</Output> 47 38 <Time>2016-07-27T14:05:54.9977289+03:00</Time> 39 </Item> 40 <Item> 41 <Source>Hirvio.png</Source> 42 <Name>Hirvio</Name> 43 <Importer>TextureImporter</Importer> 44 <Processor>TextureProcessor</Processor> 45 <Options>None</Options> 46 <Output>C:\MyTemp\AapoN\Tasohyppelypeli\Tasohyppelypeli\Tasohyppelypeli\bin\x86\Debug\Content\Hirvio.xnb</Output> 47 <Time>2016-07-28T14:33:25.500644+03:00</Time> 48 </Item> 49 <Item> 50 <Source>Pickup_Coin.wav</Source> 51 <Name>Pickup_Coin</Name> 52 <Importer>WavImporter</Importer> 53 <Processor>SoundEffectProcessor</Processor> 54 <Options>None</Options> 55 <Output>C:\MyTemp\AapoN\Tasohyppelypeli\Tasohyppelypeli\Tasohyppelypeli\bin\x86\Debug\Content\Pickup_Coin.xnb</Output> 56 <Time>2016-07-29T09:50:48.7418774+03:00</Time> 57 </Item> 58 <Item> 59 <Source>Hit_Hurt2.wav</Source> 60 <Name>Hit_Hurt2</Name> 61 <Importer>WavImporter</Importer> 62 <Processor>SoundEffectProcessor</Processor> 63 <Options>None</Options> 64 <Output>C:\MyTemp\AapoN\Tasohyppelypeli\Tasohyppelypeli\Tasohyppelypeli\bin\x86\Debug\Content\Hit_Hurt2.xnb</Output> 65 <Time>2016-07-29T09:51:18.1767789+03:00</Time> 66 </Item> 67 <Item> 68 <Source>Jump2.wav</Source> 69 <Name>Jump2</Name> 70 <Importer>WavImporter</Importer> 71 <Processor>SoundEffectProcessor</Processor> 72 <Options>None</Options> 73 <Output>C:\MyTemp\AapoN\Tasohyppelypeli\Tasohyppelypeli\Tasohyppelypeli\bin\x86\Debug\Content\Jump2.xnb</Output> 74 <Time>2016-07-29T09:51:32.255948+03:00</Time> 75 </Item> 76 <Item> 77 <Source>HealthPack.png</Source> 78 <Name>HealthPack</Name> 79 <Importer>TextureImporter</Importer> 80 <Processor>TextureProcessor</Processor> 81 <Options>None</Options> 82 <Output>C:\MyTemp\AapoN\Tasohyppelypeli\Tasohyppelypeli\Tasohyppelypeli\bin\x86\Debug\Content\HealthPack.xnb</Output> 83 <Time>2016-07-29T10:20:11.2789117+03:00</Time> 48 84 </Item> 49 85 <BuildSuccessful>true</BuildSuccessful> -
2016/30/AapoN/Tasohyppelypeli/Tasohyppelypeli/Tasohyppelypeli/obj/x86/Debug/Tasohyppelypeli.csproj.FileListAbsolute.txt
r8165 r8241 1 1 C:\MyTemp\AapoN\Tasohyppelypeli\Tasohyppelypeli\Tasohyppelypeli\bin\x86\Debug\Content\maali.xnb 2 C:\MyTemp\AapoN\Tasohyppelypeli\Tasohyppelypeli\Tasohyppelypeli\bin\x86\Debug\Content\norsu.xnb3 2 C:\MyTemp\AapoN\Tasohyppelypeli\Tasohyppelypeli\Tasohyppelypeli\bin\x86\Debug\Content\kentta1.xnb 4 3 C:\MyTemp\AapoN\Tasohyppelypeli\Tasohyppelypeli\Tasohyppelypeli\bin\x86\Debug\Tasohyppelypeli.exe … … 12 11 C:\MyTemp\AapoN\Tasohyppelypeli\Tasohyppelypeli\Tasohyppelypeli\bin\x86\Debug\Content\kaivos.xnb 13 12 C:\MyTemp\AapoN\Tasohyppelypeli\Tasohyppelypeli\Tasohyppelypeli\bin\x86\Debug\Content\kolikko.xnb 13 C:\MyTemp\AapoN\Tasohyppelypeli\Tasohyppelypeli\Tasohyppelypeli\bin\x86\Debug\Content\Hirvio.xnb 14 C:\MyTemp\AapoN\Tasohyppelypeli\Tasohyppelypeli\Tasohyppelypeli\bin\x86\Debug\Content\Pickup_Coin.xnb 15 C:\MyTemp\AapoN\Tasohyppelypeli\Tasohyppelypeli\Tasohyppelypeli\bin\x86\Debug\Content\Hit_Hurt2.xnb 16 C:\MyTemp\AapoN\Tasohyppelypeli\Tasohyppelypeli\Tasohyppelypeli\bin\x86\Debug\Content\Jump2.xnb 17 C:\MyTemp\AapoN\Tasohyppelypeli\Tasohyppelypeli\Tasohyppelypeli\bin\x86\Debug\Content\HealthPack.xnb -
2016/30/AapoN/Tasohyppelypeli/Tasohyppelypeli/Tasohyppelypeli/obj/x86/Debug/cachefile-{FB1067CC-FEED-45F1-8CB8-8F3DD59AB260}-targetpath.txt
r8165 r8241 1 1 Content\maali.xnb 2 Content\norsu.xnb3 2 Content\kentta1.xnb 4 3 Content\kaivos.xnb 5 4 Content\kolikko.xnb 5 Content\Hirvio.xnb 6 Content\Pickup_Coin.xnb 7 Content\Hit_Hurt2.xnb 8 Content\Jump2.xnb 9 Content\HealthPack.xnb -
2016/30/AapoN/Tasohyppelypeli/Tasohyppelypeli/TasohyppelypeliContent/TasohyppelypeliContent.contentproj
r8165 r8241 51 51 <Processor>SoundEffectProcessor</Processor> 52 52 </Compile> 53 <Compile Include="norsu.png">54 <Name>norsu</Name>55 <Importer>TextureImporter</Importer>56 <Processor>TextureProcessor</Processor>57 </Compile>58 53 <Compile Include="kentta1.txt"> 59 54 <Name>kentta1</Name> … … 76 71 </Compile> 77 72 </ItemGroup> 73 <ItemGroup> 74 <Compile Include="Hirvio.png"> 75 <Name>Hirvio</Name> 76 <Importer>TextureImporter</Importer> 77 <Processor>TextureProcessor</Processor> 78 </Compile> 79 </ItemGroup> 80 <ItemGroup> 81 <Compile Include="Pickup_Coin.wav"> 82 <Name>Pickup_Coin</Name> 83 <Importer>WavImporter</Importer> 84 <Processor>SoundEffectProcessor</Processor> 85 </Compile> 86 </ItemGroup> 87 <ItemGroup> 88 <Compile Include="Hit_Hurt2.wav"> 89 <Name>Hit_Hurt2</Name> 90 <Importer>WavImporter</Importer> 91 <Processor>SoundEffectProcessor</Processor> 92 </Compile> 93 </ItemGroup> 94 <ItemGroup> 95 <Compile Include="Jump2.wav"> 96 <Name>Jump2</Name> 97 <Importer>WavImporter</Importer> 98 <Processor>SoundEffectProcessor</Processor> 99 </Compile> 100 </ItemGroup> 101 <ItemGroup> 102 <Compile Include="HealthPack.png"> 103 <Name>HealthPack</Name> 104 <Importer>TextureImporter</Importer> 105 <Processor>TextureProcessor</Processor> 106 </Compile> 107 </ItemGroup> 78 108 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 79 109 <!-- To modify your build process, add your task inside one of the targets below and uncomment it. -
2016/30/AapoN/Tasohyppelypeli/Tasohyppelypeli/TasohyppelypeliContent/kentta1.txt
r8165 r8241 6 6 ........................#################################..........................................................................................############### 7 7 ........................................................##....................................................................#######################...........###### 8 .. ..N............................................*****...##.................................................................###.....................................###8 ..N..............................................*****...##.................................................................###.....................................### 9 9 ########.........................................*****...##................................................................###.................*****................## 10 .......###########..................V.....................##..............................................................###................... ...........V........##10 .......###########..................V.....................##..............................................................###...................P..........V........## 11 11 ................###.....####################################...............................................................###...........#####################.......#### 12 12 ..................#.....#..................................................................................................###..........##.....................**......### … … 14 14 ..................#.....#......................................................#################################################.......###.......................**........## 15 15 ..................#.....#.......................................################.........................................................###......................**........## 16 ..................#.....#.......................................##......................................*******.................... ........##.....................**.......#####16 ..................#.....#.......................................##......................................*******....................H.......##.....................**.......##### 17 17 ..................#.....#......................................##........................................*****....................####......##....................**..........### 18 18 ..................#.....#....................................###........................................*******..............................##...................**............### 19 ..................#.....#..................................###..............V............................. ......................#.............##...................**...........####20 ..................#.....#................................###.........##############.........###.....###########........V......###########......##......... ..........**...........#####21 ..................#.....#..............................###.........###.....................................######################.....##################### .........**.............###22 ..................#.....#............................###..........##.................###.................................................................. .#.........**............###23 .................##.....##.........................###...........##......................... ................................................................#.........**............###24 ................##.......##......####################...........##.........................###.....................................****...................... .........**..............###25 ..............###.........#########............................##.................................###..............................****....................... ........**...............###26 ......#########..............................................###......................................................................................V........ .......**.............###27 ......#...**................................V............################..#########................................. V..........############........###############........################28 ......# ...**...........................###########..........#####......#####......###########################......#################.........................###........................#######29 ......#########.............#############.......###.......................................................########## .........................................###..........................######30 ............ .#....#######....#....................#####.....................................................................................#####............###..............................######31 ............ .#...............#.......................####...............................V.............................................................****...###..................................#####32 ............ .#...............#..........................######......................#########..............**..................................V......****...###................................#####33 ............ .#...............#..............................#####....#######....######......######.............................................#######################.......................#####34 ............ .#...............#..................................#....#.....#....#..............#####......######.............................#################################################35 ............ .#################..................................#....#.....#....#.................###################......................####36 ............................................................... .#....#.....#....#..................................######..............######37 ............................................................... .#....#.....#....#......................................#######.......#####38 ............................................................... .#....#.....#....#...........................................############...........39 ............................................................... .#....#.....#....#..................................................................40 ............................................................... ..####.......####...................................................................19 ..................#.....#..................................###..............V.............................PP..................................##...................**...........#### 20 ..................#.....#................................###.........##############.........###.....###########........V......###########......##.........V.........**...........##### 21 ..................#.....#..............................###.........###.....................................######################.....######################........**.............### 22 ..................#.....#............................###..........##.................###..................................................................###........**............### 23 .................##.....##.........................###...........##.........................V...............................................................##........**............### 24 ................##.......##......####################...........##.........................###.....................................****......................##.......**..............### 25 ..............###.........#########............................##.................................###..............................****.......................##......**...............### 26 ......#########..............................................###......................................................................................V........##PP...**...PPP.......##### 27 ......#...**................................V............################..#########............................................############........###############........################ 28 ......#V..**....................H......###########..........#####......#####......###########################...P...#################.........................###........................####### 29 ......#########.............#############.......###.......................................................###########........................................###..........................###### 30 ............##....#######....##...................#####.....................................................................................#####............###..............................###### 31 ............##...............##......................####...............................V.............................................................****...###..................................##### 32 ............##...............##.........................######......................#########..............**..................................V......****...###................................##### 33 ............##...............##.............................#####....########....#################.............................................#######################..............M........##### 34 ............##PPPPPPPPPPPPPPP##................................##....##....##....##.............#####...P...######.............................################################################# 35 ............###################................................##....##....##....##................###################......................#### 36 ...............................................................##....##....##....##.................................######..............###### 37 ...............................................................##....##....##....##.....................................#######...PP...##### 38 ...............................................................##....##....##....##..........................................############........... 39 ...............................................................##PPPP##....##PPPP##................................................................. 40 ...............................................................########....########................................................................
Note: See TracChangeset
for help on using the changeset viewer.