- Timestamp:
- 2011-06-14 14:59:11 (12 years ago)
- Location:
- 2010/23/hniemi/JyTris/JyTris
- Files:
-
- 4 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
2010/23/hniemi/JyTris/JyTris/JyTris.csproj
r1980 r1994 70 70 <ItemGroup> 71 71 <Reference Include="Jypeli4"> 72 <HintPath>..\..\..\ ..\Program Files\Jypeli\lib\x86\Jypeli4.dll</HintPath>72 <HintPath>..\..\..\Jypeli\lib\x86\Jypeli4.dll</HintPath> 73 73 </Reference> 74 74 <Reference Include="Microsoft.Xna.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553"> -
2010/23/hniemi/JyTris/JyTris/JyTris.sln
r1980 r1994 6 6 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JyTrisContent", "Content\JyTrisContent.contentproj", "{F4DC0895-798C-4BEF-93D3-7D35766B520D}" 7 7 EndProject 8 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Windows Phone Copy of JyTris", "Windows Phone Copy of JyTris.csproj", "{A8BAF24D-BDD0-45B8-8251-684CDC70F356}" 9 EndProject 8 10 Global 9 11 GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 Debug|Mixed Platforms = Debug|Mixed Platforms 13 Debug|Windows Phone = Debug|Windows Phone 10 14 Debug|x86 = Debug|x86 15 Release|Mixed Platforms = Release|Mixed Platforms 16 Release|Windows Phone = Release|Windows Phone 11 17 Release|x86 = Release|x86 12 18 EndGlobalSection 13 19 GlobalSection(ProjectConfigurationPlatforms) = postSolution 20 {3854E62B-7704-4674-860B-A6E9495B100D}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 21 {3854E62B-7704-4674-860B-A6E9495B100D}.Debug|Mixed Platforms.Build.0 = Debug|x86 22 {3854E62B-7704-4674-860B-A6E9495B100D}.Debug|Windows Phone.ActiveCfg = Debug|x86 23 {3854E62B-7704-4674-860B-A6E9495B100D}.Debug|Windows Phone.Build.0 = Debug|x86 14 24 {3854E62B-7704-4674-860B-A6E9495B100D}.Debug|x86.ActiveCfg = Debug|x86 15 25 {3854E62B-7704-4674-860B-A6E9495B100D}.Debug|x86.Build.0 = Debug|x86 26 {3854E62B-7704-4674-860B-A6E9495B100D}.Release|Mixed Platforms.ActiveCfg = Release|x86 27 {3854E62B-7704-4674-860B-A6E9495B100D}.Release|Mixed Platforms.Build.0 = Release|x86 28 {3854E62B-7704-4674-860B-A6E9495B100D}.Release|Windows Phone.ActiveCfg = Release|x86 29 {3854E62B-7704-4674-860B-A6E9495B100D}.Release|Windows Phone.Build.0 = Release|x86 16 30 {3854E62B-7704-4674-860B-A6E9495B100D}.Release|x86.ActiveCfg = Release|x86 17 31 {3854E62B-7704-4674-860B-A6E9495B100D}.Release|x86.Build.0 = Release|x86 32 {F4DC0895-798C-4BEF-93D3-7D35766B520D}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 33 {F4DC0895-798C-4BEF-93D3-7D35766B520D}.Debug|Windows Phone.ActiveCfg = Debug|x86 18 34 {F4DC0895-798C-4BEF-93D3-7D35766B520D}.Debug|x86.ActiveCfg = Debug|x86 35 {F4DC0895-798C-4BEF-93D3-7D35766B520D}.Release|Mixed Platforms.ActiveCfg = Release|x86 36 {F4DC0895-798C-4BEF-93D3-7D35766B520D}.Release|Windows Phone.ActiveCfg = Release|x86 19 37 {F4DC0895-798C-4BEF-93D3-7D35766B520D}.Release|x86.ActiveCfg = Release|x86 38 {A8BAF24D-BDD0-45B8-8251-684CDC70F356}.Debug|Mixed Platforms.ActiveCfg = Debug|Windows Phone 39 {A8BAF24D-BDD0-45B8-8251-684CDC70F356}.Debug|Mixed Platforms.Build.0 = Debug|Windows Phone 40 {A8BAF24D-BDD0-45B8-8251-684CDC70F356}.Debug|Mixed Platforms.Deploy.0 = Debug|Windows Phone 41 {A8BAF24D-BDD0-45B8-8251-684CDC70F356}.Debug|Windows Phone.ActiveCfg = Debug|Windows Phone 42 {A8BAF24D-BDD0-45B8-8251-684CDC70F356}.Debug|Windows Phone.Build.0 = Debug|Windows Phone 43 {A8BAF24D-BDD0-45B8-8251-684CDC70F356}.Debug|Windows Phone.Deploy.0 = Debug|Windows Phone 44 {A8BAF24D-BDD0-45B8-8251-684CDC70F356}.Debug|x86.ActiveCfg = Debug|Windows Phone 45 {A8BAF24D-BDD0-45B8-8251-684CDC70F356}.Release|Mixed Platforms.ActiveCfg = Release|Windows Phone 46 {A8BAF24D-BDD0-45B8-8251-684CDC70F356}.Release|Mixed Platforms.Build.0 = Release|Windows Phone 47 {A8BAF24D-BDD0-45B8-8251-684CDC70F356}.Release|Mixed Platforms.Deploy.0 = Release|Windows Phone 48 {A8BAF24D-BDD0-45B8-8251-684CDC70F356}.Release|Windows Phone.ActiveCfg = Release|Windows Phone 49 {A8BAF24D-BDD0-45B8-8251-684CDC70F356}.Release|Windows Phone.Build.0 = Release|Windows Phone 50 {A8BAF24D-BDD0-45B8-8251-684CDC70F356}.Release|Windows Phone.Deploy.0 = Release|Windows Phone 51 {A8BAF24D-BDD0-45B8-8251-684CDC70F356}.Release|x86.ActiveCfg = Release|Windows Phone 20 52 EndGlobalSection 21 53 GlobalSection(SolutionProperties) = preSolution -
2010/23/hniemi/JyTris/JyTris/Peli.cs
r1980 r1994 3 3 using Jypeli.Widgets; 4 4 using Jypeli.Assets; 5 using Jypeli.WP7; 5 6 6 7 namespace JyTris … … 29 30 TetrisPalikka aktiivinenPalikka; 30 31 TetrisPalikka ennustusPalikka; 32 GameObject pausenappula; 33 34 //Liikutusvektorit 35 Vector vasemmalle = new Vector(-1, 0); 36 Vector oikealle = new Vector(1, 0); 37 Vector alas = new Vector(0, 1); 38 31 39 32 40 Timer tiputusajastin; … … 64 72 AsetaPistelista(); 65 73 LuoHud(); 74 #if WINDOWS_PHONE 75 Puhelinasetukset(); 76 #endif 66 77 } 67 78 … … 70 81 //topLista = HighScoreList.LoadOrCreate("topten.dat",10); 71 82 } 83 84 #region WP7-Metodit 85 /// <summary> 86 /// Asettaa näytön asennon ja zoomin kohilleen. 87 /// </summary> 88 public void Puhelinasetukset() 89 { 90 Phone.DisplayOrientation = Jypeli.WP7.DisplayOrientation.Portrait; 91 Camera.ZoomToLevel(); 92 Camera.Zoom(0.9); 93 Camera.Move(new Vector(40, 0)); 94 TouchPanel.Listen(ButtonState.Pressed, KasitteleKosketus, null); 95 } 96 97 /// <summary> 98 /// Käsittelee pelaamiseen liittyvät kosketukset (Palikan liikuttaminen) 99 /// </summary> 100 /// <param name="b">Käsiteltävä kosketus</param> 101 public void KasitteleLiikuntaKosketukset(Touch b) 102 { 103 104 if (b.PositionOnWorld.X < AnnaKoordinaateista(aktiivinenPalikka.Sijainti()[0]).Position.X - 30) 105 { 106 Liikuta(vasemmalle); 107 return; 108 } 109 if (b.PositionOnWorld.X > AnnaKoordinaateista(aktiivinenPalikka.Sijainti()[0]).Position.X + 30) 110 { 111 Liikuta(oikealle); 112 return; 113 } 114 115 if (b.PositionOnWorld.Y < AnnaKoordinaateista(aktiivinenPalikka.Sijainti()[0]).Position.Y - 20) 116 { 117 Liikuta(alas); 118 return; 119 } 120 else if (b.PositionOnWorld.Y > AnnaKoordinaateista(aktiivinenPalikka.Sijainti()[0]).Position.Y + 10) 121 { 122 Kaanna(); 123 return; 124 } 125 } 126 127 public void PysaytaPhone(Touch b) 128 { 129 Pysayta(true); 130 } 131 132 /// <summary> 133 /// Käsittelee kosketuksen menussa 134 /// </summary> 135 /// <param name="b"></param> 136 public void KasitteleKosketus(Touch b) 137 { 138 if (tiputusajastin == null) 139 { 140 KaynnistaPeli(); 141 return; 142 } 143 } 144 145 public void KasittelePauseKosketus(Touch b) 146 { 147 Pysayta(false); 148 } 149 #endregion 72 150 73 151 #region Intro … … 89 167 void IntroPyoritys(Timer ajastin) 90 168 { 91 TuhoaRivi(korkeus -1);169 TuhoaRivi(korkeus - 1); 92 170 93 171 Color randomvari = RandomGen.NextColor(); … … 100 178 indeksi += suunta; 101 179 vaihtoCounter++; 102 if (indeksi > leveys -1 && suunta > 0)180 if (indeksi > leveys - 1 && suunta > 0) 103 181 { 104 182 indeksi = 0; … … 123 201 void LuoHud() 124 202 { 125 Widget statistiikka = new Widget(120, 100);203 Widget statistiikka = new Widget(120, 100); 126 204 statistiikka.Layout = new VerticalLayout(); 127 205 Add(statistiikka); … … 133 211 pistenaytto.BindTo(pisteet); 134 212 statistiikka.Add(pistenaytto); 135 213 136 214 statistiikka.Position = new Vector(Level.Right + 120, Level.Top - 100); 137 215 … … 145 223 status = new Label("JyTris " + versio); 146 224 Add(status); 225 226 pausenappula = new GameObject(50, 50); 227 pausenappula.Position = new Vector(Level.Right + 75, Level.Top - 25); 228 Add(pausenappula); 147 229 148 230 /* … … 164 246 ennustuskentta[i][j].Color = Color.Transparent; 165 247 ennustuskentta[i][j].X = Level.Right + 90 + (palikkojenSivu / 2) + j * (palikkojenSivu); 166 ennustuskentta[i][j].Y = Level.Top - 200 - (palikkojenSivu / 2) - i * (palikkojenSivu);248 ennustuskentta[i][j].Y = Level.Top - 200 - (palikkojenSivu / 2) - i * (palikkojenSivu); 167 249 Add(ennustuskentta[i][j]); 168 250 } … … 244 326 Keyboard.Listen(Key.Space, ButtonState.Pressed, Tiputa, "Tiputtaa palikan"); 245 327 Keyboard.Listen(Key.P, ButtonState.Pressed, Pysayta, "Pysayttaa pelin", true); 328 TouchPanel.Listen(ButtonState.Pressed, KasitteleLiikuntaKosketukset, null); 329 TouchPanel.ListenOn(pausenappula, ButtonState.Down, PysaytaPhone ,null); 330 246 331 } 247 332 … … 249 334 { 250 335 Keyboard.Listen(Key.P, ButtonState.Pressed, Pysayta, "Jatkaa peliä", false); 336 TouchPanel.Listen(ButtonState.Pressed, KasittelePauseKosketus, null); 251 337 } 252 338 … … 258 344 Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "Poistuu pelistä"); 259 345 Keyboard.Listen(Key.F2, ButtonState.Pressed, KaynnistaPeli, "Aloittaa uuden pelin"); 346 TouchPanel.Listen(ButtonState.Pressed, KasitteleKosketus, null); 260 347 } 261 348 #endregion … … 273 360 aktiivinenPalikka.Liikuta(suunta); 274 361 } 275 362 276 363 PaivitaPalikka(aktiivinenPalikka, aktiivinenPalikka.Vari()); 277 364 } … … 289 376 for (int i = 0; i < tulevaSijainti.Length; i++) 290 377 { 291 if (!OnkoTyhja(tulevaSijainti[i])) 378 if (!OnkoTyhja(tulevaSijainti[i])) 292 379 { 293 380 PaivitaPalikka(aktiivinenPalikka, aktiivinenPalikka.Vari()); 294 381 return; 295 } 382 } 296 383 } 297 384 … … 310 397 311 398 tiputusajastin.Reset(); 312 if (!VoikoSiirtaa(new Vector(0, 1), aktiivinenPalikka))399 if (!VoikoSiirtaa(new Vector(0, 1), aktiivinenPalikka)) 313 400 { 314 401 PaivitaPalikka(aktiivinenPalikka, aktiivinenPalikka.Vari()); … … 377 464 bool OnkoTyhja(Vector paikka) 378 465 { 379 if (paikka.X > leveys -1 || paikka.X < 0) return false;380 if (paikka.Y > korkeus -1 || paikka.Y < 0) return false;466 if (paikka.X > leveys - 1 || paikka.X < 0) return false; 467 if (paikka.Y > korkeus - 1 || paikka.Y < 0) return false; 381 468 382 469 if (pelikentta[(int)paikka.Y][(int)paikka.X].Color == Color.Transparent) return true; … … 398 485 } 399 486 } 487 488 /// <summary> 489 /// Antaa gameobjectin, joka vastaa taulukon koordinaatteja (0,1,2...) 490 /// 491 /// Ei vastaa näytön koordinaatteja! 492 /// </summary> 493 /// <param name="koordinaatit">Haluttu koordinaatti</param> 494 /// <returns>Gameobject, joka vastaa koordinaatteja</returns> 495 GameObject AnnaKoordinaateista(Vector koordinaatit) 496 { 497 return pelikentta[(int)Math.Round(koordinaatit.Y)][(int)Math.Round(koordinaatit.X)]; 498 } 400 499 #endregion 401 500 #region Pelilogiikka … … 413 512 aktiivinenPalikka = ennustusPalikka; 414 513 } 415 else 416 { 417 aktiivinenPalikka = new TetrisPalikka(leveys / 2); 514 else 515 { 516 aktiivinenPalikka = new TetrisPalikka(leveys / 2); 418 517 } 419 518 … … 459 558 AsetaPeliNappaimet(); 460 559 461 560 462 561 /* 463 562 if (purkkabool)
Note: See TracChangeset
for help on using the changeset viewer.