- Timestamp:
- 2010-08-05 14:58:29 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
2010/31/vivevinu/Mittelo maasta/Peli.cs
r1602 r1630 7 7 { 8 8 Image pelto = LoadImage("pelto"); 9 Image sintorni = LoadImage("sintorni"); 10 Image sinlippu = LoadImage("sinlippu"); 11 Image puntorni = LoadImage("puntorni"); 12 Image punlippu = LoadImage("punlippu"); 13 Image lentokentta = LoadImage("lentokentta"); 14 bool a = false; 15 16 Vector paikka; 17 18 string b = "pelaaja2"; 9 19 const int ruudunLeveys = 40; 10 20 const int ruudunKorkeus = 40; 21 Label teksti2;// = new Label();// = new Label("Ostettava ruutu: " + x.ToString() + ", " + y.ToString()); 11 22 12 23 protected override void Begin() 13 24 { 14 LuoKentta(); 25 paikka = new Vector(0,0); 26 teksti2 = new Label(); 27 Add(teksti2); 28 LuoKentta(); 29 Vuoro(); 15 30 } 16 31 void LuoKentta() … … 19 34 ruudut['0'] = LuoPelto; 20 35 ruudut.Insert(ruudunLeveys, ruudunKorkeus); 21 Label teksti1 = new Label(50.0, 20.0, " Aloittaja:");22 teksti1.X = Screen.Left + 150;23 teksti1.Y = Screen.Top - 150;36 Label teksti1 = new Label(50.0, 20.0, "Vuorossa:"); 37 teksti1.X = Screen.Left + 50; 38 teksti1.Y = Screen.Top - 15; 24 39 Add(teksti1); 40 for (int i = -15; i < 16; i++) 41 { 42 Label teksti3 = new Label(10, 10, i.ToString()); 43 teksti3.X = Screen.Left + 640+40*i; 44 teksti3.Y = Screen.Top - 40; 45 Add(teksti3); 46 } 47 for (int i = 11; i > -12; i--) 48 { 49 Label teksti4 = new Label(10, 10, i.ToString()); 50 teksti4.Y = Screen.Top -515 + 40 * i; 51 teksti4.X = Screen.Left + 15; 52 Add(teksti4); 53 } 54 } 55 void Vuoro() 56 { 57 if (b == "pelaaja1") 58 { 59 b = "pelaaja2"; 60 Label teksti5 = new Label(b); 61 teksti5.X = Screen.Left + 160; 62 teksti5.Y = Screen.Top - 15; 63 Add(teksti5); 64 } 65 else 66 { 67 b = "pelaaja1"; 68 Label teksti5 = new Label(b); 69 teksti5.X = Screen.Left + 160; 70 teksti5.Y = Screen.Top - 15; 71 Add(teksti5); 72 } 73 Liikkuminen(); 74 a = false; 75 } 76 void Liikkuminen() 77 { 78 Vector vasen = new Vector(-1, 0); 79 Vector ylos = new Vector(0,1); 80 81 Keyboard.Listen(Key.Up, ButtonState.Pressed, LiikutaValintaa, null, ylos); 82 Keyboard.Listen(Key.Down, ButtonState.Pressed, LiikutaValintaa, null, -ylos); 83 Keyboard.Listen(Key.Left, ButtonState.Pressed, LiikutaValintaa, null, vasen); 84 Keyboard.Listen(Key.Right, ButtonState.Pressed, LiikutaValintaa, null, -vasen); 85 teksti2.Text = "Ostettava ruutu: " + paikka.X + ", " + paikka.Y; 86 teksti2.X = Screen.Left + 600; 87 teksti2.Y = Screen.Top - 15; 88 89 Keyboard.Listen(Key.Enter, ButtonState.Down, Ostamaa, null); 25 90 26 91 } 27 92 93 void LiikutaValintaa(Vector maara) 94 { 95 teksti2.Text = "Ostettava ruutu: " + paikka.X + ", " + paikka.Y; 96 paikka = paikka + maara; 97 } 98 99 void Ostamaa() 100 { 101 a = true; 102 103 } 28 104 PhysicsObject LuoPelto() 29 105 { … … 32 108 return peltomaa; 33 109 } 110 PhysicsObject Luosinlippu() 111 { 112 PhysicsObject sinilippu = PhysicsObject.CreateStaticObject(40.0, 40.0); 113 sinilippu.Image = sinlippu; 114 return sinilippu; 115 } 116 PhysicsObject Luopunlippu() 117 { 118 PhysicsObject punalippu = PhysicsObject.CreateStaticObject(40.0, 40.0); 119 punalippu.Image = punlippu; 120 return punalippu; 121 } 122 PhysicsObject Luosinitorni() 123 { 124 PhysicsObject sinitorni = PhysicsObject.CreateStaticObject(40.0, 40.0); 125 sinitorni.Image = sintorni; 126 return sinitorni; 127 } 128 PhysicsObject Luopuntorni() 129 { 130 PhysicsObject punatorni = PhysicsObject.CreateStaticObject(40.0, 40.0); 131 punatorni.Image = puntorni; 132 return punatorni; 133 } 134 PhysicsObject Luolentokentta() 135 { 136 PhysicsObject rata = PhysicsObject.CreateStaticObject(40.0, 40.0); 137 rata.Image = lentokentta; 138 return rata; 139 } 34 140 35 141 }
Note: See TracChangeset
for help on using the changeset viewer.