- Timestamp:
- 2010-08-04 08:59:31 (13 years ago)
- Location:
- 2010/23/hniemi/Matopeli
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
2010/23/hniemi/Matopeli/Matopeli.csproj
r1564 r1585 57 57 </PropertyGroup> 58 58 <ItemGroup> 59 <Reference Include="Jypeli2, Version= 1.0.0.0, Culture=neutral, processorArchitecture=x86">59 <Reference Include="Jypeli2, Version=2.4.1.0, Culture=neutral, processorArchitecture=x86"> 60 60 <SpecificVersion>False</SpecificVersion> 61 <HintPath>..\..\ lib\Jypeli2.dll</HintPath>61 <HintPath>..\..\..\..\..\lib\Jypeli2.dll</HintPath> 62 62 </Reference> 63 63 <Reference Include="Microsoft.Xna.Framework, Version=3.1.0.0, Culture=neutral, PublicKeyToken=6d5c3888ef60e27d" /> -
2010/23/hniemi/Matopeli/Peli.cs
r1564 r1585 8 8 { 9 9 //GameObject[] mato; 10 const double ruudun leveys= 20;10 const double ruudunKoko = 20; 11 11 const int madonPituus = 6; 12 12 int ruutujaVaakasuunnassa; 13 int ruutujaPystysuunnassa; 13 14 List<GameObject> mato = new List<GameObject>(); 15 List<GameObject> kerattavat = new List<GameObject>(); 14 16 Direction liikkumissuunta; 15 17 Timer liikutusajastin; … … 17 19 protected override void Begin() 18 20 { 19 21 LuoKentta(); 20 22 LuoLiikutusAjastin(); 21 23 LuoMato(madonPituus); … … 24 26 } 25 27 28 void LuoKentta() 29 { 30 Level.Height = 500; 31 Level.Width = 500; 32 ruutujaPystysuunnassa = (int)Math.Floor(Level.Height / ruudunKoko); 33 ruutujaVaakasuunnassa = (int)Math.Floor(Level.Width / ruudunKoko); 34 } 35 26 36 void LuoMato(int pituus) 27 37 { 28 38 for (int i = 0; i < pituus-1; i++) 29 39 { 30 mato.Add(new GameObject(ruudun leveys - 1, ruudunleveys- 1));40 mato.Add(new GameObject(ruudunKoko - 1, ruudunKoko - 1)); 31 41 Add(mato[i]); 32 42 } 33 43 //Luo madon pään viimeiseksi, jotta sen pään värin muuttaminen näkyy 34 44 //Aka. Too lazy for layers 35 mato.Insert(0, new GameObject(ruudun leveys - 1, ruudunleveys- 1));45 mato.Insert(0, new GameObject(ruudunKoko - 1, ruudunKoko - 1)); 36 46 Add(mato[0]); 37 47 } … … 44 54 Keyboard.Listen(Key.Right, ButtonState.Pressed, AsetaSuunta, "Kääntää oikealle", Direction.Right); 45 55 Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "Poistuu pelistä"); 56 } 57 58 void LuoKerattava() 59 { 60 GameObject kerattava = new GameObject(ruudunKoko / 2, ruudunKoko / 2, Shapes.Circle); 61 62 Add(kerattava); 63 kerattavat.Add(kerattava); 64 46 65 } 47 66 … … 60 79 void SiirraMatoa(Timer ajastin) 61 80 { 62 Vector suunta = Vector.FromLengthAndAngle(ruudun leveys, Angle.FromDirection(liikkumissuunta));81 Vector suunta = Vector.FromLengthAndAngle(ruudunKoko, Angle.FromDirection(liikkumissuunta)); 63 82 64 83 for (int i = mato.Count-1; i > 0; i--)
Note: See TracChangeset
for help on using the changeset viewer.