Guidance
指路人
g.yi.org
software / rapidq / Examples / Game / poke match / pokematch.bas

Register 
新用户注册
Search 搜索
首页 
Home Home
Software
Upload

  
'-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
'  Pokémon matching game
'  Rapid-Q source code
'  Steven Edwards
'  May 2000

'-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
'  Compiler directives
     $TYPECHECK ON
     $OPTIMIZE ON
     $INCLUDE "rapidq.inc"

'-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
'  graphical resources used to allow all images
'  to be included within the game .EXE for a
'  one-file distribution
     $RESOURCE BMP_BALL AS "pokeball.bmp"
     $RESOURCE BMP_BULBASAUR AS "001_bulbasaur.bmp"
     $RESOURCE BMP_IVYSAUR AS "002_ivysaur.bmp"
     $RESOURCE BMP_VENUSAUR AS "003_venusaur.bmp"
     $RESOURCE BMP_CHARMANDER AS "004_charmander.bmp"
     $RESOURCE BMP_CHARMELEON AS "005_charmeleon.bmp"
     $RESOURCE BMP_CHARIZARD AS "006_charizard.bmp"
     $RESOURCE BMP_SQUIRTLE AS "007_squirtle.bmp"
     $RESOURCE BMP_WARTORTLE AS "008_wartortle.bmp"
     $RESOURCE BMP_BLASTOISE AS "009_blastoise.bmp"
     $RESOURCE BMP_CATERPIE AS "010_caterpie.bmp"
     $RESOURCE BMP_METAPOD AS "011_metapod.bmp"
     $RESOURCE BMP_BUTTERFREE AS "012_butterfree.bmp"
     $RESOURCE BMP_WEEDLE AS "013_weedle.bmp"
     $RESOURCE BMP_KAKUNA AS "014_kakuna.bmp"
     $RESOURCE BMP_BEEDRILL AS "015_beedrill.bmp"
     $RESOURCE BMP_PIDGEY AS "016_pidgey.bmp"
     $RESOURCE BMP_PIDGEOTTO AS "017_pidgeotto.bmp"
     $RESOURCE BMP_PIDGEOT AS "018_pidgeot.bmp"
     $RESOURCE BMP_RATTATA AS "019_rattata.bmp"
     $RESOURCE BMP_RATICATE AS "020_raticate.bmp"
     $RESOURCE BMP_SPEAROW AS "021_spearow.bmp"
     $RESOURCE BMP_FEAROW AS "022_fearow.bmp"
     $RESOURCE BMP_EKANS AS "023_ekans.bmp"
     $RESOURCE BMP_ARBOK AS "024_arbok.bmp"
     $RESOURCE BMP_PIKACHU AS "025_pikachu.bmp"
     $RESOURCE BMP_RAICHU AS "026_raichu.bmp"
     $RESOURCE BMP_SANDSHREW AS "027_sandshrew.bmp"
     $RESOURCE BMP_SANDSLASH AS "028_sandslash.bmp"
     $RESOURCE BMP_NIDORANF AS "029_nidoran-f.bmp"
     $RESOURCE BMP_NIDORINA AS "030_nidorina.bmp"
     $RESOURCE BMP_NIDOQUEEN AS "031_nidoqueen.bmp"
     $RESOURCE BMP_NIDORANM AS "032_nidoran-m.bmp"
     $RESOURCE BMP_NIDORINO AS "033_nidorino.bmp"
     $RESOURCE BMP_NIDOKING AS "034_nidoking.bmp"
     $RESOURCE BMP_CLEFAIRY AS "035_clefairy.bmp"
     $RESOURCE BMP_CLEFABLE AS "036_clefable.bmp"
     $RESOURCE BMP_VULPIX AS "037_vulpix.bmp"
     $RESOURCE BMP_NINETALES AS "038_ninetales.bmp"
     $RESOURCE BMP_JIGGLYPUFF AS "039_jigglypuff.bmp"
     $RESOURCE BMP_WIGGLYTUFF AS "040_wigglytuff.bmp"
     $RESOURCE BMP_ZUBAT AS "041_zubat.bmp"
     $RESOURCE BMP_GOLBAT AS "042_golbat.bmp"
     $RESOURCE BMP_ODDISH AS "043_oddish.bmp"
     $RESOURCE BMP_GLOOM AS "044_gloom.bmp"
     $RESOURCE BMP_VILEPLUME AS "045_vileplume.bmp"
     $RESOURCE BMP_PARAS AS "046_paras.bmp"
     $RESOURCE BMP_PARASECT AS "047_parasect.bmp"
     $RESOURCE BMP_VENONAT AS "048_venonat.bmp"
     $RESOURCE BMP_VENOMOTH AS "049_venomoth.bmp"
     $RESOURCE BMP_DIGLETT AS "050_diglett.bmp"
     $RESOURCE BMP_DUGTRIO AS "051_dugtrio.bmp"
     $RESOURCE BMP_MEOWTH AS "052_meowth.bmp"
     $RESOURCE BMP_PERSIAN AS "053_persian.bmp"
     $RESOURCE BMP_PSYDUCK AS "054_psyduck.bmp"
     $RESOURCE BMP_GOLDUCK AS "055_golduck.bmp"
     $RESOURCE BMP_MANKEY AS "056_mankey.bmp"
     $RESOURCE BMP_PRIMEAPE AS "057_primeape.bmp"
     $RESOURCE BMP_GROWLITHE AS "058_growlithe.bmp"
     $RESOURCE BMP_ARCANINE AS "059_arcanine.bmp"
     $RESOURCE BMP_POLIWAG AS "060_poliwag.bmp"
     $RESOURCE BMP_POLIWHIRL AS "061_poliwhirl.bmp"
     $RESOURCE BMP_POLIWRATH AS "062_poliwrath.bmp"
     $RESOURCE BMP_ABRA AS "063_abra.bmp"
     $RESOURCE BMP_KADABRA AS "064_kadabra.bmp"
     $RESOURCE BMP_ALAKAZAM AS "065_alakazam.bmp"
     $RESOURCE BMP_MACHOP AS "066_machop.bmp"
     $RESOURCE BMP_MACHOKE AS "067_machoke.bmp"
     $RESOURCE BMP_MACHAMP AS "068_machamp.bmp"
     $RESOURCE BMP_BELLSPROUT AS "069_bellsprout.bmp"
     $RESOURCE BMP_WEEPINBELL AS "070_weepinbell.bmp"
     $RESOURCE BMP_VICTREEBEL AS "071_victreebel.bmp"
     $RESOURCE BMP_TENTACOOL AS "072_tentacool.bmp"
     $RESOURCE BMP_TENTACRUEL AS "073_tentacruel.bmp"
     $RESOURCE BMP_GEODUDE AS "074_geodude.bmp"
     $RESOURCE BMP_GRAVELER AS "075_graveler.bmp"
     $RESOURCE BMP_GOLEM AS "076_golem.bmp"
     $RESOURCE BMP_PONYTA AS "077_ponyta.bmp"
     $RESOURCE BMP_RAPIDASH AS "078_rapidash.bmp"
     $RESOURCE BMP_SLOWPOKE AS "079_slowpoke.bmp"
     $RESOURCE BMP_SLOWBRO AS "080_slowbro.bmp"
     $RESOURCE BMP_MAGNEMITE AS "081_magnemite.bmp"
     $RESOURCE BMP_MAGNETON AS "082_magneton.bmp"
     $RESOURCE BMP_FARFETCHD AS "083_farfetchd.bmp"
     $RESOURCE BMP_DODUO AS "084_doduo.bmp"
     $RESOURCE BMP_DODRIO AS "085_dodrio.bmp"
     $RESOURCE BMP_SEEL AS "086_seel.bmp"
     $RESOURCE BMP_DEWGONG AS "087_dewgong.bmp"
     $RESOURCE BMP_GRIMER AS "088_grimer.bmp"
     $RESOURCE BMP_MUK AS "089_muk.bmp"
     $RESOURCE BMP_SHELLDER AS "090_shellder.bmp"
     $RESOURCE BMP_CLOYSTER AS "091_cloyster.bmp"
     $RESOURCE BMP_GASTLY AS "092_gastly.bmp"
     $RESOURCE BMP_HAUNTER AS "093_haunter.bmp"
     $RESOURCE BMP_GENGAR AS "094_gengar.bmp"
     $RESOURCE BMP_ONIX AS "095_onix.bmp"
     $RESOURCE BMP_DROWZEE AS "096_drowzee.bmp"
     $RESOURCE BMP_HYPNO AS "097_hypno.bmp"
     $RESOURCE BMP_KRABBY AS "098_krabby.bmp"
     $RESOURCE BMP_KINGLER AS "099_kingler.bmp"
     $RESOURCE BMP_VOLTORB AS "100_voltorb.bmp"
     $RESOURCE BMP_ELECTRODE AS "101_electrode.bmp"
     $RESOURCE BMP_EXEGGCUTE AS "102_exeggcute.bmp"
     $RESOURCE BMP_EXEGGUTOR AS "103_exeggutor.bmp"
     $RESOURCE BMP_CUBONE AS "104_cubone.bmp"
     $RESOURCE BMP_MAROWAK AS "105_marowak.bmp"
     $RESOURCE BMP_HITMONLEE AS "106_hitmonlee.bmp"
     $RESOURCE BMP_HITMONCHAN AS "107_hitmonchan.bmp"
     $RESOURCE BMP_LICKITUNG AS "108_lickitung.bmp"
     $RESOURCE BMP_KOFFING AS "109_koffing.bmp"
     $RESOURCE BMP_WEEZING AS "110_weezing.bmp"
     $RESOURCE BMP_RHYHORN AS "111_rhyhorn.bmp"
     $RESOURCE BMP_RHYDON AS "112_rhydon.bmp"
     $RESOURCE BMP_CHANSEY AS "113_chansey.bmp"
     $RESOURCE BMP_TANGELA AS "114_tangela.bmp"
     $RESOURCE BMP_KANGASKHAN AS "115_kangaskhan.bmp"
     $RESOURCE BMP_HORSEA AS "116_horsea.bmp"
     $RESOURCE BMP_SEADRA AS "117_seadra.bmp"
     $RESOURCE BMP_GOLDEEN AS "118_goldeen.bmp"
     $RESOURCE BMP_SEAKING AS "119_seaking.bmp"
     $RESOURCE BMP_STARYU AS "120_staryu.bmp"
     $RESOURCE BMP_STARMIE AS "121_starmie.bmp"
     $RESOURCE BMP_MRMIME AS "122_mrmime.bmp"
     $RESOURCE BMP_SCYTHER AS "123_scyther.bmp"
     $RESOURCE BMP_JYNX AS "124_jynx.bmp"
     $RESOURCE BMP_ELECTRABUZZ AS "125_electrabuzz.bmp"
     $RESOURCE BMP_MAGMAR AS "126_magmar.bmp"
     $RESOURCE BMP_PINSIR AS "127_pinsir.bmp"
     $RESOURCE BMP_TAUROS AS "128_tauros.bmp"
     $RESOURCE BMP_MAGIKARP AS "129_magikarp.bmp"
     $RESOURCE BMP_GYARADOS AS "130_gyarados.bmp"
     $RESOURCE BMP_LAPRAS AS "131_lapras.bmp"
     $RESOURCE BMP_DITTO AS "132_ditto.bmp"
     $RESOURCE BMP_EVEE AS "133_eevee.bmp"
     $RESOURCE BMP_VAPOREON AS "134_vaporeon.bmp"
     $RESOURCE BMP_JOLTEON AS "135_jolteon.bmp"
     $RESOURCE BMP_FLAREON AS "136_flareon.bmp"
     $RESOURCE BMP_PORYGON AS "137_porygon.bmp"
     $RESOURCE BMP_OMANYTE AS "138_omanyte.bmp"
     $RESOURCE BMP_OMASTAR AS "139_omastar.bmp"
     $RESOURCE BMP_KABUTO AS "140_kabuto.bmp"
     $RESOURCE BMP_KABUTOPS AS "141_kabutops.bmp"
     $RESOURCE BMP_AERODACTYL AS "142_aerodactyl.bmp"
     $RESOURCE BMP_SNORLAX AS "143_snorlax.bmp"
     $RESOURCE BMP_ARTICUNO AS "144_articuno.bmp"
     $RESOURCE BMP_ZAPDOS AS "145_zapdos.bmp"
     $RESOURCE BMP_MOLTRES AS "146_moltres.bmp"
     $RESOURCE BMP_DRATINI AS "147_dratini.bmp"
     $RESOURCE BMP_DRAGONAIR AS "148_dragonair.bmp"
     $RESOURCE BMP_DRAGONITE AS "149_dragonite.bmp"
     $RESOURCE BMP_MEWTWO AS "150_mewtwo.bmp"
     $RESOURCE BMP_MEW AS "151_mew.bmp"
     $RESOURCE BMP_SPACER AS "spacer.bmp"

