Author Topic: A Game for those with children (or who are children themselves!)  (Read 4916 times)

0 Members and 1 Guest are viewing this topic.

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
when in doubt hit ESC.
Otherwise enjoy.
[fyi its loud and the volume controls have a bug still. :( ]
There is a short list of things to be finished at the begining of the file, but hey what do you expect with about 6 Tours total development?

Code: QB64: [Select]
  1. 'Paw Patrol matching\memory game
  2. '8/27/2021
  3. 'UniKorn ProDucKions
  4.  
  5. 'inital test release V1b(eta)
  6. '8/30/2021
  7. 'To Be Finished;
  8. 'Game Mode 2-Pup to Badge matching
  9. 'High Score addition;
  10. 'À-Name Entry and Hi-lite
  11. 'Find out why sound levels dont change
  12. 'Add and exit button to Options Screen and High Scores(just hit ESC for now)
  13.  
  14. TYPE Card_Data
  15.  Id AS _BYTE
  16.  X1 AS INTEGER
  17.  Y1 AS INTEGER
  18.  X2 AS INTEGER
  19.  Y2 AS INTEGER
  20.  
  21. TYPE Game_Data
  22.  GameType AS _BYTE 'Mode 1(P+P) or Mode 2(P+B)
  23.  BGMVol AS _BYTE 'Music volume
  24.  SFXVol AS _BYTE 'Sound volume
  25.  Status AS _BYTE 'MainMenu or GameMode
  26.  time AS INTEGER 'number of seconds in game
  27.  Match AS INTEGER 'number of matches made in game
  28.  Level AS SINGLE '"difficulty" of game 1-12cards, 2-24cards,3-48cards,4-70cards
  29.  Quit AS SINGLE 'player quits current game :(
  30.  
  31. TYPE Game_Board
  32.  Id AS _BYTE 'what card is here
  33.  Flipped AS _BYTE 'is card flipped?(displayed)
  34.  Matched AS _BYTE 'is the card still here?
  35.  
  36. '------------------------Constants-------------------------
  37. CONST TRUE = -1, FALSE = NOT TRUE
  38. CONST MainMenu = 1, Options = 2, Help = 3, GameMode = 4, HighScores = 5
  39. CONST Mode_1 = 1, Mode_2 = 2
  40. CONST Level_1 = 1, Level_2 = 1.5, Level_3 = 2, Level_4 = 2.5
  41. CONST LoadedMusic = 3
  42. CONST LoadedSounds = 0
  43. '----------------------------------------------------------
  44.  
  45. '----------------------Tile Data---------------------------
  46. Card_data: '10 tiles
  47. DATA 32,165,190,323: 'sky
  48. DATA 207,341,365,499: 'chase
  49. DATA 31,517,189,675: 'everest
  50. DATA 383,343,541,501: 'marshal
  51. DATA 30,868,188,1026: 'rubble
  52. DATA 32,340,190,498: 'marshal badge
  53. DATA 30,692,188,850: 'chase badge
  54. DATA 206,693,364,851: 'rubble badge
  55. DATA 206,869,364,1027: 'sky badge
  56. DATA 208,166,366,324: 'everest badge
  57. 'perhaps more tiles would be nice?
  58. Board_Size:
  59. DATA 2,3,5,6
  60. DATA 3,5,7,9
  61. '----------------------------------------------------------
  62.  
  63. '---------------------Array and Globals--------------------
  64. DIM SHARED Layer(13) AS LONG, BGM(5) AS LONG, G AS Game_Data, T&
  65. DIM SHARED FFX(6) AS LONG, Cards(16) AS Card_Data, SFX(5) AS LONG
  66. DIM SHARED Board(96) AS Game_Board, BoardX(4) AS _BYTE, BoardY(4) AS _BYTE
  67. '----------------------------------------------------------
  68.  
  69. '------------------------Timers----------------------------
  70. ON TIMER(T&, .5) BackGroundMusic 'control the background music
  71. ON TIMER(M&, 1) CountTime 'keeps track of time during gameplay
  72. '----------------------------------------------------------
  73. G.Status = MainMenu
  74. G.BGMVol = 75
  75. G.SFXVol = 75
  76. SetVolumes 'adjust volume levels
  77.  
  78. MFI_Loader "PawsV1b.mfi"
  79.  
  80. _PUTIMAGE , Splash&, _DISPLAY 'erase `Loading...` as that is done
  81. _DELAY 5 'leave the pups up for a few seconds.
  82. Fade_Out _DISPLAY
  83.  
  84. '--------------------------GFX setup stuff------------------------
  85. _SETALPHA 48, , Layer(4)
  86. _CLEARCOLOR _RGB32(0), Layer(3)
  87. _CLEARCOLOR _RGB32(0), Layer(4)
  88. _CLEARCOLOR _RGB32(0), Layer(11)
  89. _CLEARCOLOR _RGB32(0), Layer(12)
  90. _DEST Layer(8)
  91. COLOR _RGB32(100, 235, 250) 'menu options color
  92. _DEST Layer(9)
  93. COLOR _RGB32(100, 235, 250) 'High Score color
  94. _DEST Layer(0)
  95. _FONT FFX(0), Layer(8)
  96. _FONT FFX(0), Layer(1)
  97. _FONT FFX(2), Layer(9)
  98. '-----------------------------------------------------------------
  99. '-----------------------------Load Data---------------------------
  100. FOR i%% = 1 TO 10
  101.  READ Cards(i%%).X1, Cards(i%%).Y1, Cards(i%%).X2, Cards(i%%).Y2
  102. NEXT i%%
  103. FOR i%% = 1 TO 4
  104.  READ BoardY(i%%)
  105. NEXT i%%
  106. FOR i%% = 1 TO 4
  107.  READ BoardX(i%%)
  108. NEXT i%%
  109. '-----------------------------------------------------------------
  110.  
  111. Build_Screens MainMenu
  112. _SOURCE Layer(7) 'click check layer
  113. _DEST Layer(1)
  114. COLOR _RGB32(255, 255, 0) 'mouse over menu options highlight color
  115. _DEST Layer(0)
  116. Create_ClickMap MainMenu
  117. _DEST Layer(1)
  118. Fade_In Layer(8)
  119. G.Level = Level_1
  120. TIMER(M&) ON
  121.  
  122.  Nul = _MOUSEINPUT
  123.  _PUTIMAGE , Layer(8), Layer(1) 'prep the menu layer to screen(erases old screen cycle)
  124.  
  125.  IF _MOUSEBUTTON(1) THEN 'lets see where the user clicked
  126.   Opt%% = Mouse_Over
  127.   ButtonDown%% = TRUE
  128.   Clicked%% = TRUE
  129.   ButtonDown%% = FALSE
  130.  
  131.  'check over game options with click layer
  132.  SELECT CASE Mouse_Over
  133.   CASE 1 ' Game mode 1, Portrat+Portrat
  134.    _PRINTSTRING (400 - 64, 200), "Game 1", Layer(1)
  135.   CASE 2 ' Game Mode 2, Portrat+Badge
  136.    _PRINTSTRING (400 - 64, 250), "Game 2", Layer(1)
  137.   CASE 3 ' Help
  138.    _PRINTSTRING (400 - 56, 300), " Help", Layer(1)
  139.   CASE 4 ' High Scores(most matches in a row? Board completion time?)
  140.    _PRINTSTRING (400 - 100, 350), "High Scores", Layer(1)
  141.   CASE 5 ' Options (Sound levels, High Score Reset)
  142.    _PRINTSTRING (400 - 64, 400), "Options", Layer(1)
  143.   CASE 6 ' Quit the game(Tis a sad day indeed!)
  144.    _PRINTSTRING (400 - 48, 450), " Quit", Layer(1)
  145.  _PUTIMAGE , Layer(1), Layer(0)
  146.  _LIMIT 60
  147.  IF Clicked%% AND ButtonDown%% = FALSE THEN 'user clicked something lets see what.
  148.   SELECT CASE Opt%%
  149.    CASE 1
  150.     G.Level = Level_1
  151.     G.Status = GameMode
  152.     DO
  153.      Game_Mode1
  154.     LOOP UNTIL G.Level = 3 OR G.Quit
  155.     IF G.Level = 3 THEN 'victory screen
  156.      Run_Victory
  157.     END IF
  158.     Create_ClickMap MainMenu
  159.     G.Status = MainMenu
  160.    CASE 2
  161.    CASE 3 'Help screen
  162.     Fade_Out Layer(0)
  163.     Build_Screens Help
  164.     Build_Screens MainMenu
  165.     Fade_In Layer(8)
  166.    CASE 4 'High Scores list
  167.     Fade_Out Layer(0)
  168.     Build_Screens HighScores
  169.     Build_Screens MainMenu
  170.     Fade_In Layer(8)
  171.    CASE 5 'Options Menu
  172.     Fade_Out Layer(0)
  173.     Build_Screens Options 'Build Options
  174.     Create_ClickMap Options
  175.     Fade_In Layer(8)
  176.     Options_Menu
  177.     Fade_Out Layer(0)
  178.     Build_Screens MainMenu 'rebuild MainMenu
  179.     Create_ClickMap MainMenu
  180.     Fade_In Layer(8)
  181.  
  182.    CASE 6 'ok, :(  lets quit
  183.     QuitFlag%% = TRUE
  184.    CASE ELSE 'null click, invalid option
  185.     Opt%% = 0
  186.   Clicked%% = FALSE
  187.  DO: Nul = _MOUSEINPUT: LOOP WHILE _MOUSEINPUT 'clear the mouse buffer
  188.  IF INKEY$ = CHR$(27) THEN QuitFlag%% = TRUE
  189.  
  190.  ' BackGroundMusic 'deal with the menus background music || Handled with Timer for now
  191.  
  192.  'debugging information area
  193.  ' LINE (600, 500)-STEP(160, 99), _RGB32(0), BF
  194.  ' _PRINTSTRING (600, 500), STR$(LastPlay!), Layer(1)
  195.  ' _PRINTSTRING (600, 524), STR$(Clicked%%), Layer(1)
  196.  ' _PRINTSTRING (600, 548), STR$(ButtonDown%%), Layer(1)
  197.  ' _PRINTSTRING (600, 572), STR$(Opt%%), Layer(1)
  198.  
  199. LOOP UNTIL QuitFlag%%
  200. 'Fade_Out _DISPLAY
  201. 'SND_FadeOut
  202.  
  203. 'shut down audio
  204. IF _SNDPLAYING(SFX(1)) THEN _SNDSTOP (SFX(1))
  205. IF _SNDPLAYING(SFX(2)) THEN _SNDSTOP (SFX(2))
  206. IF _SNDPLAYING(SFX(3)) THEN _SNDSTOP (SFX(3))
  207.  
  208. 'C%% = (800 - (740 - 14)) \ 2
  209. '_PUTIMAGE (C%%, 0), Layer(2), _DISPLAY, (14, 11)-(740, 149) 'Game Menu Title
  210.  
  211. SUB Create_ClickMap (Opt%%)
  212.  _DEST Layer(7)
  213.  CLS
  214.  SELECT CASE Opt%%
  215.   CASE MainMenu
  216.    LINE (328, 196)-STEP(127, 31), _RGB32(255, 255, 1), BF
  217.    LINE (328, 246)-STEP(127, 31), _RGB32(255, 255, 2), BF
  218.    LINE (336, 300)-STEP(111, 31), _RGB32(255, 255, 3), BF
  219.    LINE (292, 350)-STEP(199, 31), _RGB32(255, 255, 4), BF
  220.    LINE (328, 400)-STEP(127, 31), _RGB32(255, 255, 5), BF
  221.    LINE (350, 446)-STEP(95, 31), _RGB32(255, 255, 6), BF
  222.   CASE Options
  223.    LINE (255, 240)-STEP(16 * 16, 32), _RGB32(255, 255, 1), BF
  224.    LINE (255, 290)-STEP(16 * 16, 32), _RGB32(255, 255, 2), BF
  225.    LINE (252, 350)-STEP(287, 31), _RGB32(255, 255, 3), BF
  226.    LINE (348, 446)-STEP(87, 31), _RGB32(255, 255, 4), BF
  227.   CASE Help
  228.   CASE GameMode
  229.    'the actual game mode is unimportant, just the number of cards to layout.
  230.    Offset% = 175 / G.Level
  231.    Scaled% = 157 / G.Level
  232.    FOR y%% = 0 TO BoardY(G.Level * 2 - 1)
  233.     FOR x%% = 0 TO BoardX(G.Level * 2 - 1)
  234.      C%% = C%% + 1
  235.      LINE (50 + x%% * Offset%, 75 + y%% * Offset%)-STEP(Scaled%, Scaled%), _RGB32(64, 64, C%%), BF
  236.    NEXT x%%, y%%
  237.  _DEST Layer(7)
  238.  
  239. FUNCTION Mouse_Over~%% ()
  240.  Result~%% = 0 'just in case?
  241.  Result~%% = _BLUE32(POINT(_MOUSEX, _MOUSEY)) 'get our blue value for option under mouse
  242.  Mouse_Over = Result~%%
  243.  
  244. SUB Build_Screens (Opt%%)
  245.  ClearLayer Layer(8)
  246.  SELECT CASE Opt%%
  247.   CASE MainMenu
  248.    Cx% = (800 - 464) \ 2 'Center the image on screen
  249.    Cy% = (600 - 396) \ 2
  250.    _PUTIMAGE (Cx%, Cy%), Layer(4), Layer(8) 'Title Screen Logo background
  251.    _PUTIMAGE (0, 64), Layer(3), Layer(8)
  252.    _PRINTSTRING (400 - 64, 200), "Game 1", Layer(8)
  253.    _PRINTSTRING (400 - 64, 250), "Game 2", Layer(8)
  254.    _PRINTSTRING (400 - 56, 300), " Help", Layer(8)
  255.    _PRINTSTRING (400 - 100, 350), "High Scores", Layer(8)
  256.    _PRINTSTRING (400 - 64, 400), "Options", Layer(8)
  257.    _PRINTSTRING (400 - 48, 450), " Quit", Layer(8)
  258.   CASE Options
  259.    _SETALPHA 96, , Layer(3) 'fade the image
  260.    _CLEARCOLOR _RGB32(0), Layer(3) 'restore clear color
  261.    Cx% = (800 - 464) \ 2 'Center the image on screen
  262.    Cy% = (600 - 396) \ 2
  263.    _PUTIMAGE (Cx%, Cy%), Layer(4), Layer(8) 'Title Screen Logo background
  264.    _PUTIMAGE (0, 64), Layer(3), Layer(8)
  265.    _SETALPHA 255, , Layer(3) 'restore opacity
  266.    _CLEARCOLOR _RGB32(0), Layer(3) 'restore clear color
  267.    _PRINTSTRING (400 - 120, 200), "Volume Level", Layer(8)
  268.    _PRINTSTRING (100, 250), "Music ", Layer(8)
  269.    _PRINTSTRING (100, 300), "Sounds", Layer(8)
  270.    _PRINTSTRING (400 - 144, 350), "Reset High Scores", Layer(8)
  271.    _PRINTSTRING (400 - 40, 450), "Exit", Layer(8)
  272.   CASE Help
  273.    ClearLayer Layer(9)
  274.    _PUTIMAGE , Layer(4), Layer(9)
  275.    _PRINTSTRING (16, 32), "In game mode one(1) the goal is to match", Layer(9)
  276.    _PRINTSTRING (16, 64), "Pup to Pup and Badge to Badge. Beat all 4", Layer(9)
  277.    _PRINTSTRING (16, 96), "levels quickly for high scores!", Layer(9)
  278.    _PRINTSTRING (16, 144), "In game mode two(2) the goal is to match", Layer(9)
  279.    _PRINTSTRING (16, 176), "Pup to badge. Make as many matches as", Layer(9)
  280.    _PRINTSTRING (16, 208), "possible in 120 seconds for high scores!", Layer(9)
  281.    _PRINTSTRING (16, 256), "Make matches by clicking on the back of", Layer(9)
  282.    _PRINTSTRING (16, 288), "the cards to reveal a pup or badge image.", Layer(9)
  283.    _PRINTSTRING (16, 320), "Depending on game mode they matched by", Layer(9)
  284.    _PRINTSTRING (16, 352), "Pup to Pup\Badge to Badge, or", Layer(9)
  285.    _PRINTSTRING (16, 384), "in game mode 2 Pup to Badge.", Layer(9)
  286.    Fade_In Layer(9)
  287.    DO
  288.     _PUTIMAGE , Layer(9), Layer(0)
  289.     _LIMIT 30
  290.    LOOP UNTIL INKEY$ <> ""
  291.    Fade_Out Layer(0)
  292.  
  293.   CASE HighScores
  294.    ClearLayer Layer(9)
  295.    _PUTIMAGE , Layer(4), Layer(9)
  296.    _PUTIMAGE (100, 0), Layer(11), Layer(9)
  297.    _PRINTSTRING (168, 160), "Names", Layer(9)
  298.    _PRINTSTRING (520, 160), "Times", Layer(9)
  299.    _PRINTSTRING (168, 365), "Names", Layer(9)
  300.    _PRINTSTRING (520, 365), "Matches", Layer(9)
  301.    IF _FILEEXISTS("Paws.HSL") THEN
  302.     N$ = SPACE$(26)
  303.     T$ = SPACE$(5)
  304.     OPEN "Paws.HSL" FOR BINARY AS #1
  305.     'Game time high scores (time to finish matches)
  306.     GET #1, , Count%%
  307.     FOR i%% = 1 TO Count%%
  308.      GET #1, , N$
  309.      GET #1, , T$
  310.      _PRINTSTRING (168, 192 + 24 * i%%), N$, Layer(9)
  311.      _PRINTSTRING (520, 192 + 24 * i%%), T$, Layer(9)
  312.     NEXT i%%
  313.     'Matches under timer (matches made in 120 sec
  314.     GET #1, , Count%%
  315.     FOR i%% = 1 TO Count%%
  316.      GET #1, , N$
  317.      GET #1, , T$
  318.      _PRINTSTRING (168, 397 + 24 * i%%), N$, Layer(9)
  319.      _PRINTSTRING (520, 397 + 24 * i%%), T$, Layer(9)
  320.     NEXT i%%
  321.    ELSE
  322.     _PRINTSTRING (168, 192 + 24 * i%%), "No game yet", Layer(9)
  323.     _PRINTSTRING (168, 397 + 24 * i%%), "No game yet", Layer(9)
  324.    END IF
  325.    CLOSE #1
  326.    Fade_In Layer(9)
  327.    DO
  328.     _PUTIMAGE , Layer(9), Layer(0)
  329.     _LIMIT 30
  330.    LOOP UNTIL INKEY$ <> ""
  331.    Fade_Out Layer(0)
  332.   CASE GameMode
  333.  
  334.  
  335. SUB Options_Menu
  336.  DO
  337.   Nul = _MOUSEINPUT
  338.   _PUTIMAGE , Layer(8), Layer(1) 'prep the menu layer to screen(erases old screen cycle)
  339.   _DEST Layer(1)
  340.   BGMV = G.BGMVol / 100: SFXV = G.SFXVol / 100
  341.   LINE (255, 240)-STEP(16 * 16, 32), _RGB32(0 + INT(255 * BGMV), 255 - INT(255 * BGMV), 0), BF
  342.   LINE (255, 290)-STEP(16 * 16, 32), _RGB32(0 + INT(255 * SFXV), 255 - INT(255 * SFXV), 0), BF
  343.   LINE (255 + (256 * BGMV), 236)-STEP(1, 40), _RGB32(224, 224, 224), B
  344.   LINE (255 + (256 * SFXV), 286)-STEP(1, 40), _RGB32(224, 224, 224), B
  345.   _DEST Layer(0)
  346.  
  347.   IF _MOUSEBUTTON(1) THEN 'lets see where the user clicked
  348.    Opt%% = Mouse_Over
  349.    ButtonDown%% = TRUE
  350.    Clicked%% = TRUE
  351.   ELSE
  352.    ButtonDown%% = FALSE
  353.   END IF
  354.  
  355.   'check over game options with click layer
  356.   SELECT CASE Mouse_Over
  357.    CASE 1 'Music Vol controller
  358.     _PRINTSTRING (100, 250), "Music ", Layer(1)
  359.    CASE 2 ' Sounds Vol Controller
  360.     _PRINTSTRING (100, 300), "Sounds", Layer(1)
  361.    CASE 3 ' Reset High Scores List
  362.     _PRINTSTRING (400 - 144, 350), "Reset High Scores", Layer(1)
  363.    CASE 4 ' Exit Options
  364.     _PRINTSTRING (400 - 40, 450), "Exit", Layer(1)
  365.  
  366.   _PUTIMAGE , Layer(1), Layer(0)
  367.   _LIMIT 60
  368.   IF (Clicked%% AND ButtonDown%% = FALSE) AND Opt%% > 2 THEN 'user clicked something lets see what.
  369.    SELECT CASE Opt%%
  370.     CASE 3 'Reset High Scores
  371.      IF _FILEEXISTS("Paws.HSL") THEN KILL "Paws.HSL" 'erase the highscore file
  372.     CASE 4 'Exit
  373.      ExitFlag%% = TRUE
  374.     CASE ELSE 'null click, invalid option
  375.      Opt%% = 0
  376.    END SELECT
  377.    Clicked%% = FALSE
  378.   ELSEIF ButtonDown%% THEN 'the volume controls are button down and slide
  379.    SELECT CASE Opt%%
  380.     CASE 1 'music
  381.      G.BGMVol = INT((_MOUSEX - 255) / 256 * 100)
  382.     CASE 2 'sounds
  383.      G.SFXVol = INT((_MOUSEX - 255) / 256 * 100)
  384.    END SELECT
  385.   ELSEIF Clicked%% THEN 'once released change volume levels
  386.    Clicked%% = FALSE
  387.    SetVolumes
  388.   END IF
  389.   DO: Nul = _MOUSEINPUT: LOOP WHILE _MOUSEINPUT 'clear the mouse buffer
  390.   IF INKEY$ = CHR$(27) THEN ExitFlag%% = TRUE
  391.   ' BackGroundMusic 'deal with the menus background music || Handled with Timer for now
  392.  LOOP UNTIL ExitFlag%%
  393.  
  394. SUB BackGroundMusic
  395.  STATIC LastPlay&
  396.  
  397.  IF LastPlay& = 0 THEN _SNDPLAY BGM(1) 'game just started
  398.  
  399.  IF _SNDPLAYING(BGM(1)) THEN
  400.   'main theme is still playing so nothing to do!
  401.   LastPlay& = TIMER '86399
  402.   IF LastPlay& > 86350 THEN LastPlay& = 0 'make the midnight jump (what are little kids doing up?)
  403.  
  404.   '-----------------------------Looping Music Section----------------------------------------
  405.  ELSEIF G.Status = MainMenu THEN 'user is in the menus
  406.  
  407.   '================================Menu Music Area===========================================
  408.   IF _SNDPLAYING(BGM(2)) THEN 'the instramental is playing
  409.    LastPlay& = TIMER '86399
  410.    IF LastPlay& > 86350 THEN LastPlay& = 0 'make the midnight jump (what are little kids doing up?)
  411.   ELSE
  412.    IF TIMER > LastPlay& + 20 AND TIMER < 86350 THEN _SNDPLAY BGM(2)
  413.   END IF
  414.   '==========================================================================================
  415.  
  416.  ELSEIF G.Status = GameMode THEN 'player is in game
  417.  
  418.   '================================Game Music Area===========================================
  419.   IF _SNDPLAYING(BGM(3)) THEN 'the instramental is playing
  420.    LastPlay& = TIMER '86399
  421.    IF LastPlay& > 86250 THEN LastPlay& = 0 'make the midnight jump (what are little kids doing up?)
  422.   ELSE
  423.    IF TIMER > LastPlay& + 10 AND TIMER < 86250 THEN _SNDPLAY BGM(3)
  424.   END IF
  425.   '==========================================================================================
  426.  '-------------------------------------------------------------------------------------------
  427.  
  428. SUB SetVolumes
  429.  FOR i%% = 1 TO LoadedMusic
  430.   _SNDVOL BGM(i%%), G.BGMVol
  431.  NEXT i%%
  432.  FOR i%% = 1 TO LoadedSounds 'start at 1 so if 0 sounds loaded nothing is affected
  433.   _SNDVOL SFX(i%%), G.SFXVol
  434.  NEXT i%%
  435.  
  436. SUB Display_Card (X%, Y%, id%%, Scale!)
  437.  'Scale options 1,1.5,2,2.5(Full,1\2,1\4,1\8[these values for refernce only, not correct])
  438.  'full-12 cards, 1.5- 24 cards, 2-48 cards, 2.5- 96 cards!
  439.  IF id%% THEN
  440.   _PUTIMAGE (X%, Y%)-STEP(157 / Scale!, 157 / Scale!), Layer(2), Layer(1), (Cards(id%%).X1, Cards(id%%).Y1)-(Cards(id%%).X2, Cards(id%%).Y2)
  441.  ELSE 'card 0 is back side
  442.   _PUTIMAGE (X%, Y%)-STEP(157 / Scale!, 157 / Scale!), Layer(2), Layer(1), (384, 166)-STEP(159, 159)
  443.  
  444. SUB Game_Mode1
  445.  DIM card(1) AS _BYTE 'what 2 cards are flipped
  446.  CardsLeft%% = (BoardX(G.Level * 2 - 1) + 1) * (BoardY(G.Level * 2 - 1) + 1) 'how many cards to match
  447.  Create_ClickMap GameMode 'set the click space
  448.  Setup_Cards G.Level 'ready the cards for matching
  449.  _DEST Layer(12)
  450.  DO
  451.   nul% = _MOUSEINPUT
  452.   IF _MOUSEBUTTON(1) THEN 'lets see where the user clicked
  453.    Opt%% = Mouse_Over
  454.    ButtonDown%% = TRUE
  455.    Clicked%% = TRUE
  456.   ELSE
  457.    ButtonDown%% = FALSE
  458.   END IF
  459.  
  460.   IF NOT ButtonDown%% AND Clicked%% THEN
  461.    IF Board(Opt%%).Flipped = FALSE THEN
  462.     Board(Opt%%).Flipped = TRUE
  463.     Clicked%% = FALSE
  464.     card(flipped%%) = Opt%% 'watch which cards are flipped
  465.     flipped%% = flipped%% + 1
  466.    END IF
  467.   END IF
  468.   tmp%% = Mouse_Over
  469.   LOCATE 1, 40: PRINT SPACE$(39)
  470.   LOCATE 1, 40: PRINT tmp%%; Board(tmp%%).Id; Board(tmp%%).Flipped; Board(tmp%%).Matched, G.Level; CardsLeft%%;
  471.   PRINT BoardX(G.Level * 2 - 1); BoardY(G.Level * 2 - 1)
  472.   '-------------------------screen update-----------------------
  473.   ClearLayer Layer(1)
  474.   _PRINTSTRING (5, 5), "Time   :", Layer(1)
  475.   _PRINTSTRING (5, 34), "Matches:", Layer(1)
  476.   Display_Game_Board_II
  477.   Display_Time_Elapsed
  478.   _PUTIMAGE , Layer(1), Layer(0)
  479.   _PUTIMAGE , Layer(12), Layer(0)
  480.   '-------------------------------------------------------------
  481.  
  482.   IF flipped%% = 2 THEN
  483.    flipped%% = 0 'reset our flipped card count
  484.    IF Board(card(0)).Id = Board(card(1)).Id THEN ' we have a match! :D
  485.     Board(card(0)).Matched = TRUE
  486.     Board(card(1)).Matched = TRUE
  487.     CardsLeft%% = CardsLeft%% - 2
  488.    ELSE 'no match :(
  489.     Board(card(0)).Flipped = FALSE
  490.     Board(card(1)).Flipped = FALSE
  491.     _DELAY .5
  492.    END IF
  493.   END IF
  494.  
  495.   _LIMIT 60
  496.   DO: Nul = _MOUSEINPUT: LOOP WHILE _MOUSEINPUT 'clear the mouse buffer
  497.  
  498.   IF INKEY$ = CHR$(27) THEN ExitFlag%% = TRUE: G.Quit = TRUE
  499.  
  500.   IF CardsLeft%% = 0 THEN 'player wins this level!
  501.    G.Level = G.Level + .5
  502.    ExitFlag%% = TRUE
  503.   END IF
  504.  LOOP UNTIL ExitFlag%%
  505.  
  506. SUB Setup_Cards (opt%%)
  507.  FOR i%% = 0 TO 96 'erase card data
  508.   Board(i%%).Id = 0
  509.   Board(i%%).Flipped = FALSE
  510.   Board(i%%).Matched = FALSE
  511.  NEXT i%%
  512.  SELECT CASE G.Level
  513.   CASE Level_1 '12 cards
  514.    'not enough cards so just load the first 6 cards to match(pups and 1 badge{marshal's})
  515.    FOR i%% = 1 TO 12 STEP 2
  516.     J%% = J%% + 1
  517.     Board(i%%).Id = J%%
  518.     Board(i%% + 1).Id = Board(i%%).Id
  519.    NEXT i%%
  520.    cc%% = 12 'Card Count for the scramble
  521.   CASE Level_2 '24 cards
  522.    'add the 10 base cards then repeat 2
  523.    FOR i%% = 1 TO 24 STEP 2
  524.     J%% = J%% + 1
  525.     Board(i%%).Id = J%%
  526.     Board(i%% + 1).Id = Board(i%%).Id
  527.     IF J%% = 10 THEN J%% = 0 'start over
  528.    NEXT i%%
  529.    cc%% = 24 'Card Count for the scramble
  530.   CASE Level_3 '48 cards
  531.    'add the 10 base cards then repeat 2
  532.    FOR i%% = 1 TO 48 STEP 2
  533.     J%% = J%% + 1
  534.     Board(i%%).Id = J%%
  535.     Board(i%% + 1).Id = Board(i%%).Id
  536.     IF J%% = 10 THEN J%% = 0 'start over
  537.    NEXT i%%
  538.    cc%% = 48 'Card Count for the scramble
  539.   CASE Level_4 '70 cards
  540.    'add the 10 base cards then repeat 2
  541.    FOR i%% = 1 TO 70 STEP 2
  542.     J%% = J%% + 1
  543.     Board(i%%).Id = J%%
  544.     Board(i%% + 1).Id = Board(i%%).Id
  545.     IF J%% = 10 THEN J%% = 0 'start over
  546.    NEXT i%%
  547.    cc%% = 70 'Card Count for the scramble
  548.  'scramble cards
  549.  FOR i% = 0 TO 200
  550.   SWAP Board(INT(RND * cc%%) + 1), Board(INT(RND * cc%%) + 1)
  551.  NEXT i%
  552.  
  553. SUB Display_Game_Board (opt%%)
  554.  SELECT CASE opt%%
  555.   CASE Level_1 ' 12 full sized cards
  556.    FOR y%% = 0 TO 2
  557.     FOR x%% = 0 TO 3
  558.      C%% = C%% + 1
  559.      IF NOT Board(C%%).Matched THEN
  560.       IF Board(C%%).Flipped THEN
  561.        Display_Card 50 + x%% * 175, 75 + y%% * 175, Board(C%%).Id, 1
  562.       ELSE
  563.        Display_Card 50 + x%% * 175, 75 + y%% * 175, 0, 1
  564.       END IF
  565.      END IF
  566.    NEXT x%%, y%%
  567.   CASE Level_2 '24 half sized cards
  568.    FOR y%% = 0 TO 3
  569.     FOR x%% = 0 TO 5
  570.      C%% = C%% + 1
  571.      IF NOT Board(C%%).Matched THEN
  572.       IF Board(C%%).Flipped THEN
  573.        Display_Card 50 + x%% * 115, 75 + y%% * 115, Board(C%%).Id, 1.5
  574.       ELSE
  575.        Display_Card 50 + x%% * 115, 75 + y%% * 115, 0, 1.5
  576.       END IF
  577.      END IF
  578.    NEXT x%%, y%%
  579.   CASE Level_3
  580.    FOR y%% = 0 TO 4
  581.     FOR x%% = 0 TO 7
  582.      C%% = C%% + 1
  583.      IF NOT Board(C%%).Matched THEN
  584.       IF Board(C%%).Flipped THEN
  585.        Display_Card 50 + x%% * 88, 75 + y%% * 88, Board(C%%).Id, 2
  586.       ELSE
  587.        Display_Card 50 + x%% * 88, 75 + y%% * 88, 0, 2
  588.       END IF
  589.      END IF
  590.    NEXT x%%, y%%
  591.   CASE Level_4
  592.    FOR y%% = 0 TO 6
  593.     FOR x%% = 0 TO 9
  594.      C%% = C%% + 1
  595.      IF NOT Board(C%%).Matched THEN
  596.       IF Board(C%%).Flipped THEN
  597.        Display_Card 50 + x%% * 64, 75 + y%% * 64, Board(C%%).Id, 2
  598.       ELSE
  599.        Display_Card 50 + x%% * 64, 75 + y%% * 64, 0, 2
  600.       END IF
  601.      END IF
  602.    NEXT x%%, y%%
  603.  
  604. SUB Display_Game_Board_II
  605.  Offset% = 175 / G.Level 'card spacing
  606.  FOR y%% = 0 TO BoardY(G.Level * 2 - 1)
  607.   FOR x%% = 0 TO BoardX(G.Level * 2 - 1)
  608.    C%% = C%% + 1
  609.    IF NOT Board(C%%).Matched THEN 'if the card is matched do not display
  610.     IF Board(C%%).Flipped THEN 'if player has flipped card then display image
  611.      Display_Card 50 + x%% * Offset%, 75 + y%% * Offset%, Board(C%%).Id, G.Level
  612.     ELSE 'otherwise display back of card
  613.      Display_Card 50 + x%% * Offset%, 75 + y%% * Offset%, 0, G.Level
  614.     END IF
  615.    END IF
  616.  NEXT x%%, y%%
  617.  
  618. SUB CountTime
  619.  IF G.Status = GameMode THEN 'count time while playing
  620.   G.time = G.time + 1
  621.  ELSE 'when in menu reset game time
  622.   G.time = 0
  623.  
  624. SUB Display_Time_Elapsed
  625.  min$ = LTRIM$(STR$(G.time \ 60))
  626.  sec$ = LTRIM$(STR$(G.time MOD 60))
  627.  IF LEN(sec$) = 1 THEN sec$ = "0" + sec$
  628.  IF G.time \ 60 THEN T$ = min$ + ":" + sec$ ELSE T$ = sec$
  629.  _PRINTSTRING (160, 8), T$, Layer(1)
  630.  
  631. SUB Run_Victory
  632.  SND_FadeOut
  633.  MFI_Loader_victory "Victory.ANI"
  634.  
  635.  
  636. SUB MFI_Loader_victory (FN$)
  637.  DIM Size(128) AS LONG, FOffset(128) AS LONG
  638.  GET #1, , c~%% 'retrieve number of files
  639.  FOR I~%% = 1 TO c~%%
  640.   GET #1, , FOffset(I~%%)
  641.   GET #1, , Size(I~%%)
  642.   FOffset&(I~%%) = FOffset&(I~%%) + 1
  643.  NEXT I~%%
  644.  ClearLayer Layer(1)
  645.  ClearLayer Layer(0)
  646.  _SNDPLAY SFX(1)
  647.  DO
  648.   fr%% = fr%% + 1
  649.   tmp& = LoadGFX(FOffset(fr%%), Size(fr%%))
  650.   _PUTIMAGE (100, 192), tmp&, Layer(1)
  651.   _PUTIMAGE (135, 16), Layer(13), Layer(1)
  652.   _PUTIMAGE , Layer(1), Layer(0)
  653.   _LIMIT 16
  654.   IF fr%% = 95 THEN Exitflag%% = TRUE
  655.   _FREEIMAGE tmp&
  656.  LOOP UNTIL Exitflag%%
  657.  tmp& = LoadGFX(FOffset(92), Size(92))
  658.  _PUTIMAGE (100, 192), tmp&, Layer(1)
  659.  _PUTIMAGE (135, 16), Layer(13), Layer(1)
  660.  _PUTIMAGE , Layer(1), Layer(0)
  661.  _FREEIMAGE tmp&
  662.  _DELAY 4
  663.  CLOSE #1
  664.  IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"
  665.  
  666. FUNCTION LoadGFX& (Foff&, Size&)
  667.  IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"
  668.  OPEN "temp.dat" FOR BINARY AS #3
  669.  dat$ = SPACE$(Size&)
  670.  GET #1, Foff&, dat$
  671.  PUT #3, , dat$
  672.  CLOSE #3
  673.  LoadGFX& = _LOADIMAGE("temp.dat", 32)
  674.  
  675. FUNCTION LoadFFX& (Foff&, Size&, Fize%%, Att$)
  676.  IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"
  677.  OPEN "temp.dat" FOR BINARY AS #3
  678.  dat$ = SPACE$(Size&)
  679.  GET #1, Foff&, dat$
  680.  PUT #3, , dat$
  681.  CLOSE #3
  682.  LoadFFX& = _LOADFONT("temp.dat", Fize%%, Att$)
  683.  
  684. FUNCTION LoadSFX& (Foff&, Size&)
  685.  IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"
  686.  OPEN "temp.dat" FOR BINARY AS #3
  687.  dat$ = SPACE$(Size&)
  688.  GET #1, Foff&, dat$
  689.  PUT #3, , dat$
  690.  CLOSE #3
  691.  LoadSFX& = _SNDOPEN("temp.dat")
  692.  
  693. SUB LoadData (Foff&, Size&)
  694.  IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"
  695.  OPEN "temp.dat" FOR BINARY AS #3
  696.  dat$ = SPACE$(Size&)
  697.  GET #1, Foff&, dat$
  698.  PUT #3, , dat$
  699.  CLOSE #3
  700.  
  701. SUB MFI_Loader (FN$)
  702.  DIM Size(128) AS LONG, FOffset(128) AS LONG
  703.  GET #1, , c~%% 'retrieve number of files
  704.  FOR I~%% = 1 TO c~%%
  705.   GET #1, , FOffset(I~%%)
  706.   GET #1, , Size(I~%%)
  707.   FOffset&(I~%%) = FOffset&(I~%%) + 1
  708.  NEXT I~%%
  709.  '-----------------------Splash Screen setup-------------------------
  710.  _PRINTSTRING (0, 574), "Loading...", _DISPLAY
  711.  Splash& = LoadGFX(FOffset(9), Size(9)) 'Splash screen
  712.  BGM(1) = LoadSFX(FOffset(1), Size(1))
  713.  TIMER(T&) ON 'start the background musics
  714.  DO: _LIMIT 60: LOOP UNTIL _SNDGETPOS(BGM(1)) > 1
  715.  Fade_In Splash&
  716.  _PUTIMAGE , Splash&, _DISPLAY 'show the splash screen while loading
  717.  _PRINTSTRING (0, 574), "Loading..."
  718.  '-------------------------------------------------------------------
  719.  Layer(0) = _DISPLAY
  720.  Layer(1) = _COPYIMAGE(_DISPLAY) 'Mix layer
  721.  Layer(7) = _NEWIMAGE(800, 600, 32) 'click map layer
  722.  Layer(8) = _NEWIMAGE(800, 600, 32) 'Main Menu\Options Layer
  723.  Layer(9) = _NEWIMAGE(800, 600, 32) 'High Score\Help layer
  724.  Layer(10) = _NEWIMAGE(800, 600, 32) 'Mouse Over hi-lite layer
  725.  Layer(12) = _NEWIMAGE(800, 600, 32) 'debug info
  726.  
  727.  Layer(2) = LoadGFX(FOffset(2), Size(2)) 'Tiles
  728.  Layer(3) = LoadGFX(FOffset(3), Size(3)) 'Title
  729.  Layer(4) = LoadGFX(FOffset(4), Size(4)) 'BackGround
  730.  Layer(5) = LoadGFX(FOffset(5), Size(5)) 'Pups
  731.  Layer(6) = LoadGFX(FOffset(6), Size(6)) 'bitmap font
  732.  Layer(11) = LoadGFX(FOffset(7), Size(7)) 'high score title
  733.  Layer(13) = LoadGFX(FOffset(8), Size(8)) 'Victory screen title
  734.  BGM(2) = LoadSFX(FOffset(10), Size(10)) 'instramental theme
  735.  BGM(3) = LoadSFX(FOffset(11), Size(11)) 'extended instramental
  736.  SFX(1) = LoadSFX(FOffset(12), Size(12)) 'victory cheer
  737.  FFX(0) = LoadFFX(FOffset(13), Size(13), 36, "BOLD") 'main font
  738.  FFX(1) = LoadFFX(FOffset(13), Size(13), 24, "") 'high score font
  739.  FFX(2) = LoadFFX(FOffset(13), Size(13), 24, "MONOSPACE") 'help font
  740.  
  741.  CLOSE #1
  742.  IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"
  743.  
  744. SUB Fade_Out (L&)
  745.  FOR n! = 1 TO 0.00 STEP -0.05
  746.   i2& = _COPYIMAGE(L&)
  747.   DarkenImage i2&, n!
  748.   _PUTIMAGE (0, 0), i2&, Layer(0)
  749.   _FREEIMAGE i2&
  750.   _DELAY .06
  751.  
  752. SUB Fade_In (L&)
  753.  FOR n! = 0.01 TO 1 STEP 0.05
  754.   i2& = _COPYIMAGE(L&)
  755.   DarkenImage i2&, n!
  756.   _PUTIMAGE (0, 0), i2&, Layer(0)
  757.   _FREEIMAGE i2&
  758.   _DELAY .06
  759.  
  760. SUB DarkenImage (Image AS LONG, Value_From_0_To_1 AS SINGLE)
  761.  IF Value_From_0_To_1 <= 0 OR Value_From_0_To_1 >= 1 OR _PIXELSIZE(Image) <> 4 THEN EXIT SUB
  762.  DIM Buffer AS _MEM: Buffer = _MEMIMAGE(Image) 'Get a memory reference to our image
  763.  DIM Frac_Value AS LONG: Frac_Value = Value_From_0_To_1 * 65536 'Used to avoid slow floating point calculations
  764.  DIM O AS _OFFSET, O_Last AS _OFFSET
  765.  O = Buffer.OFFSET 'We start at this offset
  766.  O_Last = Buffer.OFFSET + _WIDTH(Image) * _HEIGHT(Image) * 4 'We stop when we get to this offset
  767.  'use on error free code ONLY!
  768.  DO
  769.   _MEMPUT Buffer, O, _MEMGET(Buffer, O, _UNSIGNED _BYTE) * Frac_Value \ 65536 AS _UNSIGNED _BYTE
  770.   _MEMPUT Buffer, O + 1, _MEMGET(Buffer, O + 1, _UNSIGNED _BYTE) * Frac_Value \ 65536 AS _UNSIGNED _BYTE
  771.   _MEMPUT Buffer, O + 2, _MEMGET(Buffer, O + 2, _UNSIGNED _BYTE) * Frac_Value \ 65536 AS _UNSIGNED _BYTE
  772.   O = O + 4
  773.  LOOP UNTIL O = O_Last
  774.  'turn checking back on when done!
  775.  _MEMFREE Buffer
  776.  
  777. SUB SND_FadeOut
  778.  IF _SNDPLAYING(BGM(1)) THEN opt%% = 1
  779.  IF _SNDPLAYING(BGM(2)) THEN opt%% = 2
  780.  IF _SNDPLAYING(BGM(3)) THEN opt%% = 3
  781.  FOR I%% = G.BGMVol TO 0 STEP -1
  782.   _SNDVOL BGM(opt%%), I%% / 100
  783.   _DELAY .03
  784.  NEXT I%%
  785.  _SNDSTOP BGM(opt%%)
  786.  
  787. SUB ClearLayer (L&)
  788.  old& = _DEST
  789.  _DEST L&
  790.  CLS ' ,0
  791.  _DEST old&
  792.  
  793. SUB ClearLayerTrans (L&)
  794.  old& = _DEST
  795.  _DEST L&
  796.  CLS , 0
  797.  _DEST old&
  798.  
