├── LICENSE ├── README.md ├── _config.yml ├── resources └── screenshot1.png └── src ├── ScrabbleV1-1.pb └── resources ├── background.bmp ├── front.bmp └── rules.bmp /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Mong Alvarez Jr. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PureBasic Mini-Scrabble 2 | 3 | [![Hits](https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2Fxdvrx1%2FPureBasic-Scrabble&count_bg=%2379C83D&title_bg=%23555555&icon=&icon_color=%23E7E7E7&title=PAGE+VIEWS&edge_flat=false)](https://hits.seeyoufarm.com) 4 | 5 | This is a scrabble game written in PureBasic. 6 | 7 | ![GUI](resources/screenshot1.png) 8 | 9 | When playing, better play this 10 | with a dictionary, 11 | I intentionally did not include any standard dictionary 12 | so that learners/students will be engaged in 13 | playing this game, doing some manual 14 | researches for those words. 15 | 16 | There are four sets 17 | and when you click 'Reset' 18 | your score/s will be counted. 19 | 20 | And you can always change these things as per requirement of yours. 21 | 22 | ## Disclaimer 23 | Please note that this project is presented as a showcase of my work during a 24 | specific period. It represents a snapshot of my skills and accomplishments 25 | at that time. As such, this project is no longer actively maintained or updated. 26 | It is kept public for demonstration purposes and may not reflect my current 27 | abilities or the latest best practices in the field. 28 | 29 | However, feel free to learn from this archived project, 30 | preserved as it was during that specific period ! 31 | 32 | ## Compiling 33 | To compile/run, just use the PureBasic IDE, that's very fast and 34 | simple for simple programs like this. 35 | 36 | ## License 37 | MIT - The permissive license 38 | 39 | ## The Good Old Days 40 | PureBasic was my first ever programming language, so it reminds me of the good old days. 41 | Before PureBasic, I first learned Excel formulas, which really captured my interest. 42 | The very first time I encountered Excel was in college, 43 | and it was the IF function presented by the professor that really caught my attention. 44 | 45 | ## More PureBasic Projects 46 | for more PureBasic discussion and other details, 47 | check the Main Page -> [PureBasic](https://github.com/jdevfullstack/PureBasic) 48 | 49 | ## More Of My Content 50 | - [jdevfullstack Profile](https://github.com/jdevfullstack) 51 | - [jdevfullstack Repos](https://github.com/jdevfullstack?tab=repositories) 52 | - [jdevfullstack Projects](https://github.com/jdevfullstack-projects) 53 | - [jdevfullstack Tutorials](https://github.com/jdevfullstack-tutorials) 54 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-cayman -------------------------------------------------------------------------------- /resources/screenshot1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jfullstackdev/PureBasic-Scrabble/5e4393cc469d2fe75f167edc3e0b2e2eca4b3952/resources/screenshot1.png -------------------------------------------------------------------------------- /src/ScrabbleV1-1.pb: -------------------------------------------------------------------------------- 1 | ;declaration of an array 2 | ;starting from zero index 3 | ;again we do not do this by For loop 4 | ;so just to feel the burden haha 5 | Dim RandomLetters.s (50) 6 | 7 | RandomLetters(0)= "A" 8 | RandomLetters(1)= "B" 9 | RandomLetters(2)= "C" 10 | RandomLetters(3)= "D" 11 | RandomLetters(4)= "E" 12 | RandomLetters(5)= "F" 13 | RandomLetters(6)= "G" 14 | RandomLetters(7)= "H" 15 | RandomLetters(8)= "I" 16 | RandomLetters(9)= "J" 17 | RandomLetters(10)= "K" 18 | RandomLetters(11)= "L" 19 | RandomLetters(12)= "M" 20 | RandomLetters(13)= "N" 21 | RandomLetters(14)= "O" 22 | RandomLetters(15)= "P" 23 | RandomLetters(16)= "Q" 24 | RandomLetters(17)= "R" 25 | RandomLetters(18)= "S" 26 | RandomLetters(19)= "T" 27 | RandomLetters(20)= "U" 28 | RandomLetters(21)= "V" 29 | RandomLetters(22)= "W" 30 | RandomLetters(23)= "X" 31 | RandomLetters(24)= "Y" 32 | RandomLetters(25)= "Z" 33 | 34 | 35 | RandomLetters(26)= "A" 36 | RandomLetters(27)= "E" 37 | RandomLetters(28)= "I" 38 | RandomLetters(29)= "O" 39 | RandomLetters(30)= "U" 40 | 41 | RandomLetters(31)= "A" 42 | RandomLetters(32)= "E" 43 | RandomLetters(33)= "I" 44 | RandomLetters(34)= "O" 45 | RandomLetters(35)= "U" 46 | 47 | RandomLetters(36)= "A" 48 | RandomLetters(37)= "E" 49 | RandomLetters(38)= "I" 50 | RandomLetters(39)= "O" 51 | RandomLetters(40)= "U" 52 | 53 | RandomLetters(41)= "A" 54 | RandomLetters(42)= "E" 55 | RandomLetters(43)= "I" 56 | RandomLetters(44)= "O" 57 | RandomLetters(45)= "U" 58 | 59 | RandomLetters(46)= "A" 60 | RandomLetters(47)= "E" 61 | RandomLetters(48)= "I" 62 | RandomLetters(49)= "O" 63 | RandomLetters(50)= "U" 64 | 65 | ;declaration of constants 66 | ;we do not take for granted using numbers as 67 | ;constants, it can be confusing 68 | 69 | Enumeration 70 | #WIN_MAIN 71 | 72 | ;images 1 and 2 embedded in the Data Section 73 | #Image_1 74 | #Image_2 75 | #Image_3 76 | 77 | ;different buttons 78 | #Button_1 79 | #Button_2 80 | #Button_3 81 | #Button_4 82 | #Button_5 83 | #Button_6 84 | #Button_7 85 | #Button_8 86 | #Button_9 87 | #Button_10 88 | #Button_11 89 | #Button_12 90 | #Button_13 91 | #Button_14 92 | #Button_15 93 | #Button_16 94 | #Button_17 95 | #Button_18 96 | #Button_19 97 | #Button_20 98 | 99 | #BUTTON_CLEAR 100 | 101 | #SetButton_20 102 | #SetButton_15 103 | #SetButton_10 104 | #SetButton_5 105 | 106 | #BUTTON_Start 107 | #BUTTON_Rules 108 | #BUTTON_Proceed 109 | 110 | #ConfirmNo 111 | #ConfirmYes 112 | 113 | ;the Editor gadget constant 114 | ;there is also another one 115 | ;the ListView Gadget 116 | #LIST_INPUT 117 | #CORRECT_WORDS 118 | 119 | ;TextGadget to enhance 120 | ;the GUI 121 | #TextGadget_1 122 | #TextGadget_2 123 | 124 | 125 | EndEnumeration 126 | ;again declaration of the behavior of the window 127 | #F1 = #PB_Window_SystemMenu 128 | #F2 = #PB_Window_ScreenCentered 129 | #F3 = #PB_Window_MinimizeGadget 130 | 131 | Flags = #F1 | #F2 | #F3 132 | 133 | ;this is so repetitive, so we include it here 134 | ;in just one procedure, which we call Main ( ) 135 | ;this tells that if a certain button has a value of 1 136 | ;(we set toggle so that there is a value of 1) 137 | ;then it will unhide the gadget 138 | ;and it will untoggle the gadget 139 | Procedure Main() 140 | 141 | If GetGadgetState(#Button_1)=1 142 | HideGadget(#Button_1,0) 143 | SetGadgetState(#Button_1,0) 144 | EndIf 145 | 146 | If GetGadgetState(#Button_2)=1 147 | HideGadget(#Button_2,0) 148 | SetGadgetState(#Button_2,0) 149 | EndIf 150 | 151 | If GetGadgetState(#Button_3)=1 152 | HideGadget(#Button_3,0) 153 | SetGadgetState(#Button_3,0) 154 | EndIf 155 | 156 | If GetGadgetState(#Button_4)=1 157 | HideGadget(#Button_4,0) 158 | SetGadgetState(#Button_4,0) 159 | EndIf 160 | 161 | If GetGadgetState(#Button_5)=1 162 | HideGadget(#Button_5,0) 163 | SetGadgetState(#Button_5,0) 164 | EndIf 165 | 166 | If GetGadgetState(#Button_6)=1 167 | HideGadget(#Button_6,0) 168 | SetGadgetState(#Button_6,0) 169 | EndIf 170 | 171 | If GetGadgetState(#Button_7)=1 172 | HideGadget(#Button_7,0) 173 | SetGadgetState(#Button_7,0) 174 | EndIf 175 | 176 | If GetGadgetState(#Button_8)=1 177 | HideGadget(#Button_8,0) 178 | SetGadgetState(#Button_8,0) 179 | EndIf 180 | 181 | If GetGadgetState(#Button_9)=1 182 | HideGadget(#Button_9,0) 183 | SetGadgetState(#Button_9,0) 184 | EndIf 185 | 186 | If GetGadgetState(#Button_10)=1 187 | HideGadget(#Button_10,0) 188 | SetGadgetState(#Button_10,0) 189 | EndIf 190 | 191 | If GetGadgetState(#Button_11)=1 192 | HideGadget(#Button_11,0) 193 | SetGadgetState(#Button_11,0) 194 | EndIf 195 | 196 | If GetGadgetState(#Button_12)=1 197 | HideGadget(#Button_12,0) 198 | SetGadgetState(#Button_12,0) 199 | EndIf 200 | 201 | If GetGadgetState(#Button_13)=1 202 | HideGadget(#Button_13,0) 203 | SetGadgetState(#Button_13,0) 204 | EndIf 205 | 206 | If GetGadgetState(#Button_14)=1 207 | HideGadget(#Button_14,0) 208 | SetGadgetState(#Button_14,0) 209 | EndIf 210 | 211 | If GetGadgetState(#Button_15)=1 212 | HideGadget(#Button_15,0) 213 | SetGadgetState(#Button_15,0) 214 | EndIf 215 | 216 | If GetGadgetState(#Button_16)=1 217 | HideGadget(#Button_16,0) 218 | SetGadgetState(#Button_16,0) 219 | EndIf 220 | 221 | If GetGadgetState(#Button_17)=1 222 | HideGadget(#Button_17,0) 223 | SetGadgetState(#Button_17,0) 224 | EndIf 225 | 226 | If GetGadgetState(#Button_18)=1 227 | HideGadget(#Button_18,0) 228 | SetGadgetState(#Button_18,0) 229 | EndIf 230 | 231 | If GetGadgetState(#Button_19)=1 232 | HideGadget(#Button_19,0) 233 | SetGadgetState(#Button_19,0) 234 | EndIf 235 | 236 | If GetGadgetState(#Button_20)=1 237 | HideGadget(#Button_20,0) 238 | SetGadgetState(#Button_20,0) 239 | EndIf 240 | 241 | EndProcedure 242 | 243 | ;procedure to enable the #BUTTON_CLEAR 244 | Procedure EnablingButtonClear() 245 | 246 | ;the condition simply says 247 | ;there are four conditions 248 | ;in order for #BUTTON_CLEAR to 249 | ;be enabled 250 | 251 | If GetGadgetState(#SetButton_10)=1 252 | If GetGadgetState(#SetButton_15)=1 253 | If GetGadgetState(#SetButton_20)=1 254 | If GetGadgetState(#SetButton_5)=1 255 | DisableGadget(#BUTTON_CLEAR,0) 256 | EndIf 257 | EndIf 258 | EndIf 259 | EndIf 260 | 261 | EndProcedure 262 | 263 | Procedure Unhiding20Buttons() 264 | 265 | HideGadget(#Button_1,0) 266 | HideGadget(#Button_2,0) 267 | HideGadget(#Button_3,0) 268 | HideGadget(#Button_4,0) 269 | HideGadget(#Button_5,0) 270 | HideGadget(#Button_6,0) 271 | HideGadget(#Button_7,0) 272 | HideGadget(#Button_8,0) 273 | HideGadget(#Button_9,0) 274 | HideGadget(#Button_10,0) 275 | HideGadget(#Button_11,0) 276 | HideGadget(#Button_12,0) 277 | HideGadget(#Button_13,0) 278 | HideGadget(#Button_14,0) 279 | HideGadget(#Button_15,0) 280 | HideGadget(#Button_16,0) 281 | HideGadget(#Button_17,0) 282 | HideGadget(#Button_18,0) 283 | HideGadget(#Button_19,0) 284 | HideGadget(#Button_20,0) 285 | 286 | EndProcedure 287 | 288 | ;start of the user interface 289 | 290 | If OpenWindow(#WIN_MAIN, 0, 0, 700, 700, "Mini-Scrabble Version 1.1", Flags) 291 | 292 | If StartDrawing(WindowOutput(#WIN_MAIN)) 293 | CatchImage(0,?Image_1) ;welcome message 294 | ImageGadget(#Image_1,0,0,0,0,ImageID(0)) 295 | DisableGadget(#Image_1,1) ;need to be disabled in order not to cause harm 296 | ;this is the only image that is not hidden 297 | ;so that so it will appear as a welcome 298 | StopDrawing() 299 | EndIf 300 | 301 | If StartDrawing(WindowOutput(#WIN_MAIN)) 302 | CatchImage(1,?Image_2) ; background image 303 | ImageGadget(#Image_2,0,0,0,0,ImageID(1)) 304 | DisableGadget(#Image_2,1) ;need to be disabled also 305 | StopDrawing() 306 | EndIf 307 | HideGadget(#Image_2,1) ;in order not to cause harm for the first image 308 | 309 | If StartDrawing(WindowOutput(#WIN_MAIN)) 310 | CatchImage(2,?Image_3) 311 | ImageGadget(#Image_3,0,0,0,0,ImageID(2)) 312 | DisableGadget(#Image_3,1) 313 | StopDrawing() 314 | EndIf 315 | HideGadget(#Image_3,1) 316 | 317 | 318 | ;declarations of different widgets 319 | ;#PB_Default is Comic Sans MS 320 | LoadFont(1, "Comic Sans MS", 14,#PB_Font_Bold|#PB_Font_HighQuality) 321 | SetGadgetFont(#PB_Default,FontID(1)) 322 | ButtonGadget(#BUTTON_CLEAR, 15, 630, 60,40, "Reset") 323 | ButtonGadget(#BUTTON_Proceed,553,620,100,30,"Proceed") 324 | 325 | DisableGadget(#BUTTON_CLEAR,1) ;disable first and hide then 326 | DisableGadget(#BUTTON_Proceed,1) 327 | HideGadget(#BUTTON_CLEAR,1) ;hide first 328 | HideGadget(#BUTTON_Proceed,1) 329 | 330 | LoadFont(2, "Comic Sans MS", 28,#PB_Font_Bold|#PB_Font_HighQuality) 331 | SetGadgetFont(#PB_Default,FontID(2)) 332 | 333 | ;button gadgets are all blank here 334 | ;so when this is loaded. 335 | ;it will be for the first time, 336 | ;so as to limit everything 337 | ;there is no space 338 | ;so that so, 339 | ;if children click it and 340 | ;press the Yes button 341 | ;it will not be considered as 342 | ;an item 343 | ButtonGadget(#Button_1, 45, 200, 50, 50,"",#PB_Button_Toggle) 344 | ButtonGadget(#Button_2, 125, 200, 50, 50,"",#PB_Button_Toggle) 345 | ButtonGadget(#Button_3, 205, 200, 50, 50,"",#PB_Button_Toggle) 346 | ButtonGadget(#Button_4, 285, 200, 50, 50,"",#PB_Button_Toggle) 347 | 348 | ButtonGadget(#Button_5, 45, 270, 50, 50, "",#PB_Button_Toggle) 349 | ButtonGadget(#Button_6, 125, 270, 50, 50, "",#PB_Button_Toggle) 350 | ButtonGadget(#Button_7, 205, 270, 50, 50, "",#PB_Button_Toggle) 351 | ButtonGadget(#Button_8, 285, 270, 50, 50, "",#PB_Button_Toggle) 352 | 353 | ButtonGadget(#Button_9, 45, 340, 50, 50, "",#PB_Button_Toggle) 354 | ButtonGadget(#Button_10, 125, 340, 50, 50, "",#PB_Button_Toggle) 355 | ButtonGadget(#Button_11, 205, 340, 50, 50, "",#PB_Button_Toggle) 356 | ButtonGadget(#Button_12, 285, 340, 50, 50, "",#PB_Button_Toggle) 357 | 358 | ButtonGadget(#Button_13, 45, 410, 50, 50, "",#PB_Button_Toggle) 359 | ButtonGadget(#Button_14, 125, 410, 50, 50, "",#PB_Button_Toggle) 360 | ButtonGadget(#Button_15, 205, 410, 50, 50, "",#PB_Button_Toggle) 361 | ButtonGadget(#Button_16, 285, 410, 50, 50, "",#PB_Button_Toggle) 362 | 363 | ButtonGadget(#Button_17, 45, 480, 50, 50, "",#PB_Button_Toggle) 364 | ButtonGadget(#Button_18, 125, 480, 50, 50, "",#PB_Button_Toggle) 365 | ButtonGadget(#Button_19, 205, 480, 50, 50, "",#PB_Button_Toggle) 366 | ButtonGadget(#Button_20, 285, 480, 50, 50, "",#PB_Button_Toggle) 367 | 368 | ;all of these buttons must be hidden first 369 | HideGadget(#Button_1,1) 370 | HideGadget(#Button_2,1) 371 | HideGadget(#Button_3,1) 372 | HideGadget(#Button_4,1) 373 | HideGadget(#Button_5,1) 374 | HideGadget(#Button_6,1) 375 | HideGadget(#Button_7,1) 376 | HideGadget(#Button_8,1) 377 | HideGadget(#Button_9,1) 378 | HideGadget(#Button_10,1) 379 | HideGadget(#Button_11,1) 380 | HideGadget(#Button_12,1) 381 | HideGadget(#Button_13,1) 382 | HideGadget(#Button_14,1) 383 | HideGadget(#Button_15,1) 384 | HideGadget(#Button_16,1) 385 | HideGadget(#Button_17,1) 386 | HideGadget(#Button_18,1) 387 | HideGadget(#Button_19,1) 388 | HideGadget(#Button_20,1) 389 | 390 | LoadFont(3, "Comic Sans MS", 24,#PB_Font_Bold|#PB_Font_HighQuality) 391 | SetGadgetFont(#PB_Default,FontID(3)) 392 | EditorGadget(#LIST_INPUT,26,70, 648,58,#PB_Editor_ReadOnly) 393 | ;again no space for the blank 394 | AddGadgetItem(#LIST_INPUT,-1,"" ) ;blank first, to be set later 395 | HideGadget(#LIST_INPUT,1) ;must be hidden also 396 | 397 | ;these are the first buttons to show 398 | ;plus the welcome image: #Image_1 399 | LoadFont(4, "Comic Sans MS", 14,#PB_Font_Bold|#PB_Font_HighQuality) 400 | SetGadgetFont(#PB_Default,FontID(4)) 401 | ButtonGadget(#BUTTON_Start, 280, 560, 140,50, "Let's start!") 402 | ButtonGadget(#BUTTON_Rules, 280, 630, 140,50, "View Rules") 403 | 404 | LoadFont(5, "Comic Sans MS", 14,#PB_Font_Bold|#PB_Font_HighQuality) 405 | SetGadgetFont(#PB_Default,FontID(5)) 406 | ButtonGadget(#SetButton_20, 15, 550, 80,50, "Set 20",#PB_Button_Toggle) 407 | ButtonGadget(#SetButton_15,105,550,80,50,"Set 15",#PB_Button_Toggle) 408 | ButtonGadget(#SetButton_10,195,550,80,50,"Set 10",#PB_Button_Toggle) 409 | ButtonGadget(#SetButton_5,285,550,80,50,"Set 5",#PB_Button_Toggle) 410 | 411 | ButtonGadget(#ConfirmYes,230,145,80,40,"Yes!") 412 | ButtonGadget(#ConfirmNo,320,145,80,40,"No") 413 | 414 | ;must be hidden also, all of these 415 | HideGadget(#SetButton_20,1) 416 | HideGadget(#SetButton_15,1) 417 | HideGadget(#SetButton_10,1) 418 | HideGadget(#SetButton_5,1) 419 | HideGadget(#ConfirmYes,1) 420 | HideGadget(#ConfirmNo,1) 421 | 422 | 423 | LoadFont(6, "Comic Sans MS", 12,#PB_Font_Bold|#PB_Font_HighQuality) 424 | SetGadgetFont(#PB_Default,FontID(6)) 425 | ListViewGadget(#CORRECT_WORDS,375,200,300,430) 426 | 427 | ;this one will be cleared by the Resetn Button 428 | ;please take note of this 429 | AddGadgetItem(#CORRECT_WORDS,-1,"Correct words:") 430 | 431 | HideGadget(#CORRECT_WORDS,1) 432 | 433 | ;we will add here another two TextGadget for User Interface purposes 434 | LoadFont(7, "Comic Sans MS", 16,#PB_Font_Bold|#PB_Font_HighQuality) 435 | SetGadgetFont(#PB_Default,FontID(7)) 436 | TextGadget(#TextGadget_1,15,25,150,40," Your word is:") 437 | SetGadgetColor(#TextGadget_1,#PB_Gadget_BackColor,RGB(150,200,0)) 438 | 439 | HideGadget(#TextGadget_1,1) 440 | 441 | LoadFont(8, "Comic Sans MS", 16,#PB_Font_Bold|#PB_Font_HighQuality) 442 | SetGadgetFont(#PB_Default,FontID(8)) 443 | TextGadget(#TextGadget_2,40,145,180,40," Is this correct?") 444 | SetGadgetColor(#TextGadget_2,#PB_Gadget_BackColor,RGB(150,200,0)) 445 | 446 | HideGadget(#TextGadget_2,1) 447 | 448 | 449 | Repeat 450 | Event.l = WaitWindowEvent() 451 | Select Event 452 | Case #PB_Event_Gadget 453 | 454 | Select EventGadget() 455 | 456 | Case #BUTTON_Start 457 | ;#Button_Start and #Image_1 must be now hidden 458 | ;plus Button Rules 459 | HideGadget(#BUTTON_Start,1) 460 | HideGadget(#Image_1,1) 461 | HideGadget(#BUTTON_Rules,1) 462 | 463 | ;Showing #Image_2 and #BUTTON_CLEAR 464 | HideGadget(#Image_2,0) 465 | ;but the #BUTTON_CLEAR is 466 | ;still disabled 467 | HideGadget(#BUTTON_CLEAR,0) 468 | 469 | ;showing also the sets button 470 | ;these buttons were not disabled 471 | ;from the start 472 | HideGadget(#SetButton_20,0) 473 | HideGadget(#SetButton_15,0) 474 | HideGadget(#SetButton_10,0) 475 | HideGadget(#SetButton_5,0) 476 | 477 | ;in this Start Button, we are not yet showing the 478 | ;#ConfirmYes and #ConfirmNo 479 | ;because this should limit the tendency of them to be clicked 480 | ;or else, if this is accindentally clicked, 481 | ;there will be a count For the gadget 482 | ;it is another protection 483 | 484 | Case #BUTTON_Rules 485 | ;almost identical 486 | ;to the process of Start 487 | ;hiding first #BUTTON_Start 488 | ;#Image_1 489 | ;#BUTTON_Rules 490 | HideGadget(#BUTTON_Start,1) 491 | HideGadget(#Image_1,1) 492 | HideGadget(#BUTTON_Rules,1) 493 | 494 | ;unhiding Image_3 495 | ;this is the image for the rules of the game 496 | HideGadget(#Image_3,0) 497 | HideGadget(#BUTTON_Proceed,0) 498 | ;also #BUTTON_Proceed was disabled 499 | ;we need to enable it 500 | DisableGadget(#BUTTON_Proceed,0) 501 | 502 | Case #BUTTON_Proceed 503 | 504 | HideGadget(#Image_3,1) 505 | HideGadget(#BUTTON_Proceed,1) 506 | 507 | ;#Showing #Image_2 and #BUTTON_CLEAR 508 | HideGadget(#Image_2,0) 509 | ;again here we are not yet enabling them 510 | HideGadget(#BUTTON_CLEAR,0) 511 | 512 | ;showing also the sets button 513 | HideGadget(#SetButton_20,0) 514 | HideGadget(#SetButton_15,0) 515 | HideGadget(#SetButton_10,0) 516 | HideGadget(#SetButton_5,0) 517 | 518 | Case #SetButton_20 519 | ;for User Interface purpose, this is the only time 520 | ;these buttons will be shown 521 | ;this will be repeated for the other buttons: 522 | ;#SetButton_15,#SetButton_10,#SetButton and #SetButton_5 523 | HideGadget(#ConfirmYes,0) 524 | HideGadget(#ConfirmNo,0) 525 | HideGadget(#LIST_INPUT,0) 526 | HideGadget(#CORRECT_WORDS,0) 527 | HideGadget(#TextGadget_1,0) 528 | HideGadget(#TextGadget_2,0) 529 | 530 | ;this command will erase the initial "" of the # LIST_INPUT 531 | ;and if there are already items 532 | ;from other set buttons 533 | ;we erase also 534 | ;this might be confusing 535 | ;because there are actaully no items 536 | ;in the #LIST_INPUT 537 | ;but remember it does not mean 538 | ;that SET 20 is the first one to be 539 | ;played by the player 540 | ClearGadgetItems(#LIST_INPUT) 541 | 542 | ;this command will ensure that 543 | ;when for the second time 544 | ;this button is clicked, 545 | ;it will not give another 546 | ;set of 50 jumbled words 547 | ;which we do not want to happen 548 | ;we does not disable also 549 | ;the other set buttons 550 | ;they should be available, because 551 | ;we can never limit when 552 | ;a user will go to another level 553 | DisableGadget(#SetButton_20,1) 554 | 555 | ;unhidding these buttons 556 | Unhiding20Buttons() 557 | 558 | ;setting the content of these buttons, 559 | ;full 20 buttons with letters 560 | SetGadgetText(#Button_1,RandomLetters(Random(50))) 561 | SetGadgetText(#Button_2,RandomLetters(Random(50))) 562 | SetGadgetText(#Button_3,RandomLetters(Random(50))) 563 | SetGadgetText(#Button_4,RandomLetters(Random(50))) 564 | SetGadgetText(#Button_5,RandomLetters(Random(50))) 565 | SetGadgetText(#Button_6,RandomLetters(Random(50))) 566 | SetGadgetText(#Button_7,RandomLetters(Random(50))) 567 | SetGadgetText(#Button_8,RandomLetters(Random(50))) 568 | SetGadgetText(#Button_9,RandomLetters(Random(50))) 569 | SetGadgetText(#Button_10,RandomLetters(Random(50))) 570 | SetGadgetText(#Button_11,RandomLetters(Random(50))) 571 | SetGadgetText(#Button_12,RandomLetters(Random(50))) 572 | SetGadgetText(#Button_13,RandomLetters(Random(50))) 573 | SetGadgetText(#Button_14,RandomLetters(Random(50))) 574 | SetGadgetText(#Button_15,RandomLetters(Random(50))) 575 | SetGadgetText(#Button_16,RandomLetters(Random(50))) 576 | SetGadgetText(#Button_17,RandomLetters(Random(50))) 577 | SetGadgetText(#Button_18,RandomLetters(Random(50))) 578 | SetGadgetText(#Button_19,RandomLetters(Random(50))) 579 | SetGadgetText(#Button_20,RandomLetters(Random(50))) 580 | 581 | ;calling the two procedures above 582 | EnablingButtonClear() 583 | Main() 584 | 585 | Case #SetButton_15 586 | 587 | ;the same process as the above 588 | HideGadget(#ConfirmYes,0) 589 | HideGadget(#ConfirmNo,0) 590 | HideGadget(#LIST_INPUT,0) 591 | HideGadget(#CORRECT_WORDS,0) 592 | HideGadget(#TextGadget_1,0) 593 | HideGadget(#TextGadget_2,0) 594 | 595 | ClearGadgetItems(#LIST_INPUT) 596 | DisableGadget(#SetButton_15,1) 597 | 598 | Unhiding20Buttons() 599 | 600 | ;setting the content, 601 | ;but this time with numbers 15-20 blank buttons 602 | SetGadgetText(#Button_1,RandomLetters(Random(50))) 603 | SetGadgetText(#Button_2,RandomLetters(Random(50))) 604 | SetGadgetText(#Button_3,RandomLetters(Random(50))) 605 | SetGadgetText(#Button_4,RandomLetters(Random(50))) 606 | SetGadgetText(#Button_5,RandomLetters(Random(50))) 607 | SetGadgetText(#Button_6,RandomLetters(Random(50))) 608 | SetGadgetText(#Button_7,RandomLetters(Random(50))) 609 | SetGadgetText(#Button_8,RandomLetters(Random(50))) 610 | SetGadgetText(#Button_9,RandomLetters(Random(50))) 611 | SetGadgetText(#Button_10,RandomLetters(Random(50))) 612 | SetGadgetText(#Button_11,RandomLetters(Random(50))) 613 | SetGadgetText(#Button_12,RandomLetters(Random(50))) 614 | SetGadgetText(#Button_13,RandomLetters(Random(50))) 615 | SetGadgetText(#Button_14,RandomLetters(Random(50))) 616 | SetGadgetText(#Button_15,RandomLetters(Random(50))) 617 | 618 | SetGadgetText(#Button_16,"") 619 | SetGadgetText(#Button_17,"") 620 | SetGadgetText(#Button_18,"") 621 | SetGadgetText(#Button_19,"") 622 | SetGadgetText(#Button_20,"") 623 | 624 | ;calling again the two procedures 625 | EnablingButtonClear() 626 | Main() 627 | 628 | Case #SetButton_10 629 | ;the same process as the above 630 | HideGadget(#ConfirmYes,0) 631 | HideGadget(#ConfirmNo,0) 632 | HideGadget(#LIST_INPUT,0) 633 | HideGadget(#CORRECT_WORDS,0) 634 | HideGadget(#TextGadget_1,0) 635 | HideGadget(#TextGadget_2,0) 636 | 637 | ClearGadgetItems(#LIST_INPUT) 638 | DisableGadget(#SetButton_10,1) 639 | 640 | Unhiding20Buttons() 641 | 642 | ;after calling the procedure to unhide the 20 buttons 643 | ;it should be set, but this time numbers 11-20 644 | ;must be blank 645 | SetGadgetText(#Button_1,RandomLetters(Random(50))) 646 | SetGadgetText(#Button_2,RandomLetters(Random(50))) 647 | SetGadgetText(#Button_3,RandomLetters(Random(50))) 648 | SetGadgetText(#Button_4,RandomLetters(Random(50))) 649 | SetGadgetText(#Button_5,RandomLetters(Random(50))) 650 | SetGadgetText(#Button_6,RandomLetters(Random(50))) 651 | SetGadgetText(#Button_7,RandomLetters(Random(50))) 652 | SetGadgetText(#Button_8,RandomLetters(Random(50))) 653 | SetGadgetText(#Button_9,RandomLetters(Random(50))) 654 | SetGadgetText(#Button_10,RandomLetters(Random(50))) 655 | 656 | SetGadgetText(#Button_11,"") 657 | SetGadgetText(#Button_12,"") 658 | SetGadgetText(#Button_13,"") 659 | SetGadgetText(#Button_14,"") 660 | SetGadgetText(#Button_15,"") 661 | 662 | SetGadgetText(#Button_16,"") 663 | SetGadgetText(#Button_17,"") 664 | SetGadgetText(#Button_18,"") 665 | SetGadgetText(#Button_19,"") 666 | SetGadgetText(#Button_20,"") 667 | 668 | EnablingButtonClear() 669 | Main() 670 | 671 | Case #SetButton_5 672 | 673 | ;the same process as the above 674 | HideGadget(#ConfirmYes,0) 675 | HideGadget(#ConfirmNo,0) 676 | HideGadget(#LIST_INPUT,0) 677 | HideGadget(#CORRECT_WORDS,0) 678 | HideGadget(#TextGadget_1,0) 679 | HideGadget(#TextGadget_2,0) 680 | 681 | ClearGadgetItems(#LIST_INPUT) 682 | DisableGadget(#SetButton_5,1) 683 | 684 | Unhiding20Buttons() 685 | ;after calling the procedure to unhide 686 | ;there are only 5 buttons to be contained 687 | SetGadgetText(#Button_1,RandomLetters(Random(50))) 688 | SetGadgetText(#Button_2,RandomLetters(Random(50))) 689 | SetGadgetText(#Button_3,RandomLetters(Random(50))) 690 | SetGadgetText(#Button_4,RandomLetters(Random(50))) 691 | SetGadgetText(#Button_5,RandomLetters(Random(50))) 692 | 693 | SetGadgetText(#Button_6,"") 694 | SetGadgetText(#Button_7,"") 695 | SetGadgetText(#Button_8,"") 696 | SetGadgetText(#Button_9,"") 697 | SetGadgetText(#Button_10,"") 698 | 699 | SetGadgetText(#Button_11,"") 700 | SetGadgetText(#Button_12,"") 701 | SetGadgetText(#Button_13,"") 702 | SetGadgetText(#Button_14,"") 703 | SetGadgetText(#Button_15,"") 704 | 705 | SetGadgetText(#Button_16,"") 706 | SetGadgetText(#Button_17,"") 707 | SetGadgetText(#Button_18,"") 708 | SetGadgetText(#Button_19,"") 709 | SetGadgetText(#Button_20,"") 710 | 711 | EnablingButtonClear() 712 | Main() 713 | 714 | Case #ConfirmYes 715 | ;this will just tell that if #LIST_INPUT="", 716 | ;then #LIST_INPUT should be cleared 717 | ;if not, that is the time 718 | ;it will add an item 719 | 720 | ;we have another argument raised here 721 | ;why would you tell the 722 | ;LIST_INPUT should be cleared 723 | ;how about if there are 724 | ;already characters 725 | ;they will be cleared also 726 | 727 | ;if the LIST_INPUT is blank 728 | ;then clear the LIST_INPUT, 729 | ;because there are pre-defined 730 | ;numbers 1 to 50 731 | ;without the condition 732 | ;numbers will be added automatically 733 | ;when Yes is clicked 734 | ;it does not mean, 735 | ;that if the Letter Buttons 736 | ;is also blank, it will erase the LIST_INPUT 737 | ;which we do not want to happen 738 | ;so this statement is correct 739 | If GetGadgetItemText(#LIST_INPUT,0)="" 740 | ClearGadgetItems(#LIST_INPUT) 741 | Else 742 | ;declarations of variable to hold here 743 | ;so that so the reader will not scroll horizontally 744 | Item.s = Str(CountGadgetItems(#CORRECT_WORDS)) 745 | 746 | Item2.s = GetGadgetItemText(#LIST_INPUT, 0) 747 | AddGadgetItem(#CORRECT_WORDS,-1, Item + "." + " " + Item2) 748 | 749 | ;we use the listing of number from 1 to 1000 750 | ;so that so the gadget state will be automatic 751 | ;per answer of the player 752 | ;after it reach 1000, 753 | ;it will continue, but 754 | ;the SetGadgetState is no longer active 755 | ;it will stop at 1000 756 | For k = 1 To 1000 757 | SetActiveGadget(#CORRECT_WORDS) 758 | SetGadgetState(#CORRECT_WORDS,k) 759 | Next 760 | 761 | EndIf 762 | 763 | ;this is needed so that if there are 764 | ;letters it will be cleared 765 | ClearGadgetItems(#LIST_INPUT) 766 | 767 | Case #ConfirmNo 768 | ClearGadgetItems(#LIST_INPUT) 769 | 770 | Case #Button_1 771 | 772 | BI1.s = GetGadgetItemText(#LIST_INPUT,0) 773 | BI2.s = GetGadgetText(#Button_1) 774 | 775 | SetGadgetItemText(#LIST_INPUT,0, BI1 + BI2) 776 | HideGadget(#Button_1,1) 777 | 778 | Case #Button_2 779 | 780 | BI1.s = GetGadgetItemText(#LIST_INPUT,0) 781 | BI2.s = GetGadgetText(#Button_2) 782 | 783 | SetGadgetItemText(#LIST_INPUT,0, BI1 + BI2) 784 | HideGadget(#Button_2,1) 785 | 786 | Case #Button_3 787 | 788 | BI1.s = GetGadgetItemText(#LIST_INPUT,0) 789 | BI2.s = GetGadgetText(#Button_3) 790 | 791 | SetGadgetItemText(#LIST_INPUT,0, BI1 + BI2) 792 | HideGadget(#Button_3,1) 793 | 794 | Case #Button_4 795 | 796 | BI1.s = GetGadgetItemText(#LIST_INPUT,0) 797 | BI2.s = GetGadgetText(#Button_4) 798 | 799 | SetGadgetItemText(#LIST_INPUT,0, BI1 + BI2) 800 | HideGadget(#Button_4,1) 801 | 802 | Case #Button_5 803 | 804 | BI1.s = GetGadgetItemText(#LIST_INPUT,0) 805 | BI2.s = GetGadgetText(#Button_5) 806 | 807 | SetGadgetItemText(#LIST_INPUT,0, BI1 + BI2) 808 | HideGadget(#Button_5,1) 809 | 810 | Case #Button_6 811 | 812 | BI1.s = GetGadgetItemText(#LIST_INPUT,0) 813 | BI2.s = GetGadgetText(#Button_6) 814 | 815 | SetGadgetItemText(#LIST_INPUT,0, BI1 + BI2) 816 | HideGadget(#Button_6,1) 817 | 818 | Case #Button_7 819 | 820 | BI1.s = GetGadgetItemText(#LIST_INPUT,0) 821 | BI2.s = GetGadgetText(#Button_7) 822 | 823 | SetGadgetItemText(#LIST_INPUT,0, BI1 + BI2) 824 | HideGadget(#Button_7,1) 825 | 826 | Case #Button_8 827 | 828 | BI1.s = GetGadgetItemText(#LIST_INPUT,0) 829 | BI2.s = GetGadgetText(#Button_8) 830 | 831 | SetGadgetItemText(#LIST_INPUT,0, BI1 + BI2) 832 | HideGadget(#Button_8,1) 833 | 834 | Case #Button_9 835 | 836 | BI1.s = GetGadgetItemText(#LIST_INPUT,0) 837 | BI2.s = GetGadgetText(#Button_9) 838 | 839 | SetGadgetItemText(#LIST_INPUT,0, BI1 + BI2) 840 | HideGadget(#Button_9,1) 841 | 842 | Case #Button_10 843 | 844 | BI1.s = GetGadgetItemText(#LIST_INPUT,0) 845 | BI2.s = GetGadgetText(#Button_10) 846 | 847 | SetGadgetItemText(#LIST_INPUT,0, BI1 + BI2) 848 | HideGadget(#Button_10,1) 849 | 850 | Case #Button_11 851 | 852 | BI1.s = GetGadgetItemText(#LIST_INPUT,0) 853 | BI2.s = GetGadgetText(#Button_11) 854 | 855 | SetGadgetItemText(#LIST_INPUT,0, BI1 + BI2) 856 | HideGadget(#Button_11,1) 857 | 858 | Case #Button_12 859 | 860 | BI1.s = GetGadgetItemText(#LIST_INPUT,0) 861 | BI2.s = GetGadgetText(#Button_12) 862 | 863 | SetGadgetItemText(#LIST_INPUT,0, BI1 + BI2) 864 | HideGadget(#Button_12,1) 865 | 866 | Case #Button_13 867 | 868 | BI1.s = GetGadgetItemText(#LIST_INPUT,0) 869 | BI2.s = GetGadgetText(#Button_13) 870 | 871 | SetGadgetItemText(#LIST_INPUT,0, BI1 + BI2) 872 | HideGadget(#Button_13,1) 873 | 874 | Case #Button_14 875 | 876 | BI1.s = GetGadgetItemText(#LIST_INPUT,0) 877 | BI2.s = GetGadgetText(#Button_14) 878 | 879 | SetGadgetItemText(#LIST_INPUT,0, BI1 + BI2) 880 | HideGadget(#Button_14,1) 881 | 882 | Case #Button_15 883 | 884 | BI1.s = GetGadgetItemText(#LIST_INPUT,0) 885 | BI2.s = GetGadgetText(#Button_15) 886 | 887 | SetGadgetItemText(#LIST_INPUT,0, BI1 + BI2) 888 | HideGadget(#Button_15,1) 889 | 890 | Case #Button_16 891 | 892 | BI1.s = GetGadgetItemText(#LIST_INPUT,0) 893 | BI2.s = GetGadgetText(#Button_16) 894 | 895 | SetGadgetItemText(#LIST_INPUT,0, BI1 + BI2) 896 | HideGadget(#Button_16,1) 897 | 898 | Case #Button_17 899 | 900 | BI1.s = GetGadgetItemText(#LIST_INPUT,0) 901 | BI2.s = GetGadgetText(#Button_17) 902 | 903 | SetGadgetItemText(#LIST_INPUT,0, BI1 + BI2) 904 | HideGadget(#Button_17,1) 905 | 906 | Case #Button_18 907 | 908 | BI1.s = GetGadgetItemText(#LIST_INPUT,0) 909 | BI2.s = GetGadgetText(#Button_18) 910 | 911 | SetGadgetItemText(#LIST_INPUT,0, BI1 + BI2) 912 | HideGadget(#Button_18,1) 913 | 914 | Case #Button_19 915 | 916 | BI1.s = GetGadgetItemText(#LIST_INPUT,0) 917 | BI2.s = GetGadgetText(#Button_19) 918 | 919 | SetGadgetItemText(#LIST_INPUT,0, BI1 + BI2) 920 | HideGadget(#Button_19,1) 921 | 922 | Case #Button_20 923 | 924 | BI1.s = GetGadgetItemText(#LIST_INPUT,0) 925 | BI2.s = GetGadgetText(#Button_20) 926 | 927 | SetGadgetItemText(#LIST_INPUT,0, BI1 + BI2) 928 | HideGadget(#Button_20,1) 929 | 930 | Case #BUTTON_CLEAR 931 | ;button clear will only be accessed after the condition that 932 | ;if all set buttons are toggled, that is the only time button clear 933 | ;is enabled 934 | ;this is to ensure that the player will finish first the 935 | ;levels before he goes to another set 936 | 937 | ;a Message Requester is called upon to show the score of the player 938 | MR.s = Str(CountGadgetItems(#CORRECT_WORDS)-1) 939 | 940 | F1 = #PB_MessageRequester_Ok 941 | MessageRequester("Result"," Your score is" + " "+ MR + ".", F1 ) 942 | 943 | ;a need also to clear the gadget items if there is anyone left, 944 | ;and there will always be 945 | ClearGadgetItems(#LIST_INPUT) 946 | ClearGadgetItems(#CORRECT_WORDS) 947 | 948 | ;we need the initial content again, so we add this 949 | ;this is for the #CORRECT_WORDS 950 | AddGadgetItem(#CORRECT_WORDS,-1,"Correct words:") 951 | 952 | ;enabling all the set buttons gadget again, 953 | ;after it was disabled 954 | DisableGadget(#SetButton_20,0) 955 | DisableGadget(#SetButton_15,0) 956 | DisableGadget(#SetButton_10,0) 957 | DisableGadget(#SetButton_5,0) 958 | 959 | ;after enabling the set buttons, 960 | ;we set the state again to 0 961 | ;so that so it will be untoggled 962 | SetGadgetState(#SetButton_20,0) 963 | SetGadgetState(#SetButton_15,0) 964 | SetGadgetState(#SetButton_10,0) 965 | SetGadgetState(#SetButton_5,0) 966 | 967 | ;setting the buttons to blank 968 | ;this is to ensure that it is already reset 969 | ;before we press again any other set buttons 970 | SetGadgetText(#Button_1,"") 971 | SetGadgetText(#Button_2,"") 972 | SetGadgetText(#Button_3,"") 973 | SetGadgetText(#Button_4,"") 974 | SetGadgetText(#Button_5,"") 975 | 976 | SetGadgetText(#Button_6,"") 977 | SetGadgetText(#Button_7,"") 978 | SetGadgetText(#Button_8,"") 979 | SetGadgetText(#Button_9,"") 980 | SetGadgetText(#Button_10,"") 981 | 982 | SetGadgetText(#Button_11,"") 983 | SetGadgetText(#Button_12,"") 984 | SetGadgetText(#Button_13,"") 985 | SetGadgetText(#Button_14,"") 986 | SetGadgetText(#Button_15,"") 987 | 988 | SetGadgetText(#Button_16,"") 989 | SetGadgetText(#Button_17,"") 990 | SetGadgetText(#Button_18,"") 991 | SetGadgetText(#Button_19,"") 992 | SetGadgetText(#Button_20,"") 993 | 994 | ;we again call Main(), so those 995 | ;whose value is 1 (toggled) 996 | ;will go back to zero 997 | Main() 998 | DisableGadget(#BUTTON_CLEAR,1) 999 | 1000 | ;we're starting over again here 1001 | 1002 | EndSelect 1003 | EndSelect 1004 | 1005 | Until Event = #PB_Event_CloseWindow 1006 | EndIf 1007 | 1008 | ;the data sections includes the three images 1009 | 1010 | DataSection 1011 | Image_1: 1012 | IncludeBinary "resources\front.bmp" 1013 | Image_2: 1014 | IncludeBinary "resources\background.bmp" 1015 | Image_3: 1016 | IncludeBinary "resources\rules.bmp" 1017 | 1018 | EndDataSection 1019 | -------------------------------------------------------------------------------- /src/resources/background.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jfullstackdev/PureBasic-Scrabble/5e4393cc469d2fe75f167edc3e0b2e2eca4b3952/src/resources/background.bmp -------------------------------------------------------------------------------- /src/resources/front.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jfullstackdev/PureBasic-Scrabble/5e4393cc469d2fe75f167edc3e0b2e2eca4b3952/src/resources/front.bmp -------------------------------------------------------------------------------- /src/resources/rules.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jfullstackdev/PureBasic-Scrabble/5e4393cc469d2fe75f167edc3e0b2e2eca4b3952/src/resources/rules.bmp --------------------------------------------------------------------------------