'-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
'  Subroutine / Function declaration
     DECLARE SUB Init
     DECLARE SUB ImageClicked(sender AS QBUTTON)
     DECLARE SUB StartGame
     DECLARE SUB LoadNewSet(startindex AS SHORT)
     DECLARE SUB AboutScreen

'-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
'  Program constants
'  define transparent color for bitmaps
'  Blue = 255, Green = 0, Red = 255
     CONST clTransparent = &HFF00FF
'  define total count for pokemon images used in game
     CONST PokeCount = 151

'-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
'  Program global variables
     DIM PokeList(1 TO Pokecount + 1) AS SHORT
     DIM PokeName(1 TO Pokecount + 1) AS STRING
     DIM Matches(1 TO 16) AS SHORT
     DIM PokeBall(1 TO 16) AS QBUTTON
     DIM ClickHolder AS SHORT
     DIM MatchCounter AS SHORT
     DIM PokeIndex AS SHORT

'  create an image list of resources for easier
'  image reference
     CREATE GameImages AS QIMAGELIST
      width = 68
      height = 68
      addBMPhandle BMP_BALL, clTransparent
      addBMPhandle BMP_BULBASAUR, clTransparent
      addBMPhandle BMP_IVYSAUR, clTransparent
      addBMPhandle BMP_VENUSAUR, clTransparent
      addBMPhandle BMP_CHARMANDER, clTransparent
      addBMPhandle BMP_CHARMELEON, clTransparent
      addBMPhandle BMP_CHARIZARD, clTransparent
      addBMPhandle BMP_SQUIRTLE, clTransparent
      addBMPhandle BMP_WARTORTLE, clTransparent
      addBMPhandle BMP_BLASTOISE, clTransparent
      addBMPhandle BMP_CATERPIE, clTransparent
      addBMPhandle BMP_METAPOD, clTransparent
      addBMPhandle BMP_BUTTERFREE, clTransparent
      addBMPhandle BMP_WEEDLE, clTransparent
      addBMPhandle BMP_KAKUNA, clTransparent
      addBMPhandle BMP_BEEDRILL, clTransparent
      addBMPhandle BMP_PIDGEY, clTransparent
      addBMPhandle BMP_PIDGEOTTO, clTransparent
      addBMPhandle BMP_PIDGEOT, clTransparent
      addBMPhandle BMP_RATTATA, clTransparent
      addBMPhandle BMP_RATICATE, clTransparent
      addBMPhandle BMP_SPEAROW, clTransparent
      addBMPhandle BMP_FEAROW, clTransparent
      addBMPhandle BMP_EKANS, clTransparent
      addBMPhandle BMP_ARBOK, clTransparent
      addBMPhandle BMP_PIKACHU, clTransparent
      addBMPhandle BMP_RAICHU, clTransparent
      addBMPhandle BMP_SANDSHREW, clTransparent
      addBMPhandle BMP_SANDSLASH, clTransparent
      addBMPhandle BMP_NIDORANF, clTransparent
      addBMPhandle BMP_NIDORINA, clTransparent
      addBMPhandle BMP_NIDOQUEEN, clTransparent
      addBMPhandle BMP_NIDORANM, clTransparent
      addBMPhandle BMP_NIDORINO, clTransparent
      addBMPhandle BMP_NIDOKING, clTransparent
      addBMPhandle BMP_CLEFAIRY, clTransparent
      addBMPhandle BMP_CLEFABLE, clTransparent
      addBMPhandle BMP_VULPIX, clTransparent
      addBMPhandle BMP_NINETALES, clTransparent
      addBMPhandle BMP_JIGGLYPUFF, clTransparent
      addBMPhandle BMP_WIGGLYTUFF, clTransparent
      addBMPhandle BMP_ZUBAT, clTransparent
      addBMPhandle BMP_GOLBAT, clTransparent
      addBMPhandle BMP_ODDISH, clTransparent
      addBMPhandle BMP_GLOOM, clTransparent
      addBMPhandle BMP_VILEPLUME, clTransparent
      addBMPhandle BMP_PARAS, clTransparent
      addBMPhandle BMP_PARASECT, clTransparent
      addBMPhandle BMP_VENONAT, clTransparent
      addBMPhandle BMP_VENOMOTH, clTransparent
      addBMPhandle BMP_DIGLETT, clTransparent
      addBMPhandle BMP_DUGTRIO, clTransparent
      addBMPhandle BMP_MEOWTH, clTransparent
      addBMPhandle BMP_PERSIAN, clTransparent
      addBMPhandle BMP_PSYDUCK, clTransparent
      addBMPhandle BMP_GOLDUCK, clTransparent
      addBMPhandle BMP_MANKEY, clTransparent
      addBMPhandle BMP_PRIMEAPE, clTransparent
      addBMPhandle BMP_GROWLITHE, clTransparent
      addBMPhandle BMP_ARCANINE, clTransparent
      addBMPhandle BMP_POLIWAG, clTransparent
      addBMPhandle BMP_POLIWHIRL, clTransparent
      addBMPhandle BMP_POLIWRATH, clTransparent
      addBMPhandle BMP_ABRA, clTransparent
      addBMPhandle BMP_KADABRA, clTransparent
      addBMPhandle BMP_ALAKAZAM, clTransparent
      addBMPhandle BMP_MACHOP, clTransparent
      addBMPhandle BMP_MACHOKE, clTransparent
      addBMPhandle BMP_MACHAMP, clTransparent
      addBMPhandle BMP_BELLSPROUT, clTransparent
      addBMPhandle BMP_WEEPINBELL, clTransparent
      addBMPhandle BMP_VICTREEBEL, clTransparent
      addBMPhandle BMP_TENTACOOL, clTransparent
      addBMPhandle BMP_TENTACRUEL, clTransparent
      addBMPhandle BMP_GEODUDE, clTransparent
      addBMPhandle BMP_GRAVELER, clTransparent
      addBMPhandle BMP_GOLEM, clTransparent
      addBMPhandle BMP_PONYTA, clTransparent
      addBMPhandle BMP_RAPIDASH, clTransparent
      addBMPhandle BMP_SLOWPOKE, clTransparent
      addBMPhandle BMP_SLOWBRO, clTransparent
      addBMPhandle BMP_MAGNEMITE, clTransparent
      addBMPhandle BMP_MAGNETON, clTransparent
      addBMPhandle BMP_FARFETCHD, clTransparent
      addBMPhandle BMP_DODUO, clTransparent
      addBMPhandle BMP_DODRIO, clTransparent
      addBMPhandle BMP_SEEL, clTransparent
      addBMPhandle BMP_DEWGONG, clTransparent
      addBMPhandle BMP_GRIMER, clTransparent
      addBMPhandle BMP_MUK, clTransparent
      addBMPhandle BMP_SHELLDER, clTransparent
      addBMPhandle BMP_CLOYSTER, clTransparent
      addBMPhandle BMP_GASTLY, clTransparent
      addBMPhandle BMP_HAUNTER, clTransparent
      addBMPhandle BMP_GENGAR, clTransparent
      addBMPhandle BMP_ONIX, clTransparent
      addBMPhandle BMP_DROWZEE, clTransparent
      addBMPhandle BMP_HYPNO, clTransparent
      addBMPhandle BMP_KRABBY, clTransparent
      addBMPhandle BMP_KINGLER, clTransparent
      addBMPhandle BMP_VOLTORB, clTransparent
      addBMPhandle BMP_ELECTRODE, clTransparent
      addBMPhandle BMP_EXEGGCUTE, clTransparent
      addBMPhandle BMP_EXEGGUTOR, clTransparent
      addBMPhandle BMP_CUBONE, clTransparent
      addBMPhandle BMP_MAROWAK, clTransparent
      addBMPhandle BMP_HITMONLEE, clTransparent
      addBMPhandle BMP_HITMONCHAN, clTransparent
      addBMPhandle BMP_LICKITUNG, clTransparent
      addBMPhandle BMP_KOFFING, clTransparent
      addBMPhandle BMP_WEEZING, clTransparent
      addBMPhandle BMP_RHYHORN, clTransparent
      addBMPhandle BMP_RHYDON, clTransparent
      addBMPhandle BMP_CHANSEY, clTransparent
      addBMPhandle BMP_TANGELA, clTransparent
      addBMPhandle BMP_KANGASKHAN, clTransparent
      addBMPhandle BMP_HORSEA, clTransparent
      addBMPhandle BMP_SEADRA, clTransparent
      addBMPhandle BMP_GOLDEEN, clTransparent
      addBMPhandle BMP_SEAKING, clTransparent
      addBMPhandle BMP_STARYU, clTransparent
      addBMPhandle BMP_STARMIE, clTransparent
      addBMPhandle BMP_MRMIME, clTransparent
      addBMPhandle BMP_SCYTHER, clTransparent
      addBMPhandle BMP_JYNX, clTransparent
      addBMPhandle BMP_ELECTRABUZZ, clTransparent
      addBMPhandle BMP_MAGMAR, clTransparent
      addBMPhandle BMP_PINSIR, clTransparent
      addBMPhandle BMP_TAUROS, clTransparent
      addBMPhandle BMP_MAGIKARP, clTransparent
      addBMPhandle BMP_GYARADOS, clTransparent
      addBMPhandle BMP_LAPRAS, clTransparent
      addBMPhandle BMP_DITTO, clTransparent
      addBMPhandle BMP_EVEE, clTransparent
      addBMPhandle BMP_VAPOREON, clTransparent
      addBMPhandle BMP_JOLTEON, clTransparent
      addBMPhandle BMP_FLAREON, clTransparent
      addBMPhandle BMP_PORYGON, clTransparent
      addBMPhandle BMP_OMANYTE, clTransparent
      addBMPhandle BMP_OMASTAR, clTransparent
      addBMPhandle BMP_KABUTO, clTransparent
      addBMPhandle BMP_KABUTOPS, clTransparent
      addBMPhandle BMP_AERODACTYL, clTransparent
      addBMPhandle BMP_SNORLAX, clTransparent
      addBMPhandle BMP_ARTICUNO, clTransparent
      addBMPhandle BMP_ZAPDOS, clTransparent
      addBMPhandle BMP_MOLTRES, clTransparent
      addBMPhandle BMP_DRATINI, clTransparent
      addBMPhandle BMP_DRAGONAIR, clTransparent
      addBMPhandle BMP_DRAGONITE, clTransparent
      addBMPhandle BMP_MEWTWO, clTransparent
      addBMPhandle BMP_MEW, clTransparent
      addBMPhandle BMP_SPACER, clTransparent
     END CREATE

