- Timestamp:
- 2012-04-19 14:50:26 (11 years ago)
- Location:
- 2012/JAO/jouni/Tasohyppelypeli1
- Files:
-
- 1 added
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
2012/JAO/jouni/Tasohyppelypeli1/Tasohyppelypeli1/Tasohyppelypeli1/Tasohyppelypeli1.cs
r2728 r2730 9 9 public class Tasohyppelypeli1 : PhysicsGame 10 10 { 11 int lkm; 11 12 const double nopeus = 200; 12 const double hyppyNopeus = 1000; 13 int lautannopeus = 6; 14 const double hyppyNopeus = 900; 13 15 const int RUUDUN_KOKO = 40; 14 ScoreList topLista = new ScoreList(10, false, 0);16 ScoreList topLista = new ScoreList(10,true, 999); 15 17 IntMeter pisteLaskuri; 16 18 PlatformCharacter pelaaja1; 17 19 Timer aikaLaskuri; 20 Image taustaKuva = LoadImage("hello"); 18 21 Image pelaajanKuva = LoadImage("BadHelloKitty"); 19 22 Image tahtiKuva = LoadImage("heart"); … … 23 26 public override void Begin() 24 27 { 28 29 if (DataStorage.Exists("pisteet3.xml")) 30 topLista = DataStorage.Load<ScoreList>(topLista, "pisteet3.xml"); 31 Valikko(); 32 } 33 void AloitaPeli(string tied) 34 { 35 ClearAll(); 36 lkm = 0; 25 37 Gravity = new Vector(0, -1000); 26 if (DataStorage.Exists("pisteet.xml")) 27 topLista = DataStorage.Load<ScoreList>(topLista, "pisteet.xml"); 28 luoKentta(); 29 38 luoKentta(tied); 39 Level.Background.Image = taustaKuva; 40 30 41 LuoLaskuri(); 31 42 lisaaNappaimet(); 32 43 LuoAikaLaskuri(); 33 44 Camera.Follow(pelaaja1); 34 Camera.ZoomFactor = 1. 2;45 Camera.ZoomFactor = 1.3; 35 46 Camera.StayInLevel = true; 36 } 37 void Valikko() 38 { 47 Timer suuntavaihtuu = new Timer(); 48 suuntavaihtuu.Interval = 5; 49 suuntavaihtuu.Timeout += vaihdasuuntaa; 50 suuntavaihtuu.Start(); 51 } 52 void vaihdasuuntaa() 53 { 54 lautannopeus = -lautannopeus; 55 } 56 void kenttavalikko() 57 { 58 ClearAll(); 59 Level.BackgroundColor = Color.White; 60 Level.Background.Image = taustaKuva; 61 Camera.ZoomToLevel(); 62 Level.Background.ScaleToLevelFull(); 63 MultiSelectWindow valikko = new MultiSelectWindow("valitse kenttä", 64 "kenttä 1", "kenttä 2", "takaisin"); 65 valikko.ItemSelected += PainettiinkenttaValikonNappia; 66 Add(valikko); 67 Mouse.IsCursorVisible = true; 68 } 69 void PainettiinkenttaValikonNappia(int valinta) 70 { 71 switch (valinta) 72 { 73 case 0: 74 AloitaPeli("kentta1.txt"); 75 break; 76 case 1: 77 AloitaPeli("kentta2.txt"); 78 break; 79 case 2: 80 Valikko(); 81 break; 82 } 83 } 84 void Valikko() 85 { 86 87 ClearAll(); 88 Level.BackgroundColor = Color.White; 89 Level.Background.Image = taustaKuva; 90 Camera.ZoomToLevel(); 91 Level.Background.ScaleToLevelFull(); 92 MultiSelectWindow valikko = new MultiSelectWindow("Tervetuloa peliin", 93 "Aloita peli", "valitse kenttä", "Parhaat pisteet", "Lopeta"); 94 valikko.ItemSelected += PainettiinValikonNappia; 95 Add(valikko); 96 Mouse.IsCursorVisible = true; 97 //Camera.ZoomFactor = 1.2; 98 //Camera.StayInLevel = true; 99 39 100 40 101 } 102 void PainettiinValikonNappia(int valinta) 103 { 104 switch (valinta) 105 { 106 case 0: 107 AloitaPeli("kentta1.txt"); 108 break; 109 case 1: 110 kenttavalikko(); 111 break; 112 case 2: 113 ParhaatPisteet(); 114 break; 115 case 3: 116 Exit(); 117 break; 118 } 119 } 41 120 void LuoAikaLaskuri() 42 121 { … … 45 124 46 125 Label aikaNaytto = new Label(); 47 aikaNaytto.TextColor = Color. White;126 aikaNaytto.TextColor = Color.Turquoise; 48 127 aikaNaytto.DecimalPlaces = 1; 49 128 aikaNaytto.X = Screen.Left + 100; … … 60 139 pisteNaytto.Y = Screen.Top - 100; 61 140 pisteNaytto.TextColor = Color.Red; 62 pisteLaskuri.MaxValue = 1;141 pisteLaskuri.MaxValue = lkm; 63 142 pisteLaskuri.UpperLimit += laskuriYlarajassa; 64 143 pisteNaytto.BindTo(pisteLaskuri); … … 75 154 Add(topIkkuna); 76 155 } 156 void ParhaatPisteet() 157 { 158 HighScoreWindow topIkkuna = new HighScoreWindow( 159 "Parhaat pisteet", 160 topLista); 161 topIkkuna.Closed += TallennaPisteet; 162 Add(topIkkuna); 163 } 77 164 void TallennaPisteet(Window sender) 78 165 { 79 DataStorage.Save<ScoreList>(topLista, "pisteet.xml"); 80 } 81 void luoKentta() 82 { 83 TileMap kentta = TileMap.FromFile("kentta1.txt"); 166 DataStorage.Save<ScoreList>(topLista, "pisteet3.xml"); 167 Valikko(); 168 } 169 void luoKentta(string tied) 170 { 171 TileMap kentta = TileMap.FromFile(tied); 84 172 kentta.SetTileMethod('#', lisaaTaso); 85 173 kentta.SetTileMethod('*', lisaaTahti); 174 kentta.SetTileMethod('$', lisaalautta1); 175 kentta.SetTileMethod('.', lisaalattia); 176 kentta.SetTileMethod('%', lisaalautta2); 86 177 kentta.SetTileMethod('N', lisaaPelaaja); 87 178 kentta.Execute(RUUDUN_KOKO, RUUDUN_KOKO); … … 96 187 taso.Color = Color.LightPink; 97 188 Add(taso); 189 } 190 void lisaalattia(Vector paikka, double leveys, double korkeus) 191 { 192 PhysicsObject taso = PhysicsObject.CreateStaticObject(leveys, korkeus); 193 taso.Position = paikka; 194 taso.Color = Color.ForestGreen; 195 Add(taso); 196 } 197 void lisaalautta1(Vector paikka, double leveys, double korkeus) 198 { 199 PhysicsObject taso = PhysicsObject.CreateStaticObject(leveys, korkeus); 200 taso.Position = paikka; 201 taso.Color = Color.LightPink; 202 Add(taso); 203 Timer lautta1timer = new Timer(); 204 lautta1timer.Interval = 0.1; 205 lautta1timer.Timeout += delegate {lauttaliikkuu(taso);}; 206 lautta1timer.Start(); 207 } 208 void lauttaliikkuu(PhysicsObject lautta) 209 { 210 lautta.X += lautannopeus; 211 } 212 void lisaalautta2(Vector paikka, double leveys, double korkeus) 213 { 214 PhysicsObject taso = PhysicsObject.CreateStaticObject(leveys, korkeus); 215 taso.Position = paikka; 216 taso.Color = Color.LightPink; 217 Add(taso); 218 Timer lautta2timer = new Timer(); 219 lautta2timer.Interval = 0.1; 220 lautta2timer.Timeout += delegate { lautta2liikkuu(taso); }; 221 lautta2timer.Start(); 222 } 223 void lautta2liikkuu(PhysicsObject lautta) 224 { 225 lautta.X += -lautannopeus; 98 226 } 99 227 … … 105 233 tahti.Image = tahtiKuva; 106 234 tahti.Tag = "tahti"; 235 lkm++; 107 236 Add(tahti); 108 237 } -
2012/JAO/jouni/Tasohyppelypeli1/Tasohyppelypeli1/Tasohyppelypeli1/Tasohyppelypeli1.csproj
r2728 r2730 121 121 <CopyToOutputDirectory>Always</CopyToOutputDirectory> 122 122 </Content> 123 <Content Include="kentta2.txt"> 124 <CopyToOutputDirectory>Always</CopyToOutputDirectory> 125 </Content> 123 126 </ItemGroup> 124 127 <ItemGroup> -
2012/JAO/jouni/Tasohyppelypeli1/Tasohyppelypeli1/Tasohyppelypeli1/Tasohyppelypeli1.csproj.Debug.cachefile
r2728 r2730 4 4 Content\BadHelloKitty.xnb 5 5 Content\heart.xnb 6 Content\Nimetön.xnb 7 Content\hello.xnb 6 8 kentta1.txt 9 kentta2.txt -
2012/JAO/jouni/Tasohyppelypeli1/Tasohyppelypeli1/Tasohyppelypeli1/bin/x86/Debug/Data/pisteet.xml
r2728 r2730 9 9 </Field> 10 10 <Field Name="Score" Type="System.Double, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> 11 <Value> 1.0333354</Value>11 <Value>5.10001020000001</Value> 12 12 </Field> 13 13 </Item> … … 17 17 </Field> 18 18 <Field Name="Score" Type="System.Double, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> 19 <Value> 1.0333354</Value>19 <Value>4.00000800000001</Value> 20 20 </Field> 21 21 </Item> 22 22 <Item Index="2" Type="Jypeli.ScoreItem, Jypeli4, Version=4.2.1.0, Culture=neutral, PublicKeyToken=null"> 23 23 <Field Name="Name" Type="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> 24 <Value> -</Value>24 <Value>kk</Value> 25 25 </Field> 26 26 <Field Name="Score" Type="System.Double, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> 27 <Value> 0</Value>27 <Value>1.5333364</Value> 28 28 </Field> 29 29 </Item> 30 30 <Item Index="3" Type="Jypeli.ScoreItem, Jypeli4, Version=4.2.1.0, Culture=neutral, PublicKeyToken=null"> 31 31 <Field Name="Name" Type="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> 32 <Value> -</Value>32 <Value>kk</Value> 33 33 </Field> 34 34 <Field Name="Score" Type="System.Double, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> 35 <Value> 0</Value>35 <Value>1.0333354</Value> 36 36 </Field> 37 37 </Item> 38 38 <Item Index="4" Type="Jypeli.ScoreItem, Jypeli4, Version=4.2.1.0, Culture=neutral, PublicKeyToken=null"> 39 39 <Field Name="Name" Type="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> 40 <Value> -</Value>40 <Value>kk</Value> 41 41 </Field> 42 42 <Field Name="Score" Type="System.Double, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> 43 <Value> 0</Value>43 <Value>1.0333354</Value> 44 44 </Field> 45 45 </Item> -
2012/JAO/jouni/Tasohyppelypeli1/Tasohyppelypeli1/Tasohyppelypeli1/bin/x86/Debug/kentta1.txt
r2728 r2730 1 1 * 2 2 ## 3 *4 * * 5 ## ## 3 4 * * * 5 ## ## ## 6 6 7 7 * * * … … 15 15 16 16 N 17 ############################## 17 .............................. -
2012/JAO/jouni/Tasohyppelypeli1/Tasohyppelypeli1/Tasohyppelypeli1/kentta1.txt
r2728 r2730 1 1 * 2 2 ## 3 *4 * * 5 ## ## 3 4 * * * 5 ## ## ## 6 6 7 7 * * * … … 15 15 16 16 N 17 ############################## 17 .............................. -
2012/JAO/jouni/Tasohyppelypeli1/Tasohyppelypeli1/Tasohyppelypeli1/obj/x86/Debug/Tasohyppelypeli1.csproj.FileListAbsolute.txt
r2728 r2730 13 13 D:\jounikovanen\Tasohyppelypeli1\Tasohyppelypeli1\Tasohyppelypeli1\bin\x86\Debug\Content\BadHelloKitty.xnb 14 14 D:\jounikovanen\Tasohyppelypeli1\Tasohyppelypeli1\Tasohyppelypeli1\bin\x86\Debug\Content\heart.xnb 15 D:\jounikovanen\Tasohyppelypeli1\Tasohyppelypeli1\Tasohyppelypeli1\bin\x86\Debug\Content\Nimetön.xnb 16 D:\jounikovanen\Tasohyppelypeli1\Tasohyppelypeli1\Tasohyppelypeli1\bin\x86\Debug\Content\hello.xnb 17 D:\jounikovanen\Tasohyppelypeli1\Tasohyppelypeli1\Tasohyppelypeli1\bin\x86\Debug\kentta2.txt -
2012/JAO/jouni/Tasohyppelypeli1/Tasohyppelypeli1/Tasohyppelypeli1/obj/x86/Debug/cachefile-{54F346DA-69AE-4C48-9FF4-FE82230C2AE7}-targetpath.txt
r2728 r2730 4 4 Content\BadHelloKitty.xnb 5 5 Content\heart.xnb 6 Content\Nimetön.xnb 7 Content\hello.xnb -
2012/JAO/jouni/Tasohyppelypeli1/Tasohyppelypeli1/Tasohyppelypeli1Content/Tasohyppelypeli1Content.contentproj
r2728 r2730 75 75 </Compile> 76 76 </ItemGroup> 77 <ItemGroup> 78 <Compile Include="Nimetön.png"> 79 <Name>Nimetön</Name> 80 <Importer>TextureImporter</Importer> 81 <Processor>TextureProcessor</Processor> 82 </Compile> 83 </ItemGroup> 84 <ItemGroup> 85 <Compile Include="hello.png"> 86 <Name>hello</Name> 87 <Importer>TextureImporter</Importer> 88 <Processor>TextureProcessor</Processor> 89 </Compile> 90 </ItemGroup> 77 91 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 78 92 <!-- To modify your build process, add your task inside one of the targets below and uncomment it. -
2012/JAO/jouni/Tasohyppelypeli1/Tasohyppelypeli1/Tasohyppelypeli1Content/obj/x86/Debug/ContentPipeline.xml
r2728 r2730 47 47 <Time>2012-04-19T12:03:53.890625+03:00</Time> 48 48 </Item> 49 <Item> 50 <Source>Nimetön.png</Source> 51 <Name>Nimetön</Name> 52 <Importer>TextureImporter</Importer> 53 <Processor>TextureProcessor</Processor> 54 <Options>None</Options> 55 <Output>D:\jounikovanen\Tasohyppelypeli1\Tasohyppelypeli1\Tasohyppelypeli1\bin\x86\Debug\Content\Nimetön.xnb</Output> 56 <Time>2012-04-19T13:09:41.515625+03:00</Time> 57 </Item> 58 <Item> 59 <Source>hello.png</Source> 60 <Name>hello</Name> 61 <Importer>TextureImporter</Importer> 62 <Processor>TextureProcessor</Processor> 63 <Options>None</Options> 64 <Output>D:\jounikovanen\Tasohyppelypeli1\Tasohyppelypeli1\Tasohyppelypeli1\bin\x86\Debug\Content\hello.xnb</Output> 65 <Time>2012-04-19T13:11:32.625+03:00</Time> 66 </Item> 49 67 <BuildSuccessful>true</BuildSuccessful> 50 68 <Settings>
Note: See TracChangeset
for help on using the changeset viewer.