Changeset 663
- Timestamp:
- 2010-06-10 11:42:33 (13 years ago)
- Location:
- 2010/23/lavevake/Rise of darkness
- Files:
-
- 11 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
2010/23/lavevake/Rise of darkness/Content/Content.contentproj
r643 r663 55 55 </ItemGroup> 56 56 <ItemGroup> 57 <Compile Include="aurinko.png"> 58 <Name>aurinko</Name> 57 <Compile Include="Virta.png"> 58 <Name>Virta</Name> 59 <Importer>TextureImporter</Importer> 60 <Processor>TextureProcessor</Processor> 61 </Compile> 62 </ItemGroup> 63 <ItemGroup> 64 <Compile Include="Extra.png"> 65 <Name>Extra</Name> 59 66 <Importer>TextureImporter</Importer> 60 67 <Processor>TextureProcessor</Processor> -
2010/23/lavevake/Rise of darkness/Peli.cs
r643 r663 1 using System ;1 using System.Collections.Generic; 2 2 using Jypeli; 3 3 using Jypeli.ScreenObjects; … … 5 5 6 6 7 namespace Rise_of_darkness 7 namespace Rise_of_darkness // Lauri Kemppi 8 8 { 9 9 class Tasohyppely : PhysicsGame … … 19 19 const double virtaMaara = 5000; 20 20 21 bool voikoHirvioitaSyoda = false; 22 21 23 DoubleMeter virtaLaskuri; 22 24 ValueDisplay virtaNaytto; … … 24 26 25 27 PlatformCharacter pelaaja1; 26 PlatformCharacter hirviö; 27 PhysicsObject aurinko; 28 PlatformCharacter Hirvio; 29 PhysicsObject Virta; 30 PhysicsObject Extra; 31 28 32 int kenttaNro; // monesko kenttä on menossa 29 33 … … 38 42 pisteLaskuri = new IntMeter(0); 39 43 40 41 42 44 45 46 43 47 44 48 … … 62 66 void vahennaVirtaa(Timer t) 63 67 { 64 virtaLaskuri.Value -= 100;68 virtaLaskuri.Value -= 5; 65 69 } 66 70 … … 69 73 ClearAll(); 70 74 pisteLaskuri.Reset(); 71 75 72 76 73 77 kenttaNro += 1; // lisätään kenttänumeroa yhdellä … … 82 86 LuoNaytot(); 83 87 laskuri = new Timer(); 84 laskuri.Interval = 0. 1;88 laskuri.Interval = 0.001; 85 89 laskuri.Trigger += vahennaVirtaa; 86 90 Add(laskuri); … … 93 97 Level.Background.CreateGradient(Color.Black, Color.SkyBlue); 94 98 95 lisaaTaso(-200, -350); 96 lisaaTaso(0, -200); 97 lisaaTaso(100, -100); 99 var merkit = new Dictionary<char, ObjectCreator>(); 100 merkit['='] = lisaaTaso; 101 merkit['X'] = Pelaaja1; 102 merkit['0'] = LuoHirvio; 103 merkit['z'] = LuoVirta; 104 merkit['a'] = lisaaMaali; 105 merkit['e'] = LuoExtra; 106 107 const int ruudunLeveys = 50; 108 const int ruudunKorkeus = 50; 109 110 char[,] ruudut = Tiles.ReadFromFile("Text.txt"); 111 Tiles.Insert(this, ruudut, merkit, ruudunLeveys, ruudunKorkeus); 98 112 99 113 lisaaMaali(); 100 lisaaPelaajat(); 101 } 102 103 void lisaaTaso(double x, double y) 114 } 115 116 PhysicsObject lisaaTaso() 104 117 { 105 118 PhysicsObject taso = PhysicsObject.CreateStaticObject(100, 30); 106 119 taso.Color = Color.Green; 107 taso.X = x; 108 taso.Y = y; 120 109 121 Add(taso); 110 } 111 112 void lisaaPelaajat() 113 { 114 pelaaja1 = new PlatformCharacter(40, 40); 115 pelaaja1.Mass = 4.0; 116 pelaaja1.Image = LoadImage("Ukko 2"); 117 pelaaja1.X = 0; 118 pelaaja1.Y = Level.Bottom; 119 120 hirviö = new PlatformCharacter(80, 80); 121 hirviö.Mass = 4.0; 122 hirviö.Image = LoadImage("hirviö"); 123 hirviö.X = 100; 124 hirviö.Y = -120; 125 126 aurinko = new PhysicsObject(40, 40); 127 aurinko.Mass = 4.0; 128 aurinko.Image = LoadImage("aurinko"); 129 aurinko.X = int luku.RandomGen.NextInt(-300,300) ; 130 aurinko.Y = -150; 131 132 AddCollisionHandler(pelaaja1, osuiMaaliin); 133 134 AddCollisionHandler(pelaaja1, KasitteleTormays); 135 136 Add(pelaaja1); 137 Add(hirviö); 138 Add(aurinko); 139 } 140 141 void lisaaMaali() 122 return taso; 123 } 124 125 PhysicsObject lisaaMaali() 142 126 { 143 127 PhysicsObject maali = PhysicsObject.CreateStaticObject(50, 50, Shapes.Circle); 144 128 maali.Tag = "maali"; 145 129 maali.IgnoresCollisionResponse = true; 146 maali.X = 100;147 maali.Y = -60;148 130 maali.Image = LoadImage("Kone 2"); 149 Add(maali);131 return maali; 150 132 } 151 133 … … 155 137 Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "Poistu pelistä"); 156 138 157 Keyboard.Listen(Key.Left, ButtonState.Down, liikuta, "Liikkuu vasemmalle", pelaaja1,-nopeus);158 Keyboard.Listen(Key.Right, ButtonState.Down, liikuta, "Liikkuu oikealle", pelaaja1,nopeus);159 Keyboard.Listen(Key.Up, ButtonState.Pressed, hyppaa, "Hyppää", pelaaja1,hyppyVoima);139 Keyboard.Listen(Key.Left, ButtonState.Down, liikuta, "Liikkuu vasemmalle", -nopeus); 140 Keyboard.Listen(Key.Right, ButtonState.Down, liikuta, "Liikkuu oikealle", nopeus); 141 Keyboard.Listen(Key.Up, ButtonState.Pressed, hyppaa, "Hyppää", hyppyVoima); 160 142 161 143 lisaaGamePadNappaimet(ControllerOne); … … 166 148 controller.Listen(Button.Back, ButtonState.Pressed, Exit, "Poistu pelistä"); 167 149 168 controller.Listen(Button.DPadLeft, ButtonState.Down, liikuta, "Pelaaja liikkuu vasemmalle", pelaaja1,-nopeus);169 controller.Listen(Button.DPadRight, ButtonState.Down, liikuta, "Pelaaja liikkuu oikealle", pelaaja1,nopeus);170 controller.Listen(Button.A, ButtonState.Pressed, hyppaa, "Pelaaja hyppää", pelaaja1,hyppyVoima);171 } 172 173 void liikuta( PlatformCharacter hahmo,double nopeus)174 { 175 hahmo.Walk(nopeus);176 } 177 178 void hyppaa( PlatformCharacter hahmo,double voima)179 { 180 hahmo.Jump(voima);150 controller.Listen(Button.DPadLeft, ButtonState.Down, liikuta, "Pelaaja liikkuu vasemmalle", -nopeus); 151 controller.Listen(Button.DPadRight, ButtonState.Down, liikuta, "Pelaaja liikkuu oikealle", nopeus); 152 controller.Listen(Button.A, ButtonState.Pressed, hyppaa, "Pelaaja hyppää", hyppyVoima); 153 } 154 155 void liikuta(double nopeus) 156 { 157 pelaaja1.Walk(nopeus); 158 } 159 160 void hyppaa(double voima) 161 { 162 pelaaja1.Jump(voima); 181 163 } 182 164 … … 199 181 void KasitteleTormays(PhysicsObject pelaaja1, PhysicsObject toinen) 200 182 { 201 if (toinen == hirviö)183 if (toinen.Tag.ToString() == "H") 202 184 { 203 TextDisplay loppu = new TextDisplay(); 204 loppu.Position = Screen.Center; 205 loppu.TextColor = Color.Red; 206 Add(loppu); 207 loppu.Text = "Kuolit.Peli loppu"; 208 209 Timer lopetus = new Timer(); 210 lopetus.Interval = 2; 211 lopetus.Trigger += new Timer.TriggerHandler(lopetaPeli); 212 Add(lopetus); 213 lopetus.Enabled = true; 214 185 if (voikoHirvioitaSyoda) 186 { 187 toinen.Destroy(); 188 } 189 else 190 { 191 TextDisplay loppu = new TextDisplay(); 192 loppu.Position = Screen.Center; 193 loppu.TextColor = Color.Red; 194 Add(loppu); 195 loppu.Text = "Kuolit.Peli loppu"; 196 197 Timer lopetus = new Timer(); 198 lopetus.Interval = 2; 199 lopetus.Trigger += new Timer.TriggerHandler(lopetaPeli); 200 Add(lopetus); 201 lopetus.Enabled = true; 202 } 215 203 } 216 else if (toinen == aurinko) 204 205 else if (toinen.Tag.ToString() == "V") 217 206 { 218 207 virtaLaskuri.Value += 1000; 219 208 MessageDisplay.Add("Sait lisää energiaa."); 220 aurinko.Destroy();209 toinen.Destroy(); 221 210 } 222 } 223 211 else if (toinen.Tag.ToString() == "E") 212 { 213 voikoHirvioitaSyoda = true; 214 215 Timer syonti = new Timer(); 216 syonti.Interval = 10; 217 syonti.Trigger += voikoHirvioitaSyoda; 218 Add(syonti); 219 syonti.Start(); 220 221 } 222 } 223 224 224 void LuoNaytot() 225 225 { … … 241 241 virtaNayttoBar.ValueColor = Color.Green; 242 242 virtaNayttoBar.Max = virtaMaara; 243 virtaNayttoBar.X = Screen.RightSafe - 20;244 virtaNayttoBar.Y = Screen.TopSafe - 20;243 virtaNayttoBar.X = Screen.RightSafe - 20; 244 virtaNayttoBar.Y = Screen.TopSafe - 20; 245 245 virtaNayttoBar.Width = 30; 246 246 virtaNayttoBar.Height = 200; … … 259 259 Add(virtaNaytto); 260 260 } 261 261 262 262 void virtaUhkaaLoppua(double maara) 263 263 { … … 266 266 MessageDisplay.Add("Varoitus: virta alkaa olla vähissä!"); 267 267 } 268 268 269 269 void virtaLoppui(double polttoAineMaara) 270 270 { … … 282 282 lopetus.Enabled = true; 283 283 } 284 285 PhysicsObject Pelaaja1() 286 { 287 pelaaja1 = new PlatformCharacter(40, 40); 288 pelaaja1.Mass = 4.0; 289 pelaaja1.Image = LoadImage("Ukko 2"); 290 291 AddCollisionHandler(pelaaja1, osuiMaaliin); 292 293 AddCollisionHandler(pelaaja1, KasitteleTormays); 294 295 return pelaaja1; 296 } 297 298 PhysicsObject LuoHirvio() 299 { 300 Hirvio = new PlatformCharacter(80, 80); 301 Hirvio.Mass = 4.0; 302 Hirvio.Image = LoadImage("hirviö"); 303 304 Hirvio.Tag = "H"; 305 306 return Hirvio; 307 308 } 309 310 PhysicsObject LuoVirta() 311 { 312 313 Virta = new PhysicsObject(40, 40); 314 Virta.Mass = 4.0; 315 Virta.Image = LoadImage("Virta"); 316 317 Virta.Tag = "V"; 318 319 return Virta; 320 } 321 322 PhysicsObject LuoExtra() 323 { 324 Extra = new PhysicsObject(40, 40); 325 Extra.Mass = 4.0; 326 Extra.Image = LoadImage("Extra"); 327 328 Extra.Tag = "E"; 329 330 return Extra; 331 } 284 332 } 285 333 } -
2010/23/lavevake/Rise of darkness/Rise of darkness.csproj
r566 r663 89 89 <Content Include="Game.ico" /> 90 90 <Content Include="GameThumbnail.png" /> 91 <None Include="Text.txt"> 92 <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> 93 </None> 91 94 </ItemGroup> 92 95 <ItemGroup>
Note: See TracChangeset
for help on using the changeset viewer.