Changeset 902
- Timestamp:
- 2010-06-16 11:33:14 (11 years ago)
- Location:
- 2010/24/Vilvaini/Smile Jump
- Files:
-
- 5 added
- 6 deleted
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
2010/24/Vilvaini/Smile Jump/Content/Content.contentproj
r870 r902 19 19 </PropertyGroup> 20 20 <ItemGroup> 21 <Compile Include="norsu.png">22 <Name>norsu</Name>23 <Importer>TextureImporter</Importer>24 <Processor>TextureProcessor</Processor>25 </Compile>26 </ItemGroup>27 <ItemGroup>28 <Compile Include="tahti.png">29 <Name>tahti</Name>30 <Importer>TextureImporter</Importer>31 <Processor>TextureProcessor</Processor>32 </Compile>33 </ItemGroup>34 <ItemGroup>35 <Compile Include="maali.wav">36 <Name>maali</Name>37 <Importer>WavImporter</Importer>38 <Processor>SoundEffectProcessor</Processor>39 </Compile>40 </ItemGroup>41 <ItemGroup>42 21 <Reference Include="Microsoft.Xna.Framework.Content.Pipeline.AudioImporters, Version=3.1.0.0, Culture=neutral, PublicKeyToken=6d5c3888ef60e27d" /> 43 22 <Reference Include="Microsoft.Xna.Framework.Content.Pipeline.EffectImporter, Version=3.1.0.0, Culture=neutral, PublicKeyToken=6d5c3888ef60e27d" /> … … 48 27 </ItemGroup> 49 28 <ItemGroup> 50 <Compile Include="smile jump %28keltainen pelaaja%29.png">51 <Name>smile jump %28keltainen pelaaja%29</Name>29 <Compile Include="smile jump %28vihreä pelaaja%29 %282%29.png"> 30 <Name>smile jump %28vihreä pelaaja%29 %282%29</Name> 52 31 <Importer>TextureImporter</Importer> 53 32 <Processor>TextureProcessor</Processor> … … 55 34 </ItemGroup> 56 35 <ItemGroup> 57 <Compile Include="smile jump %28vihreä pelaaja%29.png">58 <Name>smile jump %28vihreä pelaaja%29</Name>36 <Compile Include="smile jump%28keltainen pelaaja%29 %282%29.png"> 37 <Name>smile jump%28keltainen pelaaja%29 %282%29</Name> 59 38 <Importer>TextureImporter</Importer> 60 39 <Processor>TextureProcessor</Processor> … … 62 41 </ItemGroup> 63 42 <ItemGroup> 64 <Compile Include="smile jump%28Gun%29.png"> 65 <Name>smile jump%28Gun%29</Name> 43 <Compile Include="smile jump%28vihollinen%29 %282%29.png"> 44 <Name>smile jump%28vihollinen%29 %282%29</Name> 45 <Importer>TextureImporter</Importer> 46 <Processor>TextureProcessor</Processor> 47 </Compile> 48 </ItemGroup> 49 <ItemGroup> 50 <Compile Include="Smile Jump%28trampoliini-laatta%29.png"> 51 <Name>Smile Jump%28trampoliini-laatta%29</Name> 52 <Importer>TextureImporter</Importer> 53 <Processor>TextureProcessor</Processor> 54 </Compile> 55 </ItemGroup> 56 <ItemGroup> 57 <Compile Include="Smile Jump%28laatta%29.png"> 58 <Name>Smile Jump%28laatta%29</Name> 66 59 <Importer>TextureImporter</Importer> 67 60 <Processor>TextureProcessor</Processor> -
2010/24/Vilvaini/Smile Jump/Peli.cs
r870 r902 8 8 { 9 9 const double nopeus = 300; 10 const double tasokorkeus = 0;11 10 const double hyppyVoima = 4000; 12 13 Timer aikaLaskuri; // laskee aikaa 11 double tasokorkeus = 150; 12 double tasokorkeutus = 1; 13 double tasoleveys = 150; 14 14 15 15 16 IntMeter pisteLaskuri; … … 18 19 PlatformCharacter pelaaja1; 19 20 PlatformCharacter pelaaja2; 21 PhysicsObject vihollinen; 22 23 Timer aikaLaskuri; // laskee aikaa 24 ValueDisplay aikaNaytto; // näyttää ajan 25 26 PhysicsObject vasenReuna; 27 PhysicsObject alaReuna; 28 PhysicsObject oikeaReuna; 20 29 21 30 int kenttaNro; // monesko kenttä on menossa 22 23 private void aikaLoppui(Timer sender) 24 { 25 // täydennä: mitä tapahtuu, kun aika loppui 26 lisaaTaso(RandomGen.NextInt(-150, 100), Level.Bottom + 150); 27 const double tasokorkeus = tasokorkeus + 200; 28 aikaLaskuri.Reset(); // nollataan aikalaskuri oletusarvoonsa, joka oli 0. 29 } 31 30 32 31 33 protected override void Begin() 32 34 { 33 35 36 aikaLaskuri = new Timer(); // luodaan uusi ajastin, nimeltä aikaLaskuri 37 aikaLaskuri.Interval = 5; // ajastukseksi 5 sekuntia 38 aikaLaskuri.Trigger += new Timer.TriggerHandler(aikaLoppui); // // asetetaan tapahtuma, kun aikaLaskuri kun 5 sekuntia on kulunut. 39 Add(aikaLaskuri); // lisätään aikaLaskuri peliin 40 aikaLaskuri.Start(); // käynnistetään aikaLaskuri 41 42 aikaNaytto = new ValueDisplay(); // luo uuden aikaNayton 43 aikaNaytto.Text = "Aikaa jäljellä: "; // laitetaan näytöllä näkyvä teksti 44 aikaNaytto.TextColor = Color.Red; // vaihdetaan tekstin väriä 45 aikaNaytto.FormatDouble(0, true); // asetetaan näyttämään aika siten, ettei siinä näy yhtään (0) desimaalia 46 aikaNaytto.BindTo(aikaLaskuri.SecondCounter); // liitetään aikaNaytto aikaLaskuriin 47 Add(aikaNaytto); // lisätään aikaNaytto peliin 48 34 49 kenttaNro = 0; 35 50 Level.Width = 1024; 36 Level.Height = 5000; 51 Level.Height = 15000; 52 53 LisaaVihollinen(0.0, Level.Bottom); 37 54 38 55 // Luodaan pistelaskuri … … 55 72 MessageDisplay.Add("Pompi pidemmälle kuin toinen pelaaja!"); 56 73 57 aikaLaskuri = new Timer(); // luodaan uusi ajastin, nimeltä aikaLaskuri 58 aikaLaskuri.Interval = 0.1; // ajastukseksi 5 sekuntia 59 aikaLaskuri.Trigger += new Timer.TriggerHandler(aikaLoppui); // // asetetaan tapahtuma, kun aikaLaskuri kun 5 sekuntia on kulunut. 60 Add(aikaLaskuri); // lisätään aikaLaskuri peliin 61 aikaLaskuri.Start(); // käynnistetään aikaLaskuri 74 75 for (int i = 0; i < 70; i++) 76 { 77 tasokorkeus = tasokorkeus + 180 + tasokorkeutus; 78 lisaaTaso(RandomGen.NextDouble(Level.Left + 50, 0), Level.Bottom + tasokorkeus + RandomGen.NextDouble(30.0,50.0),tasoleveys); 79 lisaaTaso(RandomGen.NextDouble(0, Level.Right - 50), Level.Bottom + tasokorkeus + RandomGen.NextDouble(10.0,30.0), tasoleveys); 80 81 tasoleveys = tasoleveys - 2; 82 83 84 } 85 86 87 62 88 } 63 89 … … 78 104 } 79 105 106 void KasittelePallonTormays(PhysicsObject pelaaja1, PhysicsObject kohde) 107 { 108 if (kohde == oikeaReuna) 109 { 110 pelaaja1.X = Level.Left + 30; 111 } 112 else if (kohde == vasenReuna) 113 { 114 pelaaja1.X = Level.Right - 30; 115 } 116 } 80 117 void luoKentta() 81 118 { 82 Level.CreateBorders(1, true); // Miksei reunat näy? 119 vasenReuna = Level.CreateLeftBorder(); 120 vasenReuna.Restitution = 0.0; 121 vasenReuna.IsVisible = false; 122 123 alaReuna = Level.CreateBottomBorder(); 124 vasenReuna.Restitution = 0.0; 125 vasenReuna.IsVisible = false; 126 127 oikeaReuna = Level.CreateRightBorder(); 128 vasenReuna.Restitution = 0.0; 129 vasenReuna.IsVisible = false; 130 83 131 Level.Background.CreateGradient(Color.Beige, Color.Wheat); 84 132 85 lisaaTaso(RandomGen.NextInt(-150, 100), Level.Bottom + 150); 86 lisaaTaso(RandomGen.NextInt(-50, 200), Level.Bottom + 300); 87 lisaaTaso(RandomGen.NextInt(-100, 350), Level.Bottom + 450); 88 lisaaTaso(RandomGen.NextInt(-250, 400), Level.Bottom + 600); 89 lisaaTaso(RandomGen.NextInt(-450, 500), Level.Bottom + 750); 90 lisaaTaso(RandomGen.NextInt(-550, 400), Level.Bottom + 900); 91 lisaaTaso(RandomGen.NextInt(-350, 600), Level.Bottom + 1050); 92 93 lisaaMaali(); 133 lisaaTaso(RandomGen.NextInt(-150, 100), Level.Bottom + 150, tasoleveys); 134 135 94 136 lisaaPelaajat(); 95 137 } 96 138 97 void lisaaTaso(double x, double y )98 { 99 PhysicsObject taso = PhysicsObject.CreateStaticObject( 150, 30);139 void lisaaTaso(double x, double y, double leveys) 140 { 141 PhysicsObject taso = PhysicsObject.CreateStaticObject(leveys, 30); 100 142 taso.Color = Color.Green; 101 143 taso.X = x; 102 144 taso.Y = y; 145 taso.Image = LoadImage("Smile Jump(laatta)"); 103 146 Add(taso); 104 147 } … … 108 151 pelaaja1 = new PlatformCharacter(40, 40); 109 152 pelaaja1.Mass = 4.0; 110 pelaaja1.Image = LoadImage("smile jump(keltainen pelaaja) ");153 pelaaja1.Image = LoadImage("smile jump(keltainen pelaaja) (2)"); 111 154 pelaaja1.X = 0; 112 155 pelaaja1.Y = Level.Bottom + 120; … … 114 157 pelaaja2 = new PlatformCharacter(40, 40); 115 158 pelaaja2.Mass = 4.0; 116 pelaaja2.Image = LoadImage("smile jump (vihreä pelaaja) ");159 pelaaja2.Image = LoadImage("smile jump (vihreä pelaaja) (2)"); 117 160 pelaaja2.X = 50; 118 161 pelaaja2.Y = Level.Bottom + 120; 119 162 163 164 165 166 167 AddCollisionHandler(pelaaja1, KasittelePallonTormays); 168 AddCollisionHandler(pelaaja2, KasittelePallonTormays); 169 120 170 Add(pelaaja1); 121 171 Add(pelaaja2); 122 172 } 123 173 124 void lisaaMaali() 125 { 126 PhysicsObject maali = PhysicsObject.CreateStaticObject(50, 50, Shapes.Circle); 127 maali.Tag = "maali"; 128 maali.IgnoresCollisionResponse = true; 129 maali.X = 30; 130 maali.Y = -60; 131 maali.Image = LoadImage("tahti"); 132 Add(maali); 133 } 174 void LisaaVihollinen(double x, double y) 175 { 176 vihollinen = new PhysicsObject(50, 50); 177 vihollinen.Image = LoadImage("smile jump(vihollinen) (2)"); 178 vihollinen.X = x; 179 vihollinen.Y = y; 180 vihollinen.IgnoresCollisionResponse = true; 181 vihollinen.IgnoresPhysicsLogics = true; 182 vihollinen.Velocity = new Vector(100.0, 0.0); 183 184 Add(vihollinen); 185 186 } 187 188 private void aikaLoppui(Timer sender) 189 { 190 191 MessageDisplay.Add("Aika loppui..."); // näytetään viestinäytöllä teksti 192 // täydennä: mitä tapahtuu, kun aika loppui 193 aikaLaskuri.Reset(); // nollataan aikalaskuri oletusarvoonsa, joka oli 0. 194 } 195 134 196 135 197 void lisaaNappaimet()
Note: See TracChangeset
for help on using the changeset viewer.