PowerBuilder Looking Around Game
Srouce Code
w_main from window
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 |
forward global type w_main from window end type type cb_1 from commandbutton within w_main end type type rb_4 from radiobutton within w_main end type type rb_3 from radiobutton within w_main end type type cbx_1 from checkbox within w_main end type type rb_2 from radiobutton within w_main end type type rb_1 from radiobutton within w_main end type type st_4 from statictext within w_main end type type st_3 from statictext within w_main end type type st_2 from statictext within w_main end type type cb_reopen from commandbutton within w_main end type type cb_start from commandbutton within w_main end type type p_1 from picture within w_main end type type p_model from picture within w_main end type type r_box from rectangle within w_main end type type st_1 from statictext within w_main end type type gb_1 from groupbox within w_main end type type gb_2 from groupbox within w_main end type type ov_3 from oval within w_main end type type ov_1 from oval within w_main end type type ov_2 from oval within w_main end type end forward global type w_main from window integer width = 1861 integer height = 1376 boolean titlebar = true string title = "looking around" boolean controlmenu = true boolean minbox = true boolean maxbox = true boolean resizable = true long backcolor = 16777215 string icon = "AppIcon!" boolean center = true cb_1 cb_1 rb_4 rb_4 rb_3 rb_3 cbx_1 cbx_1 rb_2 rb_2 rb_1 rb_1 st_4 st_4 st_3 st_3 st_2 st_2 cb_reopen cb_reopen cb_start cb_start p_1 p_1 p_model p_model r_box r_box st_1 st_1 gb_1 gb_1 gb_2 gb_2 ov_3 ov_3 ov_1 ov_1 ov_2 ov_2 end type global w_main w_main type variables //Record the multiple, the maximum level Dec ii_multiple,ii_multiple_max = 12 //Store dynamically generated controls and clear them picture ii_any_picture[], ii_any_null[] //countdown String is_timer = '5' //God's perspective - record coordinates Long il_subscript //blood volume Long il_hp = 3 end variables forward prototypes public function integer wf_random (integer ai_bound) public subroutine wf_deleteobject () public subroutine wf_draw_new () end prototypes public function integer wf_random (integer ai_bound);Int i Int li_number li_number = Rand(ai_bound) Return li_number end function public subroutine wf_deleteobject ();Long li_i For li_i = UpperBound(ii_any_picture) To 1 Step -1 CloseUserObject(ii_any_picture[li_i]) Next end subroutine public subroutine wf_draw_new ();picture lp_pic Int li_x = 0,li_y = 0,li_i Int li_for_x, li_for_y Decimal li_box_width,li_box_height,li_model_width,li_model_height Int li_line,li_column Int li_coordinates_x, li_coordinates_y For li_i = UpperBound(ii_any_picture) To 1 Step -1 CloseUserObject(ii_any_picture[li_i]) Next // clear the array ii_any_picture = ii_any_null st_1.Text = is_timer li_x = r_box.X li_y = r_box.Y li_box_width = r_box.Width li_box_height = r_box.Height // redefine the content image size li_model_width = li_box_width /ii_multiple li_model_height = li_box_height /ii_multiple li_line = li_box_height /li_model_height //line li_column = li_box_width /li_model_width //column li_coordinates_x = wf_random(li_column) //coordinate 1 li_coordinates_y = wf_random(li_line) //coordinate 2 For li_for_y = 1 To li_line For li_for_x = 1 To li_column lp_pic = Create Using "p_model" If li_for_y = li_coordinates_y And li_coordinates_x = li_for_x Then //right CheckOut lp_pic.PictureName = 'right.bmp' lp_pic.Tag = '1' il_subscript = UpperBound(ii_any_picture) +1 End If lp_pic.Width = li_model_width //Set properties lp_pic.Height = li_model_height lp_pic.Enabled = True This.OpenUserObject(lp_pic,""+String(li_for_x)+"", li_x,li_y) li_x+= li_model_width ii_any_picture[UpperBound(ii_any_picture) + 1] = lp_pic Next li_y+= li_model_height li_x = r_box.X Next //Redraw border width and height; //r_box.width=li_column *li_model_width //r_box.height=li_line * li_model_height end subroutine on w_main.create this.cb_1=create cb_1 this.rb_4=create rb_4 this.rb_3=create rb_3 this.cbx_1=create cbx_1 this.rb_2=create rb_2 this.rb_1=create rb_1 this.st_4=create st_4 this.st_3=create st_3 this.st_2=create st_2 this.cb_reopen=create cb_reopen this.cb_start=create cb_start this.p_1=create p_1 this.p_model=create p_model this.r_box=create r_box this.st_1=create st_1 this.gb_1=create gb_1 this.gb_2=create gb_2 this.ov_3=create ov_3 this.ov_1=create ov_1 this.ov_2=create ov_2 this.Control[]={this.cb_1,& this.rb_4,& this.rb_3,& this.cbx_1,& this.rb_2,& this.rb_1,& this.st_4,& this.st_3,& this.st_2,& this.cb_reopen,& this.cb_start,& this.p_1,& this.p_model,& this.r_box,& this.st_1,& this.gb_1,& this.gb_2,& this.ov_3,& this.ov_1,& this.ov_2} end on on w_main.destroy destroy(this.cb_1) destroy(this.rb_4) destroy(this.rb_3) destroy(this.cbx_1) destroy(this.rb_2) destroy(this.rb_1) destroy(this.st_4) destroy(this.st_3) destroy(this.st_2) destroy(this.cb_reopen) destroy(this.cb_start) destroy(this.p_1) destroy(this.p_model) destroy(this.r_box) destroy(this.st_1) destroy(this.gb_1) destroy(this.gb_2) destroy(this.ov_3) destroy(this.ov_1) destroy(this.ov_2) end on event timer;Long ll_num String ls_score ll_num = Long(st_1.Text) If ll_num = 0 Then ls_score = st_4.Text Timer(0) cb_start.Enabled = True MessageBox("Tips", "Game Over; Score:" +ls_score) cb_reopen.TriggerEvent( Clicked!) Else st_1.Text = String(ll_num -1) End If end event event open;Randomize(0) end event type cb_1 from commandbutton within w_main integer x = 1326 integer y = 864 integer width = 457 integer height = 128 integer taborder = 60 integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" string text = "Tips" end type event clicked;If Upperbound(ii_any_picture) < 1 Then Return ii_any_picture[il_subscript].Invert = True end event type rb_4 from radiobutton within w_main integer x = 1248 integer y = 1124 integer width = 384 integer height = 64 integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" long textcolor = 33554432 long backcolor = 16777215 string text = "unlimited" end type type rb_3 from radiobutton within w_main integer x = 786 integer y = 1124 integer width = 384 integer height = 64 integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" long textcolor = 33554432 long backcolor = 16777215 string text = "12 levels" boolean checked = true end type type cbx_1 from checkbox within w_main boolean visible = false integer x = 2336 integer y = 912 integer width = 352 integer height = 68 integer textsize = -10 integer weight = 400 fontcharset fontcharset = gb2312charset! fontpitch fontpitch = variable! string facename = "Tahoma" long textcolor = 33554432 long backcolor = 16777215 boolean enabled = false string text = "God's perspective" end type type rb_2 from radiobutton within w_main integer x = 320 integer y = 1124 integer width = 384 integer height = 64 integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" long textcolor = 33554432 long backcolor = 16777215 string text = "unlimited" end type type rb_1 from radiobutton within w_main integer x = 50 integer y = 1124 integer width = 224 integer height = 64 integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" long textcolor = 33554432 long backcolor = 16777215 string text = "time" boolean checked = true end type type st_4 from statictext within w_main integer x = 1504 integer y = 176 integer width = 242 integer height = 76 integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" long textcolor = 33554432 long backcolor = 16777215 string text = "0" boolean border = true boolean focusrectangle = false end type type st_3 from statictext within w_main integer x = 1312 integer y = 184 integer width = 206 integer height = 76 integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" long textcolor = 33554432 long backcolor = 16777215 string text = "Score:" boolean focusrectangle = false end type type st_2 from statictext within w_main integer x = 1335 integer y = 268 integer width = 178 integer height = 76 integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" long textcolor = 33554432 long backcolor = 16777215 string text = "time:" boolean focusrectangle = false end type type cb_reopen from commandbutton within w_main integer x = 1326 integer y = 716 integer width = 457 integer height = 128 integer taborder = 30 integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" string text = "Refresh" end type event clicked;ii_multiple = 2 r_box.Width = 1200 r_box.Height = 1000 If rb_1.Checked Then st_1.Text = is_timer Else is_timer = 'none' st_1.Text = is_timer End If st_4.Text = '0' wf_deleteobject() ii_any_picture = ii_any_null Timer(0) cb_start.Enabled = True rb_1.Enabled = True rb_2.Enabled = True rb_3.Enabled = True rb_4.Enabled = True ov_1.FillColor = RGB(255,0,0) ov_2.FillColor = RGB(255,0,0) ov_3.FillColor = RGB(255,0,0) il_hp = 3 end event type cb_start from commandbutton within w_main integer x = 1326 integer y = 568 integer width = 457 integer height = 128 integer taborder = 20 integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" string text = "Start" end type event clicked;cb_reopen.TriggerEvent(Clicked!) wf_draw_new() If rb_1.Checked Then Timer(1) End If cb_start.Enabled = False rb_1.Enabled = False rb_2.Enabled = False rb_3.Enabled = False rb_4.Enabled = False end event type p_1 from picture within w_main string tag = "0" integer x = 1563 integer y = 372 integer width = 201 integer height = 160 boolean enabled = false string picturename = "right.bmp" boolean border = true boolean focusrectangle = false end type event clicked;String ls_tag ls_tag = This.Tag MessageBox("",ls_tag) end event type p_model from picture within w_main string tag = "0" integer x = 1335 integer y = 372 integer width = 201 integer height = 160 boolean enabled = false string picturename = "left.bmp" boolean border = true boolean focusrectangle = false end type event clicked;String ls_tag Int li_i ls_tag = This.Tag If ls_tag = '1' Then st_4.Text = String(Long(st_4.Text) + ((Long(st_1.Text) * 10) )) ii_multiple = ii_multiple+1 If rb_3.Checked Then If ii_multiple > ii_multiple_max Then MessageBox("Tips", "Game Over; Score: "+st_4.Text) cb_reopen.TriggerEvent(Clicked!) Return End If Else If ii_multiple > ii_multiple_max Then ii_multiple = ii_multiple_max End If End If wf_draw_new() Else il_hp = il_hp -1 If il_hp = 2 Then ov_3.FillColor = RGB(255,255,255) ElseIf il_hp = 1 Then ov_2.FillColor = RGB(255,255,255) Else ov_1.FillColor = RGB(255,255,255) End If If il_hp = 0 Then MessageBox("Tips", "Game Over; Score: "+st_4.Text) cb_reopen.TriggerEvent(Clicked!) Return End If // messagebox("",il_hp) End If end event type r_box from rectangle within w_main long linecolor = 33554432 integer linethickness = 4 long fillcolor = 1073741824 integer width = 1202 integer height = 1000 end type type st_1 from statictext within w_main integer x = 1504 integer y = 256 integer width = 242 integer height = 76 boolean bringtotop = true integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" long textcolor = 33554432 long backcolor = 16777215 string text = "0" boolean border = true boolean focusrectangle = false end type type gb_1 from groupbox within w_main integer y = 1036 integer width = 713 integer height = 196 integer taborder = 40 integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" long textcolor = 255 long backcolor = 16777215 string text = "time" end type type gb_2 from groupbox within w_main integer x = 741 integer y = 1036 integer width = 1029 integer height = 196 integer taborder = 50 integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" long textcolor = 255 long backcolor = 16777215 string text = "level" end type type ov_3 from oval within w_main long linecolor = 33554432 integer linethickness = 4 long fillcolor = 255 integer x = 1664 integer y = 80 integer width = 55 integer height = 48 end type type ov_1 from oval within w_main long linecolor = 33554432 integer linethickness = 4 long fillcolor = 255 integer x = 1390 integer y = 80 integer width = 55 integer height = 48 end type type ov_2 from oval within w_main long linecolor = 33554432 integer linethickness = 4 long fillcolor = 255 integer x = 1527 integer y = 80 integer width = 55 integer height = 48 end type |
Find Projects On Github click here
Good Luck!
Subscribe
Login
0 Comments
Oldest