- Timestamp:
- 2011-06-14 14:57:25 (12 years ago)
- Location:
- 2011/24/EkiM/nimeton/nimeton
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
2011/24/EkiM/nimeton/nimeton/nimeton/Peli.cs
r1963 r1988 4 4 using System.Text; 5 5 using Jypeli; 6 7 class Peli : Game 6 using Jypeli.Widgets; 7 8 class Peli : PhysicsGame 8 9 { 9 Image seinanKuva = LoadImage("seina"); 10 11 const int ruudunLeveys = 70; 12 const int ruudunKorkeus = 70; 10 Image seinaoikeanKuva = LoadImage("seinaoikea"); 11 Image seinavasemmanKuva = LoadImage("seinavasen"); 12 Image lattianKuva = LoadImage("lattia"); 13 Image koydenKuva = LoadImage("koysi"); 14 Image nostinKuva = LoadImage("nostin"); 15 Image tikkaatKuva = LoadImage("tikkaat"); 16 Image lattiatikkaatKuva = LoadImage("lattiatikkaat"); 17 Image pelaajaKuva = LoadImage("ukko"); 18 Image vihunKuva = LoadImage("vihu1"); 19 20 PlatformCharacter pelaaja; 21 PhysicsObject vihu1; 22 MessageWindow kysymysIkkuna; 23 13 24 14 25 public override void Begin() 15 26 { 16 LuoSeina(); 17 //LuoLattia(); 18 /* 19 GameObject Seina; 20 GameObject Lattia; 21 GameObject Koysi; 22 GameObject Hissi; 23 GameObject Nostin; 24 GameObject Ovi; 25 GameObject Putki; 26 GameObject Tikkaat; 27 * */ 27 Gravity = new Vector(0.0, -500.0); 28 LataaKentta("map.txt"); 29 Camera.ZoomToLevel(); 30 31 LuoOhjain(); 28 32 } 29 33 … … 32 36 33 37 TileMap merkit = TileMap.FromFile(map); 34 /* 35 merkit['|'] = LuoSeina; 36 merkit['_'] = LuoLattia; 37 merkit['I'] = LuoKoysi; 38 merkit['E'] = LuoHissi; 39 merkit['L'] = LuoNostin; 40 * */ 41 } 42 43 void LuoSeina() 44 { 45 PhysicsObject seina = PhysicsObject.CreateStaticObject(70, 70); 46 seina.Image = seinanKuva; 47 Add(seina); 48 } 38 39 merkit.SetTileMethod('P', LuoPelaaja); 40 merkit.SetTileMethod('V', LuoVihu); 41 merkit.SetTileMethod('|', LuoSeinaoikea); 42 merkit.SetTileMethod('i', LuoSeinavasen); 43 merkit.SetTileMethod('_', LuoLattia); 44 merkit.SetTileMethod('L', LuoNostin); 45 merkit.SetTileMethod('H', LuoTikkaat); 46 merkit.SetTileMethod('h', LuoLattiatikkaat); 47 48 merkit.Execute(70, 70); 49 50 } 51 void LuoPelaaja(Vector paikka, double leveys, double korkeus) 52 { 53 pelaaja = new PlatformCharacter(40, 62); 54 pelaaja.CanRotate = false; 55 pelaaja.Mass = 40.0; 56 pelaaja.Position = paikka; 57 pelaaja.Image = pelaajaKuva; 58 AddCollisionHandler(pelaaja, VihuunTormays); 59 Add(pelaaja); 60 61 } 62 void LuoVihu(Vector paikka, double leveys, double korkeus) 63 { 64 vihu1 = new PhysicsObject(40, 62); 65 vihu1.CanRotate = false; 66 vihu1.Mass = 40.0; 67 vihu1.Position = paikka; 68 vihu1.Image = vihunKuva; 69 Add(vihu1); 70 71 } 72 void VihuunTormays(PhysicsObject pelaaja, PhysicsObject kohde) 73 { 74 IsMouseVisible = true; 75 if (kohde == vihu1) 76 { 77 InputWindow kysymysIkkuna = new InputWindow("Kysymys", "Nimesi?"); 78 kysymysIkkuna.TextEntered += vastaus; 79 Add(kysymysIkkuna); 80 } 81 } 82 83 void vastaus(InputWindow Ikkuna) 84 { 85 string vastaus = Ikkuna.InputBox.Text; 86 kysymysIkkuna = new MessageWindow("Kysymys", "Hmm...en muista ketään tuon nimistä täällä..."); 87 kysymysIkkuna.Closed += new Jypeli.Widgets.Window.WindowHandler(kysymysIkkuna_Closed); 88 89 Add(kysymysIkkuna); 90 } 91 92 void kysymysIkkuna_Closed(Window sender) 93 { 94 kysymysIkkuna = new MessageWindow("Kysymys", "Oletko uusi talossa?"); 95 kysymysIkkuna.OKButton.Text="Kyllä olen"; 96 97 Add(kysymysIkkuna); 98 } 99 100 101 void LuoSeinaoikea(Vector paikka, double leveys, double korkeus) 102 { 103 PhysicsObject seinaoikea = PhysicsObject.CreateStaticObject(70, 70); 104 seinaoikea.Position = paikka; 105 seinaoikea.Image = seinaoikeanKuva; 106 Add(seinaoikea); 107 } 108 109 void LuoSeinavasen(Vector paikka, double leveys, double korkeus) 110 111 { 112 PhysicsObject seinavasen = PhysicsObject.CreateStaticObject(70, 70); 113 seinavasen.Position = paikka; 114 seinavasen.Image = seinavasemmanKuva; 115 Add(seinavasen); 116 117 } 118 119 void LuoLattia(Vector paikka, double leveys, double korkeus) 120 { 121 PhysicsObject lattia = PhysicsObject.CreateStaticObject(70, 10); 122 lattia.Position = paikka; 123 lattia.Image = lattianKuva; 124 Add(lattia); 125 } 126 127 void LuoNostin(Vector paikka, double leveys, double korkeus) 128 { 129 PhysicsObject nostin = new PhysicsObject(69, 10); 130 nostin.Position = paikka; 131 nostin.Image = nostinKuva; 132 nostin.IgnoresPhysicsLogics = true; 133 nostin.CanRotate = false; 134 nostin.Mass = 10000; 135 nostin.Velocity = new Vector(0.0, 90.0); 136 AddCollisionHandler(nostin, SeinaanTormays); 137 Add(nostin); 138 139 } 140 141 void SeinaanTormays(PhysicsObject nostin, PhysicsObject seinavasen) 142 { 143 nostin.Velocity = -nostin.Velocity; 144 } 145 146 147 void LuoTikkaat(Vector paikka, double leveys, double korkeus) 148 { 149 PhysicsObject tikkaat = PhysicsObject.CreateStaticObject(35, 150); 150 tikkaat.Position = paikka; 151 tikkaat.Image = tikkaatKuva; 152 Add(tikkaat); 153 } 154 void LuoLattiatikkaat(Vector paikka, double leveys, double korkeus) 155 { 156 PhysicsObject lattiatikkaat = PhysicsObject.CreateStaticObject(70, 70); 157 lattiatikkaat.Position = paikka; 158 lattiatikkaat.Image = lattiatikkaatKuva; 159 Add(lattiatikkaat); 160 } 161 162 void LuoOhjain() 163 { 164 //näppäin alhaalla 165 Keyboard.Listen(Key.Left, ButtonState.Down, pelaaja.Walk, null, -100.0); 166 Keyboard.Listen(Key.Right, ButtonState.Down, pelaaja.Walk, null, 100.0); 167 Keyboard.Listen(Key.Up, ButtonState.Down, LiikutaPelaajaaYlos, null); 168 Keyboard.Listen(Key.Down, ButtonState.Down, LiikutaPelaajaaAlas, null); 169 170 //näppäin ylhäällä 171 Keyboard.Listen(Key.Left, ButtonState.Released, pelaaja.StopHorizontal, null); 172 Keyboard.Listen(Key.Right, ButtonState.Released, pelaaja.StopHorizontal, null); 173 Keyboard.Listen(Key.Up, ButtonState.Released, pelaaja.StopVertical, null); 174 Keyboard.Listen(Key.Down, ButtonState.Released, pelaaja.StopVertical, null); 175 } 176 177 178 void LiikutaPelaajaaVasemmalle() 179 { 180 pelaaja.Hit(new Vector(-100, 0)); 181 } 182 183 void LiikutaPelaajaaOikealle() 184 { 185 pelaaja.Hit(new Vector(100, 0)); 186 } 187 188 void LiikutaPelaajaaYlos() 189 { 190 pelaaja.Jump (90); 191 } 192 193 void LiikutaPelaajaaAlas() 194 { 195 pelaaja.Hit(new Vector(0, -100)); 196 } 197 198 199 200 49 201 50 202 } -
2011/24/EkiM/nimeton/nimeton/nimeton/map.txt
r1963 r1988 1 | 2 __________ _____| 3 _________/ | _______________ 4 _A2_______ | | I 5 | L__________D__| I 6 ___________X_ |H I 7 TECH |H I 8 _____________ |H______________________V___P___ 9 F-G | O _______ 10 _____________ | O O O O O O| | 11 _____BOSS____ | O O |_D_D__| 12 C | O _____ 13 _____________ | ____O_ |_______ 14 E__ | |_____| 15 16 _________A___S_____ _ 17 _________ ______________________| 18 oooooooo7 oooo ____C__ 1 i 2 __________ _____i 3 _________/ i _______________ 4 __________ | i 1 5 | __________D__i 1 6 ______________LiH 1 P 7 TEC ih 1 V 8 ______________ i _____________________________ 9 F-G i O ______ 10 ______________ i O O O O O Oi i 11 i O O |_D_D__i 12 ______________ i O 13 C i O _____ 14 ______________ i ____O_ |_______ 15 E___ i |_____i 16 17 ___________________ _ 18 _________ ______________________i 19 oooooooo7 oooo _______ 19 20 Z ___________________________< 20 ___Q___ Z ___ H-M F________ 21 Z s____D_D_D_D_D_D_________| 22 Z 23 Z LAB AREA 24 ________Z ___________S______S_________ 25 Z 26 21 _______ Z __ -M F________ 22 Z s____D_D_D_D_D_D_________i 23 Z 24 Z lAB AREA S 25 ________Z ____________________________ 26 Z -
2011/24/EkiM/nimeton/nimeton/nimeton/nimeton.csproj
r1963 r1988 118 118 <Content Include="Game.ico" /> 119 119 <Content Include="GameThumbnail.png" /> 120 <Content Include="map.txt" /> 121 <Content Include="seina.png" /> 120 <Content Include="map.txt"> 121 <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> 122 </Content> 122 123 </ItemGroup> 123 124 <ItemGroup> -
2011/24/EkiM/nimeton/nimeton/nimetonContent/nimetonContent.contentproj
r1963 r1988 42 42 </Reference> 43 43 </ItemGroup> 44 <ItemGroup> 45 <Compile Include="seinaoikea.png"> 46 <Name>seinaoikea</Name> 47 <Importer>TextureImporter</Importer> 48 <Processor>TextureProcessor</Processor> 49 </Compile> 50 </ItemGroup> 51 <ItemGroup> 52 <Compile Include="seinavasen.png"> 53 <Name>seinavasen</Name> 54 <Importer>TextureImporter</Importer> 55 <Processor>TextureProcessor</Processor> 56 </Compile> 57 </ItemGroup> 58 <ItemGroup> 59 <Compile Include="lattiatikkaat.png"> 60 <Name>lattiatikkaat</Name> 61 <Importer>TextureImporter</Importer> 62 <Processor>TextureProcessor</Processor> 63 </Compile> 64 </ItemGroup> 65 <ItemGroup> 66 <Compile Include="lattia.png"> 67 <Name>lattia</Name> 68 <Importer>TextureImporter</Importer> 69 <Processor>TextureProcessor</Processor> 70 </Compile> 71 </ItemGroup> 72 <ItemGroup> 73 <Compile Include="ukko.png"> 74 <Name>ukko</Name> 75 <Importer>TextureImporter</Importer> 76 <Processor>TextureProcessor</Processor> 77 </Compile> 78 </ItemGroup> 79 <ItemGroup> 80 <Compile Include="tikkaat.png"> 81 <Name>tikkaat</Name> 82 <Importer>TextureImporter</Importer> 83 <Processor>TextureProcessor</Processor> 84 </Compile> 85 </ItemGroup> 86 <ItemGroup> 87 <Compile Include="nostin.png"> 88 <Name>nostin</Name> 89 <Importer>TextureImporter</Importer> 90 <Processor>TextureProcessor</Processor> 91 </Compile> 92 </ItemGroup> 93 <ItemGroup> 94 <Compile Include="vihu1.png"> 95 <Name>vihu1</Name> 96 <Importer>TextureImporter</Importer> 97 <Processor>TextureProcessor</Processor> 98 </Compile> 99 </ItemGroup> 44 100 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 45 101 <!-- 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.