Changeset 6033 for 2015/24/JouniP/Tasohyppelyesimerkki
- Timestamp:
- 2015-06-11 16:39:37 (8 years ago)
- Location:
- 2015/24/JouniP/Tasohyppelyesimerkki/Tasohyppelyesimerkki
- Files:
-
- 2 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
2015/24/JouniP/Tasohyppelyesimerkki/Tasohyppelyesimerkki/Tasohyppelyesimerkki/Tasohyppelyesimerkki.cs
r6021 r6033 13 13 const int RUUDUN_KOKO = 40; 14 14 15 P latformCharacterpelaaja1;15 Pelaaja pelaaja1; 16 16 17 17 Image pelaajanKuva = LoadImage("norsu"); 18 18 Image tahtiKuva = LoadImage("tahti"); 19 Image viholliskuva = LoadImage("sininenpahis"); 19 20 20 21 SoundEffect maaliAani = LoadSoundEffect("maali"); … … 23 24 int kenttaNro = 1; 24 25 26 // TODO lisää pelaajan elämälaskurille näyttö 27 25 28 public override void Begin() 26 29 { 30 SmoothTextures = false; 27 31 //IsFullScreen = true; 28 32 VaihdaKenttaa(); … … 55 59 kentta.SetTileMethod('*', LisaaTahti); 56 60 kentta.SetTileMethod('N', LisaaPelaaja); 61 kentta.SetTileMethod('v', LisaaVihollinen); 57 62 kentta.SetTileMethod('m', LisaaMaali); 58 63 kentta.Execute(RUUDUN_KOKO, RUUDUN_KOKO); … … 97 102 void LisaaPelaaja(Vector paikka, double leveys, double korkeus) 98 103 { 99 pelaaja1 = new P latformCharacter(leveys, korkeus);104 pelaaja1 = new Pelaaja(leveys, korkeus); 100 105 pelaaja1.Position = paikka; 101 106 pelaaja1.Mass = 4.0; … … 103 108 AddCollisionHandler(pelaaja1, "tahti", TormaaTahteen); 104 109 AddCollisionHandler(pelaaja1, "maali", TormaaMaaliin); 110 AddCollisionHandler(pelaaja1, "pahis", TormaaViholliseen); 105 111 Add(pelaaja1); 112 } 113 114 void LisaaVihollinen(Vector paikka, double leveys, double korkeus) 115 { 116 PlatformCharacter vihollinen = new PlatformCharacter(leveys, korkeus); 117 vihollinen.Position = paikka; 118 vihollinen.Image = viholliskuva; 119 vihollinen.Tag = "pahis"; 120 Add(vihollinen); 121 122 PlatformWandererBrain tasoAivot = new PlatformWandererBrain(); 123 tasoAivot.Speed = 100; 124 tasoAivot.JumpSpeed = 700; 125 tasoAivot.TriesToJump = true; 126 tasoAivot.FallsOffPlatforms = true; 127 vihollinen.Brain = tasoAivot; 106 128 } 107 129 … … 110 132 Keyboard.Listen(Key.F1, ButtonState.Pressed, ShowControlHelp, "Näytä ohjeet"); 111 133 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 134 Keyboard.Listen(Key.R, ButtonState.Pressed, VaihdaKenttaa, "Aloita kenttä alusta"); 112 135 113 136 Keyboard.Listen(Key.Left, ButtonState.Down, Liikuta, "Liikkuu vasemmalle", pelaaja1, -nopeus); … … 140 163 tahti.Destroy(); 141 164 } 165 166 void TormaaViholliseen(PhysicsObject hahmo, PhysicsObject vihu) 167 { 168 MessageDisplay.Add("Osuit viholliseen!"); 169 ((Pelaaja)hahmo).Elamalaskuri.Value -= 1; 170 if (((Pelaaja)hahmo).Elamalaskuri.Value == ((Pelaaja)hahmo).Elamalaskuri.MinValue) 171 { 172 Timer.SingleShot(5.0, VaihdaKenttaa); 173 } 174 } 142 175 } -
2015/24/JouniP/Tasohyppelyesimerkki/Tasohyppelyesimerkki/Tasohyppelyesimerkki/Tasohyppelyesimerkki.csproj
r6021 r6033 112 112 <ItemGroup> 113 113 <Compile Include="Ohjelma.cs" /> 114 <Compile Include="Pelaaja.cs" /> 114 115 <Compile Include="Tasohyppelyesimerkki.cs" /> 115 116 <Compile Include="Properties\AssemblyInfo.cs" /> -
2015/24/JouniP/Tasohyppelyesimerkki/Tasohyppelyesimerkki/Tasohyppelyesimerkki/Tasohyppelyesimerkki.csproj.Debug.cachefile
r6021 r6033 4 4 Content\kentta1.xnb 5 5 Content\kentta2.xnb 6 Content\sininenpahis.xnb -
2015/24/JouniP/Tasohyppelyesimerkki/Tasohyppelyesimerkki/Tasohyppelyesimerkki/obj/x86/Debug/ContentPipeline-{FB1067CC-FEED-45F1-8CB8-8F3DD59AB260}.xml
r6021 r6033 36 36 <Options>None</Options> 37 37 <Output>C:\MyTemp\JouniP\Tasohyppelyesimerkki\Tasohyppelyesimerkki\Tasohyppelyesimerkki\bin\x86\Debug\Content\kentta1.xnb</Output> 38 <Time>2015-06-11T 08:40:57.6186043+03:00</Time>38 <Time>2015-06-11T14:14:59.5789158+03:00</Time> 39 39 </Item> 40 40 <Item> … … 46 46 <Output>C:\MyTemp\JouniP\Tasohyppelyesimerkki\Tasohyppelyesimerkki\Tasohyppelyesimerkki\bin\x86\Debug\Content\kentta2.xnb</Output> 47 47 <Time>2015-06-11T08:53:32.5080801+03:00</Time> 48 </Item> 49 <Item> 50 <Source>sininenpahis.png</Source> 51 <Name>sininenpahis</Name> 52 <Importer>TextureImporter</Importer> 53 <Processor>TextureProcessor</Processor> 54 <Options>None</Options> 55 <Output>C:\MyTemp\JouniP\Tasohyppelyesimerkki\Tasohyppelyesimerkki\Tasohyppelyesimerkki\bin\x86\Debug\Content\sininenpahis.xnb</Output> 56 <Time>2015-06-11T13:49:43.5248407+03:00</Time> 48 57 </Item> 49 58 <BuildSuccessful>true</BuildSuccessful> -
2015/24/JouniP/Tasohyppelyesimerkki/Tasohyppelyesimerkki/Tasohyppelyesimerkki/obj/x86/Debug/Tasohyppelyesimerkki.csproj.FileListAbsolute.txt
r6021 r6033 12 12 C:\MyTemp\JouniP\Tasohyppelyesimerkki\Tasohyppelyesimerkki\Tasohyppelyesimerkki\obj\x86\Debug\Tasohyppelyesimerkki.csprojResolveAssemblyReference.cache 13 13 C:\MyTemp\JouniP\Tasohyppelyesimerkki\Tasohyppelyesimerkki\Tasohyppelyesimerkki\bin\x86\Debug\Content\kentta2.xnb 14 C:\MyTemp\JouniP\Tasohyppelyesimerkki\Tasohyppelyesimerkki\Tasohyppelyesimerkki\bin\x86\Debug\Content\sininenpahis.xnb -
2015/24/JouniP/Tasohyppelyesimerkki/Tasohyppelyesimerkki/Tasohyppelyesimerkki/obj/x86/Debug/cachefile-{FB1067CC-FEED-45F1-8CB8-8F3DD59AB260}-targetpath.txt
r6021 r6033 4 4 Content\kentta1.xnb 5 5 Content\kentta2.xnb 6 Content\sininenpahis.xnb -
2015/24/JouniP/Tasohyppelyesimerkki/Tasohyppelyesimerkki/TasohyppelyesimerkkiContent/TasohyppelyesimerkkiContent.contentproj
r6021 r6033 74 74 </Compile> 75 75 </ItemGroup> 76 <ItemGroup> 77 <Compile Include="sininenpahis.png"> 78 <Name>sininenpahis</Name> 79 <Importer>TextureImporter</Importer> 80 <Processor>TextureProcessor</Processor> 81 </Compile> 82 </ItemGroup> 76 83 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 77 84 <!-- To modify your build process, add your task inside one of the targets below and uncomment it. -
2015/24/JouniP/Tasohyppelyesimerkki/Tasohyppelyesimerkki/TasohyppelyesimerkkiContent/kentta1.txt
r6021 r6033 14 14 .##..##..##..##..##... 15 15 ...................... 16 ........N.. ........m..16 ........N..#..v....m.. 17 17 ######################
Note: See TracChangeset
for help on using the changeset viewer.