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 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 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 |
using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using System.Threading; using tonysound; using System.IO; namespace Packman { public enum Nitro { Var, Yok } public enum Yon { Yatay, Dikey } /// <summary> /// Summary description for Level1. /// </summary> public class Level1 : System.Windows.Forms.Form { public Level1() { // // Required for Windows Form Designer support // InitializeComponent(); Money=0; yemlik=0; Hak=3; //over=false; // // TODO: Add any constructor code after InitializeComponent call // } /// <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 Path rotate; Direction go; public void kapat() { /*if(over==true) { over=false; } else { over=true; }*/ timer1.Stop(); timer3.Stop(); timer5.Stop(); timer4.Stop(); timer6.Stop(); timer2.Stop(); } private void Level1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) { if(label2.Visible!=true) { Nitro nityol=Nitro.Yok; if(nitro.Width<=1) { nityol=Nitro.Yok; } 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; } } else { timer1.Stop(); timer2.Start(); nityol=Nitro.Yok; } go.Move(e,Boman,this,ref Money,nityol,new int[]{694,184,752,184},new int[]{48,440},ref Hak,ref yemlik,ref intbomb,"Form2",Exit,htable,"up"); lblPara.Text=Money.ToString()+" YTL"; lblCani.Text="X"+ Hak.ToString(); lblYemlik.Text="X"+yemlik.ToString(); if(Hak==0) { kapat(); } if(e.KeyCode==Keys.Escape) { timer1.Stop(); timer2.Stop(); timer3.Stop(); timer4.Stop(); timer5.Stop(); timer6.Stop(); if(MessageBox.Show("Çıkmak istediğinize eminmisiniz","Çıkış",MessageBoxButtons.OKCancel,MessageBoxIcon.Asterisk)==DialogResult.OK) { this.Dispose(); this.Close(); Giris frm=new Giris(); frm.Show(); } else { timer1.Start(); timer2.Start(); timer3.Start(); timer4.Start(); timer5.Start(); timer6.Start(); } } if(e.KeyCode==Keys.D) { timer1.Stop(); timer2.Stop(); timer3.Stop(); timer4.Stop(); timer5.Stop(); timer6.Stop(); if(MessageBox.Show("Duraklat","Due",MessageBoxButtons.OK,MessageBoxIcon.Information)==DialogResult.OK) { timer1.Start(); timer2.Start(); timer3.Start(); timer4.Start(); timer5.Start(); timer6.Start(); } } } } private void Level1_Load(object sender, System.EventArgs e) { htable=new Hashtable(); htable["monster"]=""; htable["monster2"]=""; htable["monster3"]=""; htable["smonster"]=""; htable["smonster2"]=""; htable["smonster3"]=""; timer3.Start(); } private void timer1_Tick(object sender, System.EventArgs e)//nitro azalıyo { if(nitro.Width>=2) { nitro.Width-=2; } } private void timer2_Tick(object sender, System.EventArgs e)//nitro artıyo { if((nitro.Width+2)<=75) { nitro.Width +=2; } } int i=4; private void timer3_Tick(object sender, System.EventArgs e)//başlarken ki geri sayım { if(i==4) { string str=Application.StartupPath.ToString()+"\\sound\\aoogah.wav"; Sound.Play(str,PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_NOSTOP); } i-=1; if(i==0) { label2.Text="Git"; } if(i<0) { timer3.Stop(); label2.Visible=false; rotate=new Path(); go=new Direction(); this.Focus(); timer4.Start(); timer5.Start(); timer6.Start(); } if(i>0) label2.Text =i.ToString(); } private void Level1_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e)//kurufasulye { if(e.Shift==false && Hak>0) { timer1.Stop(); timer2.Start(); } } Keys dir,dir2,dir3; //monster int xkBak=0; int xbBak=0; int ykBak=0; int ybBak=0; int xkilk=0; int xbilk=0; int ykilk=0; int ybilk=0; int intKere=0; //----------------- //monster2 int xkBak2=0; int xbBak2=0; int ykBak2=0; int ybBak2=0; int xkilk2=0; int xbilk2=0; int ykilk2=0; int ybilk2=0; int intKere2=0; //----------------- //monster2 int xkBak3=0; int xbBak3=0; int ykBak3=0; int ybBak3=0; int xkilk3=0; int xbilk3=0; int ykilk3=0; int ybilk3=0; int intKere3=0; //----------------- int kere=0,kere2=0,kere3=0; private void timer4_Tick(object sender, System.EventArgs e)//hayalet1 { if(htable["monster"].ToString()!="") { label3.Text=htable["monster"].ToString(); imgSiren.Visible=true; } else if(htable["monster2"].ToString()!="") { label3.Text=htable["monster2"].ToString(); imgSiren.Visible=true; } else if(htable["monster3"].ToString()!="") { imgSiren.Visible=true; label3.Text=htable["monster3"].ToString(); } else { imgSiren.Visible=false; label3.Text=""; } if(htable["monster"].ToString().Trim()=="") { if(htable["smonster"].ToString().Trim()=="")//sınırı aşmamışsa { // intKere=0; xkBak=0; xbBak=0; ykBak=0; ybBak=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,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(); } } 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(); } } } 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(); } } } private void timer5_Tick(object sender, System.EventArgs e)//hayalet2 { if(htable["monster"].ToString()!="") { imgSiren.Visible=true; label3.Text=htable["monster"].ToString(); } else if(htable["monster2"].ToString()!="") { imgSiren.Visible=true; label3.Text=htable["monster2"].ToString(); } else if(htable["monster3"].ToString()!="") { imgSiren.Visible=true; label3.Text=htable["monster3"].ToString(); } else { imgSiren.Visible=false; label3.Text=""; } 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(); } } else { go.Boundery(monster2,htable,ref dir2,xbilk2,ybilk2,192,392,ref xbBak2,ref ybBak2,ref xkBak2,ref ykBak2,ref intKere2,144,312,392,496,ref kere2); Nitro nit=Nitro.Var; xbilk2=monster2.Location.X; ybilk2=monster2.Location.Y; go.Move(dir2,monster2,this,ref Money,nit,new int[]{56,440},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(); } } } else if(htable["monster2"].ToString().Trim()=="monster2")//takip var demek { // intKere2=0; xkBak2=0; xbBak2=0; ykBak2=0; ybBak2=0; // Random rnd=new Random(); int i=rnd.Next(1,3); if(i==1) { if(monster2.Location.X>Boman.Location.X) { dir=Keys.Left; } else { dir=Keys.Right; } } else { if(monster2.Location.Y>Boman.Location.Y) { dir=Keys.Up; } else { dir=Keys.Down; } } 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(); } } } private void Level1_Closing(object sender, System.ComponentModel.CancelEventArgs e) { Application.Exit(); } private void Exit_VisibleChanged(object sender, System.EventArgs e) { if(Exit.Visible==true) { cikisDuvari.Visible=false; } else { cikisDuvari.Visible=true; } } private void timer6_Tick(object sender, System.EventArgs e) { if(htable["monster"].ToString()!="") { imgSiren.Visible=true; label3.Text=htable["monster"].ToString(); } else if(htable["monster2"].ToString()!="") { imgSiren.Visible=true; label3.Text=htable["monster2"].ToString(); } else if(htable["monster3"].ToString()!="") { imgSiren.Visible=true; label3.Text=htable["monster3"].ToString(); } else { imgSiren.Visible=false; label3.Text=""; } if(htable["monster3"].ToString().Trim()=="") { if(htable["smonster3"].ToString().Trim()=="")//sınırı aşmamışsa { // intKere3=0; xkBak3=0; xbBak3=0; ykBak3=0; ybBak3=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,monster3,this,ref Money,nit,new int[]{56,456},Boman,ref Hak,ref yemlik,ref intbomb,Exit,htable,544,184,752,400); lblPara.Text=Money.ToString()+" YTL"; lblCani.Text="X"+ Hak.ToString(); lblYemlik.Text="X"+yemlik.ToString(); if(Hak==0) { kapat(); } } else { go.Boundery(monster3,htable,ref dir3,xbilk3,ybilk3,600,296,ref xbBak3,ref ybBak3,ref xkBak3,ref ykBak3,ref intKere3,544,184,752,400,ref kere3);//sınırı aşmışsa Nitro nit=Nitro.Var; xbilk3=monster3.Location.X; ybilk3=monster3.Location.Y; go.Move(dir3,monster3,this,ref Money,nit,new int[]{56,440},Boman,ref Hak,ref yemlik,ref intbomb,Exit,htable,544,184,752,400); lblPara.Text=Money.ToString()+" YTL"; lblCani.Text="X"+ Hak.ToString(); lblYemlik.Text="X"+yemlik.ToString(); if(Hak==0) { kapat(); } } } else if(htable["monster3"].ToString().Trim()=="monster3")//takip var { // intKere3=0; xkBak3=0; xbBak3=0; ykBak3=0; ybBak3=0; // Random rnd=new Random(); int i=rnd.Next(1,3); if(i==1) { if(monster3.Location.X>Boman.Location.X) { dir=Keys.Left; } else { dir=Keys.Right; } } else { if(monster3.Location.Y>Boman.Location.Y) { dir=Keys.Up; } else { dir=Keys.Down; } } Nitro nit=Nitro.Yok; go.Move(dir,monster3,this,ref Money,nit,new int[]{56,456},Boman,ref Hak,ref yemlik,ref intbomb,Exit,htable,544,184,752,400); lblPara.Text=Money.ToString()+" YTL"; lblCani.Text="X"+ Hak.ToString(); lblYemlik.Text="X"+yemlik.ToString(); if(Hak==0) { kapat(); } } } } } |
- Diğer bölümlerden farklı olan ekran Boss ekranıdır. Yukarıda görüldüğü gibi 2 yarışmacı arasında ençok taşı toplayan oyunu kazanır. 8 timer’dan ilk 2’si nitroyu 3. Başlangıç timer’ı 4.sü oyunun kalan süresini geri sayarak tutar. 5.Timer bölüm sonunda kazanılan taşların efektli bir şekilde paraya dönmesini sağlar. 6.Timer 2 round arasındaki bekeleme süresini.7. Timer Boss’un hareketlerini belirler. 10.Timre gene nitronun gazlı içicek alındıktan sonra azalmasını sağlar. Boss’un yukarı, aşağı, sağ ve sol hareketlerinde randomize gene belli noktalarda sadece belli yönlere göre olmaktadır. Bu noktalar yukarıda görülen platformdaki yol ayrımlarının olduğı kritik noktalardır. Mesela aşağıda görüldüğü gibi a2.1.3 bölümünde y>568 ve x<= 240 ise yani en altta soldan 2. kıvrımda ve sola hareket ediyor ise sadece sola veya yukarı gidebilir.
1 2 3 4 5 6 7 8 9 10 |
if((hareket==5 || hareket==4) && i1==1 && monsterBoss1.Location.Y>=568 && monsterBoss1.Location.X<=240)//a2.1_3 { rnd=new Random(); i1=rnd.Next(1,3); if(i1==1) dir=Keys.Left; if(i1==2) dir=Keys.Up; hareket++; } |
Ya da a2.3 bölümünde boss sola hareket ediyor ise ve x>928, y>568 ise sadece yukarı gidilebilir. Yani boss sağ alt köşede ise ve yatay hareket ediyor ise sadece yukarı çıkabilmektedir. İlgili kod aşağıdadır. Özet olarak bölümün kritik noktalarına göre randomize hareketler kordinatlara göre filitrelenmiş ve Boss’un hareketlerine Timer9 ile yön verilmiştir. Diğer tüm yol ayrımları için aynı algoritma işletilir.
1 2 3 4 5 6 |
if(hareket==8 && i1==1 && monsterBoss1.Location.Y>=568 && monsterBoss1.Location.X>=928)//a2.3_1_4 { i1=2; dir=Keys.Up; hareket++; } |
Yukarıda gördüğünüz gibi Boss’un hareketleri için belli kordinatlara göre birçok aritmetiksel işlemler yapılmaktadır.
Boss.cs: Boss ekranına ait tüm kodlar aşağıdadır. 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 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 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 |
using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using tonysound; namespace Packman { /// <summary> /// Summary description for Level4. /// </summary> public class Boss1 : System.Windows.Forms.Form { public Boss1() { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // } /// <summary> /// Clean up any resources being used. /// </summary> protected override void Dispose( bool disposing ) { if( disposing ) { if(components != null) { components.Dispose(); } } base.Dispose( disposing ); } double gelenPara=0; int intRound=0; int intBen=0; int intCmp=0; public Boss1(double dblMoney,int intyemlik,int intHak,Form frm,int intCin,int intOsuruk,int round,int ben,int cmp) { InitializeComponent(); gelenPara=dblMoney; Money=dblMoney; yemlik=intyemlik; Hak=intHak; Cin=intCin; Osuruk=intOsuruk; //over=false; frm.Close(); frm.Dispose(); lblPara.Text=Money.ToString()+" YTL"; lblCani.Text="X"+ Hak.ToString(); lblYemlik.Text="X"+yemlik.ToString(); lblCin.Text=intCin.ToString() +"X"; lblCin2.Text="X"+intCin.ToString(); lblOs.Text=intOsuruk.ToString() +"X"; lblOs2.Text="X"+intOsuruk.ToString(); intBen=ben; intCmp=cmp; if(intCmp>0) picCmpRound.Visible=true; if(intBen>0) picBenround.Visible=true; intRound=round; } #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 public Hashtable htable; Over frmOver; int Cin; int Osuruk; double Money; double Money2; int yemlik; int intbomb; int Hak; private void Level4_Load(object sender, System.EventArgs e) { htable=new Hashtable(); htable["monster5"]=""; htable["smonster5"]=""; timer3.Start(); } Path rotate; Direction go; Keys dir; public void kapat() { /*if(over==true) { over=false; } else { over=true; }*/ timer1.Stop(); timer3.Stop(); timer9.Stop(); timer2.Stop(); //if(over==true) //{ if(frmOver==null) { this.Dispose(); this.Close(); frmOver=new Over(this); frmOver.Show(); } //} } private void timer1_Tick(object sender, System.EventArgs e) { if(nitro.Width>=2) { nitro.Width-=2; } } private void timer2_Tick(object sender, System.EventArgs e) { if((nitro.Width+2)<=75) { nitro.Width +=2; } } int i=4; private void timer3_Tick(object sender, System.EventArgs e) { if(i==4) { string str=Application.StartupPath.ToString()+"\\sound\\aoogah.wav"; Sound.Play(str,PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_NOWAIT); } i-=1; if(i==0) { label2.Text="Git"; } if(i<0) { label2.Visible=false; lblRound.Visible=true; lblRound.Text="Round "+(intRound+1).ToString(); if(i<-2) { lblRound.Visible=false; timer3.Stop(); rotate=new Path(); go=new Direction(); this.Focus(); timer9.Start(); timer4.Start(); } } if(i>0) label2.Text =i.ToString(); } private void Level4_Closing(object sender, System.ComponentModel.CancelEventArgs e) { Application.Exit(); } private void Level4_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) { if(label2.Visible!=true && zaman>0 && lblRound.Visible==false) { if(e.KeyCode==Keys.D1 && Cin>0 && (nitro.Visible==true || ostime.Visible==true))//cin için { string str=Application.StartupPath.ToString()+"\\sound\\evil_laf.wav"; Sound.Play(str,PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_NOWAIT); if(nitro.Visible==true) { label1.Visible=false; nitro.Visible=false; } if(ostime.Visible==true) { if(Osuruk>0) { ostime.Width=100; } ostime.Visible=false; lblOs.Visible=false; osuruk.Visible=false; lblOs.Text=Osuruk.ToString()+"X"; lblOs2.Text="X"+Osuruk.ToString(); timer10.Stop(); } breakTime.Visible=true; lblCin.Visible=true; gin.Visible=true; Cin--; lblCin.Text=Cin.ToString()+"X"; lblCin2.Text="X"+Cin.ToString(); System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Level4)); this.Boman.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox4.Image"))); this.Boman.Size = new System.Drawing.Size(41, 41); timer8.Start(); } else if(e.KeyCode==Keys.D1 && Boman.Width==41) { if(Cin>0) { breakTime.Width=100; } string str=Application.StartupPath.ToString()+"\\sound\\SOUND53.wav"; Sound.Play(str,PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_NOWAIT); label1.Visible=true; nitro.Visible=true; breakTime.Visible=false; lblCin.Visible=false; gin.Visible=false; lblCin.Text=Cin.ToString()+"X"; lblCin2.Text="X"+Cin.ToString(); System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Level4)); this.Boman.Image = ((System.Drawing.Image)(resources.GetObject("Boman.Image"))); this.Boman.Size = new System.Drawing.Size(40, 40); timer8.Stop(); } if(e.KeyCode==Keys.D2 && Osuruk>0 && (nitro.Visible==true || breakTime.Visible==true))//osuruk için { string str=Application.StartupPath.ToString()+"\\sound\\SOUND54.wav"; Sound.Play(str,PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_NOWAIT); if(nitro.Visible==true) { label1.Visible=false; nitro.Visible=false; } if(breakTime.Visible==true) { if(Cin>0) { breakTime.Width=100; } breakTime.Visible=false; lblCin.Visible=false; gin.Visible=false; lblCin.Text=Cin.ToString()+"X"; lblCin2.Text="X"+Cin.ToString(); timer8.Stop(); } ostime.Visible=true; lblOs.Visible=true; osuruk.Visible=true; Osuruk--; lblOs.Text=Osuruk.ToString()+"X"; lblOs2.Text="X"+Osuruk.ToString(); System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Level4)); this.Boman.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox8.Image"))); this.Boman.Size = new System.Drawing.Size(39, 39); timer10.Start(); } else if(e.KeyCode==Keys.D2 && Boman.Width==39) { if(Osuruk>0) { ostime.Width=100; } string str=Application.StartupPath.ToString()+"\\sound\\SOUND53.wav"; Sound.Play(str,PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_NOWAIT); label1.Visible=true; nitro.Visible=true; ostime.Visible=false; lblOs.Visible=false; osuruk.Visible=false; lblOs.Text=Osuruk.ToString()+"X"; lblOs2.Text="X"+Osuruk.ToString(); System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Level4)); this.Boman.Image = ((System.Drawing.Image)(resources.GetObject("Boman.Image"))); this.Boman.Size = new System.Drawing.Size(40, 40); timer10.Stop(); } Nitro nityol=Nitro.Yok; if(nitro.Width<=1) { nityol=Nitro.Yok; } if(e.Shift==true && Boman.Width==40) { 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; } } else if(zaman>0) { timer1.Stop(); timer2.Start(); nityol=Nitro.Yok; } //Gas Alıyoruz----------------- if(Math.Abs((Boman.Location.X+20)-572)<=45 && Math.Abs((Boman.Location.Y+20)-336)<=45) { if(pictureBox4.Visible==true) { string str=Application.StartupPath.ToString()+"\\sound\\SOUND240.wav"; Sound.Play(str,PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_NOWAIT); nitro.Width=80; } pictureBox4.Visible=false; } //bitti------------ //Gas Alıyoruz----------------- if(Math.Abs((Boman.Location.X+20)-436)<=43 && Math.Abs((Boman.Location.Y+20)-224)<=40) { if(pictureBox6.Visible==true) { string str=Application.StartupPath.ToString()+"\\sound\\SOUND240.wav"; Sound.Play(str,PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_NOWAIT); nitro.Width=80; } pictureBox6.Visible=false; } //bitti------------ int oncekiHak=Hak; go.Move(e,Boman,this,ref Money,nityol,new int[]{16,576,72,576},new int[]{24, 568},ref Hak,ref yemlik,ref intbomb,"Form4",Exit,htable,"down"); //lblPara.Text=Money.ToString()+" YTL"; lblMyMoney.Text=((Money-gelenPara)/10).ToString(); lblCani.Text="X"+ Hak.ToString(); lblYemlik.Text="X"+yemlik.ToString(); //label4.Text=Boman.Location.X+"-"+Boman.Location.Y; if(Hak==0) { kapat(); } else if(oncekiHak>Hak) { if(breakTime.Visible==true) { if(Cin>0) { breakTime.Width=100; } breakTime.Visible=false; lblCin.Visible=false; gin.Visible=false; lblCin.Text=Cin.ToString()+"X"; lblCin2.Text="X"+Cin.ToString(); timer8.Stop(); } if(ostime.Visible==true) { if(Osuruk>0) { ostime.Width=100; } ostime.Visible=false; lblOs.Visible=false; osuruk.Visible=false; lblOs.Text=Osuruk.ToString()+"X"; lblOs2.Text="X"+Osuruk.ToString(); timer10.Stop(); } label1.Visible=true; nitro.Visible=true; System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Level4)); this.Boman.Image = ((System.Drawing.Image)(resources.GetObject("Boman.Image"))); this.Boman.Size = new System.Drawing.Size(40, 40); } if(e.KeyCode==Keys.Escape) { timer1.Stop(); timer2.Stop(); timer3.Stop(); timer9.Stop(); if(MessageBox.Show("Çıkmak istediğinize eminmisiniz","Çıkış",MessageBoxButtons.OKCancel,MessageBoxIcon.Asterisk)==DialogResult.OK) { this.Dispose(); this.Close(); Giris frm=new Giris(); frm.Show(); } else if(zaman>0) { timer1.Start(); timer2.Start(); timer3.Start(); timer9.Start(); } } if(e.KeyCode==Keys.D) { timer1.Stop(); timer2.Stop(); timer3.Stop(); timer4.Stop(); timer8.Stop(); timer9.Stop(); timer10.Stop(); if(MessageBox.Show("Duraklat","Dur",MessageBoxButtons.OK,MessageBoxIcon.Information)==DialogResult.OK) { timer1.Start(); timer2.Start(); timer3.Start(); timer4.Start(); timer8.Start(); timer9.Start(); timer10.Start(); } } } } private void Level4_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e) { if(e.Shift==false && Hak>0 && zaman>0) { timer1.Stop(); timer2.Start(); } } private void Exit_VisibleChanged(object sender, System.EventArgs e) { if(Exit.Visible==true) { cikisDuvari.Visible=false; } else { cikisDuvari.Visible=true; } } private void timer8_Tick(object sender, System.EventArgs e) { if(breakTime.Width>=2) { breakTime.Width-=2; } else { timer8.Stop(); if(Cin>0) { breakTime.Width=100; } string str=Application.StartupPath.ToString()+"\\sound\\SOUND53.wav"; Sound.Play(str,PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_NOWAIT); label1.Visible=true; nitro.Visible=true; breakTime.Visible=false; lblCin.Visible=false; gin.Visible=false; lblCin.Text=Cin.ToString()+"X"; lblCin2.Text="X"+Cin.ToString(); System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Level4)); this.Boman.Image = ((System.Drawing.Image)(resources.GetObject("Boman.Image"))); this.Boman.Size = new System.Drawing.Size(40, 40); } } int i1=0; int hareket=0; Random rnd; int b24=0; int a21=0; int b2=0; int b22=0; private void timer9_Tick(object sender, System.EventArgs e) { if(i1==0) { rnd=new Random(); i1=rnd.Next(1,3); } if(i1==1 && hareket==0)//a1 { dir=Keys.Left; hareket++; } if(i1==2 && hareket==0)//b1 { dir=Keys.Down; hareket++; } if(hareket==1 && i1==1 && monsterBoss1.Location.X<=560)//a2 { rnd=new Random(); i1=rnd.Next(1,3); if(i1==1) { dir=Keys.Left; a21=1; } if(i1==2) dir=Keys.Down; hareket++; } if(hareket==1 && i1==2 && monsterBoss1.Location.Y>=328 && monsterBoss1.Location.X>=928)//b2 { rnd=new Random(); i1=rnd.Next(1,3); if(i1==1) { dir=Keys.Left; b2=1; } if(i1==2) dir=Keys.Down; hareket++; } if(hareket==2 && i1==2 && monsterBoss1.Location.Y>=328 && monsterBoss1.Location.X<=560)//a2.1 { rnd=new Random(); i1=rnd.Next(1,4); if(i1==1) { a21=1; dir=Keys.Left; } if(i1==2) dir=Keys.Down; if(i1==3) dir=Keys.Right; hareket++; } if(hareket==3 && i1==3 && monsterBoss1.Location.Y>=328 && monsterBoss1.Location.X>=928)//a2.1_1 { i1=2; dir=Keys.Down; hareket++; } if((hareket==4 || hareket==2) && i1==2 && monsterBoss1.Location.Y>=568 && monsterBoss1.Location.X>=928)//a2.1_2 { i1=1; dir=Keys.Left; hareket++; } if((hareket==5 || hareket==4) && i1==1 && monsterBoss1.Location.Y>=568 && monsterBoss1.Location.X<=240)//a2.1_3 { rnd=new Random(); i1=rnd.Next(1,3); if(i1==1) dir=Keys.Left; if(i1==2) dir=Keys.Up; hareket++; } if(hareket==3 && i1==2 && monsterBoss1.Location.Y>=568 && monsterBoss1.Location.X>240 && monsterBoss1.Location.X<=560)//a2.3 { i1=1; dir=Keys.Left; hareket++; } if(hareket==3 && i1==1 && monsterBoss1.Location.Y<=568 && monsterBoss1.Location.X>240 && monsterBoss1.Location.X<=560)//b2.2 { rnd=new Random(); i1=rnd.Next(1,3); if(i1==1) dir=Keys.Left; if(i1==2) { dir=Keys.Up; b22=1; } hareket++; } if(hareket==4 && i1==2 && monsterBoss1.Location.Y<=328 && monsterBoss1.Location.X>240 && monsterBoss1.Location.X<=560)//b2.3 { i1=1; dir=Keys.Left; hareket++; b22=0; } if((hareket==5 || hareket==4 )&& i1==1 && monsterBoss1.Location.Y<=328 && monsterBoss1.Location.X<=240)//b2.4 { if(a21==0) { b2=0; b24=1; i1=2; dir=Keys.Up; hareket++; } else { i1=1; dir=Keys.Left; hareket++; } } if((hareket==6 || hareket==5) && i1==2 && monsterBoss1.Location.Y<=328 && monsterBoss1.Location.X<=240)//a2.1_4 { rnd=new Random(); i1=rnd.Next(1,3); if(b24==1) i1=2; if(i1==1) dir=Keys.Right; if(i1==2) dir=Keys.Up; hareket++; } if(hareket==7 && i1==1 && monsterBoss1.Location.Y>=328 && monsterBoss1.Location.X>=928)//a2.1_5 { i1=2; dir=Keys.Up; hareket++; } if((hareket==8 || hareket==6 || hareket==11) && i1==2 && monsterBoss1.Location.Y<=48 && monsterBoss1.Location.X>=928)//a2.1_son1 { i1=0; hareket=0; } if(hareket==7 && i1==2 && monsterBoss1.Location.Y<=48 && monsterBoss1.Location.X<=240)//a2.1_6 { i1=1; dir=Keys.Right; hareket++; } if(hareket==8 && i1==1 && monsterBoss1.Location.Y<=48 && monsterBoss1.Location.X>=928)//a2.1_son2 { i1=0; hareket=0; } if((hareket==6 || hareket==4) && i1==1 && monsterBoss1.Location.Y>=568 && monsterBoss1.Location.X<=24)//a2.1_7 { i1=2; dir=Keys.Up; hareket++; } if((hareket==7 || hareket==5) && i1==2 && monsterBoss1.Location.Y<=120 && monsterBoss1.Location.X<=24)//a2.1_8 { i1=1; dir=Keys.Right; hareket++; } if(hareket==8 && i1==1 && monsterBoss1.Location.Y<=120 && monsterBoss1.Location.X>=240)//a2.1_9 { rnd=new Random(); i1=rnd.Next(1,3); if(a21==1) { a21=0; } if(b24==1) { b24=0; } else { if(i1==1) dir=Keys.Down; if(i1==2) dir=Keys.Up; } hareket++; } if(hareket==9 && i1==2 && monsterBoss1.Location.Y<=48 && monsterBoss1.Location.X>=240)//a2.1_10 { i1=1; dir=Keys.Right; hareket++; } if((hareket==10|| hareket==9) && i1==1 && monsterBoss1.Location.Y<=48 && monsterBoss1.Location.X>=928)//a2.1_son3 { i1=0; hareket=0; } if(b22==0 && b2==0 && (hareket==4 || hareket==9) && monsterBoss1.Location.Y>=328 && monsterBoss1.Location.X>=240 && monsterBoss1.Location.Y<400 && monsterBoss1.Location.X<560)//a2.1_11 { i1=1; dir=Keys.Right; hareket++; } if((hareket==5 || hareket==10)&& i1==1 && monsterBoss1.Location.Y>=328 && monsterBoss1.Location.X>=928 && monsterBoss1.Location.Y<540)//a2.1_12 { i1=2; dir=Keys.Up; hareket++; } if(a21==1 && hareket==2 && i1==1 && monsterBoss1.Location.X<=240)//a2.2 { i1=2; dir=Keys.Down; hareket++; } if(hareket==3 && i1==2 && monsterBoss1.Location.Y>=120 && monsterBoss1.Location.X<=258)//a2.3 { rnd=new Random(); i1=rnd.Next(1,3); if(i1==1) dir=Keys.Left; if(i1==2) dir=Keys.Down; hareket++; } if(hareket==6 && i1==1 && monsterBoss1.Location.Y>=120 && monsterBoss1.Location.X<=24)//a2.3_1 { i1=2; dir=Keys.Down; hareket++; } if(hareket==5 && i1==2 && monsterBoss1.Location.Y>=328 && monsterBoss1.Location.X<=24)//a2.3_1_1 { rnd=new Random(); i1=rnd.Next(1,3); if(i1==1) dir=Keys.Right; if(i1==2) dir=Keys.Down; hareket++; } if(hareket==6 && i1==1 && monsterBoss1.Location.Y>=328 && monsterBoss1.Location.X<=24)//a2.2 { i1=2; dir=Keys.Up; hareket++; } if(hareket==6 && i1==1 && monsterBoss1.Location.Y>=328 && monsterBoss1.Location.X>=928)//a2.3_1_2 { i1=2; dir=Keys.Up; hareket++; } if(hareket==7 && i1==2 && monsterBoss1.Location.Y<=48 && monsterBoss1.Location.X>=928)//a2.3_1_son1 { i1=0; hareket=0; } if(hareket==7 && i1==2 && monsterBoss1.Location.Y>=568 && monsterBoss1.Location.X<=24)//a2.3_1_3 { if(dir==Keys.Down) { i1=1; dir=Keys.Right; hareket++; } } //if(hareket==7 && i1==1 && monsterBoss1.Location.Y>=568 && monsterBoss1.Location.X>=928)//a2.3_1_4 if(hareket==8 && i1==1 && monsterBoss1.Location.Y>=568 && monsterBoss1.Location.X>=928)//a2.3_1_4 { i1=2; dir=Keys.Up; hareket++; } if(hareket==9 && i1==2 && monsterBoss1.Location.Y<=48 && monsterBoss1.Location.X>=928)//a2.3_1_son2 { i1=0; hareket=0; } if(hareket==2 && i1==1 && monsterBoss1.Location.X<=560 && monsterBoss1.Location.Y>=328)//b2.1 { rnd=new Random(); if(i1==1) { dir=Keys.Left; } if(i1==2) dir=Keys.Down; hareket++; } Nitro nit=Nitro.Var; go.Move(dir,monsterBoss1,this,ref Money2,nit,new int[]{24,568},Boman,ref Hak,ref yemlik,ref intbomb,Exit,htable,0,0,1000,648); if(Money2>0) lblPara2.Text=(Money2/10).ToString(); else { lblPara2.Text=(Money2).ToString(); } lblCani.Text="X"+ Hak.ToString(); lblYemlik.Text="X"+yemlik.ToString(); if(Hak==0) { kapat(); } } private void timer10_Tick(object sender, System.EventArgs e) { if(ostime.Width>=2) { ostime.Width-=2; } else { if(Osuruk>0) { ostime.Width=100; } timer10.Stop(); string str=Application.StartupPath.ToString()+"\\sound\\SOUND53.wav"; Sound.Play(str,PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_NOWAIT); label1.Visible=true; nitro.Visible=true; ostime.Visible=false; lblOs.Visible=false; osuruk.Visible=false; lblOs.Text=Cin.ToString()+"X"; lblOs2.Text="X"+Cin.ToString(); System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Level4)); this.Boman.Image = ((System.Drawing.Image)(resources.GetObject("Boman.Image"))); this.Boman.Size = new System.Drawing.Size(40, 40); } } int zaman=40; private void timer4_Tick(object sender, System.EventArgs e) { zaman--; if(zaman>=0) this.Text="Kalan zaman:"+(zaman).ToString();; if(zaman==0) { timer2.Stop(); timer1.Stop(); timer3.Stop(); timer8.Stop(); timer10.Stop(); timer9.Stop(); if((Money-gelenPara)>Money2) { intBen++; string str=Application.StartupPath.ToString()+"\\sound\\J0214098.wav"; Sound.Play(str,PlaySoundFlags.SND_ASYNC|PlaySoundFlags.SND_FILENAME|PlaySoundFlags.SND_NOWAIT); //lblPara.Text=Money.ToString()+" YTL"; lblKazan.Visible=true; if(intBen<2 && zaman<-2) { timer4.Stop(); this.Dispose(); this.Close(); Boss1 boss=new Boss1(gelenPara,yemlik,Hak,this,Cin,Osuruk,intRound+1,intBen+1 ,intCmp); boss.Show(); } } else { lblKaybet.Visible=true; intCmp++; if(Hak>1) { Hak--; //Boss1 boss=new Boss1(gelenPara,yemlik,Hak/*,this*/,Cin,Osuruk); if(intCmp<2) { if(zaman<-2) { timer4.Stop(); this.Dispose(); this.Close(); Boss1 boss=new Boss1(gelenPara,yemlik,Hak,this,Cin,Osuruk,intRound+1,intBen ,intCmp+1); boss.Show(); } } else { kapat(); } } else { kapat(); } } } else if(zaman<-2) { if(intCmp<2 && intBen<2) { timer4.Stop(); this.Dispose(); this.Close(); Boss1 boss=new Boss1(gelenPara,yemlik,Hak,this,Cin,Osuruk,intRound+1,intBen ,intCmp); boss.Show(); } else if(intCmp>=2) { kapat(); } else if(intBen>=2) { timer5.Start(); } } } double miktar=0; int i3,ekle=0; private void timer5_Tick(object sender, System.EventArgs e) { if(i3==0) { miktar=(Money-gelenPara); i3++; } if(miktar>0) { miktar-=10; ekle+=10; lblPara.Text=(gelenPara+ekle).ToString(); lblMyMoney.Text=(int.Parse(lblMyMoney.Text)-1).ToString(); } else { timer5.Stop(); this.Dispose(); this.Close(); Form5 frm5=new Form5(Money,yemlik,Hak); frm5.Show(); } } } } |
Yukarıdaki kodlardan da anlaşılacağı gibi oyun yazmak gerçekten zahmetli bir süreçtir. Çokça algoritmanın yazılması gerektiği gibi, matematiksel işlemlerinde bolca kullanlması özellikle oyun motoru için vazgeçilmez bir kavramdır. Oynun grafikleri, sesleri ve efektleri de en az kodlama kadar önemli ve belki de çok daha fazla zaman alan süreçlerin başındadır. Modelleme, platform ve level tasarımları önce kağıt üzerinde yapılmalıdır. Oyunda yapılacak işler ve her ihtimal adım adım çizilip modellendikten sonra kodlamaya dökülmeli ve en sonunda da bolca teste tabi tutulmalıdır. Yukarıda gördüğünüz platform oynu size feyz olması ve aynı zamanda biraz olsun oyun yazmanın nasıl bir his olduğu hakkında fikir vermesi amacı ile yapılmıştır. Kodların tamamından ziyade dikkat çekici önemli kısımlara değinilmiştir.Oyunun kodları aşağıdaki linkdedir.
Umarım sizde oyun dünyasına olan bakış açınızı değiştirir ve artık sadece oynamaktan ziyade hangi teknolojiler ile ve nasıl yapıldığı konusunda da fikir yürütebilirsiniz.
Bir sonraki makalede görüşmek üzere hoşçakalın.
Source Code : http://www.borakasmer.com/projects/BoMan.rar
Son Yorumlar