- Timestamp:
- 2011-06-08 14:22:40 (10 years ago)
- Location:
- 2011/23/hejumunt/RunRunRun/RunRunRun
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
2011/23/hejumunt/RunRunRun/RunRunRun/RunRunRun/Peli.cs
r1744 r1757 11 11 Image hahmonKuva = LoadImage("hahmo"); 12 12 Image talonKuva = LoadImage("talo"); 13 Image katon1Kuva = LoadImage("katto1"); 14 Image ikkunanKuva = LoadImage("ikkuna"); 15 Image katonKuva = LoadImage("katto"); 16 Image katon2Kuva = LoadImage("katto2"); 17 Image ovenKuva = LoadImage("ovi"); 18 Image seinanKuva = LoadImage("seinä"); 19 Image tangonKuva = LoadImage("lipputanko"); 20 Image nupinKuva = LoadImage("nuppi"); 21 Image roskanKuva = LoadImage("roska"); 22 Image koydenKuva = LoadImage("köysi"); 23 Image parvekkeenKuva = LoadImage("parveke"); 24 Image puskanKuva = LoadImage("puska"); 25 Image puunKuva = LoadImage("puurunko"); 26 Image puun1Kuva = LoadImage("puulehdet"); 13 27 Shape hahmonMuoto; 14 28 15 29 PlatformCharacter hahmo; 16 30 31 DoubleMeter alaspainLaskuri; 32 int elämät = 3; 33 17 34 public override void Begin() 18 35 { 19 36 // TODO: Kirjoita ohjelmakoodisi tähän 20 37 hahmonMuoto = Shape.FromImage(hahmonKuva); 38 21 39 LuoKenttä(); 22 40 AloitaPeli(); 23 41 AsetaOhjaimet(); 24 42 25 43 alaspainLaskuri = new DoubleMeter(2); 44 45 Timer ajastin = new Timer(); 46 ajastin.Interval = 0.1; 47 ajastin.Trigger += aikaloppui; 48 ajastin.Start(); 49 50 Label aikaNaytto = new Label(); 51 aikaNaytto.TextColor = Color.Black; 52 aikaNaytto.BindTo(alaspainLaskuri); 53 Add(aikaNaytto); 54 55 56 } 57 void aikaloppui(Timer Sender) 58 { 59 alaspainLaskuri.Value -= 0.1; 60 61 if (alaspainLaskuri.Value <= 0) 62 { 63 MessageDisplay.Add("Aika loppui..."); 64 Sender.Stop(); 65 elämät--; 66 if (elämät > 0) { Uudestaan(); } 67 else 68 { 69 gameover(); 70 } 71 72 73 } 74 75 } 76 void gameover() 77 { 78 79 } 80 void Uudestaan() 81 { 82 ClearGameObjects(); 83 LuoKenttä(); 84 ResetElapsedTime(); 26 85 } 27 86 void LuoAloitusruutu() … … 31 90 { 32 91 TileMap kentta = TileMap.FromFile("kentta.txt"); 33 kentta['%'] = lisaaTa so;34 kentta['#'] = lisaa Talo;92 kentta['%'] = lisaaTanko; 93 kentta['#'] = lisaaSeina; 35 94 kentta['/'] = lisaaTaso; 36 95 kentta['='] = lisaaTaso; 37 kentta['+'] = lisaaTaso;96 //kentta['+'] = lisaaTaso; 38 97 kentta['K'] = lisaaKatto; 98 kentta['1'] = lisaaKatto1; 99 kentta['I'] = lisaaIkkuna; 100 kentta['2'] = lisaaKatto2; 101 kentta['O'] = lisaaOvi; 102 kentta['N'] = lisaaNuppi; 103 kentta['&'] = lisaaRoska; 104 kentta['/'] = lisaaKoysi; 105 kentta['?'] = lisaaParveke; 106 kentta['P'] = lisaaPuska; 107 kentta['0'] = lisaaPuu; 108 kentta['9'] = lisaaPuu1; 39 109 kentta.Insert(40.0, 40.0); 40 110 41 hahmo = new PlatformCharacter( 50, 50, hahmonMuoto);111 hahmo = new PlatformCharacter(40, 40, hahmonMuoto); 42 112 hahmo.Image = hahmonKuva; 43 113 hahmo.X = -2300.0; 44 114 hahmo.Y = -225.0; 115 AddCollisionHandler(hahmo, kasittelehahmontormays); 45 116 46 117 Add(hahmo); … … 56 127 //ajastin.Start(); 57 128 } 129 void kasittelehahmontormays(PhysicsObject hahmo, PhysicsObject kohde) 130 { 131 132 } 58 133 PhysicsObject lisaaTaso() 59 134 { … … 62 137 return taso; 63 138 } 139 PhysicsObject lisaaKatto1() 140 { 141 PhysicsObject katto1 = PhysicsObject.CreateStaticObject(40.0, 40.0); 142 katto1.Image = katon1Kuva; 143 return katto1; 144 } 145 PhysicsObject lisaaKatto2() 146 { 147 PhysicsObject katto2 = PhysicsObject.CreateStaticObject(40.0, 40.0); 148 katto2.Image = katon2Kuva; 149 return katto2; 150 } 151 PhysicsObject lisaaIkkuna() 152 { 153 PhysicsObject ikkuna = PhysicsObject.CreateStaticObject(40.0, 40.0); 154 ikkuna.Image = ikkunanKuva; 155 return ikkuna; 156 } 157 PhysicsObject lisaaSeina() 158 { 159 PhysicsObject seina = PhysicsObject.CreateStaticObject(40.0, 40.0); 160 seina.Image = seinanKuva; 161 return seina; 162 } 64 163 PhysicsObject lisaaTalo() 65 164 { … … 68 167 return talo; 69 168 } 169 PhysicsObject lisaaTanko() 170 { 171 PhysicsObject tanko = PhysicsObject.CreateStaticObject(20.0, 40.0); 172 tanko.Image = tangonKuva; 173 return tanko; 174 } 70 175 PhysicsObject lisaaKatto() 71 176 { 72 177 PhysicsObject katto = PhysicsObject.CreateStaticObject(40.0, 40.0); 178 katto.Image = katonKuva; 73 179 return katto; 180 } 181 PhysicsObject lisaaOvi() 182 { 183 PhysicsObject ovi = PhysicsObject.CreateStaticObject(40.0, 40.0); 184 ovi.Image = ovenKuva; 185 return ovi; 186 } 187 PhysicsObject lisaaNuppi() 188 { 189 PhysicsObject nuppi = PhysicsObject.CreateStaticObject(40.0, 40.0); 190 nuppi.Image = nupinKuva; 191 return nuppi; 192 } 193 PhysicsObject lisaaRoska() 194 { 195 PhysicsObject roska = PhysicsObject.CreateStaticObject(40.0, 40.0); 196 roska.Image = roskanKuva; 197 return roska; 198 } 199 PhysicsObject lisaaKoysi() 200 { 201 PhysicsObject koysi = PhysicsObject.CreateStaticObject(10.0, 40.0); 202 koysi.Image = koydenKuva; 203 return koysi; 204 } 205 PhysicsObject lisaaParveke() 206 { 207 PhysicsObject parveke = PhysicsObject.CreateStaticObject(40.0, 40.0); 208 parveke.Image = parvekkeenKuva; 209 return parveke; 74 210 } 75 211 void AloitaPeli() … … 78 214 hahmo.Hit(impulssi); 79 215 } 216 PhysicsObject lisaaPuska() 217 { 218 PhysicsObject puska = PhysicsObject.CreateStaticObject(40.0, 40.0); 219 puska.Image = puskanKuva; 220 return puska; 221 } 222 PhysicsObject lisaaPuu() 223 { 224 PhysicsObject puu = PhysicsObject.CreateStaticObject(40.0, 40.0); 225 puu.Image = puunKuva; 226 return puu; 227 } 228 PhysicsObject lisaaPuu1() 229 { 230 PhysicsObject puu1 = PhysicsObject.CreateStaticObject(40.0, 40.0); 231 puu1.Image = puun1Kuva; 232 return puu1; 233 } 80 234 void AsetaOhjaimet() 81 235 { 82 236 Keyboard.Listen(Key.Right, ButtonState.Down, AsetaNopeus, "Paina oikealle nuolta niin hahmo liikkuu oikealle", new Vector(10000.0, 0.0)); 83 Keyboard.Listen(Key.Left, ButtonState.Down, AsetaNopeus, "Paina nuolta oikealle niin hahmo liikkuu oikealle", new Vector(-10000.0, 0.0));237 Keyboard.Listen(Key.Left, ButtonState.Down, AsetaNopeus, "Paina nuolta vasemmalle niin hahmo liikkuu vasemmalle", new Vector(-10000.0, 0.0)); 84 238 Keyboard.Listen(Key.Space, ButtonState.Pressed, LiikutaPelaajaa, "Paina SPACE niin hahmo hyppää"); 85 239 Keyboard.Listen(Key.F1, ButtonState.Pressed, ShowControlHelp, "Näytä ohjeet"); … … 96 250 hahmo.Jump(1000.0); 97 251 } 252 253 98 254 //void liikutaHahmoa(Timer Sender) 99 255 //{ -
2011/23/hejumunt/RunRunRun/RunRunRun/RunRunRun/kentta.txt
r1742 r1757 1 1 =========================================================================================================================== 2 = / / 3 = / / 4 = / / 5 = / / 6 = / / 7 = / % /=8 = / #### % /=9 = #### / #### % /=10 = %%% #### / ### #### % /=11 = %%% #### / ### #### % /=12 = %%% #### ### #### %=13 = %%% #### ### #### %=2 = / / / = 3 = / / / = 4 = / / / = 5 = / / K12 / = 6 = / / ### / = 7 = / N / N N N ### / 9 = 8 = / K112 % / % % % #I# / 99 = 9 = K112 / #### % / % % % ### / 999 = 10 = &&& #### / K12 #II# % / % % % #I# 9999 = 11 = &&&& #II# / ### #### % / % % % ?### 909 = 12 = &&&&&& #### #I# #II# % & %P %P % #I# 0 = 13 = &&&&&&&& #O## #O# #O#& % && %P %P % #O# 0 = 14 14 =========================================================================================================================== -
2011/23/hejumunt/RunRunRun/RunRunRun/RunRunRunContent/RunRunRunContent.contentproj
r1744 r1757 56 56 </Compile> 57 57 </ItemGroup> 58 <ItemGroup> 59 <Compile Include="Ikkuna.png"> 60 <Name>Ikkuna</Name> 61 <Importer>TextureImporter</Importer> 62 <Processor>TextureProcessor</Processor> 63 </Compile> 64 </ItemGroup> 65 <ItemGroup> 66 <Compile Include="Katto.png"> 67 <Name>Katto</Name> 68 <Importer>TextureImporter</Importer> 69 <Processor>TextureProcessor</Processor> 70 </Compile> 71 </ItemGroup> 72 <ItemGroup> 73 <Compile Include="Katto1.png"> 74 <Name>Katto1</Name> 75 <Importer>TextureImporter</Importer> 76 <Processor>TextureProcessor</Processor> 77 </Compile> 78 </ItemGroup> 79 <ItemGroup> 80 <Compile Include="Katto2.png"> 81 <Name>Katto2</Name> 82 <Importer>TextureImporter</Importer> 83 <Processor>TextureProcessor</Processor> 84 </Compile> 85 </ItemGroup> 86 <ItemGroup> 87 <Compile Include="Ovi.png"> 88 <Name>Ovi</Name> 89 <Importer>TextureImporter</Importer> 90 <Processor>TextureProcessor</Processor> 91 </Compile> 92 </ItemGroup> 93 <ItemGroup> 94 <Compile Include="Seinä.png"> 95 <Name>Seinä</Name> 96 <Importer>TextureImporter</Importer> 97 <Processor>TextureProcessor</Processor> 98 </Compile> 99 </ItemGroup> 100 <ItemGroup> 101 <Compile Include="Lipputanko.png"> 102 <Name>Lipputanko</Name> 103 <Importer>TextureImporter</Importer> 104 <Processor>TextureProcessor</Processor> 105 </Compile> 106 </ItemGroup> 107 <ItemGroup> 108 <Compile Include="Nuppi.png"> 109 <Name>Nuppi</Name> 110 <Importer>TextureImporter</Importer> 111 <Processor>TextureProcessor</Processor> 112 </Compile> 113 </ItemGroup> 114 <ItemGroup> 115 <Compile Include="Roska.png"> 116 <Name>Roska</Name> 117 <Importer>TextureImporter</Importer> 118 <Processor>TextureProcessor</Processor> 119 </Compile> 120 </ItemGroup> 121 <ItemGroup> 122 <Compile Include="Köysi.png"> 123 <Name>Köysi</Name> 124 <Importer>TextureImporter</Importer> 125 <Processor>TextureProcessor</Processor> 126 </Compile> 127 </ItemGroup> 128 <ItemGroup> 129 <Compile Include="parveke.png"> 130 <Name>parveke</Name> 131 <Importer>TextureImporter</Importer> 132 <Processor>TextureProcessor</Processor> 133 </Compile> 134 </ItemGroup> 135 <ItemGroup> 136 <Compile Include="puska.png"> 137 <Name>puska</Name> 138 <Importer>TextureImporter</Importer> 139 <Processor>TextureProcessor</Processor> 140 </Compile> 141 </ItemGroup> 142 <ItemGroup> 143 <Compile Include="PuuRunko.png"> 144 <Name>PuuRunko</Name> 145 <Importer>TextureImporter</Importer> 146 <Processor>TextureProcessor</Processor> 147 </Compile> 148 </ItemGroup> 149 <ItemGroup> 150 <Compile Include="PuuLehdet.png"> 151 <Name>PuuLehdet</Name> 152 <Importer>TextureImporter</Importer> 153 <Processor>TextureProcessor</Processor> 154 </Compile> 155 </ItemGroup> 58 156 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 59 157 <!-- 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.