'  custom font definition for game
     CREATE GameFont AS QFONT
      name = "Comic Sans MS"
      addstyles(fsBold)
      size = 12
     END CREATE

'  main form for the application
     CREATE form AS QFORM
      CAPTION = "Pokémon Matching Game"
  '  set client width/height to ensure enough space
  '  for the 4x4 grid of 100x100 buttons
      clientwidth = 400 + 200
      clientheight = 400 + 25
  '  disable scroll bars because of the narrow area
  '  between the objects and the edge of the form
      autoscroll = FALSE
  '  a very simple menu
      CREATE menu AS QMAINMENU
    '  only one item - About
       CREATE itmAbout AS QMENUITEM
        CAPTION = "About"
        onclick = AboutScreen
       END CREATE
      END CREATE
  '  label for the "found" description
      CREATE lblFound AS QLABEL
       top = 5
       left = 450
       font = GameFont
       CAPTION = "Pokémon Found:"
      END CREATE
  '  label for actual "found" count
      CREATE lblFoundCount AS QLABEL
       top = 30
       left = 490
       font = GameFont
       CAPTION = "000"
      END CREATE
  '  list box to show the number and name of all
  '  "captured" pokemon
      CREATE lstPokemon AS QLISTBOX
       top = 60
       left = 415
       width = 170
       height = 330
      END CREATE
      center
     END CREATE

