Video Oyunu Yazarken Nelere Dikkat Edilmeli Bölüm 2
Selamlar;
Aşağıda geçen hafta bahsettiğim BoMan oyununun oynanış videosu bulunmaktadır. Umarım sizde benim kadar keyif alırsınız.
İsterseniz geçen makalede anlattığım BoMan oyununun kodlamasından bahsedelim. Öncelikle karakterimizi hareket ettirelim.
- Hareketten önce basılan tuşlar kontrol edilir.
1 |
if(e.KeyCode==Keys.Up || e.KeyCode==Keys.Down || e.KeyCode==Keys.Left || e.KeyCode==Keys.Right) |
- Eğer yön tuşlarından birine basılmış ise yürüme sesi çıkarılıp ben bu uygulamada özel bir ses dosyası olan tonysound.cs kullandım ilgili hareket işlemine başlanır.
1 2 |
string str=Application.StartupPath.ToString()+"\\sound\\F0.wav";//hareket ederkenki sesimiz. Sound.Play(str,PlaySoundFlags.SND_FILENAME| PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_NOWAIT|PlaySoundFlags.SND_NOSTOP); |
- Hareket sırasında oyundaki tüm bölümlere ait çıkış kordinatları ile kahramanımızın kordinatları konrol edilip bir sonraki level’e ilgili özellikler ile birlikte geçilip geçilmediğine bakılır. İlgili özelliklerden kasıt toplanan taş, para, hak ve özellik sayılarıdır.
1 |
if(yon=="up" && Boman.Location.X>exit[0] && Boman.Location.Y<exit[1] && Boman.Location.X<exit[2] && exit1.Visible==true)//çıkışa gelmişsek |
- Nitor’ya basılıp basılmadığı yani (shift tuşu) bakılarak hareket aralığı buna göre aşağıda görüldüğü gibi belirlenir. Ayrıca Kyle özelliği alınınca da hareket hızı aynı nitrodaki gibi arttırılmaktadır.
1 2 3 4 5 6 7 8 9 10 11 |
if(e.Shift==true) { timer2.Stop(); timer1.Start(); if(nitro.Width>1) { string str=Application.StartupPath.ToString()+"\\sound\\zart.wav"; Sound.Play(str,PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_NOSTOP); nityol=Nitro.Var; } } |
1 2 3 4 5 6 7 8 9 10 11 12 |
if(nit==Nitro.Var) { miktar=8; } else { miktar=4; } if(Boman.Name=="monsterBoss1") { miktar=8; } |
- Yapılan hareketin yönüne göre tüm yaratıklar tek tek gezilerek yakınlarda yartık varmı diye bakılır. Varmı() methodu Path.cs altında tanımlı başka bir method’dur. Yakınlık derecesine göre ya takip işlemine başlanır ya da yaratığa dokunulmuş ise hem oyun başa döner hem de hakkımız -1 azalır. Eğer hiç hak kalmamış ise geri sayan bir ekranla karşılaşırız. Takip işlemine Path.cs’deki TakipVarmi() function’ı ile yapılır. İlgili kod aşağıdadır. TakipVarmı()’da kasıt BoMan yaratıklardan birine belirli bir mesafe yaklaşınca yaratık tarafından kovalanır. İşte belirlenen meseafeye gelinmiş mi diye bakılan method TakipVarmi() methodudur.
- Path.cs’deki Varmı() function’ile hareket yapılınca taşlara gelinmiş ise taş yenir ve para 10 Tl artar. Ayrıca tüm taşlar yenmiş mi diye kotrol edilir. Tüm taşlar yenmiş ise çıkış kapısı açılır. Ayrıca gazlı bir içecek içilirse nitro özelliği dolar. İlgili kod aşağıdadır.
- Yapılan hareketin ardından tüm buttonlar gezilerek, burada buttonlar duvarlar manasına geliyor; ilgili hareketi duvarların sınırları içinde yapılıp yapılmadığına kısaca herhangi bir duvar engeli olup olmadığına bakılır.
- Yukarıdaki örnekte de görüldüğü gibi tüm yaratıklar önceden tanımlanan Timer ile belli bir alan içinde random olarak hareket ederler. Yaratıkların duvarları geçememesi ve kendilerine bellirlenen alanı geçmiş ise mesela takip anında tekrardan eski yerlerine dönmeleri Direction.cs’deki aşırı yüklenmiş diğer bir Move() methodu ile yapılır.
- Canavarların her timer anında kendi sınırlarında olup olmadıkları değiller ise kendi sınırlarına gitmelerini Direcition.cs’deki Boundery() Move() method’u ile birlikte sağlamaktadır. Tüm levellerdeki yaratıkların sınırları bu method içinde tanımlıdır. İlgili kodlar aşağıdadır.
1 |
go.Boundery(monster,htable,ref dir,xbilk,ybilk,72,176,ref xbBak,ref ybBak,ref xkBak,ref ykBak,ref intKere,16,104,264,392,ref kere); |
- Levellar arasında haklar, para, toplanan taşlar ve özellik sayıları constructer’a parametreler atanarak aşağıda görüldüğü gibi atılmaktadır.
1 2 |
Level2 frm2=new Level2(Money,Yemlik,Hak,this); public Level2(double dblMoney,int intyemlik,int intHak,Form frm){ } |
- Yaratık ‘da takip yoksa ve sınırı aşmamış ise yani kendisine belirlenen alan içinde ise, random hareketi aşağıda görüldüğü gibi önce random yön belirlenir, daha sonra Direction’daki Move() methodu ilgili parametreler ile aşağıda görüldüğü gibi çağrılır.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
if(htable["monster2"].ToString().Trim()=="")//takip yoksa { if(htable["smonster2"].ToString().Trim()=="")//sınırı aşmamışsa { // intKere2=0; xkBak2=0; xbBak2=0; ykBak2=0; ybBak2=0; // Random rnd=new Random(); int i=rnd.Next(1,5); if(i==1) dir=Keys.Up; if(i==2) dir=Keys.Down; if(i==3) dir=Keys.Left; if(i==4) dir=Keys.Right; Nitro nit=Nitro.Yok; go.Move(dir,monster2,this,ref Money,nit,new int[]{56,456},Boman,ref Hak,ref yemlik,ref intbomb,Exit,htable,144,312,392,496); lblPara.Text=Money.ToString()+" YTL"; lblCani.Text="X"+ Hak.ToString(); lblYemlik.Text="X"+yemlik.ToString(); if(Hak==0) { kapat(); } } |
- Eğer sınırı aşmış ise nitro açık bir şekilde kendisine belirlenen alana yine Direction.cs’deki Move() methodu ile hızlıca aşağıda görüldüğü gibi döner.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
else { go.Boundery(monster,htable,ref dir,xbilk,ybilk,352,272,ref xbBak,ref ybBak,ref xkBak,ref ykBak,ref intKere,14,132,416,432,ref kere); Nitro nit=Nitro.Var; xbilk=monster.Location.X; ybilk=monster.Location.Y; go.Move(dir,monster,this,ref Money,nit,new int[]{56,440},Boman,ref Hak,ref yemlik,ref intbomb,Exit,htable,14,132,416,432); lblPara.Text=Money.ToString()+" YTL"; lblCani.Text="X"+ Hak.ToString(); lblYemlik.Text="X"+yemlik.ToString(); if(Hak==0) { kapat(); } } |
- Eğer yaratık için takip var ise BoMan’e X veya Y ekseninde random olarak nitro olmadan yaklaşılır. Yaklaşma komutu gene Direction.cs’deki Move() komutudur.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
else if(htable["monster"].ToString().Trim()=="monster")//takip var demek { // intKere=0; xkBak=0; xbBak=0; ykBak=0; ybBak=0; // Random rnd=new Random(); int i=rnd.Next(1,3); if(i==1) { if(monster.Location.X>Boman.Location.X) { dir=Keys.Left; } else { dir=Keys.Right; } } else { if(monster.Location.Y>Boman.Location.Y) { dir=Keys.Up; } else { dir=Keys.Down; } } Nitro nit=Nitro.Yok; go.Move(dir,monster,this,ref Money,nit,new int[]{56,456},Boman,ref Hak,ref yemlik,ref intbomb,Exit,htable,14,132,416,432); lblPara.Text=Money.ToString()+" YTL"; lblCani.Text="X"+ Hak.ToString(); lblYemlik.Text="X"+yemlik.ToString(); if(Hak==0) { kapat(); } } } |
Tüm yukarıda bahsedilen bu işlemler bütün bölümlerdeki yaratıklar için geçerlidir.
Direction.cs (Boundery()) : Tüm levellerdeki yaratıklar için kendilerinen atanan lokasyonda olup olmadıkları aşağıdaki kod ile bakılır.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 |
public void Boundery(PictureBox monster,Hashtable htable,ref Keys dir,int xbilk,int ybilk,int yeniX,int yeniY,ref int xbBak,ref int ybBak,ref int xkBak,ref int ykBak,ref int intKere,int minX,int minY,int maxX,int maxY,ref int kere) { if(Char.IsNumber(htable["s"+monster.Name].ToString(),1)==false && htable["s"+monster.Name].ToString().Substring(0,1)=="1")//sınırlardan küçük { Random rnd=new Random(); int i=rnd.Next(1,3); if(i==1) { dir=Keys.Right; if(xbilk==monster.Location.X) { xkBak=1; if(xkBak==1 && ykBak==1) { intKere++; if(intKere>10) { string str=Application.StartupPath.ToString()+"\\sound\\SOUND14.WAV"; Sound.Play(str,PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_NOWAIT); monster.Location=new Point(yeniX ,yeniY); intKere=0; xkBak=0; xbBak=0; ykBak=0; ybBak=0; } } } else { xkBak=0; ykBak=0; intKere=0; } } if(i==2) { dir=Keys.Down; if(ybilk==monster.Location.Y) { ykBak=1; if(xkBak==1 && ykBak==1) { intKere++; if(intKere>10) { string str=Application.StartupPath.ToString()+"\\sound\\SOUND14.WAV"; Sound.Play(str,PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_NOWAIT); monster.Location=new Point(yeniX,yeniY); intKere=0; xkBak=0; xbBak=0; ykBak=0; ybBak=0; } } } } } if(htable["s"+monster.Name].ToString().Substring(0,2)=="11")//x arttır,y küçült { Random rnd=new Random(); int i=rnd.Next(1,3); if(i==1) { dir=Keys.Right; if(xbilk==monster.Location.X) { xkBak=1; if(xkBak==1 && ykBak==1) { intKere++; if(intKere>10) { string str=Application.StartupPath.ToString()+"\\sound\\SOUND14.WAV"; Sound.Play(str,PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_NOWAIT); monster.Location=new Point(yeniX,yeniY); intKere=0; xkBak=0; xbBak=0; ykBak=0; ybBak=0; } } } else { xkBak=0; ykBak=0; intKere=0; } } if(i==2) { dir=Keys.Up; if(ybilk==monster.Location.Y) { ykBak=1; if(xkBak==1 && ykBak==1) { intKere++; if(intKere>10) { string str=Application.StartupPath.ToString()+"\\sound\\SOUND14.WAV"; Sound.Play(str,PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_NOWAIT); monster.Location=new Point(yeniX,yeniY); intKere=0; xkBak=0; xbBak=0; ykBak=0; ybBak=0; } } } } } if(htable["s"+monster.Name].ToString().Substring(0,2)=="12")//sadece x artıracan { dir=Keys.Right; if(xbilk==monster.Location.X) { xkBak=1; if(xkBak==1) { intKere++; if(intKere>10) { if(intKere<20) { if(monster.Location.Y>minY) { if(ybilk!=monster.Location.Y) intKere--; kere++; if((kere%2)!=0) { dir=Keys.Up; intKere--; } else { dir=Keys.Right; } } } else if(intKere<30) { if(monster.Location.Y<maxY) { if(ybilk!=monster.Location.Y) intKere--; kere++; if((kere%2)!=0) { dir=Keys.Down; intKere--; } else { dir=Keys.Right; } } } else { string str=Application.StartupPath.ToString()+"\\sound\\SOUND14.WAV"; Sound.Play(str,PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_NOWAIT); monster.Location=new Point(yeniX,yeniY); intKere=0; xkBak=0; xbBak=0; ykBak=0; ybBak=0; } } } } else { xkBak=0; ykBak=0; intKere=0; } } if(htable["s"+monster.Name].ToString().Substring(0,2)=="13")//sadece x azaltacan { dir=Keys.Left; if(xbilk==monster.Location.X) { xkBak=1; if(xkBak==1) { intKere++; if(intKere>10) { if(intKere<20) { if(monster.Location.Y>minY) { if(ybilk!=monster.Location.Y) intKere--; kere++; if((kere%2)!=0) { dir=Keys.Up; intKere--; } else { dir=Keys.Left; } } } else if(intKere<30) { if(monster.Location.Y<maxY) { if(ybilk!=monster.Location.Y) intKere--; kere++; if((kere%2)!=0) { dir=Keys.Down; intKere--; } else { dir=Keys.Left; } } } else { kere=0; string str=Application.StartupPath.ToString()+"\\sound\\SOUND14.WAV"; Sound.Play(str,PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_NOWAIT); monster.Location=new Point(yeniX,yeniY); intKere=0; xkBak=0; xbBak=0; ykBak=0; ybBak=0; } } } } else { xkBak=0; ykBak=0; intKere=0; } } if(htable["s"+monster.Name].ToString().Substring(0,2)=="21")//x azaltacan,y arttıracan { Random rnd=new Random(); int i=rnd.Next(1,3); if(i==1) { dir=Keys.Left; if(xbilk==monster.Location.X) { xkBak=1; if(xkBak==1 && ykBak==1) { intKere++; if(intKere>10) { string str=Application.StartupPath.ToString()+"\\sound\\SOUND14.WAV"; Sound.Play(str,PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_NOWAIT); monster.Location=new Point(yeniX,yeniY); intKere=0; xkBak=0; xbBak=0; ykBak=0; ybBak=0; } } } else { xkBak=0; ykBak=0; intKere=0; } } if(i==2) { dir=Keys.Down; if(ybilk==monster.Location.Y) { ykBak=1; if(xkBak==1 && ykBak==1) { intKere++; if(intKere>10) { string str=Application.StartupPath.ToString()+"\\sound\\SOUND14.WAV"; Sound.Play(str,PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_NOWAIT); monster.Location=new Point(yeniX,yeniY); intKere=0; xkBak=0; xbBak=0; ykBak=0; ybBak=0; } } } else { ykBak=0; xkBak=0; intKere=0; } } } if(htable["s"+monster.Name].ToString().Substring(0,2)=="22")//sadece y yi arttıracam { dir=Keys.Down; if(ybilk==monster.Location.Y) { ykBak=1; if(ykBak==1) { intKere++; if(intKere>10) { if(intKere<20) { if(monster.Location.X>minX) { if(xbilk!=monster.Location.X) intKere--; kere++; if((kere%2)!=0) { dir=Keys.Left; intKere--; } else { dir=Keys.Down; } } } else if(intKere<30) { if(monster.Location.X<maxX) { if(xbilk!=monster.Location.X) intKere--; kere++; if((kere%2)!=0) { dir=Keys.Right; intKere--; } else { dir=Keys.Down; } } } else { string str=Application.StartupPath.ToString()+"\\sound\\SOUND14.WAV"; Sound.Play(str,PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_NOWAIT); monster.Location=new Point(yeniX,yeniY); intKere=0; xkBak=0; xbBak=0; ykBak=0; ybBak=0; } } } } else { xkBak=0; ykBak=0; intKere=0; } } if(htable["s"+monster.Name].ToString().Substring(0,2)=="23")//sadece y yi azaltacam { dir=Keys.Up; if(ybilk==monster.Location.Y) { ykBak=1; if(ykBak==1) { intKere++; if(intKere>10) { if(intKere<20) { if(monster.Location.X>minX) { if(xbilk!=monster.Location.X) intKere--; kere++; if((kere%2)!=0) { dir=Keys.Left; intKere--; } else { dir=Keys.Up; } } } else if(intKere<30) { if(monster.Location.X<maxX) { if(xbilk!=monster.Location.X) intKere--; kere++; if((kere%2)!=0) { dir=Keys.Right; intKere--; } else { dir=Keys.Up; } } } else { kere=0; string str=Application.StartupPath.ToString()+"\\sound\\SOUND14.WAV"; Sound.Play(str,PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_NOWAIT); monster.Location=new Point(yeniX,yeniY); intKere=0; xkBak=0; xbBak=0; ykBak=0; ybBak=0; } } } } else { kere=0; xkBak=0; ykBak=0; intKere=0; } } else if(Char.IsNumber(htable["s"+monster.Name].ToString(),1)==false && htable["s"+monster.Name].ToString().Substring(0,1)=="2")//sınırlardan büyük { Random rnd=new Random(); int i=rnd.Next(1,3); if(i==1) { dir=Keys.Left; if(xbilk==monster.Location.X) { xbBak=1; if(xbBak==1 && ybBak==1) { intKere++; if(intKere>10) { string str=Application.StartupPath.ToString()+"\\sound\\SOUND14.WAV"; Sound.Play(str,PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_NOWAIT); monster.Location=new Point(yeniX,yeniY); intKere=0; xkBak=0; xbBak=0; ykBak=0; ybBak=0; } } } else { xbBak=0; ybBak=0; intKere=0; } } if(i==2) { if(ybilk==monster.Location.Y) { ybBak=1; if(xbBak==1 && ybBak==1) { intKere++; if(intKere>10) { string str=Application.StartupPath.ToString()+"\\sound\\SOUND14.WAV"; Sound.Play(str,PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_NOWAIT); monster.Location=new Point(yeniX,yeniY); intKere=0; xkBak=0; xbBak=0; ykBak=0; ybBak=0; } } } else { ybBak=0; xbBak=0; intKere=0; } dir=Keys.Up; } } } |
Direction.cs( Move()) : BoMan için geçerli hareket komutlarının ve ilgili hareket sırasında gerekli kontrollerin yapıldığı kodlar aşağıdaki gibidir.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 |
public void Move(KeyEventArgs e,PictureBox Boman,Form frm,ref double Money,Nitro nit,int[] exit,int[] start,ref int Hak,ref int yemlik,ref int bomb,string form,PictureBox exit1,Hashtable htable,string yon)//boman için { string str=Application.StartupPath.ToString()+"\\sound\\F0.wav";//hareket ederkenki sesimiz. if(e.KeyCode==Keys.Up || e.KeyCode==Keys.Down || e.KeyCode==Keys.Left || e.KeyCode==Keys.Right) //Sound.Play(str,PlaySoundFlags.SND_FILENAME| PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_NOSTOP); Sound.Play(str,PlaySoundFlags.SND_FILENAME| PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_NOWAIT|PlaySoundFlags.SND_NOSTOP); if(yon=="up" && Boman.Location.X>exit[0] && Boman.Location.Y<exit[1] && Boman.Location.X<exit[2] && exit1.Visible==true)//çıkışa gelmişsek { if(form=="Form2") { frm.Dispose(); frm.Close(); Form2 frm2=new Form2(Money,yemlik,Hak); frm2.Show(); } if(form=="Form3") { frm.Dispose(); frm.Close(); Form3 frm3=new Form3(Money,yemlik,Hak); frm3.Show(); } if(form=="Form4") { frm.Dispose(); frm.Close(); Form4 frm4=new Form4(Money,yemlik,Hak); frm4.Show(); } //frm.Visible=false; } if(yon=="left" && Boman.Location.X<exit[0] && Boman.Location.Y>exit[1] && Boman.Location.Y<exit[3] && exit1.Visible==true)//çıkışa gelmişsek { if(form=="Form2") { frm.Dispose(); frm.Close(); Form2 frm2=new Form2(); frm2.Show(); } if(form=="Form3") { frm.Dispose(); frm.Close(); Form3 frm3=new Form3(Money,yemlik,Hak); frm3.Show(); } if(form=="Form4") { frm.Dispose(); frm.Close(); Form4 frm4=new Form4(Money,yemlik,Hak); frm4.Show(); } //frm.Visible=false; } if(yon=="down" && Boman.Location.X>exit[0] && Boman.Location.Y>exit[1] && Boman.Location.X<exit[2] && exit1.Visible==true)//çıkışa gelmişsek { if(form=="Form2") { frm.Dispose(); frm.Close(); Form2 frm2=new Form2(Money,yemlik,Hak); frm2.Show(); } if(form=="Form3") { frm.Dispose(); frm.Close(); Form3 frm3=new Form3(Money,yemlik,Hak); frm3.Show(); } if(form=="Form4") { frm.Dispose(); frm.Close(); Form4 frm4=new Form4(Money,yemlik,Hak); frm4.Show(); } if(form=="FormBoss") { frm.Dispose(); frm.Close(); FormBoss frmBoss=new FormBoss(Money,yemlik,Hak); frmBoss.Show(); } //frm.Visible=false; } bool yapma=false; if(yapma==false) { if(nit==Nitro.Var || Boman.Width==39) { miktar=8; } else { miktar=4; } switch(e.KeyCode) { case Keys.Up: { if(rotate.Varmi(Boman.Location.X,Boman.Location.Y-miktar,Yon.Dikey,Boman.Width,Boman.Height,frm,ref Money,ref yemlik,ref bomb,"Booman",exit1)==0)//duvar yoksa hareket ve küçükleri yeme { if(Boman.Width!=39 && rotate.TakipVarmi(Boman.Location.X,Boman.Location.Y,Boman.Width,Boman.Height,frm, ref isim,"Boman")==1)//yaratığa yakınlaştıkmı { htable[isim]=isim;//dönen yaratık ismine yaratığa atıyoruz. } else { htable[Boman.Name]="";//Boman'e boş değer atıyoruz } Boman.Location=new Point(Boman.Location.X,Boman.Location.Y-miktar); } if(rotate.Varmi(Boman.Location.X,Boman.Location.Y-miktar,Yon.Dikey,Boman.Width,Boman.Height,frm,ref Money,ref yemlik,ref bomb,"Booman",exit1)==2)//yaratığa deydik ölüyoruz { string str2=Application.StartupPath.ToString()+"\\sound\\toon8.wav"; Sound.Play(str2,PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_NOWAIT); for(int i=0;i<8;i++) { Boman.Location=new Point(Boman.Location.X-3,Boman.Location.Y-3); Thread.Sleep(200); } --Hak; string stryol=Application.StartupPath.ToString()+"\\sound\\sus.wav"; Sound.Play(stryol,PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_NOWAIT); Boman.Location=new Point(start[0],start[1]); } break; } case Keys.Down: { if(rotate.Varmi(Boman.Location.X,Boman.Location.Y+Boman.Height+miktar,Yon.Dikey,Boman.Width,Boman.Height,frm,ref Money,ref yemlik,ref bomb,"Booman",exit1)==0) { if(Boman.Width!=39 && rotate.TakipVarmi(Boman.Location.X,Boman.Location.Y,Boman.Width,Boman.Height,frm, ref isim,"Boman")==1) { htable[isim]=isim;//dönen yaratık ismine yaratığa atıyoruz. } else { htable[Boman.Name]="";//Boman'e boş atıyoruz } Boman.Location=new Point(Boman.Location.X,Boman.Location.Y+miktar); } if(rotate.Varmi(Boman.Location.X,Boman.Location.Y+Boman.Height+miktar,Yon.Dikey,Boman.Width,Boman.Height,frm,ref Money,ref yemlik,ref bomb,"Booman",exit1)==2) { string str3=Application.StartupPath.ToString()+"\\sound\\toon8.wav"; Sound.Play(str3,PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_NOWAIT); for(int i=0;i<8;i++) { Boman.Location=new Point(Boman.Location.X-3,Boman.Location.Y-3); Thread.Sleep(200); } --Hak; string stryol=Application.StartupPath.ToString()+"\\sound\\sus.wav"; Sound.Play(stryol,PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_NOWAIT); Boman.Location=new Point(start[0],start[1]); } break; } case Keys.Right: { if(rotate.Varmi(Boman.Location.X+miktar+Boman.Width,Boman.Location.Y,Yon.Yatay,Boman.Width,Boman.Height,frm,ref Money,ref yemlik,ref bomb,"Booman",exit1)==0) { if(Boman.Width!=39 && rotate.TakipVarmi(Boman.Location.X,Boman.Location.Y,Boman.Width,Boman.Height,frm, ref isim,"Boman")==1) { htable[isim]=isim;//dönen yaratık ismine ismi yaratığa atıyoruz. } else { htable[Boman.Name]="";//kendimize boş atıyoruz Boman'e } Boman.Location=new Point(Boman.Location.X+miktar,Boman.Location.Y); } if(rotate.Varmi(Boman.Location.X+miktar+Boman.Width,Boman.Location.Y,Yon.Yatay,Boman.Width,Boman.Height,frm,ref Money,ref yemlik,ref bomb,"Booman",exit1)==2) { string str4=Application.StartupPath.ToString()+"\\sound\\toon8.wav"; Sound.Play(str4,PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_NOWAIT); for(int i=0;i<8;i++) { Boman.Location=new Point(Boman.Location.X-3,Boman.Location.Y-3); Thread.Sleep(200); } --Hak; string stryol=Application.StartupPath.ToString()+"\\sound\\sus.wav"; Sound.Play(stryol,PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_NOWAIT); Boman.Location=new Point(start[0],start[1]); } break; } case Keys.Left: { if(rotate.Varmi(Boman.Location.X-miktar,Boman.Location.Y,Yon.Yatay,Boman.Width,Boman.Height,frm,ref Money,ref yemlik,ref bomb,"Booman",exit1)==0) { if(Boman.Width!=39 && rotate.TakipVarmi(Boman.Location.X,Boman.Location.Y,Boman.Width,Boman.Height,frm, ref isim,"Boman")==1) { //Level1.yMonster=isim; htable[isim]=isim;//dönen yaratık ismine ismi yaratığa atıyoruz. } else { htable[Boman.Name]="";//Burda Boman biziz.Yani kendimize boş atıyoruz } Boman.Location=new Point(Boman.Location.X-miktar,Boman.Location.Y); } if(rotate.Varmi(Boman.Location.X-miktar,Boman.Location.Y,Yon.Yatay,Boman.Width,Boman.Height,frm,ref Money,ref yemlik,ref bomb,"Booman",exit1)==2) { string str5=Application.StartupPath.ToString()+"\\sound\\toon8.wav"; Sound.Play(str5,PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_NOWAIT); for(int i=0;i<8;i++) { Boman.Location=new Point(Boman.Location.X-3,Boman.Location.Y-3); Thread.Sleep(200); } --Hak; string stryol=Application.StartupPath.ToString()+"\\sound\\sus.wav"; Sound.Play(stryol,PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_NOWAIT); Boman.Location=new Point(start[0],start[1]); } break; } } } } |
Direction.cs(Move()): Yaratıklar için olan bu hareket komutlarının tanımlamdığı kısm aşağıda görüldüğü gibidir.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 |
public void Move(Keys e,PictureBox Boman,Form frm,ref double Money,Nitro nit,int[] start,PictureBox RelBoman,ref int Hak,ref int yemlik,ref int bomb,PictureBox exit1,Hashtable htable,int minX1,int minY1,int maxX1,int maxY1)//hayalet için { if(nit==Nitro.Var) { miktar=8; } else { miktar=4; } if(Boman.Name=="monsterBoss1") { miktar=8; } if(Boman.Name!="monsterBoss1") { switch(e) { case Keys.Up: { //önce yaratık gosth hareket edebilirmi diye baktık duvar var mı? if(rotate.Varmi(Boman.Location.X,Boman.Location.Y-miktar,Yon.Dikey,Boman.Width,Boman.Height,frm,ref Money,ref yemlik,ref bomb,"Monster",exit1)==0) { //hareket ediyosa bize yaklaşmış mı? if(RelBoman.Width!=39 && rotate.TakipVarmi(Boman.Location.X,Boman.Location.Y,Boman.Width,Boman.Height,frm, ref isim,Boman.Name)==1)//yaratığa yakınlaştıkmı { htable[isim]=isim;//hangi yaratıksa(hangisine yaklaşılmışsa) ona değer atıyoruz. } else { int sinir=rotate.SinirAsmismi(Boman.Location.X,Boman.Location.Y-miktar,Boman.Width,Boman.Height,minX1,minY1,maxX1,maxY1); switch (sinir) { case 0: { htable["s"+Boman.Name]=""; break; } case 1: { htable["s"+Boman.Name]="1"+Boman.Name; break; } case 11: { htable["s"+Boman.Name]="11"+Boman.Name; break; } case 12: { htable["s"+Boman.Name]="12"+Boman.Name; break; } case 13: { htable["s"+Boman.Name]="13"+Boman.Name; break; } case 21: { htable["s"+Boman.Name]="21"+Boman.Name; break; } case 22: { htable["s"+Boman.Name]="22"+Boman.Name; break; } case 23: { htable["s"+Boman.Name]="23"+Boman.Name; break; } case 2: { htable["s"+Boman.Name]="2"+Boman.Name; break; } } htable[Boman.Name]="";//()Boman burda yaratığın ismi aynı zamanda.hangi yaratıktan geliyosa ona boş değer atıyoruz. } Boman.Location=new Point(Boman.Location.X,Boman.Location.Y-miktar); } //yaklaşıp değmişse ölürüz..... if(rotate.Varmi(Boman.Location.X,Boman.Location.Y-miktar,Yon.Dikey,Boman.Width,Boman.Height,frm,ref Money,ref yemlik,ref bomb,"Monster",exit1)==2) { string str=Application.StartupPath.ToString()+"\\sound\\toon8.wav"; Sound.Play(str,PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_NOWAIT); for(int i=0;i<8;i++) { RelBoman.Location=new Point(RelBoman.Location.X-3,RelBoman.Location.Y-3); Thread.Sleep(200); } RelBoman.Location=new Point(start[0],start[1]); --Hak; string stryol=Application.StartupPath.ToString()+"\\sound\\sus.wav"; Sound.Play(stryol,PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_NOWAIT); } break; } case Keys.Down: { if(rotate.Varmi(Boman.Location.X,Boman.Location.Y+Boman.Height+miktar,Yon.Dikey,Boman.Width,Boman.Height,frm,ref Money,ref yemlik,ref bomb,"Monster",exit1)==0) { if(RelBoman.Width!=39 && rotate.TakipVarmi(Boman.Location.X,Boman.Location.Y,Boman.Width,Boman.Height,frm, ref isim,Boman.Name)==1)//yaratığa yakınlaştıkmı { //Level1.yMonster=isim; htable[isim]=isim;//hangi yaratıksa ona değer atıyoruz. } else { /*if(Boman.Name=="monster2") { int i=0; }*/ int sinir=rotate.SinirAsmismi(Boman.Location.X,Boman.Location.Y-miktar,Boman.Width,Boman.Height,minX1,minY1,maxX1,maxY1); switch (sinir) { case 0: { htable["s"+Boman.Name]=""; break; } case 1: { htable["s"+Boman.Name]="1"+Boman.Name; break; } case 11: { htable["s"+Boman.Name]="11"+Boman.Name; break; } case 12: { htable["s"+Boman.Name]="12"+Boman.Name; break; } case 13: { htable["s"+Boman.Name]="13"+Boman.Name; break; } case 21: { htable["s"+Boman.Name]="21"+Boman.Name; break; } case 22: { htable["s"+Boman.Name]="22"+Boman.Name; break; } case 23: { htable["s"+Boman.Name]="23"+Boman.Name; break; } case 2: { htable["s"+Boman.Name]="2"+Boman.Name; break; } } htable[Boman.Name]="";//()Boman yaratığın ismi aynı zamanda.hangi yaratıktan geliyosa ona boş değer atıyoruz. } Boman.Location=new Point(Boman.Location.X,Boman.Location.Y+miktar); } if(rotate.Varmi(Boman.Location.X,Boman.Location.Y+Boman.Height+miktar,Yon.Dikey,Boman.Width,Boman.Height,frm,ref Money,ref yemlik,ref bomb,"Monster",exit1)==2) { string str=Application.StartupPath.ToString()+"\\sound\\toon8.wav"; Sound.Play(str,PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_NOWAIT); for(int i=0;i<8;i++) { RelBoman.Location=new Point(RelBoman.Location.X-3,RelBoman.Location.Y-3); Thread.Sleep(200); } RelBoman.Location=new Point(start[0],start[1]); --Hak; string stryol=Application.StartupPath.ToString()+"\\sound\\sus.wav"; Sound.Play(stryol,PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_NOWAIT); } break; } case Keys.Right: { if(rotate.Varmi(Boman.Location.X+miktar+Boman.Width,Boman.Location.Y,Yon.Yatay,Boman.Width,Boman.Height,frm,ref Money,ref yemlik,ref bomb,"Monster",exit1)==0) { if(RelBoman.Width!=39 && rotate.TakipVarmi(Boman.Location.X,Boman.Location.Y,Boman.Width,Boman.Height,frm, ref isim,Boman.Name)==1)//yaratığa yakınlaştıkmı { htable[isim]=isim;//hangi yaratıksa ona değer atıyoruz. } else { int sinir=rotate.SinirAsmismi(Boman.Location.X,Boman.Location.Y-miktar,Boman.Width,Boman.Height,minX1,minY1,maxX1,maxY1); switch (sinir) { case 0: { htable["s"+Boman.Name]=""; break; } case 1: { htable["s"+Boman.Name]="1"+Boman.Name; break; } case 11: { htable["s"+Boman.Name]="11"+Boman.Name; break; } case 12: { htable["s"+Boman.Name]="12"+Boman.Name; break; } case 13: { htable["s"+Boman.Name]="13"+Boman.Name; break; } case 21: { htable["s"+Boman.Name]="21"+Boman.Name; break; } case 22: { htable["s"+Boman.Name]="22"+Boman.Name; break; } case 23: { htable["s"+Boman.Name]="23"+Boman.Name; break; } case 2: { htable["s"+Boman.Name]="2"+Boman.Name; break; } } htable[Boman.Name]="";//()Boman yaratığın ismi aynı zamanda.hangi yaratıktan geliyosa ona boş değer atıyoruz. } Boman.Location=new Point(Boman.Location.X+miktar,Boman.Location.Y); } if(rotate.Varmi(Boman.Location.X+miktar+Boman.Width,Boman.Location.Y,Yon.Yatay,Boman.Width,Boman.Height,frm,ref Money,ref yemlik,ref bomb,"Monster",exit1)==2) { string str=Application.StartupPath.ToString()+"\\sound\\toon8.wav"; Sound.Play(str,PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_NOWAIT); for(int i=0;i<8;i++) { RelBoman.Location=new Point(RelBoman.Location.X-3,RelBoman.Location.Y-3); Thread.Sleep(200); } RelBoman.Location=new Point(start[0],start[1]); --Hak; string stryol=Application.StartupPath.ToString()+"\\sound\\sus.wav"; Sound.Play(stryol,PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_NOWAIT); } break; } case Keys.Left: { if(rotate.Varmi(Boman.Location.X-miktar,Boman.Location.Y,Yon.Yatay,Boman.Width,Boman.Height,frm,ref Money,ref yemlik,ref bomb,"Monster",exit1)==0) { if(RelBoman.Width!=39 && rotate.TakipVarmi(Boman.Location.X,Boman.Location.Y,Boman.Width,Boman.Height,frm, ref isim,Boman.Name)==1)//yaratığa yakınlaştıkmı { //Level1.yMonster=isim; htable[isim]=isim;//hangi yaratıksa ona değer atıyoruz. } else { int sinir=rotate.SinirAsmismi(Boman.Location.X,Boman.Location.Y-miktar,Boman.Width,Boman.Height,minX1,minY1,maxX1,maxY1); switch (sinir) { case 0: { htable["s"+Boman.Name]=""; break; } case 1: { htable["s"+Boman.Name]="1"+Boman.Name; break; } case 11: { htable["s"+Boman.Name]="11"+Boman.Name; break; } case 12: { htable["s"+Boman.Name]="12"+Boman.Name; break; } case 13: { htable["s"+Boman.Name]="13"+Boman.Name; break; } case 21: { htable["s"+Boman.Name]="21"+Boman.Name; break; } case 22: { htable["s"+Boman.Name]="22"+Boman.Name; break; } case 23: { htable["s"+Boman.Name]="23"+Boman.Name; break; } case 2: { htable["s"+Boman.Name]="2"+Boman.Name; break; } } htable[Boman.Name]="";//eger değer yoksa hangi yaratıktan dönerse onu boşa atıyoruz. } Boman.Location=new Point(Boman.Location.X-miktar,Boman.Location.Y); } if(rotate.Varmi(Boman.Location.X-miktar,Boman.Location.Y,Yon.Yatay,Boman.Width,Boman.Height,frm,ref Money,ref yemlik,ref bomb,"Monster",exit1)==2) { string str=Application.StartupPath.ToString()+"\\sound\\toon8.wav"; Sound.Play(str,PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_NOWAIT); for(int i=0;i<8;i++) { RelBoman.Location=new Point(RelBoman.Location.X-3,RelBoman.Location.Y-3); Thread.Sleep(200); } RelBoman.Location=new Point(start[0],start[1]); --Hak; string stryol=Application.StartupPath.ToString()+"\\sound\\sus.wav"; Sound.Play(stryol,PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_NOWAIT); } break; } } } else//eger Monster Boss ise bu satırlar çalışır(Takip yok;sınır yok) { switch(e) { case Keys.Up: { //önce yaratık gosth harelet edebilirmi diye baktık duvar var mı? if(rotate.Varmi(Boman.Location.X,Boman.Location.Y-miktar,Yon.Dikey,Boman.Width,Boman.Height,frm,ref Money,ref yemlik,ref bomb,"Boss",exit1)==0) { Boman.Location=new Point(Boman.Location.X,Boman.Location.Y-miktar); } //yaklaşıp değmişse ölürüz..... if(rotate.Varmi(Boman.Location.X,Boman.Location.Y-miktar,Yon.Dikey,Boman.Width,Boman.Height,frm,ref Money,ref yemlik,ref bomb,"Monster",exit1)==2) { string str=Application.StartupPath.ToString()+"\\sound\\toon8.wav"; Sound.Play(str,PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_NOWAIT); for(int i=0;i<8;i++) { RelBoman.Location=new Point(RelBoman.Location.X-3,RelBoman.Location.Y-3); Thread.Sleep(200); } RelBoman.Location=new Point(start[0],start[1]); --Hak; string stryol=Application.StartupPath.ToString()+"\\sound\\sus.wav"; Sound.Play(stryol,PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_NOWAIT); } break; } case Keys.Down: { if(rotate.Varmi(Boman.Location.X,Boman.Location.Y+Boman.Height+miktar,Yon.Dikey,Boman.Width,Boman.Height,frm,ref Money,ref yemlik,ref bomb,"Boss",exit1)==0) { Boman.Location=new Point(Boman.Location.X,Boman.Location.Y+miktar); } if(rotate.Varmi(Boman.Location.X,Boman.Location.Y+Boman.Height+miktar,Yon.Dikey,Boman.Width,Boman.Height,frm,ref Money,ref yemlik,ref bomb,"Monster",exit1)==2) { string str=Application.StartupPath.ToString()+"\\sound\\toon8.wav"; Sound.Play(str,PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_NOWAIT); for(int i=0;i<8;i++) { RelBoman.Location=new Point(RelBoman.Location.X-3,RelBoman.Location.Y-3); Thread.Sleep(200); } RelBoman.Location=new Point(start[0],start[1]); --Hak; string stryol=Application.StartupPath.ToString()+"\\sound\\sus.wav"; Sound.Play(stryol,PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_NOWAIT); } break; } case Keys.Left: { if(rotate.Varmi(Boman.Location.X-miktar,Boman.Location.Y,Yon.Yatay,Boman.Width,Boman.Height,frm,ref Money,ref yemlik,ref bomb,"Boss",exit1)==0) { Boman.Location=new Point(Boman.Location.X-miktar,Boman.Location.Y); } if(rotate.Varmi(Boman.Location.X-miktar,Boman.Location.Y,Yon.Yatay,Boman.Width,Boman.Height,frm,ref Money,ref yemlik,ref bomb,"Monster",exit1)==2) { string str=Application.StartupPath.ToString()+"\\sound\\toon8.wav"; Sound.Play(str,PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_NOWAIT); for(int i=0;i<8;i++) { RelBoman.Location=new Point(RelBoman.Location.X-3,RelBoman.Location.Y-3); Thread.Sleep(200); } RelBoman.Location=new Point(start[0],start[1]); --Hak; string stryol=Application.StartupPath.ToString()+"\\sound\\sus.wav"; Sound.Play(stryol,PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_NOWAIT); } break; } case Keys.Right: { if(rotate.Varmi(Boman.Location.X+miktar+Boman.Width,Boman.Location.Y,Yon.Yatay,Boman.Width,Boman.Height,frm,ref Money,ref yemlik,ref bomb,"Boss",exit1)==0) { Boman.Location=new Point(Boman.Location.X+miktar,Boman.Location.Y); } if(rotate.Varmi(Boman.Location.X+miktar+Boman.Width,Boman.Location.Y,Yon.Yatay,Boman.Width,Boman.Height,frm,ref Money,ref yemlik,ref bomb,"Monster",exit1)==2) { string str=Application.StartupPath.ToString()+"\\sound\\toon8.wav"; Sound.Play(str,PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_NOWAIT); for(int i=0;i<8;i++) { RelBoman.Location=new Point(RelBoman.Location.X-3,RelBoman.Location.Y-3); Thread.Sleep(200); } RelBoman.Location=new Point(start[0],start[1]); --Hak; string stryol=Application.StartupPath.ToString()+"\\sound\\sus.wav"; Sound.Play(stryol,PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_NOWAIT); } break; } } } } |
Path.cs (TakipVarmi()): Yaratıkların BoMa’e belli bir mesefe kadar yaklaşıp takip sınırları içine girip girmediği aşağıdaki kodlar ile check edilir.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
public int TakipVarmi(double x,double y,double xEn,double yBoy,Form frm,ref string isim,string sender) { foreach(object ob in frm.Controls) { if(ob is PictureBox && ((PictureBox)ob).Visible==true)//hayalete çarpmasın. { //----- PictureBox btn=(PictureBox)ob; int obX=btn.Location.X; int obY=btn.Location.Y; if(sender=="Boman" && btn.Name.Trim()!="Boman" && btn.Name.Trim()!="Exit") { int yorta=(obY+btn.Height/2); int xorta=(obX+btn.Width/2); double bmanxOrta=(x+xEn/2); double bmanyOrta=(y+yBoy/2); if(Math.Abs(yorta -bmanyOrta)<=100 && Math.Abs(xorta -bmanxOrta)<=100 ) { isim=btn.Name; return 1; } } else if(sender!="Boman" && btn.Name.Trim()=="Boman") { int yorta=(obY+btn.Height/2); int xorta=(obX+btn.Width/2); double bmanxOrta=(x+xEn/2); double bmanyOrta=(y+yBoy/2); if(Math.Abs(yorta -bmanyOrta)<=100 && Math.Abs(xorta -bmanxOrta)<=100 ) { isim=sender; return 1; } } } } return 0; } |
Path.cs (Varmi()):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 |
int pay=0;//resimlerin arasındaki boşluktan dolayı. public int Varmi(double x,double y,Yon hareket,double en,double boy,Form frm,ref double Money,ref int yemlikHak,ref int bombHak,string sender,PictureBox Exit) { foreach(object ob in frm.Controls) { if(ob is Button && ((Button)ob).Visible==true) { Button btn=(Button)ob; int obX=btn.Location.X; int obY=btn.Location.Y; if(hareket==Yon.Yatay) { if((y>=obY && y<obY+btn.Height) && x>obX && x<obX+btn.Width) { if(btn.Width==10 && btn.Height==10 && sender!="Monster") { string str=Application.StartupPath.ToString()+"\\sound\\newemail.wav"; Sound.Play(str,PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_NOWAIT); btn.Visible=false; Money+=10; //Kapı acılacak mı//---- bool kapi=false; foreach(object ob2 in frm.Controls) { if(ob2 is Button && ((Button)ob2).Visible==true) { Button btn2=(Button)ob2; if(btn2.Width==10 && btn2.Height==10 && sender!="Monster") { kapi=true;//küçük button var açılmaz demek } } } if(kapi==false)//yoksa açılır hepsini yersen. { string str2=Application.StartupPath.ToString()+"\\sound\\yehaw.wav"; Sound.Play(str2,PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_NOWAIT); Exit.Visible=true; } //----------------------------- return 0; } else if(btn.Width==10 && btn.Height==10 && sender=="Monster") { return 0; } else if(sender!="Monster" && btn.BackColor==Color.Transparent && en==41)//kıralacak duvar kırılır { btn.Visible=false; string str2=Application.StartupPath.ToString()+"\\sound\\SOUND12.WAV"; Sound.Play(str2,PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_NOWAIT); return 0; } else return 1; } if((y<=obY && y+boy>obY)&& x>obX && x<obX+btn.Width) { if(btn.Width==10 && btn.Height==10 && sender!="Monster") { string str=Application.StartupPath.ToString()+"\\sound\\newemail.wav"; Sound.Play(str,PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_NOWAIT); btn.Visible=false; Money+=10; //Kapı acılacak mı//---- bool kapi=false; foreach(object ob2 in frm.Controls) { if(ob2 is Button && ((Button)ob2).Visible==true) { Button btn2=(Button)ob2; if(btn2.Width==10 && btn2.Height==10 && sender!="Monster") { kapi=true; } } } if(kapi==false) { string str2=Application.StartupPath.ToString()+"\\sound\\yehaw.wav"; Sound.Play(str2,PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_NOWAIT); Exit.Visible=true; } //----------------------------- return 0; } else if(btn.Width==10 && btn.Height==10 && sender=="Monster") { return 0; } else return 1; } } else { if((x>=obX && x<obX+btn.Width) && y>obY && y<obY+btn.Height) { if(btn.Width==10 && btn.Height==10 && sender!="Monster") { string str=Application.StartupPath.ToString()+"\\sound\\newemail.wav"; Sound.Play(str,PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_NOWAIT); btn.Visible=false; Money+=10; //Kapı acılacak mı//---- bool kapi=false; foreach(object ob2 in frm.Controls) { if(ob2 is Button && ((Button)ob2).Visible==true) { Button btn2=(Button)ob2; if(btn2.Width==10 && btn2.Height==10 && sender!="Monster") { kapi=true; } } } if(kapi==false) { string str2=Application.StartupPath.ToString()+"\\sound\\yehaw.wav"; Sound.Play(str2,PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_NOWAIT); Exit.Visible=true; } //----------------------------- return 0; } else if(btn.Width==10 && btn.Height==10 && sender=="Monster") { return 0; } else if(sender!="Monster" && btn.BackColor==Color.Transparent && en==41)//kıralacak duvar kırılır { btn.Visible=false; string str2=Application.StartupPath.ToString()+"\\sound\\SOUND12.WAV"; Sound.Play(str2,PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_NOWAIT); return 0; } else return 1; } if((x<=obX && x+en>=obX+btn.Width) && y>obY && y<obY+btn.Height) { if(btn.Width==10 && btn.Height==10 && sender!="Monster") { string str=Application.StartupPath.ToString()+"\\sound\\newemail.wav"; Sound.Play(str,PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_NOWAIT); btn.Visible=false; Money+=10; //Kapı acılacak mı//---- bool kapi=false; foreach(object ob2 in frm.Controls) { if(ob2 is Button && ((Button)ob2).Visible==true) { Button btn2=(Button)ob2; if(btn2.Width==10 && btn2.Height==10 && sender!="Monster") { kapi=true; } } } if(kapi==false) { string str2=Application.StartupPath.ToString()+"\\sound\\yehaw.wav"; Sound.Play(str2,PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_NOWAIT); Exit.Visible=true; } //----------------------------- return 0; } else if(btn.Width==10 && btn.Height==10 && sender=="Monster") { return 0; } else if(sender!="Monster" && btn.BackColor==Color.Transparent && en==41)//kıralacak duvar kırılır { btn.Visible=false; string str2=Application.StartupPath.ToString()+"\\sound\\SOUND12.WAV"; Sound.Play(str2,PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_NOWAIT); return 0; } else return 1; } if((x<=obX && (x+en<=obX+btn.Width && x+en>obX)) && y>obY && y<obY+btn.Height) { if(btn.Width==10 && btn.Height==10 && sender!="Monster") { string str=Application.StartupPath.ToString()+"\\sound\\newemail.wav"; Sound.Play(str,PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_NOWAIT); btn.Visible=false; Money+=10; //Kapı acılacak mı//---- bool kapi=false; foreach(object ob2 in frm.Controls) { if(ob2 is Button && ((Button)ob2).Visible==true) { Button btn2=(Button)ob2; if(btn2.Width==10 && btn2.Height==10 && sender!="Monster") { kapi=true; } } } if(kapi==false) { string str2=Application.StartupPath.ToString()+"\\sound\\yehaw.wav"; Sound.Play(str2,PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_NOWAIT); Exit.Visible=true; } //----------------------------- return 0; } else if(btn.Width==10 && btn.Height==10 && sender=="Monster") { return 0; } else if(sender!="Monster" && btn.BackColor==Color.Transparent && en==41)//kıralacak duvar kırılır { btn.Visible=false; string str2=Application.StartupPath.ToString()+"\\sound\\SOUND12.WAV"; Sound.Play(str2,PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_NOWAIT); return 0; } else return 1; } } } if(ob is PictureBox && ((PictureBox)ob).Visible==true)//hayalete çarpmasın. { //----- PictureBox btn=(PictureBox)ob; int obX=btn.Location.X;//yeni(Level1 569 zart) int obY=btn.Location.Y;//yeni if(btn.Name.IndexOf("yemlik")==-1 && btn.Name.IndexOf("bomb")==-1)//yeni yeni resim yemlik resmi özel { //-------Gost mu,Boman mi--- bool check=false; if(sender=="Booman" && btn.Name.Trim()!="Boman" && btn.Name.Trim()!="Exit") { check=true; } else if(sender=="Monster" && btn.Name.Trim()=="Boman") { check=true; } //-------bitti------------------------------- //if(sender=="Booman" && btn.Name.Trim()!="Boman") if(check) { //int obX=btn.Location.X; //int obY=btn.Location.Y; /*if(y>385) { return 1; }*/ if(hareket==Yon.Yatay) { if((y>=obY+pay && y<obY+btn.Height-pay) && x>obX+pay && x<obX+btn.Width-pay) { return 2; } if((y<=obY-pay && y+boy>obY+pay)&& x>obX+pay && x<obX+btn.Width-pay) { return 2; } } else { if((x>=obX+pay && x<obX+btn.Width-pay) && y>obY+pay && y<obY+btn.Height-pay) { return 2; } if((x<=obX-pay && x+en>obX+btn.Width+pay) && y>obY+pay && y<obY+btn.Height-pay) { return 2; } if((x<=obX-pay && (x+en<obX+btn.Width-pay && x+en>obX+pay)) && y>obY+pay && y<obY+btn.Height-pay) { return 2; } } } //----- } //Yemlik içi---------------- else if(btn.Name.IndexOf("yemlik")!=-1 && sender=="Booman")//taamen yeni { if(hareket==Yon.Yatay) { if((y>=obY && y<obY+btn.Height) && x>obX && x<obX+btn.Width) { string str=Application.StartupPath.ToString()+"\\sound\\SOUND528.WAV"; Sound.Play(str,PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_NOWAIT); //MessageBox.Show("1"); btn.Visible=false; Money+=10; yemlikHak+=1; return 0; } if((y<=obY && y+boy>obY)&& x>obX && x<obX+btn.Width) { string str=Application.StartupPath.ToString()+"\\sound\\SOUND528.WAV"; Sound.Play(str,PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_NOWAIT); //MessageBox.Show("2"); btn.Visible=false; Money+=10; yemlikHak+=1; return 0; } } else { if((x>=obX && x<=obX+btn.Width) && y>=obY && y<=obY+btn.Height) { string str=Application.StartupPath.ToString()+"\\sound\\SOUND528.WAV"; Sound.Play(str,PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_NOWAIT); //MessageBox.Show("3"); btn.Visible=false; Money+=10; yemlikHak+=1; return 0; } if((x<=obX && x+en>=obX+btn.Width) && y>=obY && y<=obY+btn.Height) { string str=Application.StartupPath.ToString()+"\\sound\\SOUND528.WAV"; Sound.Play(str,PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_NOWAIT); //MessageBox.Show("4"); btn.Visible=false; Money+=10; yemlikHak+=1; return 0; } if((x<=obX && (x+en<obX+btn.Width && x+en>obX)) && y>obY && y<obY+btn.Height) { string str=Application.StartupPath.ToString()+"\\sound\\SOUND528.WAV"; Sound.Play(str,PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_NOWAIT); //MessageBox.Show("5"); btn.Visible=false; Money+=10; yemlikHak+=1; return 0; } } } //Bomb içi---------------- else if(btn.Name.IndexOf("bomb")!=-1 && sender=="Booman")//taamen yeni { if(hareket==Yon.Yatay) { if((y>=obY && y<obY+btn.Height) && x>obX && x<obX+btn.Width) { string str=Application.StartupPath.ToString()+"\\sound\\SOUND45.WAV"; Sound.Play(str,PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_NOWAIT); //MessageBox.Show("1"); btn.Visible=false; bombHak+=1; return 0; } if((y<=obY && y+boy>obY)&& x>obX && x<obX+btn.Width) { string str=Application.StartupPath.ToString()+"\\sound\\SOUND45.WAV"; Sound.Play(str,PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_NOWAIT); //MessageBox.Show("2"); btn.Visible=false; bombHak+=1; return 0; } } else { if((x>=obX && x<=obX+btn.Width) && y>=obY && y<=obY+btn.Height) { string str=Application.StartupPath.ToString()+"\\sound\\SOUND45.WAV"; Sound.Play(str,PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_NOWAIT); //MessageBox.Show("3"); btn.Visible=false; bombHak+=1; return 0; } if((x<=obX && x+en>=obX+btn.Width) && y>=obY && y<=obY+btn.Height) { string str=Application.StartupPath.ToString()+"\\sound\\SOUND45.WAV"; Sound.Play(str,PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_NOWAIT); //MessageBox.Show("4"); btn.Visible=false; bombHak+=1; return 0; } if((x<=obX && (x+en<obX+btn.Width && x+en>obX)) && y>obY && y<obY+btn.Height) { string str=Application.StartupPath.ToString()+"\\sound\\SOUND45.WAV"; Sound.Play(str,PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_NOWAIT); //MessageBox.Show("5"); btn.Visible=false; bombHak+=1; return 0; } } } } } |
- Form’larda yani bölümler geçilince çıkan ara ekranlarda para ile taş ve taş ile de özellik alınmaktadır. Örnek kod aşağıda görülmektedir. Bu örnek de diğer formlar ile aynı mantıkda çalışmaktadır.
Form3.cs: Tüm tanımlamalar ve InitializeComponent içerisi kodun rahat okunması için temizlenmiştir.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using tonysound; namespace Packman { /// <summary> /// Summary description for Form3. /// </summary> public class Form3 : System.Windows.Forms.Form { public Form3() { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // } double Money=0; int Yemlik=0; int Hak=0; int i=0; public Form3(double dblMoney,int intyemlik,int intHak) { InitializeComponent(); Money=dblMoney; Yemlik=intyemlik; Hak=intHak; lblCani.Text="X "+Hak.ToString(); lblPara.Text="X "+Money.ToString(); lblMoney.Text="X "+Money.ToString(); lblYemlik.Text="X "+Yemlik.ToString(); lblYem.Text="X "+Yemlik.ToString(); } /// <summary> /// Clean up any resources being used. /// </summary> protected override void Dispose( bool disposing ) { if( disposing ) { if(components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { } #endregion private void timer1_Tick(object sender, System.EventArgs e) { if(i>100) { string str=Application.StartupPath.ToString()+"\\sound\\glassbrk.wav"; Sound.Play(str,PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_NOWAIT); timer1.Stop(); pictureBox4.Visible=true; pictureBox2.Visible=false; } i++; } private void Form3_Load(object sender, System.EventArgs e) { this.Focus(); string str=Application.StartupPath.ToString()+"\\sound\\meow.wav"; Sound.Play(str,PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_ASYNC); timer1.Start(); } int intYemal=0; int intCinal=0; private void button3_Click(object sender, System.EventArgs e) { if(Money>=50) { intYemal++; Money-=50; Yemlik+=1; lblMoney.Text="X "+Money.ToString(); lblYem.Text="X "+Yemlik.ToString(); lblYem2.Text="X "+intYemal.ToString(); } } private void button1_Click(object sender, System.EventArgs e) { if(Yemlik>=2) { intCinal++; Yemlik-=2; lblYem.Text="X "+Yemlik.ToString(); lblCin.Text="X "+intCinal.ToString(); } } private void button2_Click(object sender, System.EventArgs e) { string str=Application.StartupPath.ToString()+"\\sound\\sus.wav"; Sound.Play(str,PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_NOWAIT); timer1.Stop(); Level3 lv3=new Level3(Money,Yemlik,Hak,this,intCinal); lv3.Show(); this.Close(); this.Dispose(); } private void Form3_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) { if(e.KeyCode==Keys.Space) { string str=Application.StartupPath.ToString()+"\\sound\\sus.wav"; Sound.Play(str,PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_NOWAIT); Level3 frm3=new Level3(Money,Yemlik,Hak,this,intCinal); frm3.Show(); timer1.Stop(); this.Visible=false; this.Dispose(); this.Close(); } } } } |
Level1.cs: Öncelikle BoMan diğer 3 yaratık, toplanması gereken mavi taşlar , kırmızı taşlar, duvarlar ve giriş çıkış kapıları nesneleri tanımlanır. 6 tane timer tanımlıdır. Timer ve Timer2 nitronun zamanla artıp azalması için tanımlanmıştır. Timer3 oyun başlarken ki geri sayım amaçlı kullanılır. Timer4,Timer5 ve Timer6 oyundaki yaratıkların random hareketleri için tanımlanmıştır. “Esc” tuşuna basılınca oyundan çıkılır. “D” tuşuna basılınca oyun ve buna bağlı tüm timer’lar stop edilir. Kısaca pause edilir. Yaratıklar takip mesafesine girince htable[“monster2”] hastable’ına değer atanır. Ekranın sol üstünde siren ve takip eden yaratığın ismi yazılır. Kısaca takip eden yaratığın ismi hastable’a eklenir. Sonra da varmı diye aşağıdaki gibi bakılır.
1 2 3 4 5 |
if(htable["monster"].ToString()!="") { label3.Text=htable["monster"].ToString(); imgSiren.Visible=true; } |
Level1.cs : Tüm tanımlamalar ve InitializeComponent içerisi kodun rahat okunması için temizlenmiştir.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 |