* PawsV1b.MFI (Filesize: 5.4 MB, Downloads: 192)
* Victory.ANI (Filesize: 4.99 MB, Downloads: 194)
« Last Edit: August 30, 2021, 10:11:40 pm by odin »
Granted after becoming radioactive I only have a half-life!

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: A Game for those with children (or who are children themselves!)
« Reply #1 on: August 31, 2021, 11:44:39 am »
I had an error on line 718, but then I copied your file to a folder below (to the IDE) and then it started. I like this!
« Last Edit: August 31, 2021, 11:49:01 am by Petr »

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: A Game for those with children (or who are children themselves!)
« Reply #2 on: August 31, 2021, 12:06:38 pm »
Cobalt, i find your SNDVOL problem:

 
Volume.PNG


Just add /100 to your SetVolumes SUB.

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: A Game for those with children (or who are children themselves!)
« Reply #3 on: August 31, 2021, 01:33:50 pm »
Did Steve help you name this game? If so, tell him he spelled opossum wrong.

Pete
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline Ashish

  • Forum Resident
  • Posts: 630
  • Never Give Up!
    • View Profile
Re: A Game for those with children (or who are children themselves!)
« Reply #4 on: September 01, 2021, 01:14:30 am »
Nice work! I played it for a while. :)
if (Me.success) {Me.improve()} else {Me.tryAgain()}