'-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
'  Program Main routine
     Init
     LoadNewSet(PokeIndex)
     form.SHOWMODAL

'-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
'  Program procedures
     SUB Init
      DIM Counter AS SHORT
      DIM TopLocation AS SHORT
      DIM LeftLocation AS SHORT
      DIM Switcher AS SHORT
  '  define the 16 pokeballs to display in a
  '  4x4 grid on the screen
      TopLocation = 0
      LeftLocation = 0
  '  cycle through the 16 objects
      FOR Counter = 1 TO 16
    '  set all properties
       PokeBall(Counter).PARENT = form
       PokeBall(Counter).height = 100
       PokeBall(Counter).width = 100
       PokeBall(Counter).BMP = GameImages.GetBMP(0)
       PokeBall(Counter).onclick = ImageClicked
       PokeBall(Counter).enabled = true
       PokeBall(Counter).cursor = crHandPoint
       PokeBall(Counter).top = TopLocation
       PokeBall(Counter).left = LeftLocation
       LeftLocation = LeftLocation + 100
       IF Counter MOD 4 = 0 THEN
      '  after each 4 defines, shift down to the
      '  start of the next "row"
        TopLocation = TopLocation + 100
        LeftLocation = 0
       END IF
      NEXT Counter
  '  load numbers into pokemon array and load
  '  names into pokemon name array from DATA
      RESTORE beginDATA
      FOR Counter = 1 TO PokeCount
       DOEVENTS
       PokeList(Counter) = Counter
       READ PokeName(Counter)
      NEXT Counter
  '  shuffle pokemon number list to allow variation
  '  in the order that the pokemon are grouped
      RANDOMIZE
      FOR Counter = 1 TO PokeCount
       DOEVENTS
    '  pick a random location within the array
       Switcher = RND(PokeCount) + 1
    '  swap the random location with the current
    '  location from the loop counter
       SWAP PokeList(Counter), PokeList(Switcher)
      NEXT Counter
  '  insert a spacer image to equal 152 for even
  '  division by 8.  8 * 2 = 16 images on screen
  '  at one time
      PokeList(PokeCount + 1) = PokeCount + 1
  '  load listbox with all Pokemon numbers
      FOR Counter = 1 TO PokeCount
       lstPokemon.additems RIGHT$("000" + STR$(counter), 3) + " : "
       DOEVENTS
      NEXT Counter
  '  add a blank string for the final "spacer"
      lstPokemon.additems " "
  '  reset variables
      ClickHolder = 0
      Matchcounter = 0
      PokeIndex = 0
     END SUB

     SUB LoadNewSet(startindex AS SHORT)
      DIM Counter AS SHORT
      DIM Switcher AS SHORT
  '  place the first 8 pokemon from the main array
  '  into the matches array at locations 1 - 8
      FOR Counter = 1 TO 8
       Matches(Counter) = PokeList(startindex + Counter)
    '  repeat the same pokemon again in locations
    '  9 - 16
       Matches(Counter + 8) = PokeList(startindex + Counter)
      NEXT Counter
  '  shuffle the array by looping through each
  '  element and switching the value with another
  '  randomly chosen element
      RANDOMIZE
      FOR Counter = 1 TO 16
       Switcher = RND(16) + 1
       SWAP Matches(Counter), Matches(Switcher)
    '  re-enable pokeball buttons for new round
       PokeBall(Counter).enabled = true
      NEXT Counter
     END SUB

     SUB ImageClicked(sender AS QBUTTON)
      DIM sendernumber AS SHORT
      DIM Counter AS SHORT
      DIM Time AS DOUBLE
      DIM holdName AS STRING
  '  determine which button was clicked from the
  '  top and left coordinates
      sendernumber = 4 * (sender.top / 100)
      sendernumber = sendernumber + (sender.left / 100) + 1
  '  show the image referenced by the button
      sender.bmp = GameImages.GetBMP(Matches(sendernumber))
  '  force a repaint to show image
      form.repaint
  '  check if initial click
      IF ClickHolder = 0 THEN
    '  load click holder with button value
       ClickHolder = sendernumber
      ELSE
       IF sendernumber <> ClickHolder THEN
      '  allow images to remain a moment
        Time = TIMER
        WHILE (TIMER - Time < 1)
        WEND
      '  check for a match
        IF Matches(ClickHolder) = Matches(sendernumber) THEN
        '  we have a match
        '  replace with pokeball image
         sender.bmp = GameImages.getBMP(0)
         PokeBall(ClickHolder).bmp = GameImages.getBMP(0)
        '  lock images
         sender.enabled = false
         PokeBall(ClickHolder).enabled = false
        '  update match counter
         MatchCounter = MatchCounter + 1
         lblFoundCount.CAPTION = RIGHT$("000" + STR$(PokeIndex + MatchCounter), 3)
        '  add name to pokemon listbox
         lstPokemon.Item(Matches(sendernumber)-1) = lstPokemon.Item(Matches(sendernumber)-1) + PokeName(Matches(sendernumber))
         lstPokemon.topindex = Matches(sendernumber)-1
        ELSE
        '  no match / reset images
         sender.bmp = GameImages.GetBMP(0)
         PokeBall(ClickHolder).bmp = GameImages.GetBMP(0)
        END IF
        ClickHolder = 0
       END IF
      END IF
      IF MatchCounter = 8 THEN
    '  reset for next group of pokemon
       PokeIndex = PokeIndex + 8
       IF PokeIndex >= PokeCount THEN
        SHOWMESSAGE "All Matches Found!"
       ELSE
        MatchCounter = 0
        LoadNewSet(PokeIndex)
       END IF
      END IF
     END SUB

     SUB AboutScreen
      DIM messageline AS STRING
      DIM linebreak AS STRING
      linebreak = CHR$(13)
      messageline = "Pokémon Matching Game"
      messageline = messageline + linebreak
      messageline = messageline + "by Steven Edwards"
      messageline = messageline + linebreak
      messageline = messageline + "http://go.to/thebasics"
      messageline = messageline + linebreak
      messageline = messageline + linebreak
      messageline = messageline + "Can you catch all 151 Pokémon by"
      messageline = messageline + linebreak
      messageline = messageline + "finding the matching pokéballs?"
      SHOWMESSAGE messageline
     END SUB


'-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
'  Stored DATA information
beginDATA:
     DATA bulbasaur, ivysaur, venusaur
     DATA charmander, charmeleon, charizard
     DATA squirtle, wartortle, blastoise
     DATA caterpie, metapod, butterfree
     DATA weedle, kakuna, beedrill
     DATA pidgey, pidgeotto, pidgeot
     DATA rattata, raticate
     DATA spearow, fearow
     DATA ekans, arbok
     DATA pikachu, raichu
     DATA sandshrew, sandslash
     DATA nidoran, nidorina, nidoqueen
     DATA nidoran, nidorino, nidoking
     DATA clefairy, clefable
     DATA vulpix, ninetales
     DATA jigglypuff, wigglytuff
     DATA zubat, golbat
     DATA oddish, gloom, vileplume
     DATA paras, parasect
     DATA venonat, venomoth
     DATA diglett, dugtrio
     DATA meowth, persian
     DATA psyduck, golduck
     DATA mankey, primeape
     DATA growlithe, arcanine
     DATA poliwag, poliwhirl, poliwrath
     DATA abra, kadabra, alakazam
     DATA machop, machoke, machamp
     DATA bellsprout, weepinbell, victreebel
     DATA tentacool, tentacruel
     DATA geodude, graveler, golem
     DATA ponyta, rapidash
     DATA slowpoke, slowbro
     DATA magnemite, magneton
     DATA "farfetch'd"
     DATA doduo, dodrio
     DATA seel, dewgong
     DATA grimer, muk
     DATA shellder, cloyster
     DATA gastly, haunter, gengar
     DATA onix
     DATA drowzee, hypno
     DATA krabby, kingler
     DATA voltorb, electrode
     DATA exeggcute, exeggutor
     DATA cubone, marowak
     DATA hitmonlee, hitmonchan
     DATA lickitung
     DATA koffing, weezing
     DATA rhyhorn, rhydon
     DATA chansey
     DATA tangela
     DATA kangaskhan
     DATA horsea, seadra
     DATA goldeen, seaking
     DATA staryu, starmie
     DATA "mr.mime"
     DATA scyther
     DATA jynx
     DATA electrabuzz
     DATA magmar
     DATA pinsir
     DATA tauros
     DATA magikarp, gyarados
     DATA lapras
     DATA ditto
     DATA eevee, vaporeon, jolteon, flareon
     DATA porygon
     DATA omanyte, omastar
     DATA kabuto, kabutops
     DATA aerodactyl
     DATA snorlax
     DATA articuno
     DATA zapdos
     DATA moltres
     DATA dratini, dragonair, dragonite
     DATA mewtwo
     DATA mew
     DATA "the future"
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Fri 2019-4-26  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2000-06-20 12:22:24