My Projects - https://github.com/AshishKingdom?tab=repositories
OpenGL tutorials - https://ashishkingdom.github.io/OpenGL-Tutorials

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Re: A Game for those with children (or who are children themselves!)
« Reply #5 on: September 03, 2021, 03:21:03 pm »
Updated release,
-fixed sound level change issue.
-added an animation for matching
-Changed some jpg images to png for artifact issues.

Updated the MFI file. So a redownload is needed.

Code: QB64: [Select]
  1. 'Paw Patrol matching\memory game
  2. '8/27/2021
  3. 'UniKorn ProDucKions
  4.  
  5. 'inital test release V1b(eta)
  6. '9/2/2021:Release-002
  7. 'To Be Finished;
  8. 'Game Mode 2-Pup to Badge matching
  9. 'High Score addition;
  10. 'À-Name Entry and Hi-lite
  11. 'Add and exit button to Options Screen and High Scores(just hit ESC for now)
  12.  
  13. TYPE Card_Data
  14.  Id AS _BYTE
  15.  X1 AS INTEGER
  16.  Y1 AS INTEGER
  17.  X2 AS INTEGER
  18.  Y2 AS INTEGER
  19.  
  20. TYPE Game_Data
  21.  GameType AS _BYTE 'Mode 1(P+P,B+B) or Mode 2(P+B)
  22.  BGMVol AS _BYTE 'Music volume
  23.  SFXVol AS _BYTE 'Sound volume
  24.  Status AS _BYTE 'MainMenu or GameMode
  25.  time AS INTEGER 'number of seconds in game
  26.  Match AS INTEGER 'number of matches made in game
  27.  Level AS SINGLE '"difficulty" of game 1-12cards, 2-24cards,3-48cards,4-70cards
  28.  Quit AS SINGLE 'player quits current game :(
  29.  
  30. TYPE Game_Board
  31.  Id AS _BYTE 'what card is here
  32.  Flipped AS _BYTE 'is card flipped?(displayed)
  33.  Matched AS _BYTE 'is the card still here?
  34.  X AS _BYTE
  35.  Y AS _BYTE
  36.  
  37. '------------------------Constants-------------------------
  38. CONST TRUE = -1, FALSE = NOT TRUE
  39. CONST MainMenu = 1, Options = 2, Help = 3, GameMode = 4, HighScores = 5
  40. CONST Mode_1 = 1, Mode_2 = 2
  41. CONST Level_1 = 1, Level_2 = 1.5, Level_3 = 2, Level_4 = 2.5
  42. CONST LoadedMusic = 3
  43. CONST LoadedSounds = 1
  44. '----------------------------------------------------------
  45.  
  46. '----------------------Tile Data---------------------------
  47. Card_data: '10 tiles
  48. DATA 32,165,190,323: 'sky
  49. DATA 207,341,365,499: 'chase
  50. DATA 31,517,189,675: 'everest
  51. DATA 383,343,541,501: 'marshal
  52. DATA 30,868,188,1026: 'rubble
  53. DATA 32,340,190,498: 'marshal badge
  54. DATA 30,692,188,850: 'chase badge
  55. DATA 206,693,364,851: 'rubble badge
  56. DATA 206,869,364,1027: 'sky badge
  57. DATA 208,166,366,324: 'everest badge
  58. 'perhaps more tiles would be nice?
  59. Board_Size:
  60. DATA 2,3,5,6
  61. DATA 3,5,7,9
  62. '----------------------------------------------------------
  63.  
  64. '---------------------Array and Globals--------------------
  65. DIM SHARED Layer(16) AS LONG, BGM(5) AS LONG, G AS Game_Data, T&, M&
  66. DIM SHARED FFX(6) AS LONG, Cards(16) AS Card_Data, SFX(5) AS LONG
  67. DIM SHARED Board(96) AS Game_Board, BoardX(4) AS _BYTE, BoardY(4) AS _BYTE
  68. '----------------------------------------------------------
  69.  
  70. '------------------------Timers----------------------------
  71. ON TIMER(T&, .5) BackGroundMusic 'control the background music
  72. ON TIMER(M&, 1) CountTime 'keeps track of time during gameplay
  73. '----------------------------------------------------------
  74. G.Status = MainMenu
  75. G.BGMVol = 45
  76. G.SFXVol = 45
  77.  
  78. MFI_Loader "PawsV1b.mfi"
  79.  
  80. _PUTIMAGE , Splash&, _DISPLAY 'erase `Loading...` as that is done
  81. SetVolumes 'adjust volume levels
  82. _DELAY 5 'leave the pups up for a few seconds.
  83. Fade_Out _DISPLAY
  84.  
  85. '--------------------------GFX setup stuff------------------------
  86. _SETALPHA 48, , Layer(4)
  87. _CLEARCOLOR _RGB32(0), Layer(3)
  88. _CLEARCOLOR _RGB32(0), Layer(4)
  89. _CLEARCOLOR _RGB32(0), Layer(11)
  90. _CLEARCOLOR _RGB32(0), Layer(12)
  91. _CLEARCOLOR _RGB32(0), Layer(14)
  92. _DEST Layer(8)
  93. COLOR _RGB32(100, 235, 250) 'menu options color
  94. _DEST Layer(9)
  95. COLOR _RGB32(100, 235, 250) 'High Score color
  96. _DEST Layer(0)
  97. _FONT FFX(0), Layer(8)
  98. _FONT FFX(0), Layer(1)
  99. _FONT FFX(2), Layer(9)
  100. '-----------------------------------------------------------------
  101. '-----------------------------Load Data---------------------------
  102. FOR i%% = 1 TO 10
  103.  READ Cards(i%%).X1, Cards(i%%).Y1, Cards(i%%).X2, Cards(i%%).Y2
  104. NEXT i%%
  105. FOR i%% = 1 TO 4
  106.  READ BoardY(i%%)
  107. NEXT i%%
  108. FOR i%% = 1 TO 4
  109.  READ BoardX(i%%)
  110. NEXT i%%
  111. '-----------------------------------------------------------------
  112.  
  113. Build_Screens MainMenu
  114. _SOURCE Layer(7) 'click check layer
  115. _DEST Layer(1)
  116. COLOR _RGB32(255, 255, 0) 'mouse over menu options highlight color
  117. _DEST Layer(0)
  118. Create_ClickMap MainMenu
  119. _DEST Layer(1)
  120. Fade_In Layer(8)
  121. G.Level = Level_1
  122. TIMER(M&) ON
  123.  
  124.  Nul = _MOUSEINPUT
  125.  _PUTIMAGE , Layer(8), Layer(1) 'prep the menu layer to screen(erases old screen cycle)
  126.  
  127.  IF _MOUSEBUTTON(1) THEN 'lets see where the user clicked
  128.   Opt%% = Mouse_Over
  129.   ButtonDown%% = TRUE
  130.   Clicked%% = TRUE
  131.   ButtonDown%% = FALSE
  132.  
  133.  'check over game options with click layer
  134.  SELECT CASE Mouse_Over
  135.   CASE 1 ' Game mode 1, Portrat+Portrat
  136.    _PRINTSTRING (400 - 64, 200), "Game 1", Layer(1)
  137.   CASE 2 ' Game Mode 2, Portrat+Badge
  138.    _PRINTSTRING (400 - 64, 250), "Game 2", Layer(1)
  139.   CASE 3 ' Help
  140.    _PRINTSTRING (400 - 56, 300), " Help", Layer(1)
  141.   CASE 4 ' High Scores(most matches in a row? Board completion time?)
  142.    _PRINTSTRING (400 - 100, 350), "High Scores", Layer(1)
  143.   CASE 5 ' Options (Sound levels, High Score Reset)
  144.    _PRINTSTRING (400 - 64, 400), "Options", Layer(1)
  145.   CASE 6 ' Quit the game(Tis a sad day indeed!)
  146.    _PRINTSTRING (400 - 48, 450), " Quit", Layer(1)
  147.  _PUTIMAGE , Layer(1), Layer(0)
  148.  _LIMIT 60
  149.  IF Clicked%% AND ButtonDown%% = FALSE THEN 'user clicked something lets see what.
  150.   SELECT CASE Opt%%
  151.    CASE 1
  152.     G.Level = Level_1
  153.     G.Status = GameMode
  154.     DO
  155.      Game_Mode1
  156.     LOOP UNTIL G.Level = 3 OR G.Quit
  157.     IF G.Level = 3 THEN 'victory screen
  158.      Run_Victory
  159.     END IF
  160.     Create_ClickMap MainMenu
  161.     G.Status = MainMenu
  162.    CASE 2
  163.    CASE 3 'Help screen
  164.     Fade_Out Layer(0)
  165.     Build_Screens Help
  166.     Build_Screens MainMenu
  167.     Fade_In Layer(8)
  168.    CASE 4 'High Scores list
  169.     Fade_Out Layer(0)
  170.     Build_Screens HighScores
  171.     Build_Screens MainMenu
  172.     Fade_In Layer(8)
  173.    CASE 5 'Options Menu
  174.     Fade_Out Layer(0)
  175.     Build_Screens Options 'Build Options
  176.     Create_ClickMap Options
  177.     Fade_In Layer(8)
  178.     Options_Menu
  179.     Fade_Out Layer(0)
  180.     Build_Screens MainMenu 'rebuild MainMenu
  181.     Create_ClickMap MainMenu
  182.     Fade_In Layer(8)
  183.  
  184.    CASE 6 'ok, :(  lets quit
  185.     QuitFlag%% = TRUE
  186.    CASE ELSE 'null click, invalid option
  187.     Opt%% = 0
  188.   Clicked%% = FALSE
  189.  DO: Nul = _MOUSEINPUT: LOOP WHILE _MOUSEINPUT 'clear the mouse buffer
  190.  IF INKEY$ = CHR$(27) THEN QuitFlag%% = TRUE
  191.  
  192.  ' BackGroundMusic 'deal with the menus background music || Handled with Timer for now
  193.  
  194.  'debugging information area
  195.  ' LINE (600, 500)-STEP(160, 99), _RGB32(0), BF
  196.  ' _PRINTSTRING (600, 500), STR$(LastPlay!), Layer(1)
  197.  ' _PRINTSTRING (600, 524), STR$(Clicked%%), Layer(1)
  198.  ' _PRINTSTRING (600, 548), STR$(ButtonDown%%), Layer(1)
  199.  ' _PRINTSTRING (600, 572), STR$(Opt%%), Layer(1)
  200.  
  201. LOOP UNTIL QuitFlag%%
  202. 'Fade_Out _DISPLAY
  203. 'SND_FadeOut
  204.  
  205. 'shut down audio
  206. IF _SNDPLAYING(SFX(1)) THEN _SNDSTOP (SFX(1))
  207. IF _SNDPLAYING(SFX(2)) THEN _SNDSTOP (SFX(2))
  208. IF _SNDPLAYING(SFX(3)) THEN _SNDSTOP (SFX(3))
  209.  
  210. 'C%% = (800 - (740 - 14)) \ 2
  211. '_PUTIMAGE (C%%, 0), Layer(2), _DISPLAY, (14, 11)-(740, 149) 'Game Menu Title
  212.  
  213. SUB Create_ClickMap (Opt%%)
  214.  _DEST Layer(7)
  215.  CLS
  216.  SELECT CASE Opt%%
  217.   CASE MainMenu
  218.    LINE (328, 196)-STEP(127, 31), _RGB32(255, 255, 1), BF
  219.    LINE (328, 246)-STEP(127, 31), _RGB32(255, 255, 2), BF
  220.    LINE (336, 300)-STEP(111, 31), _RGB32(255, 255, 3), BF
  221.    LINE (292, 350)-STEP(199, 31), _RGB32(255, 255, 4), BF
  222.    LINE (328, 400)-STEP(127, 31), _RGB32(255, 255, 5), BF
  223.    LINE (350, 446)-STEP(95, 31), _RGB32(255, 255, 6), BF
  224.   CASE Options
  225.    LINE (255, 240)-STEP(16 * 16, 32), _RGB32(255, 255, 1), BF
  226.    LINE (255, 290)-STEP(16 * 16, 32), _RGB32(255, 255, 2), BF
  227.    LINE (252, 350)-STEP(287, 31), _RGB32(255, 255, 3), BF
  228.    LINE (348, 446)-STEP(87, 31), _RGB32(255, 255, 4), BF
  229.   CASE Help
  230.   CASE GameMode
  231.    'the actual game mode is unimportant, just the number of cards to layout.
  232.    Offset% = 175 / G.Level
  233.    Scaled% = 157 / G.Level
  234.    FOR y%% = 0 TO BoardY(G.Level * 2 - 1)
  235.     FOR x%% = 0 TO BoardX(G.Level * 2 - 1)
  236.      C%% = C%% + 1
  237.      LINE (50 + x%% * Offset%, 75 + y%% * Offset%)-STEP(Scaled%, Scaled%), _RGB32(64, 64, C%%), BF
  238.    NEXT x%%, y%%
  239.  _DEST Layer(7)
  240.  
  241. FUNCTION Mouse_Over~%% ()
  242.  Result~%% = 0 'just in case?
  243.  Result~%% = _BLUE32(POINT(_MOUSEX, _MOUSEY)) 'get our blue value for option under mouse
  244.  Mouse_Over = Result~%%
  245.  
  246. SUB Build_Screens (Opt%%)
  247.  ClearLayer Layer(8)
  248.  SELECT CASE Opt%%
  249.   CASE MainMenu
  250.    Cx% = (800 - 464) \ 2 'Center the image on screen
  251.    Cy% = (600 - 396) \ 2
  252.    _PUTIMAGE (Cx%, Cy%), Layer(4), Layer(8) 'Title Screen Logo background
  253.    _PUTIMAGE (0, 64), Layer(3), Layer(8)
  254.    _PRINTSTRING (400 - 64, 200), "Game 1", Layer(8)
  255.    _PRINTSTRING (400 - 64, 250), "Game 2", Layer(8)
  256.    _PRINTSTRING (400 - 56, 300), " Help", Layer(8)
  257.    _PRINTSTRING (400 - 100, 350), "High Scores", Layer(8)
  258.    _PRINTSTRING (400 - 64, 400), "Options", Layer(8)
  259.    _PRINTSTRING (400 - 48, 450), " Quit", Layer(8)
  260.   CASE Options
  261.    _SETALPHA 96, , Layer(3) 'fade the image
  262.    _CLEARCOLOR _RGB32(0), Layer(3) 'restore clear color
  263.    Cx% = (800 - 464) \ 2 'Center the image on screen
  264.    Cy% = (600 - 396) \ 2
  265.    _PUTIMAGE (Cx%, Cy%), Layer(4), Layer(8) 'Title Screen Logo background
  266.    _PUTIMAGE (0, 64), Layer(3), Layer(8)
  267.    _SETALPHA 255, , Layer(3) 'restore opacity
  268.    _CLEARCOLOR _RGB32(0), Layer(3) 'restore clear color
  269.    _PRINTSTRING (400 - 120, 200), "Volume Level", Layer(8)
  270.    _PRINTSTRING (100, 250), "Music ", Layer(8)
  271.    _PRINTSTRING (100, 300), "Sounds", Layer(8)
  272.    _PRINTSTRING (400 - 144, 350), "Reset High Scores", Layer(8)
  273.    _PRINTSTRING (400 - 40, 450), "Exit", Layer(8)
  274.   CASE Help
  275.    ClearLayer Layer(9)
  276.    _PUTIMAGE , Layer(4), Layer(9)
  277.    _PRINTSTRING (16, 32), "In game mode one(1) the goal is to match", Layer(9)
  278.    _PRINTSTRING (16, 64), "Pup to Pup and Badge to Badge. Beat all 4", Layer(9)
  279.    _PRINTSTRING (16, 96), "levels quickly for high scores!", Layer(9)
  280.    _PRINTSTRING (16, 144), "In game mode two(2) the goal is to match", Layer(9)
  281.    _PRINTSTRING (16, 176), "Pup to badge. Make as many matches as", Layer(9)
  282.    _PRINTSTRING (16, 208), "possible in 120 seconds for high scores!", Layer(9)
  283.    _PRINTSTRING (16, 256), "Make matches by clicking on the back of", Layer(9)
  284.    _PRINTSTRING (16, 288), "the cards to reveal a pup or badge image.", Layer(9)
  285.    _PRINTSTRING (16, 320), "Depending on game mode they matched by", Layer(9)
  286.    _PRINTSTRING (16, 352), "Pup to Pup\Badge to Badge, or", Layer(9)
  287.    _PRINTSTRING (16, 384), "in game mode 2 Pup to Badge.", Layer(9)
  288.    Fade_In Layer(9)
  289.    DO
  290.     _PUTIMAGE , Layer(9), Layer(0)
  291.     _LIMIT 30
  292.    LOOP UNTIL INKEY$ <> ""
  293.    Fade_Out Layer(0)
  294.  
  295.   CASE HighScores
  296.    ClearLayer Layer(9)
  297.    _PUTIMAGE , Layer(4), Layer(9)
  298.    _PUTIMAGE (100, 0), Layer(11), Layer(9)
  299.    _PRINTSTRING (168, 160), "Names", Layer(9)
  300.    _PRINTSTRING (520, 160), "Times", Layer(9)
  301.    _PRINTSTRING (168, 365), "Names", Layer(9)
  302.    _PRINTSTRING (520, 365), "Matches", Layer(9)
  303.    IF _FILEEXISTS("Paws.HSL") THEN
  304.     N$ = SPACE$(26)
  305.     T$ = SPACE$(5)
  306.     OPEN "Paws.HSL" FOR BINARY AS #1
  307.     'Game time high scores (time to finish matches)
  308.     GET #1, , Count%%
  309.     FOR i%% = 1 TO Count%%
  310.      GET #1, , N$
  311.      GET #1, , T$
  312.      _PRINTSTRING (168, 192 + 24 * i%%), N$, Layer(9)
  313.      _PRINTSTRING (520, 192 + 24 * i%%), T$, Layer(9)
  314.     NEXT i%%
  315.     'Matches under timer (matches made in 120 sec
  316.     GET #1, , Count%%
  317.     FOR i%% = 1 TO Count%%
  318.      GET #1, , N$
  319.      GET #1, , T$
  320.      _PRINTSTRING (168, 397 + 24 * i%%), N$, Layer(9)
  321.      _PRINTSTRING (520, 397 + 24 * i%%), T$, Layer(9)
  322.     NEXT i%%
  323.    ELSE
  324.     _PRINTSTRING (168, 192 + 24 * i%%), "No game yet", Layer(9)
  325.     _PRINTSTRING (168, 397 + 24 * i%%), "No game yet", Layer(9)
  326.    END IF
  327.    CLOSE #1
  328.    Fade_In Layer(9)
  329.    DO
  330.     _PUTIMAGE , Layer(9), Layer(0)
  331.     _LIMIT 30
  332.    LOOP UNTIL INKEY$ <> ""
  333.    Fade_Out Layer(0)
  334.   CASE GameMode
  335.  
  336.  
  337. SUB Options_Menu
  338.  DO
  339.   Nul = _MOUSEINPUT
  340.   _PUTIMAGE , Layer(8), Layer(1) 'prep the menu layer to screen(erases old screen cycle)
  341.   _DEST Layer(1)
  342.   BGMV = G.BGMVol / 100: SFXV = G.SFXVol / 100
  343.   LINE (255, 240)-STEP(16 * 16, 32), _RGB32(0 + INT(255 * BGMV), 255 - INT(255 * BGMV), 0), BF
  344.   LINE (255, 290)-STEP(16 * 16, 32), _RGB32(0 + INT(255 * SFXV), 255 - INT(255 * SFXV), 0), BF
  345.   LINE (255 + (256 * BGMV), 236)-STEP(1, 40), _RGB32(224, 224, 224), B
  346.   LINE (255 + (256 * SFXV), 286)-STEP(1, 40), _RGB32(224, 224, 224), B
  347.   _DEST Layer(0)
  348.  
  349.   IF _MOUSEBUTTON(1) THEN 'lets see where the user clicked
  350.    Opt%% = Mouse_Over
  351.    ButtonDown%% = TRUE
  352.    Clicked%% = TRUE
  353.   ELSE
  354.    ButtonDown%% = FALSE
  355.   END IF
  356.  
  357.   'check over game options with click layer
  358.   SELECT CASE Mouse_Over
  359.    CASE 1 'Music Vol controller
  360.     _PRINTSTRING (100, 250), "Music ", Layer(1)
  361.    CASE 2 ' Sounds Vol Controller
  362.     _PRINTSTRING (100, 300), "Sounds", Layer(1)
  363.    CASE 3 ' Reset High Scores List
  364.     _PRINTSTRING (400 - 144, 350), "Reset High Scores", Layer(1)
  365.    CASE 4 ' Exit Options
  366.     _PRINTSTRING (400 - 40, 450), "Exit", Layer(1)
  367.  
  368.   _PUTIMAGE , Layer(1), Layer(0)
  369.   _LIMIT 60
  370.   IF (Clicked%% AND ButtonDown%% = FALSE) AND Opt%% > 2 THEN 'user clicked something lets see what.
  371.    SELECT CASE Opt%%
  372.     CASE 3 'Reset High Scores
  373.      IF _FILEEXISTS("Paws.HSL") THEN KILL "Paws.HSL" 'erase the highscore file
  374.     CASE 4 'Exit
  375.      ExitFlag%% = TRUE
  376.     CASE ELSE 'null click, invalid option
  377.      Opt%% = 0
  378.    END SELECT
  379.    Clicked%% = FALSE
  380.   ELSEIF ButtonDown%% THEN 'the volume controls are button down and slide
  381.    SELECT CASE Opt%%
  382.     CASE 1 'music
  383.      G.BGMVol = INT((_MOUSEX - 255) / 256 * 100)
  384.     CASE 2 'sounds
  385.      G.SFXVol = INT((_MOUSEX - 255) / 256 * 100)
  386.    END SELECT
  387.   ELSEIF Clicked%% THEN 'once released change volume levels
  388.    Clicked%% = FALSE
  389.    SetVolumes
  390.   END IF
  391.   DO: Nul = _MOUSEINPUT: LOOP WHILE _MOUSEINPUT 'clear the mouse buffer
  392.   IF INKEY$ = CHR$(27) THEN ExitFlag%% = TRUE
  393.   ' BackGroundMusic 'deal with the menus background music || Handled with Timer for now
  394.  LOOP UNTIL ExitFlag%%
  395.  
  396. SUB BackGroundMusic
  397.  STATIC LastPlay&
  398.  
  399.  IF LastPlay& = 0 THEN _SNDPLAY BGM(1) 'game just started
  400.  
  401.  IF _SNDPLAYING(BGM(1)) THEN
  402.   'main theme is still playing so nothing to do!
  403.   LastPlay& = TIMER '86399
  404.   IF LastPlay& > 86350 THEN LastPlay& = 0 'make the midnight jump (what are little kids doing up?)
  405.  
  406.   '-----------------------------Looping Music Section----------------------------------------
  407.  ELSEIF G.Status = MainMenu THEN 'user is in the menus
  408.  
  409.   '================================Menu Music Area===========================================
  410.   IF _SNDPLAYING(BGM(2)) THEN 'the instramental is playing
  411.    LastPlay& = TIMER '86399
  412.    IF LastPlay& > 86350 THEN LastPlay& = 0 'make the midnight jump (what are little kids doing up?)
  413.   ELSE
  414.    IF TIMER > LastPlay& + 20 AND TIMER < 86350 THEN _SNDPLAY BGM(2)
  415.   END IF
  416.   '==========================================================================================
  417.  
  418.  ELSEIF G.Status = GameMode THEN 'player is in game
  419.  
  420.   '================================Game Music Area===========================================
  421.   IF _SNDPLAYING(BGM(3)) THEN 'the instramental is playing
  422.    LastPlay& = TIMER '86399
  423.    IF LastPlay& > 86250 THEN LastPlay& = 0 'make the midnight jump (what are little kids doing up?)
  424.   ELSE
  425.    IF TIMER > LastPlay& + 10 AND TIMER < 86250 THEN _SNDPLAY BGM(3)
  426.   END IF
  427.   '==========================================================================================
  428.  '-------------------------------------------------------------------------------------------
  429.  
  430. SUB SetVolumes
  431.  FOR i%% = 1 TO LoadedMusic
  432.   _SNDVOL BGM(i%%), G.BGMVol / 100
  433.  NEXT i%%
  434.  FOR i%% = 1 TO LoadedSounds 'start at 1 so if 0 sounds loaded nothing is affected
  435.   _SNDVOL SFX(i%%), G.SFXVol / 100
  436.  NEXT i%%
  437.  
  438. SUB Display_Card (X%, Y%, id%%, Scale!)
  439.  'Scale options 1,1.5,2,2.5(Full,1\2,1\4,1\8[these values for refernce only, not correct])
  440.  'full-12 cards, 1.5- 24 cards, 2-48 cards, 2.5- 96 cards!
  441.  IF id%% THEN
  442.   _PUTIMAGE (X%, Y%)-STEP(157 / Scale!, 157 / Scale!), Layer(2), Layer(1), (Cards(id%%).X1, Cards(id%%).Y1)-(Cards(id%%).X2, Cards(id%%).Y2)
  443.  ELSE 'card 0 is back side
  444.   _PUTIMAGE (X%, Y%)-STEP(157 / Scale!, 157 / Scale!), Layer(2), Layer(1), (384, 166)-STEP(159, 159)
  445.  
  446. SUB Game_Mode1
  447.  DIM card(1) AS _BYTE 'what 2 cards are flipped
  448.  CardsLeft%% = (BoardX(G.Level * 2 - 1) + 1) * (BoardY(G.Level * 2 - 1) + 1) 'how many cards to match
  449.  Create_ClickMap GameMode 'set the click space
  450.  Setup_Cards G.Level 'ready the cards for matching
  451.  _DEST Layer(12)
  452.  DO
  453.   nul% = _MOUSEINPUT
  454.   IF _MOUSEBUTTON(1) THEN 'lets see where the user clicked
  455.    Opt%% = Mouse_Over
  456.    ButtonDown%% = TRUE
  457.    Clicked%% = TRUE
  458.   ELSE
  459.    ButtonDown%% = FALSE
  460.   END IF
  461.  
  462.   IF NOT ButtonDown%% AND Clicked%% THEN
  463.    IF Opt%% THEN 'dont allow 0 click area(black area)
  464.     IF Board(Opt%%).Flipped = FALSE THEN
  465.      Board(Opt%%).Flipped = TRUE
  466.      Clicked%% = FALSE
  467.      card(flipped%%) = Opt%% 'watch which cards are flipped
  468.      flipped%% = flipped%% + 1
  469.     END IF
  470.    END IF
  471.   END IF
  472.   tmp%% = Mouse_Over
  473.   '-------------------------screen update-----------------------
  474.   ClearLayer Layer(1)
  475.   _PRINTSTRING (5, 5), "Time   :", Layer(1)
  476.   _PRINTSTRING (5, 34), "Matches:", Layer(1)
  477.   Display_Game_Board_II
  478.   Display_Time_Elapsed
  479.   Display_Matches_Made
  480.   _PUTIMAGE , Layer(1), Layer(0)
  481.   _PUTIMAGE , Layer(12), Layer(0)
  482.   '-------------------------------------------------------------
  483.  
  484.   IF flipped%% = 2 THEN
  485.    flipped%% = 0 'reset our flipped card count
  486.    IF Board(card(0)).Id = Board(card(1)).Id THEN ' we have a match! :D
  487.     Board(card(0)).Matched = TRUE
  488.     Board(card(1)).Matched = TRUE
  489.     CardsLeft%% = CardsLeft%% - 2
  490.     G.Match = G.Match + 1
  491.     Card_Match_Animation card()
  492.    ELSE 'no match :(
  493.     Board(card(0)).Flipped = FALSE
  494.     Board(card(1)).Flipped = FALSE
  495.     _DELAY .5
  496.    END IF
  497.   END IF
  498.  
  499.   _LIMIT 60
  500.   DO: Nul = _MOUSEINPUT: LOOP WHILE _MOUSEINPUT 'clear the mouse buffer
  501.  
  502.   IF INKEY$ = CHR$(27) THEN ExitFlag%% = TRUE: G.Quit = TRUE
  503.  
  504.   IF CardsLeft%% = 0 THEN 'player wins this level!
  505.    G.Level = G.Level + .5
  506.    ExitFlag%% = TRUE
  507.   END IF
  508.  LOOP UNTIL ExitFlag%%
  509.  
  510. SUB Setup_Cards (opt%%)
  511.  FOR i%% = 0 TO 96 'erase card data
  512.   Board(i%%).Id = 0
  513.   Board(i%%).Flipped = FALSE
  514.   Board(i%%).Matched = FALSE
  515.  NEXT i%%
  516.  SELECT CASE G.Level
  517.   CASE Level_1 '12 cards
  518.    'not enough cards so just load the first 6 cards to match(pups and 1 badge{marshal's})
  519.    FOR i%% = 1 TO 12 STEP 2
  520.     J%% = J%% + 1
  521.     Board(i%%).Id = J%%
  522.     Board(i%% + 1).Id = Board(i%%).Id
  523.    NEXT i%%
  524.    cc%% = 12 'Card Count for the scramble
  525.   CASE Level_2 '24 cards
  526.    'add the 10 base cards then repeat 2
  527.    FOR i%% = 1 TO 24 STEP 2
  528.     J%% = J%% + 1
  529.     Board(i%%).Id = J%%
  530.     Board(i%% + 1).Id = Board(i%%).Id
  531.     IF J%% = 10 THEN J%% = 0 'start over
  532.    NEXT i%%
  533.    cc%% = 24 'Card Count for the scramble
  534.   CASE Level_3 '48 cards
  535.    'add the 10 base cards then repeat 2
  536.    FOR i%% = 1 TO 48 STEP 2
  537.     J%% = J%% + 1
  538.     Board(i%%).Id = J%%
  539.     Board(i%% + 1).Id = Board(i%%).Id
  540.     IF J%% = 10 THEN J%% = 0 'start over
  541.    NEXT i%%
  542.    cc%% = 48 'Card Count for the scramble
  543.   CASE Level_4 '70 cards
  544.    'add the 10 base cards then repeat 2
  545.    FOR i%% = 1 TO 70 STEP 2
  546.     J%% = J%% + 1
  547.     Board(i%%).Id = J%%
  548.     Board(i%% + 1).Id = Board(i%%).Id
  549.     IF J%% = 10 THEN J%% = 0 'start over
  550.    NEXT i%%
  551.    cc%% = 70 'Card Count for the scramble
  552.  'scramble cards
  553.  FOR i% = 0 TO 200
  554.   SWAP Board(INT(RND * cc%%) + 1), Board(INT(RND * cc%%) + 1)
  555.  NEXT i%
  556.  
  557. SUB Display_Game_Board (opt%%)
  558.  SELECT CASE opt%%
  559.   CASE Level_1 ' 12 full sized cards
  560.    FOR y%% = 0 TO 2
  561.     FOR x%% = 0 TO 3
  562.      C%% = C%% + 1
  563.      Board(C%%).X = x%%: Board(C%%).Y = y%%
  564.      IF NOT Board(C%%).Matched THEN
  565.       IF Board(C%%).Flipped THEN
  566.        Display_Card 50 + x%% * 175, 75 + y%% * 175, Board(C%%).Id, 1
  567.       ELSE
  568.        Display_Card 50 + x%% * 175, 75 + y%% * 175, 0, 1
  569.       END IF
  570.      END IF
  571.    NEXT x%%, y%%
  572.   CASE Level_2 '24 half sized cards
  573.    FOR y%% = 0 TO 3
  574.     FOR x%% = 0 TO 5
  575.      C%% = C%% + 1
  576.      IF NOT Board(C%%).Matched THEN
  577.       IF Board(C%%).Flipped THEN
  578.        Display_Card 50 + x%% * 115, 75 + y%% * 115, Board(C%%).Id, 1.5
  579.       ELSE
  580.        Display_Card 50 + x%% * 115, 75 + y%% * 115, 0, 1.5
  581.       END IF
  582.      END IF
  583.    NEXT x%%, y%%
  584.   CASE Level_3
  585.    FOR y%% = 0 TO 4
  586.     FOR x%% = 0 TO 7
  587.      C%% = C%% + 1
  588.      IF NOT Board(C%%).Matched THEN
  589.       IF Board(C%%).Flipped THEN
  590.        Display_Card 50 + x%% * 88, 75 + y%% * 88, Board(C%%).Id, 2
  591.       ELSE
  592.        Display_Card 50 + x%% * 88, 75 + y%% * 88, 0, 2
  593.       END IF
  594.      END IF
  595.    NEXT x%%, y%%
  596.   CASE Level_4
  597.    FOR y%% = 0 TO 6
  598.     FOR x%% = 0 TO 9
  599.      C%% = C%% + 1
  600.      IF NOT Board(C%%).Matched THEN
  601.       IF Board(C%%).Flipped THEN
  602.        Display_Card 50 + x%% * 64, 75 + y%% * 64, Board(C%%).Id, 2
  603.       ELSE
  604.        Display_Card 50 + x%% * 64, 75 + y%% * 64, 0, 2
  605.       END IF
  606.      END IF
  607.    NEXT x%%, y%%
  608.  
  609. SUB Display_Game_Board_II
  610.  Offset% = 175 / G.Level 'card spacing
  611.  FOR y%% = 0 TO BoardY(G.Level * 2 - 1)
  612.   FOR x%% = 0 TO BoardX(G.Level * 2 - 1)
  613.    C%% = C%% + 1
  614.    Board(C%%).X = x%%: Board(C%%).Y = y%%
  615.    IF NOT Board(C%%).Matched THEN 'if the card is matched do not display
  616.     IF Board(C%%).Flipped THEN 'if player has flipped card then display image
  617.      Display_Card 50 + x%% * Offset%, 75 + y%% * Offset%, Board(C%%).Id, G.Level
  618.     ELSE 'otherwise display back of card
  619.      Display_Card 50 + x%% * Offset%, 75 + y%% * Offset%, 0, G.Level
  620.     END IF
  621.    END IF
  622.  NEXT x%%, y%%
  623.  
  624. SUB CountTime
  625.  IF G.Status = GameMode THEN 'count time while playing
  626.   G.time = G.time + 1
  627.  ELSE 'when in menu reset game time
  628.   G.time = 0
  629.  
  630. SUB Display_Time_Elapsed
  631.  min$ = LTRIM$(STR$(G.time \ 60))
  632.  sec$ = LTRIM$(STR$(G.time MOD 60))
  633.  IF LEN(sec$) = 1 THEN sec$ = "0" + sec$
  634.  IF G.time \ 60 THEN T$ = min$ + ":" + sec$ ELSE T$ = sec$
  635.  _PRINTSTRING (160, 8), T$, Layer(1)
  636.  
  637. SUB Display_Matches_Made
  638.  _PRINTSTRING (160, 32), LTRIM$(STR$(G.Match)), Layer(1)
  639.  
  640. SUB Run_Victory
  641.  SND_FadeOut
  642.  MFI_Loader_victory "Victory.ANI"
  643.  
  644. SUB Card_Match_Animation (c() AS _BYTE)
  645.  TIMER(M&) OFF
  646.  _DEST Layer(0)
  647.  Offset% = 175 / G.Level 'card spacing
  648.  'blank out cards
  649.  LINE (50 + Board(c(0)).X * Offset%, 75 + Board(c(0)).Y * Offset%)-STEP(157 / G.Level, 157 / G.Level), _RGB32(0), BF
  650.  LINE (50 + Board(c(1)).X * Offset%, 75 + Board(c(1)).Y * Offset%)-STEP(157 / G.Level, 157 / G.Level), _RGB32(0), BF
  651.  'make a tme copy of the desktop
  652.  '----------------------card start points----------------------------
  653.  StartX! = 50 + Board(c(0)).X * Offset%
  654.  StartY! = 75 + Board(c(0)).Y * Offset%
  655.  Start2X! = 50 + Board(c(1)).X * Offset%
  656.  Start2Y! = 75 + Board(c(1)).Y * Offset%
  657.  '-------------------------------------------------------------------
  658.  '----------------------distance to center---------------------------
  659.  IF StartX! < 320 THEN Card1X_dist% = 320 - StartX! ELSE Card1X_dist% = -(StartX! - 320)
  660.  IF StartY! < 220 THEN Card1Y_dist% = 220 - StartY! ELSE Card1Y_dist% = -(StartY! - 220)
  661.  IF Start2X! < 320 THEN Card2X_dist% = 320 - Start2X! ELSE Card2X_dist% = -(Start2X! - 320)
  662.  IF Start2Y! < 220 THEN Card2Y_dist% = 220 - Start2Y! ELSE Card2Y_dist% = -(Start2Y! - 220)
  663.  '-------------------------------------------------------------------
  664.  '------------travel per frame for 60 moves----------------
  665.  x1! = Card1X_dist% / 60
  666.  y1! = Card1Y_dist% / 60
  667.  x2! = Card2X_dist% / 60
  668.  y2! = Card2Y_dist% / 60
  669.  '---------------------------------------------------------
  670.  
  671.  DO
  672.   StartX! = StartX! + x1!
  673.   StartY! = StartY! + y1!
  674.   Start2X! = Start2X! + x2!
  675.   Start2Y! = Start2Y! + y2!
  676.  
  677.   _PUTIMAGE , tmp&, Layer(1)
  678.   Display_Card StartX!, StartY!, Board(c(0)).Id, G.Level
  679.   Display_Card Start2X!, Start2Y!, Board(c(1)).Id, G.Level
  680.   _PUTIMAGE , Layer(1), Layer(0)
  681.   IF INKEY$ = CHR$(27) THEN Exitflag%% = TRUE
  682.   _LIMIT 48
  683.   count% = count% + 1
  684.   IF count% = 61 THEN Exitflag%% = TRUE
  685.  LOOP UNTIL Exitflag%%
  686.  
  687.  Startx% = INT(StartX!)
  688.  Starty% = INT(StartX!) - 48
  689.  
  690.  FOR i! = 1 TO .25 STEP -.05
  691.   _PUTIMAGE , tmp&, Layer(1)
  692.   c% = c% + 15
  693.   Display_Card 5 + Startx% - c%, Starty% - c%, Board(c(0)).Id, i!
  694.   _PUTIMAGE , Layer(1), Layer(0)
  695.   _LIMIT 30
  696.  NEXT i!
  697.  _DELAY .75
  698.  
  699.  FOR i! = .25 TO 3.5 STEP .1
  700.   _PUTIMAGE , tmp&, Layer(1)
  701.   c% = c% - 20
  702.   Display_Card Startx% - c%, Starty% - c%, Board(c(0)).Id, i!
  703.   _PUTIMAGE (Startx% - c% - 33, Starty% - c% - 33)-STEP(190 / (i! - .05), 183 / (i! - .05)), Layer(14), Layer(1), (0 + 191 * f%%, 0)-STEP(190, 183)
  704.   _PUTIMAGE , Layer(1), Layer(0)
  705.   _LIMIT 17
  706.   f%% = f%% + 1
  707.   IF f%% = 30 THEN f%% = 0
  708.  NEXT i!
  709.  
  710.  TIMER(M&) ON
  711.  
  712. '$include:'PPMG_GFXRoutines.bas'
  713.  
  714. SUB MFI_Loader_victory (FN$)
  715.  DIM Size(128) AS LONG, FOffset(128) AS LONG
  716.  GET #1, , c~%% 'retrieve number of files
  717.  FOR I~%% = 1 TO c~%%
  718.   GET #1, , FOffset(I~%%)
  719.   GET #1, , Size(I~%%)
  720.   FOffset&(I~%%) = FOffset&(I~%%) + 1
  721.  NEXT I~%%
  722.  ClearLayer Layer(1)
  723.  ClearLayer Layer(0)
  724.  _SNDPLAY SFX(1)
  725.  DO
  726.   fr%% = fr%% + 1
  727.   tmp& = LoadGFX(FOffset(fr%%), Size(fr%%))
  728.   _PUTIMAGE (100, 192), tmp&, Layer(1)
  729.   _PUTIMAGE (135, 16), Layer(13), Layer(1)
  730.   _PUTIMAGE , Layer(1), Layer(0)
  731.   _LIMIT 16
  732.   IF fr%% = 95 THEN Exitflag%% = TRUE
  733.   _FREEIMAGE tmp&
  734.  LOOP UNTIL Exitflag%%
  735.  tmp& = LoadGFX(FOffset(92), Size(92))
  736.  _PUTIMAGE (100, 192), tmp&, Layer(1)
  737.  _PUTIMAGE (135, 16), Layer(13), Layer(1)
  738.  _PUTIMAGE , Layer(1), Layer(0)
  739.  _FREEIMAGE tmp&
  740.  _DELAY 4
  741.  CLOSE #1
  742.  IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"
  743.  
  744. FUNCTION LoadGFX& (Foff&, Size&)
  745.  IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"
  746.  OPEN "temp.dat" FOR BINARY AS #3
  747.  dat$ = SPACE$(Size&)
  748.  GET #1, Foff&, dat$
  749.  PUT #3, , dat$
  750.  CLOSE #3
  751.  LoadGFX& = _LOADIMAGE("temp.dat", 32)
  752.  
  753. FUNCTION LoadFFX& (Foff&, Size&, Fize%%, Att$)
  754.  IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"
  755.  OPEN "temp.dat" FOR BINARY AS #3
  756.  dat$ = SPACE$(Size&)
  757.  GET #1, Foff&, dat$
  758.  PUT #3, , dat$
  759.  CLOSE #3
  760.  LoadFFX& = _LOADFONT("temp.dat", Fize%%, Att$)
  761.  
  762. FUNCTION LoadSFX& (Foff&, Size&)
  763.  IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"
  764.  OPEN "temp.dat" FOR BINARY AS #3
  765.  dat$ = SPACE$(Size&)
  766.  GET #1, Foff&, dat$
  767.  PUT #3, , dat$
  768.  CLOSE #3
  769.  LoadSFX& = _SNDOPEN("temp.dat")
  770.  
  771. SUB LoadData (Foff&, Size&)
  772.  IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"
  773.  OPEN "temp.dat" FOR BINARY AS #3
  774.  dat$ = SPACE$(Size&)
  775.  GET #1, Foff&, dat$
  776.  PUT #3, , dat$
  777.  CLOSE #3
  778.  
  779. SUB MFI_Loader (FN$)
  780.  DIM Size(128) AS LONG, FOffset(128) AS LONG
  781.  GET #1, , c~%% 'retrieve number of files
  782.  FOR I~%% = 1 TO c~%%
  783.   GET #1, , FOffset(I~%%)
  784.   GET #1, , Size(I~%%)
  785.   FOffset&(I~%%) = FOffset&(I~%%) + 1
  786.  NEXT I~%%
  787.  '-----------------------Splash Screen setup-------------------------
  788.  _PRINTSTRING (0, 574), "Loading...", _DISPLAY
  789.  Splash& = LoadGFX(FOffset(9), Size(9)) 'Splash screen
  790.  BGM(1) = LoadSFX(FOffset(1), Size(1))
  791.  TIMER(T&) ON 'start the background musics
  792.  SetVolumes 'adjust volume levels
  793.  DO: _LIMIT 60: LOOP UNTIL _SNDGETPOS(BGM(1)) > 1
  794.  Fade_In Splash&
  795.  _PUTIMAGE , Splash&, _DISPLAY 'show the splash screen while loading
  796.  _PRINTSTRING (0, 574), "Loading..."
  797.  '-------------------------------------------------------------------
  798.  Layer(0) = _DISPLAY
  799.  Layer(1) = _COPYIMAGE(_DISPLAY) 'Mix layer
  800.  Layer(7) = _NEWIMAGE(800, 600, 32) 'click map layer
  801.  Layer(8) = _NEWIMAGE(800, 600, 32) 'Main Menu\Options Layer
  802.  Layer(9) = _NEWIMAGE(800, 600, 32) 'High Score\Help layer
  803.  Layer(10) = _NEWIMAGE(800, 600, 32) 'Mouse Over hi-lite layer
  804.  Layer(12) = _NEWIMAGE(800, 600, 32) 'debug info
  805.  
  806.  Layer(2) = LoadGFX(FOffset(2), Size(2)) 'Tiles
  807.  Layer(3) = LoadGFX(FOffset(3), Size(3)) 'Title
  808.  Layer(4) = LoadGFX(FOffset(4), Size(4)) 'BackGround
  809.  Layer(5) = LoadGFX(FOffset(5), Size(5)) 'Pups
  810.  Layer(6) = LoadGFX(FOffset(6), Size(6)) 'bitmap font
  811.  Layer(11) = LoadGFX(FOffset(7), Size(7)) 'high score title
  812.  Layer(13) = LoadGFX(FOffset(8), Size(8)) 'Victory screen title
  813.  Layer(14) = LoadGFX(FOffset(14), Size(14)) 'Match sparkle animation
  814.  BGM(2) = LoadSFX(FOffset(10), Size(10)) 'instramental theme
  815.  BGM(3) = LoadSFX(FOffset(11), Size(11)) 'extended instramental
  816.  SFX(1) = LoadSFX(FOffset(12), Size(12)) 'victory cheer
  817.  FFX(0) = LoadFFX(FOffset(13), Size(13), 36, "BOLD") 'main font
  818.  FFX(1) = LoadFFX(FOffset(13), Size(13), 24, "") 'high score font
  819.  FFX(2) = LoadFFX(FOffset(13), Size(13), 24, "MONOSPACE") 'help font
  820.  
  821.  CLOSE #1
  822.  IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"
  823.  
* PawsV1b.MFI (Filesize: 5.4 MB, Downloads: 219)
Granted after becoming radioactive I only have a half-life!

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: A Game for those with children (or who are children themselves!)
« Reply #6 on: September 03, 2021, 04:55:02 pm »
The splash screen looks very professional. It's no easy task to design a good logo and color scheme.

Pete
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/