Author Topic: Fantasy  (Read 7925 times)

0 Members and 1 Guest are viewing this topic.

Offline Juan Tamarit

  • Newbie
  • Posts: 53
    • View Profile
Re: Fantasy
« Reply #15 on: June 18, 2021, 12:57:20 pm »
Question: if i have dimensioned a global variable dinamic array (REDIM SHARED) in general program, can i REDIM _PRESERVE in a SUB or FUNCTION, or should i REDIM SHARED _PRESERVE? O i can't REDIM it in a SUB/FUNC?

FellippeHeitor

  • Guest
Re: Fantasy
« Reply #16 on: June 18, 2021, 01:42:32 pm »
If an array has been REDIM SHARED in the main module, you can REDIM _PRESERVE in a sub/function, but you must remember to specify the data type again (AS whatever type, or by using the type suffix).

Offline Juan Tamarit

  • Newbie
  • Posts: 53
    • View Profile
Re: Fantasy
« Reply #17 on: June 23, 2021, 05:06:03 pm »
Hello there again. Sorry for my ignorance, but in the next SUB:

Code: QB64: [Select]
  1. SUB drawWorld () ' <-  if i could came up with a random generator... geez
  2.  
  3.     DIM i%
  4.     DIM j%
  5.     DIM tmp%%
  6.     DIM orgFile&
  7.     DIM destFile&
  8.     DIM tmpWorlds&
  9.  
  10.     IF NOT _FILEEXISTS("tmpWorlds.txt") THEN '              if this file dosn't exists means that we started a new game. We must create the first map of the game, wich is a pre-arranged map of the Town
  11.         CHDIR ".\.." '                                      so we move back to data
  12.         CHDIR ".\worlds" '                                  and into the pre-worlds folder
  13.         'we are @ Fantasy\data\wolrds\
  14.         orgFile& = FREEFILE '                               we need two filehandles: one for origin file,
  15.         destFile& = FREEFILE '                              and another for destination file
  16.         OPEN "town.txt" FOR INPUT AS #orgFile& '            we will extract info from this file
  17.         OPEN "tmp.txt" FOR OUTPUT AS #destFile& '           and place it into this one
  18.         WHILE NOT EOF(orgFile&) '                           we make sure we read the full file
  19.             INPUT #orgFile&, tmp%% '    ¿ <---------------- DATA TRANSFER
  20.             PRINT #destFile&, tmp%% '   ¾
  21.         WEND '                                              done with that thing
  22.         CLOSE #orgFile& '  ¿ <----------------------------- close files
  23.         CLOSE #destFile& ' ¾
  24.         CHDIR ".\.." '                                      move back to data
  25.         'we are @ Fantasy\data\
  26.         NAME ".\worlds\tmp.txt" AS ".\tmp\tmpWorlds.txt" '  now we extract the file from worlds folder and put it on tmp folder with the right name
  27.         CHDIR ".\tmp" '                                     into tmp folder again, map ready for use
  28.         'we are @ Fantasy\data\tmp\
  29.     END IF
  30.  
  31.     IF lastMapWorking%% <> actualMapWorking%% THEN '        if map has changed we need to actualize the WolrdTiles%% array
  32.         tmpWorlds& = FREEFILE '                             get a handle
  33.         OPEN "tmpWorlds.txt" FOR INPUT AS #tmpWorlds& '     we will extract data from this file
  34.         INPUT #tmpWorlds&, tmp%% '                          we check the first number of the file
  35.         WHILE tmp%% <> actualMapWorking%% '                 if it isn't the number of the level we need to know
  36.             FOR i% = 0 TO 279 '            ¿
  37.                 INPUT #tmpWorlds&, tmp%% ' ³ <------------ walk over the info of this map (which is not what we need to know, but we skip that data)
  38.             NEXT i% '                      ¾
  39.             INPUT #tmpWorlds&, tmp%% '                      and get the next number for evaluate again (that should be the number of next map)
  40.         WEND '                                              keep doing this untill the right map number has been found
  41.         FOR j% = 0 TO 13 '                    ¿
  42.             FOR i% = 0 TO 19 '                ³
  43.                 INPUT #tmpWorlds&, tmp%% '    ³ <---------- then extract the data we need
  44.                 WorldTiles%%(i%, j%) = tmp%% '³             and load it into WorldTiles%% array !
  45.             NEXT i% '                         ³
  46.         NEXT j% '                             ¾
  47.         CLOSE #tmpWorlds& '                                 close the file
  48.         lastMapWorking%% = actualMapWorking%% '             and actualize map situation, so no need for reload until the map changes
  49.     END IF
  50.  
  51.     FOR j% = 0 TO 13 '                                                          ¿
  52.         FOR i% = 0 TO 19 '                                                      ³
  53.             _PUTIMAGE (i% * 32, j% * 32 + 32), WorldImg&(WorldTiles%%(i%, j%)) '³ actual drawing
  54.         NEXT i% '                                                               ³
  55.     NEXT j% '                                                                   ¾
  56.  

I'm having an error that stands "file already open", particularly in line "OPEN "tmp.txt" FOR OUTPUT AS #destFile&". Does this means that QB64 can't have 2 files simoultaneously open? Or i'm making a mistake in the coding? Again, sorry by my newbiesness, but i can't understand what is wrong whit this

Cheers to all bros in forum. Still waiting for comments on the idea of the program!

Offline Juan Tamarit

  • Newbie
  • Posts: 53
    • View Profile
Re: Fantasy
« Reply #18 on: June 23, 2021, 05:28:26 pm »
By the way, this is the version im actuly working on. Also attached the folder structure and assets as they work now:

Code: QB64: [Select]
  1. 'we are @ Fantasy\
  2. '----------------------------------------------------------------------------------------------------------Û    SETUP    Û--------------------------------------------------------------------------------------------------------------
  3. SCREEN _NEWIMAGE(640, 480, 32) ' enter in graphics mode 640x480 32 bith color depth
  4. _FULLSCREEN ' fullscreen mode, make it shine
  5. _MOUSEHIDE ' dont show OS cursor, we will use our own
  6. 'x = 20 cells
  7. 'y = 15 cells(14 in fact for gameplay, the upper one holds the HUD)
  8.  
  9. '----------------------------------------------------------------------------------------------------------Û VARAIABLES Û--------------------------------------------------------------------------------------------------------------
  10. 'Û PROGRAM GLOBALS Û- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  11. CONST FALSE = 0: CONST TRUE = NOT FALSE ' ying-yang
  12. DIM SHARED menuMain AS _BIT
  13. DIM SHARED menuPocket AS _BIT
  14. DIM SHARED menuSpells AS _BIT
  15. DIM SHARED menuStats AS _BIT
  16. DIM SHARED menuHelp AS _BIT
  17. DIM SHARED menuMap AS _BIT
  18. DIM SHARED playerTurn AS _BIT
  19. DIM SHARED HUDpromt$
  20.  
  21. 'im gonna use this?
  22. DIM SHARED drawFingerAs AS _BYTE
  23. DIM SHARED clockForFantasy AS _BYTE
  24. DIM SHARED historyTimeline AS _BYTE
  25. 'Û COLORS Û- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  26. CONST GREEN1 = _RGB32(215, 232, 148) ' lighter ¿
  27. CONST GREEN2 = _RGB32(174, 196, 64) '          ³ colors
  28. CONST GREEN3 = _RGB32(82, 127, 57) '           ³
  29. CONST GREEN4 = _RGB32(32, 70, 49) ' darker     Ù
  30.  
  31. 'Û IMAGES Û- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  32. DIM SHARED ArmorImg&(7): DIM SHARED ArrowImg&(2): DIM SHARED AxeImg&(7): DIM SHARED BarImg&(6): DIM SHARED BijouImg&(3): DIM SHARED BoltImg&(1): DIM SHARED BombImg&(2): DIM SHARED BookImg&(3): DIM SHARED BowImg&(2)
  33. DIM SHARED ChestImg&(1): DIM SHARED CrossbowImg&(1): DIM SHARED DirArrowImg&(12): DIM SHARED EnemyImg&(31): DIM SHARED FingerImg&(8): DIM SHARED GndItemsImg&(17): DIM SHARED HeartImg&(5): DIM SHARED HelmImg&(7)
  34. DIM SHARED HeroImg&(7): DIM SHARED HUDImg&(3): DIM SHARED KeyImg&(5): DIM SHARED LightImg&(7): DIM SHARED LvlImg&(10): DIM SHARED MoneyImg&(3): DIM SHARED PaperImg&(1): DIM SHARED PortalImg&(7): DIM SHARED PotionImg&(7)
  35. DIM SHARED ShieldImg&(7): DIM SHARED SpellImg&(5): DIM SHARED SwordImg&(7): DIM SHARED ThrowImg&(2): DIM SHARED WandImg&(7): DIM SHARED WorldImg&(23)
  36. DIM SHARED BlankImg&
  37.  
  38. 'Û MECHS Û- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  39. TYPE MECHANICAL
  40.     x AS INTEGER ' mouse x position
  41.     y AS INTEGER ' mouse y position
  42.     kind AS _BYTE
  43.     map AS _BYTE
  44.     state AS _BYTE
  45. REDIM SHARED Mechs(0) AS MECHANICAL
  46.  
  47. 'Û POINTER/MOUSE Û- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  48. TYPE POINTER '
  49.     x AS INTEGER ' mouse x position
  50.     y AS INTEGER ' mouse y position
  51.     image AS LONG ' mouse aspect
  52.     clickL AS _BYTE ' left click
  53.     clickR AS _BYTE ' right click
  54.     tmpClickL AS _BYTE '¿
  55.     tmpClickR AS _BYTE '³ debouncing
  56.     oldClickL AS _BYTE '³ stuff
  57.     oldClickR AS _BYTE
  58. DIM SHARED Finger AS POINTER ' create the mouse
  59.  
  60. 'Û HERO Û- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  61. TYPE USER '
  62.     x AS INTEGER ' x position
  63.     y AS INTEGER ' y position
  64.     id AS STRING ' player name
  65.     class AS _BYTE ' 0=Barbarian, 1=Clerig, 2=Assasin or 3=Wizard
  66.     lvl AS _BYTE ' current character level
  67.     strength AS _BYTE '¿
  68.     agility AS _BYTE ' ³ basic
  69.     power AS _BYTE '   ³ skills
  70.     vigor AS _BYTE '   Ù
  71.     life AS INTEGER ' actual life ammount
  72.     mana AS INTEGER ' actual life ammount
  73.     xp AS INTEGER ' actual experience level
  74.     nextXp AS INTEGER ' the next target for lvlUp
  75.     prevNextXp AS INTEGER '
  76.     attributePoints AS INTEGER
  77. DIM SHARED Hero AS USER ' create the hero
  78.  
  79. 'Û ITEMS Û- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  80. TYPE OBJECT
  81.     x AS INTEGER
  82.     y AS INTEGER
  83.     kind AS _BYTE
  84.     lvl AS _BYTE ' level of the object
  85.     ammount AS INTEGER ' can be simply 1 or more
  86.     special AS STRING '<--------------------------¿
  87.     map AS _BYTE 'MAP number OR -1 for POCKET     ³
  88. END TYPE '                                        ³
  89. ' ITEMS SPECIAL VARIABLE:-------------------------¾
  90. 's=adds strength; a=adds agility; p=adds power; v=adds vigor;¿ CAN BE
  91. 'd=adds defense; b=adds to base damage;m=adds to max damage; ³ FROM 1              eg:a1,v3,d2,etc...
  92. 'c=adds to chance TO HIT%,will be multiplied by 7;           ¾ TO 3
  93.  
  94. 't= teaches some spell, for books (0 to 5) ;
  95. 'r= cast a spell, for wands and scrolls (0 to 5);
  96.  
  97. 'u=unidentified (has no number?)
  98.  
  99. DIM SHARED Pocket(22) AS OBJECT
  100. DIM SHARED inHand AS OBJECT
  101. REDIM SHARED Items(0) AS OBJECT
  102.  
  103. 'Û WORLD Û- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  104. DIM SHARED WorldTiles%%(19, 13)
  105. DIM SHARED actualMapWorking%%
  106. DIM SHARED lastMapWorking%%
  107.  
  108. 'Û ENEMIES Û- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  109. TYPE PROGRAMMER '
  110.     x AS INTEGER ' x position
  111.     y AS INTEGER ' y position
  112.     map AS _BYTE ' in wich map enemy is
  113.     lvl AS _BYTE ' enemies level goes from 0 to 31, same as the image array
  114.     life AS INTEGER 'enemy remaining life
  115.  
  116. REDIM SHARED Enemy(3) AS PROGRAMMER ' create enemies
  117.  
  118. 'Û SPELLS Û- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  119. DIM SHARED SpellsIknow%%(5) ' array contains the level that the player knows from each one of the spells 0 to 5. Never will be greater than 10
  120. DIM SHARED turnsRemainingSpell%%(5) ' array contains how many more turns the spell will be ON,when reaches 0 spell is OFF
  121. DIM SHARED lastSpellSelected%%(1) ' array contain: 0=the number of the last spell use; 1= the level of the last spell used
  122.  
  123. '----------------------------------------------------------------------------------------------------------Û PRE-PROGRAM Û--------------------------------------------------------------------------------------------------------------
  124. checkForAssets
  125. loadImages
  126. _ICON SpellImg&(0)
  127. _TITLE "Fantasy"
  128. loadProgramInitialVariables
  129. MKDIR "tmp"
  130. CHDIR ".\tmp" 'we are @ Fantasy\tmp\
  131. '----------------------------------------------------------------------------------------------------------Û   PROGRAM   Û--------------------------------------------------------------------------------------------------------------
  132.     _LIMIT 60
  133.     CLS , GREEN3
  134.  
  135.     HUDpromt$ = "" '       ¿ reinitialize this variables
  136.     drawFingerAs%% = 1 '   ¾
  137.  
  138.     'What happened to the MUSIC????? XD
  139.  
  140.     getMouseData
  141.     thingsYouCanDoWithFinger
  142.     keyboardInputs
  143.  
  144.     IF Hero.life > calculateMaxLife% THEN Hero.life = calculateMaxLife%
  145.     IF Hero.mana > calculateMaxMana% THEN Hero.mana = calculateMaxMana%
  146.     actualizeMoneyAspect
  147.  
  148.     IF actualMapWorking%% > -1 THEN drawMyFantasy
  149.     IF menuStats` = TRUE THEN showTheStats
  150.     IF menuPocket` = TRUE THEN lookInPocket
  151.     IF menuSpells = TRUE THEN selectSomeSpell
  152.     IF menuMain` = TRUE THEN mainMenu
  153.     IF actualMapWorking%% > -1 THEN drawHUD
  154.     printHUDpromt HUDpromt$
  155.     drawFinger
  156.     TESTER
  157.     _DISPLAY
  158. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  159. SUB thingsYouCanDoWithFinger () '°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°Û ACTION PERFORMING Û°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
  160.     DIM tmp%
  161.  
  162.     IF playerTurn` = TRUE THEN
  163.         drawFingerAs%% = 1
  164.         IF menuPocket` = TRUE THEN
  165.             itemManipulation ' if you are looking at pocket you are allowed to manipulate items there
  166.             IF NOT inHand.lvl = -1 THEN drawFingerAs%% = 3 ' if lvl of inhand isn't -1 means you are holding something
  167.         END IF
  168.         IF menuMain` = FALSE AND menuPocket` = FALSE AND menuSpells` = FALSE AND menuStats` = FALSE THEN
  169.             tmp% = checkFingerSector%
  170.  
  171.  
  172.  
  173.  
  174.  
  175.         END IF
  176.     ELSE
  177.         drawFingerAs%% = 6
  178.     END IF
  179.  
  180. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  181. FUNCTION checkFingerSector% ()
  182.  
  183.     IF fingerIsOnSurface%(Hero.x - 32, Hero.y + 32, 32, 32) THEN '     sector 1
  184.         checkFingerSector% = 1
  185.     ELSEIF fingerIsOnSurface%(Hero.x, Hero.y + 32, 32, 32) THEN '      sector 2
  186.         checkFingerSector% = 2
  187.     ELSEIF fingerIsOnSurface%(Hero.x + 32, Hero.y + 32, 32, 32) THEN ' sector 3
  188.         checkFingerSector% = 3
  189.     ELSEIF fingerIsOnSurface%(Hero.x - 32, Hero.y, 32, 32) THEN '      sector 4
  190.         checkFingerSector% = 4
  191.     ELSEIF fingerIsOnSurface%(Hero.x, Hero.y, 32, 32) THEN '           sector 5
  192.         checkFingerSector% = 5
  193.     ELSEIF fingerIsOnSurface%(Hero.x + 32, Hero.y, 32, 32) THEN '      sector 6
  194.         checkFingerSector% = 6
  195.     ELSEIF fingerIsOnSurface%(Hero.x - 32, Hero.y - 32, 32, 32) THEN ' sector 7
  196.         checkFingerSector% = 7
  197.     ELSEIF fingerIsOnSurface%(Hero.x, Hero.y - 32, 32, 32) THEN '      sector 8
  198.         checkFingerSector% = 8
  199.     ELSEIF fingerIsOnSurface%(Hero.x + 32, Hero.y - 32, 32, 32) THEN ' sector 9
  200.         checkFingerSector% = 9
  201.     ELSE '                     nothing to do, further away from playable sectors
  202.         checkFingerSector% = 0
  203.     END IF
  204.  
  205. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  206. FUNCTION checkEnemyPresenceInSector% (sect%, orgX%, orgY%)
  207.     FOR i% = 1 TO UBOUND(Enemy)
  208.         IF Enemy(i%).map = actualMapWorking%% THEN
  209.             SELECT CASE sect%
  210.                 CASE 1: IF Enemy(i%).x = orgX% - 32 AND Enemy(i%).y = orgY% + 32 THEN checkEnemyPresenceInSector% = TRUE: EXIT FUNCTION
  211.                 CASE 2: IF Enemy(i%).x = orgX% AND Enemy(i%).y = orgY% + 32 THEN checkEnemyPresenceInSector% = TRUE: EXIT FUNCTION
  212.                 CASE 3: IF Enemy(i%).x = orgX% + 32 AND Enemy(i%).y = orgY% + 32 THEN checkEnemyPresenceInSector% = TRUE: EXIT FUNCTION
  213.                 CASE 4: IF Enemy(i%).x = orgX% - 32 AND Enemy(i%).y = orgY% THEN checkEnemyPresenceInSector% = TRUE: EXIT FUNCTION
  214.                 CASE 6: IF Enemy(i%).x = orgX% + 32 AND Enemy(i%).y = orgY% THEN checkEnemyPresenceInSector% = TRUE: EXIT FUNCTION
  215.                 CASE 7: IF Enemy(i%).x = orgX% - 32 AND Enemy(i%).y = orgY% - 32 THEN checkEnemyPresenceInSector% = TRUE: EXIT FUNCTION
  216.                 CASE 8: IF Enemy(i%).x = orgX% AND Enemy(i%).y = orgY% - 32 THEN checkEnemyPresenceInSector% = TRUE: EXIT FUNCTION
  217.                 CASE 9: IF Enemy(i%).x = orgX% + 32 AND Enemy(i%).y = orgY% - 32 THEN checkEnemyPresenceInSector% = TRUE: EXIT FUNCTION
  218.             END SELECT
  219.         END IF
  220.     NEXT i%
  221.     checkEnemyPresenceInSector% = FALSE
  222. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  223. FUNCTION checkItemPresenceInSector% (sect%, orgX%, orgY%)
  224.     FOR i% = 1 TO UBOUND(Items)
  225.         IF Items(i%).map = actualMapWorking%% THEN
  226.             SELECT CASE sect%
  227.                 CASE 1: IF Items(i%).x = orgX% - 32 AND Items(i%).y = orgY% + 32 THEN checkItemPresenceInSector% = TRUE: EXIT FUNCTION
  228.                 CASE 2: IF Items(i%).x = orgX% AND Items(i%).y = orgY% + 32 THEN checkItemPresenceInSector% = TRUE: EXIT FUNCTION
  229.                 CASE 3: IF Items(i%).x = orgX% + 32 AND Items(i%).y = orgY% + 32 THEN checkItemPresenceInSector% = TRUE: EXIT FUNCTION
  230.                 CASE 4: IF Items(i%).x = orgX% - 32 AND Items(i%).y = orgY% THEN checkItemPresenceInSector% = TRUE: EXIT FUNCTION
  231.                 CASE 5: IF Items(i%).x = orgX% AND Items(i%).y = orgY% THEN checkItemPresenceInSector% = TRUE: EXIT FUNCTION
  232.                 CASE 6: IF Items(i%).x = orgX% + 32 AND Items(i%).y = orgY% THEN checkItemPresenceInSector% = TRUE: EXIT FUNCTION
  233.                 CASE 7: IF Items(i%).x = orgX% - 32 AND Items(i%).y = orgY% - 32 THEN checkItemPresenceInSector% = TRUE: EXIT FUNCTION
  234.                 CASE 8: IF Items(i%).x = orgX% AND Items(i%).y = orgY% - 32 THEN checkItemPresenceInSector% = TRUE: EXIT FUNCTION
  235.                 CASE 9: IF Items(i%).x = orgX% + 32 AND Items(i%).y = orgY% - 32 THEN checkItemPresenceInSector% = TRUE: EXIT FUNCTION
  236.             END SELECT
  237.         END IF
  238.     NEXT i%
  239.     checkItemPresenceInSector% = FALSE
  240. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  241. FUNCTION checkWorldAtSector% (sect%, orgX%, orgY%)
  242.     SELECT CASE sect%
  243.         CASE 1:
  244.         CASE 2:
  245.         CASE 3:
  246.         CASE 4:
  247.         CASE 5:
  248.         CASE 6:
  249.         CASE 7:
  250.         CASE 8:
  251.         CASE 9:
  252.     END SELECT
  253. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  254. FUNCTION checkMechPresenceInSector% (sect%, orgX%, orgY%)
  255. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  256. SUB drawFinger
  257.     SELECT CASE drawFingerAs%%
  258.         CASE 0: _PUTIMAGE (Finger.x - 8, Finger.y - 8), FingerImg&(0) 'cross
  259.         CASE 1: _PUTIMAGE (Finger.x - 1, Finger.y - 1), FingerImg&(1) 'finger
  260.         CASE 2: _PUTIMAGE (Finger.x - 1, Finger.y - 1), FingerImg&(2) 'attack sword
  261.         CASE 3: _PUTIMAGE (Finger.x - 1, Finger.y - 1), FingerImg&(3) 'grabbing hand
  262.         CASE 4: _PUTIMAGE (Finger.x - 8, Finger.y - 8), FingerImg&(4) 'wait clock
  263.         CASE 5: _PUTIMAGE (Finger.x - 1, Finger.y - 1), FingerImg&(5) 'GO
  264.         CASE 6: _PUTIMAGE (Finger.x - 1, Finger.y - 1), FingerImg&(6) 'sand clock
  265.         CASE 7: _PUTIMAGE (Finger.x - 1, Finger.y - 1), FingerImg&(7) '?
  266.         CASE 8: _PUTIMAGE (Finger.x - 1, Finger.y - 1), FingerImg&(8) '!
  267.         CASE 11:
  268.         CASE 12:
  269.     END SELECT
  270. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  271. SUB allowedMotions (where%)
  272.  
  273.     SELECT CASE where%
  274.         CASE 1
  275.             printHUDpromt "Move down & left" '                        ¿
  276.             _PUTIMAGE (Finger.x - 8, Finger.y - 8), DirArrowImg&(9) ' ³
  277.             IF Finger.clickL THEN '                                   ³
  278.                 Hero.y = Hero.y + 32 '                                ³
  279.                 Hero.x = Hero.x - 32 '
  280.                 gameTurn% = 0
  281.             END IF '                                                  ¾
  282.         CASE 2
  283.             printHUDpromt "Move down" '                                ¿
  284.             _PUTIMAGE (Finger.x - 8, Finger.y - 8), DirArrowImg&(10) ' ³
  285.             IF Finger.clickL THEN '                                    ³
  286.                 Hero.y = Hero.y + 32 '
  287.                 gameTurn% = 0
  288.             END IF '                                                   ¾
  289.         CASE 3
  290.             printHUDpromt "Move down & right" '                       ¿
  291.             _PUTIMAGE (Finger.x - 8, Finger.y - 8), DirArrowImg&(2) ' ³
  292.             IF Finger.clickL THEN '                                   ³
  293.                 Hero.y = Hero.y + 32 '                                ³
  294.                 Hero.x = Hero.x + 32 '
  295.                 gameTurn% = 0
  296.             END IF '                                                  ¾
  297.         CASE 4
  298.             printHUDpromt "Move left" '                               ¿
  299.             _PUTIMAGE (Finger.x - 8, Finger.y - 8), DirArrowImg&(7) ' ³
  300.             IF Finger.clickL THEN '                                   ³
  301.                 Hero.x = Hero.x - 32 '
  302.                 gameTurn% = 0
  303.             END IF '                                                  ¾
  304.         CASE 5
  305.             printHUDpromt "Rest one turn" '                         ¿
  306.             _PUTIMAGE (Finger.x - 8, Finger.y - 8), FingerImg&(4) ' ¾
  307.  
  308.             '!!!!!!!!!!!!!!!!!!!!
  309.             IF Finger.clickL THEN '                                   ³
  310.                 gameTurn% = 0
  311.             END IF '                                                  ¾
  312.             '!!!!!!!!!!!!!!!!!!!!
  313.  
  314.  
  315.         CASE 6
  316.             printHUDpromt "Move right" '                              ¿
  317.             _PUTIMAGE (Finger.x - 8, Finger.y - 8), DirArrowImg&(1) ' ³
  318.             IF Finger.clickL THEN '                                   ³
  319.                 Hero.x = Hero.x + 32 '
  320.                 gameTurn% = 0
  321.             END IF '                                                  ¾
  322.         CASE 7
  323.             printHUDpromt "Move up & left" '                          ¿
  324.             _PUTIMAGE (Finger.x - 8, Finger.y - 8), DirArrowImg&(8) ' ³
  325.             IF Finger.clickL THEN '                                   ³
  326.                 Hero.y = Hero.y - 32 '                                ³
  327.                 Hero.x = Hero.x - 32 '
  328.                 gameTurn% = 0
  329.             END IF '                                                  ¾
  330.         CASE 8
  331.             printHUDpromt "Move up" '                                 ¿
  332.             _PUTIMAGE (Finger.x - 8, Finger.y - 8), DirArrowImg&(4) ' ³
  333.             IF Finger.clickL THEN '                                   ³
  334.                 Hero.y = Hero.y - 32 '
  335.                 gameTurn% = 0
  336.             END IF '                                                  ¾
  337.         CASE 9
  338.             printHUDpromt "Move up & right" '                         ¿
  339.             _PUTIMAGE (Finger.x - 8, Finger.y - 8), DirArrowImg&(3) ' ³
  340.             IF Finger.clickL THEN '                                   ³
  341.                 Hero.y = Hero.y - 32 '                                ³
  342.                 Hero.x = Hero.x + 32 '
  343.                 gameTurn% = 0
  344.             END IF '                                                  ¾
  345.         CASE 0
  346.             _PUTIMAGE (Finger.x - 1, Finger.y - 1), FingerImg&(0) ' normal finger
  347.     END SELECT
  348.  
  349.  
  350. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  351.  
  352. SUB mainMenu () '°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°Û MENUS Û°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
  353.     ' TO DO: allow acces to SAVE GAME & LOAD GAME
  354.  
  355.     drawMenuBack 240, 99, 391, 306
  356.  
  357.     LOCATE 8, 37 '          ¿
  358.     PRINT "FANTASY"; '      ¾  TITLE
  359.  
  360.     _PUTIMAGE (259, 103), SpellImg&(0) '¿ demoniac
  361.     _PUTIMAGE (340, 103), SpellImg&(0) 'Ù stars
  362.  
  363.     IF actualMapWorking%% > -1 THEN '                 are we already playing?
  364.         _PUTIMAGE (369, 108), HUDImg&(3) '            then this menu has to show this image
  365.         IF fingerIsOnSurface%(369, 108, 16, 16) THEN '
  366.             HUDpromt$ = "Back to game"
  367.             IF Finger.clickL THEN menuMain` = FALSE
  368.         END IF
  369.     END IF
  370.  
  371.     LOCATE 10, 36
  372.     IF fingerIsOnSurface%(280, 144, 72, 16) THEN
  373.         COLOR GREEN4, GREEN1
  374.         IF Finger.clickL THEN
  375.             COLOR GREEN1, GREEN4 ' so no wrong printing in newGame
  376.             menuMain` = FALSE
  377.             menuPocket = FALSE
  378.             menuSpells` = FALSE
  379.             menuStats` = FALSE
  380.             newGame
  381.         END IF
  382.     ELSE
  383.         COLOR GREEN1, GREEN4
  384.     END IF
  385.     PRINT "New  game";
  386.  
  387.     LOCATE 12, 36
  388.     IF fingerIsOnSurface%(280, 176, 72, 16) THEN
  389.         COLOR GREEN4, GREEN1
  390.         IF Finger.clickL THEN loadGame
  391.     ELSE
  392.         COLOR GREEN1, GREEN4
  393.     END IF
  394.     PRINT "Load game";
  395.  
  396.     LOCATE 14, 36
  397.     IF actualMapWorking%% > -1 THEN ' we only allowed to save if we are playing
  398.         IF fingerIsOnSurface%(280, 208, 72, 16) THEN
  399.             COLOR GREEN4, GREEN1
  400.             'IF Finger.clickL THEN actualMenuWorking% = -7 '<----------------WRONG! assign a variable for this
  401.         ELSE
  402.             COLOR GREEN1, GREEN4
  403.         END IF
  404.     ELSE
  405.         COLOR GREEN3, GREEN4 ' if NOT in game
  406.     END IF
  407.     PRINT "Save Game";
  408.  
  409.     LOCATE 16, 38
  410.     IF fingerIsOnSurface%(296, 240, 32, 16) THEN
  411.         COLOR GREEN4, GREEN1
  412.         IF Finger.clickL THEN
  413.             menuMain` = FALSE
  414.             menuHelp` = TRUE
  415.         END IF
  416.     ELSE
  417.         COLOR GREEN1, GREEN4
  418.     END IF
  419.     PRINT "Help";
  420.  
  421.     LOCATE 18, 38
  422.     IF fingerIsOnSurface%(296, 272, 32, 16) THEN
  423.         COLOR GREEN4, GREEN1
  424.         IF Finger.clickL THEN
  425.             exitProgram
  426.         END IF
  427.     ELSE
  428.         COLOR GREEN1, GREEN4
  429.     END IF
  430.     PRINT "Exit";
  431.  
  432.     IF actualMapWorking%% > -1 THEN
  433.         IF fingerIsOnSurface%(280, 144, 72, 16) THEN HUDpromt$ = "Start a new game"
  434.         IF fingerIsOnSurface%(280, 176, 72, 16) THEN HUDpromt$ = "Load a saved game"
  435.         IF fingerIsOnSurface%(280, 208, 72, 16) THEN HUDpromt$ = "Save current game"
  436.         IF fingerIsOnSurface%(296, 240, 32, 16) THEN HUDpromt$ = "Learn how to play"
  437.         IF fingerIsOnSurface%(296, 272, 32, 16) THEN HUDpromt$ = "Close and leave"
  438.     END IF
  439.  
  440.     COLOR GREEN1, GREEN4 ' don't conlictuate with other stuff
  441.  
  442. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  443. SUB exitProgram ()
  444.     unloadImages
  445.     CHDIR ".\.." 'to data
  446.     RMDIR "tmp"
  447.     SYSTEM
  448. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  449. SUB newGame () '!!!!!!! set me to 0 after testing
  450.  
  451.     DIM i%
  452.  
  453.     actualMapWorking%% = -1 'leave actual game
  454.     Hero.lvl = 1 ' start with a fresh character
  455.     Hero.class = -1
  456.     Hero.id = ""
  457.     Hero.xp = 0 '              ¿
  458.     Hero.nextXp = 100 '        ³ with no xp
  459.     Hero.prevNextXp = 0 '      ³
  460.     Hero.attributePoints = 2 ' ¾<------!!!!!!! set me to 0 after testing
  461.     FOR i% = 0 TO 5
  462.         SpellsIknow%%(i%) = 1 ' you don't know any spells 'CHANGE ME TO 0 AFTER TESTING
  463.     NEXT i%
  464.     chooseClass '¿ don't switch
  465.     enterName '  Ù the order!
  466.     'Û LOAD CHARACTER INITIAL VARIABLES Û
  467.     SELECT CASE Hero.class 'according to class
  468.         CASE 0 'Barbarian       ¿
  469.             Hero.strength = 20
  470.             Hero.agility = 10 ' ³ BARBARIAN
  471.             Hero.power = 5 '    ³ SKILLS
  472.             Hero.vigor = 15 '   Ù
  473.         CASE 1 ' Clerig         ¿
  474.             Hero.strength = 15
  475.             Hero.agility = 5 '  ³ CLERIG
  476.             Hero.power = 10 '   ³ SKILLS
  477.             Hero.vigor = 20 '   Ù
  478.         CASE 2 'Assasin         ¿
  479.             Hero.strength = 10
  480.             Hero.agility = 20 ' ³ ASSASIN
  481.             Hero.power = 5 '    ³ SKILLS
  482.             Hero.vigor = 15 '   Ù
  483.         CASE 3 'Wizard          ¿
  484.             Hero.strength = 5 ' ³
  485.             Hero.agility = 10 ' ³ WIZARD
  486.             Hero.power = 20 '   ³ SKILLS
  487.             Hero.vigor = 15 '   ³
  488.     END SELECT '                Ù
  489.  
  490.     Hero.life = calculateMaxLife%
  491.     Hero.mana = calculateMaxMana%
  492.  
  493.     FOR i% = 0 TO 22
  494.         cleanOnePocketSlot i% ' clearPocket
  495.     NEXT i%
  496.  
  497.     equipOurHero
  498.     loadEnemiesInitialVariables
  499.     loadMechsInitialVariables
  500.     'showHistory 0
  501.  
  502.     actualMapWorking%% = 0 ' ¿ we start
  503.     Hero.x = 32 '            ³ at this
  504.     Hero.y = 64 '            Ù place
  505.  
  506. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  507. SUB loadGame () 'INCOMPLETE
  508.  
  509.     DIM leaving%
  510.     DIM keyPress$
  511.     DIM i%
  512.     DIM heroName$
  513.     DIM inputNumber%
  514.     DIM inputNumber2%
  515.     DIM tmpString$
  516.     DIM slot&(2)
  517.  
  518.     leaving% = 0
  519.     CHDIR ".\.." 'to data
  520.     CHDIR ".\saved" 'into saved
  521.     DO
  522.         _LIMIT 60
  523.         CLS , GREEN3
  524.         getMouseData
  525.  
  526.         drawMenuBack 240, 99, 391, 306
  527.         COLOR GREEN1, GREEN4 '¿
  528.         LOCATE 8, 36 '        ³ TITLE
  529.         PRINT "LOAD  GAME"; ' Ù
  530.  
  531.         keyPress$ = INKEY$ '
  532.         IF keyPress$ <> "" THEN '
  533.             IF ASC(keyPress$) = 27 THEN leaving% = 1 '
  534.         END IF '
  535.  
  536.         FOR i% = 0 TO 2 '
  537.             drawItemSlots 252, 142 + (i% * 48) '
  538.             slot&(i%) = FREEFILE
  539.             COLOR GREEN1, GREEN4
  540.             LOCATE 10 + (i% * 3), 37
  541.             tmpString$ = ".\save" + _TRIM$(STR$(i% + 1))
  542.             IF _DIREXISTS(tmpString$) THEN
  543.                 CHDIR tmpString$
  544.                 tmpString$ = "s" + _TRIM$(STR$(i% + 1)) + "Game.txt"
  545.                 OPEN tmpString$ FOR INPUT AS #slot&(i%)
  546.                 INPUT #slot&(i%), heroName$
  547.                 INPUT #slot&(i%), inputNumber%
  548.                 INPUT #slot&(i%), inputNumber2%
  549.                 CLOSE #slot&(i%)
  550.                 CHDIR ".\.."
  551.                 tmpString$ = calculateNameOfHeroClass$(inputNumber%) '
  552.                 tmpString$ = tmpString$ + "(" + _TRIM$(STR$(inputNumber2%)) + ")" '
  553.                 IF fingerIsOnSurface%(252, 142 + (i% * 48), 123, 32) THEN '
  554.                     COLOR GREEN4, GREEN1 '
  555.                     'IF Finger.clickL THEN acceptedLoadGame(1): EXIT DO? or EXIT SUB?
  556.                 END IF '
  557.                 PRINT heroName$ '
  558.                 LOCATE 11 + (i% * 3), 37 '
  559.                 PRINT tmpString$ '
  560.                 _PUTIMAGE (252, 142 + (i% * 48)), calculateHeroImg&(inputNumber%, inputNumber2%) '
  561.             ELSE
  562.                 PRINT "Empty slot" '
  563.             END IF
  564.         NEXT i% '
  565.  
  566.         _PUTIMAGE (Finger.x, Finger.y), FingerImg&(1)
  567.         _DISPLAY
  568.     LOOP UNTIL leaving% = 1
  569.     CHDIR ".\.." ' back to data
  570.     CHDIR ".\tmp" 'and then to tmp
  571. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  572. SUB saveGame () 'INCOMPLETE
  573.     drawMenuBack 247, 99, 391, 274
  574.     LOCATE 8, 36 '    ¿ TITLE
  575.     PRINT "SAVE  GAME"; ' Ù
  576. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  577. SUB helpMenu () ' INCOMPLETE
  578.     LOCATE 1, 1
  579.     PRINT "How to play"
  580.  
  581. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  582. SUB chooseClass ()
  583.     DIM i% ' ¿ LOCALS
  584.     DIM ii%
  585.     DO
  586.         _LIMIT 60
  587.         getMouseData
  588.         CLS , GREEN3 'all screen clear on green3
  589.         drawMenuBack 240, 99, 398, 280
  590.         LOCATE 8, 35 '                                               ¿ TITLE
  591.         PRINT "CHOOSE CLASS"; ' Barbarian, Clerig, Assasin or Wizard Ù
  592.         FOR i% = 0 TO 3: drawItemSlots 252 + i% * 34, 139: NEXT i% ' slots for hero images
  593.         _PUTIMAGE (252, 139), HeroImg&(0) ' Barbarian ¿
  594.         _PUTIMAGE (286, 139), HeroImg&(2) ' Clerig    ³ characters
  595.         _PUTIMAGE (320, 139), HeroImg&(4) ' Assasin   ³ images
  596.         _PUTIMAGE (354, 139), HeroImg&(6) ' Wizard    Ù
  597.         LOCATE 14, 33: PRINT "Strength"; '¿ static
  598.         LOCATE 15, 34: PRINT "Agility"; ' ³ ATRIBUTTE
  599.         LOCATE 16, 36: PRINT "Power"; '   ³ WORDS
  600.         LOCATE 17, 36: PRINT "Vigor"; '   Ù
  601.         FOR i% = 0 TO 3 '                                             ¿
  602.             _PUTIMAGE (327, i% * 16 + 212), BarImg&(0) ' open         ³
  603.             _PUTIMAGE (367, i% * 16 + 212), BarImg&(6) ' close        ³ static
  604.             FOR ii% = 0 TO 3 '                                        ³ BARS
  605.                 _PUTIMAGE (ii% * 8 + 335, i% * 16 + 212), BarImg&(5)
  606.             NEXT ii% '                                                ³
  607.         NEXT i% '                                                     Ù
  608.         IF fingerIsOnSurface%(252, 139, 32, 32) THEN '    ¿
  609.             LOCATE 13, 37 '                               ³
  610.             PRINT "Barbarian"; '                          ³
  611.             barShowingPercentage 327, 212, 100 'STRENGTH  ³
  612.             barShowingPercentage 327, 228, 50 'AGILITY    ³ BARBARIAN
  613.             barShowingPercentage 327, 244, 25 'POWER      ³
  614.             barShowingPercentage 327, 260, 75 ' VIGOR     ³
  615.             IF Finger.clickL THEN Hero.class = 0 '        ¾
  616.         ELSEIF fingerIsOnSurface%(286, 139, 32, 32) THEN '¿
  617.             LOCATE 13, 38 '                               ³
  618.             PRINT "Clerig"; '                             ³
  619.             barShowingPercentage 327, 212, 75 'STRENGTH   ³
  620.             barShowingPercentage 327, 228, 25 'AGILITY    ³ CLERIG
  621.             barShowingPercentage 327, 244, 50 'POWER      ³
  622.             barShowingPercentage 327, 260, 100 ' VIGOR    ³
  623.             IF Finger.clickL THEN Hero.class = 1 '        ¾
  624.         ELSEIF fingerIsOnSurface%(320, 139, 32, 32) THEN '¿
  625.             LOCATE 13, 38 '                               ³
  626.             PRINT "Assasin"; '                            ³
  627.             barShowingPercentage 327, 212, 50 'STRENGTH   ³
  628.             barShowingPercentage 327, 228, 100 'AGILITY   ³ ASSASIN
  629.             barShowingPercentage 327, 244, 25 'POWER      ³
  630.             barShowingPercentage 327, 260, 75 ' VIGOR     ³
  631.             IF Finger.clickL THEN Hero.class = 2 '        ¾
  632.         ELSEIF fingerIsOnSurface%(354, 139, 32, 32) THEN '¿
  633.             LOCATE 13, 38 '                               ³
  634.             PRINT "Wizard"; '                             ³
  635.             barShowingPercentage 327, 212, 25 'STRENGTH   ³
  636.             barShowingPercentage 327, 228, 50 'AGILITY    ³ WIZARD
  637.             barShowingPercentage 327, 244, 100 'POWER     ³
  638.             barShowingPercentage 327, 260, 75 ' VIGOR     ³
  639.             IF Finger.clickL THEN Hero.class = 3 '        ³
  640.         END IF '                                          ¾
  641.         _PUTIMAGE (Finger.x - 1, Finger.y - 1), FingerImg&(1) ' show finger
  642.         _DISPLAY
  643.     LOOP UNTIL Hero.class <> -1 ' leave when we have a class
  644. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - - - - - - - - - - - -
  645. SUB enterName () '
  646.     DIM playerChoosingName$ '¿
  647.     DIM suffixForName$ '     ³
  648.     DIM key$ '               ³ LOCALS
  649.     DIM i% '                 ³
  650.     DIM ii% '                Ù
  651.     Hero.id = "" '             ¿ get ready for recive
  652.     playerChoosingName$ = "" ' Ù something
  653.     suffixForName$ = "the "
  654.     SELECT CASE Hero.class ' Hero.class in words                ¿
  655.         CASE 0: suffixForName$ = suffixForName$ + "Barbarian" ' ³
  656.         CASE 1: suffixForName$ = suffixForName$ + "Clerig" '    ³
  657.         CASE 2: suffixForName$ = suffixForName$ + "Assasin" '   ³ we already have
  658.         CASE 3: suffixForName$ = suffixForName$ + "Wizard" '    ³ an rpg class ;)
  659.     END SELECT '                                                ³
  660.     ii% = 40 - (LEN(suffixForName$) \ 2) ' center it            Ù
  661.     DO
  662.         _LIMIT 60
  663.         getMouseData
  664.         CLS , GREEN3 'all screen clear on green3
  665.         drawMenuBack 240, 99, 398, 274
  666.         LOCATE 8, 34 '              ¿ TITLE
  667.         PRINT "ENTER YOUR NAME"; '  Ù
  668.         drawItemSlots 303, 139 ' slot for hero image
  669.         SELECT CASE Hero.class ' images of possible hero chosen
  670.             CASE 0: _PUTIMAGE (303, 139), HeroImg&(0)
  671.             CASE 1: _PUTIMAGE (303, 139), HeroImg&(2)
  672.             CASE 2: _PUTIMAGE (303, 139), HeroImg&(4)
  673.             CASE 3: _PUTIMAGE (303, 139), HeroImg&(6)
  674.         END SELECT '
  675.         LOCATE 12, 32 '               ¿ print
  676.         PRINT "This story begins"; '  ³ text pre
  677.         LOCATE 13, 32 '               ³ name
  678.         PRINT "with a hero called"; ' Ù
  679.         key$ = INKEY$ ' get the key                                                                                                                     ¿
  680.         IF key$ <> "" THEN '                                                                                                                            ³
  681.             ' write                                                                                                                                     ³
  682.             IF LEN(playerChoosingName$) < 11 THEN '                                                                                                     ³ keyboard
  683.                 IF ((ASC(key$) > 96 AND ASC(key$) < 123)) THEN playerChoosingName$ = playerChoosingName$ + key$ '                                       ³ inputs
  684.             END IF '                                                                                                                                    ³ for this
  685.             IF LEN(playerChoosingName$) > 0 THEN ' if the name has at least one character                                                               ³ particular
  686.                 IF LEN(playerChoosingName$) = 1 THEN playerChoosingName$ = UCASE$(playerChoosingName$) 'capitalize the first one                        ³
  687.                 IF ASC(key$) = 8 THEN playerChoosingName$ = LEFT$(playerChoosingName$, LEN(playerChoosingName$) - 1) ' if backspace erease one letter   ³ menu
  688.                 IF ASC(key$) = 13 THEN Hero.id = playerChoosingName$ ' confirm name                                                                     ³
  689.             END IF '                                                                                                                                    ³
  690.         END IF '                                                                                                                                        Ù
  691.         i% = 40 - (LEN(playerChoosingName$) \ 2) '¿ print the name
  692.         LOCATE 14, i% '                           ³ the player is
  693.         PRINT playerChoosingName$; "_"; '         Ù actually writing
  694.         LOCATE 15, ii% '       ¿ print
  695.         PRINT suffixForName$; 'Ù "the " + Hero.class as words
  696.         _PUTIMAGE (287, 245), FingerImg&(5) ' GO ¿ print
  697.         _PUTIMAGE (335, 245), FingerImg&(0) ' X  Ù "buttons"
  698.         IF Finger.clickL THEN ' when u click                                                ¿
  699.             IF LEN(playerChoosingName$) > 0 THEN ' and some name has been written           ³
  700.                 ' if finger position ok, then confirm name                                  ³ mouse click
  701.                 IF fingerIsOnSurface%(287, 245, 16, 16) THEN Hero.id = playerChoosingName$ '³ inputs in
  702.             END IF '                                                                        ³ this particular
  703.             ' if u click on the cross erease the pre-name                                   ³ menu
  704.             IF fingerIsOnSurface(335, 245, 16, 16) THEN playerChoosingName$ = "" '          ³
  705.         END IF '                                                                            Ù
  706.         _PUTIMAGE (Finger.x - 1, Finger.y - 1), FingerImg&(1) ' show finger
  707.         _DISPLAY
  708.     LOOP UNTIL Hero.id <> "" ' leave here when we have a name
  709. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  710. SUB lookInPocket () 'what about in case of commerce or chest, bag, bones, etc....????
  711.  
  712.     drawMenuBack 320, 32, 639, 383 ' POCKET & EQUIPED
  713.     drawMenuBack 0, 384, 639, 479 ' ITEM INFO
  714.  
  715.     LOCATE 5, 48 '
  716.     PRINT "POCKET"; '
  717.     LOCATE 5, 67 '
  718.     PRINT "EQUIPPED"; '
  719.  
  720.     _PUTIMAGE (328, 40), HUDImg&(3)
  721.     IF fingerIsOnSurface%(328, 40, 16, 16) AND inHand.lvl = -1 THEN
  722.         HUDpromt$ = "Back to game"
  723.         IF Finger.clickL THEN menuPocket` = FALSE
  724.     END IF
  725.  
  726.     FOR i% = 0 TO 22
  727.         drawItemSlots Pocket(i%).x, Pocket(i%).y ' POCKET & EQUIPPED slots draw
  728.     NEXT i%
  729.  
  730.     LINE (480, 64)-(480, 351), GREEN1 ' divisory line
  731.  
  732.     FOR i% = 0 TO 22
  733.         IF fingerIsOnSurface(Pocket(i%).x, Pocket(i%).y, 32, 32) THEN itemInformation i% ' if mouse over an item inform
  734.     NEXT i%
  735.  
  736.  
  737.     drawItemsInPocket
  738. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  739. SUB selectSomeSpell () ' INCOMPLETE
  740.  
  741.     DIM i%, j%, x%, y%
  742.  
  743.     drawMenuBack 320, 32, 639, 383
  744.     drawMenuBack 0, 384, 639, 479 ' spell info board
  745.     LOCATE 5, 58: PRINT "SPELLS";
  746.     x% = 409
  747.     y% = 120
  748.     FOR i% = 0 TO 1
  749.         FOR j% = 0 TO 2
  750.             drawItemSlots x% + (j% * 54), y% + (i% * 54)
  751.         NEXT j%
  752.     NEXT i%
  753.     IF SpellsIknow%%(0) > 0 THEN _PUTIMAGE (409, 120), SpellImg&(0)
  754.     IF SpellsIknow%%(1) > 0 THEN _PUTIMAGE (463, 120), SpellImg&(1)
  755.     IF SpellsIknow%%(2) > 0 THEN _PUTIMAGE (517, 120), SpellImg&(2)
  756.     IF SpellsIknow%%(3) > 0 THEN _PUTIMAGE (409, 174), SpellImg&(3)
  757.     IF SpellsIknow%%(4) > 0 THEN _PUTIMAGE (463, 174), SpellImg&(4)
  758.     IF SpellsIknow%%(5) > 0 THEN _PUTIMAGE (517, 174), SpellImg&(5)
  759.  
  760.  
  761.     LOCATE 17, 59: PRINT "WAND";
  762.     drawItemSlots 447, 286
  763.     LOCATE 19, 62: PRINT "CHARGES";
  764.     LOCATE 20, 62
  765.     IF Pocket(2).kind = 15 THEN
  766.         IF INSTR(Pocket(2).special, "0") THEN
  767.             _PUTIMAGE (447, 286), SpellImg&(0)
  768.         ELSEIF INSTR(Pocket(2).special, "1") THEN
  769.             _PUTIMAGE (447, 286), SpellImg&(1)
  770.         ELSEIF INSTR(Pocket(2).special, "2") THEN
  771.             _PUTIMAGE (447, 286), SpellImg&(2)
  772.         ELSEIF INSTR(Pocket(2).special, "3") THEN
  773.             _PUTIMAGE (447, 286), SpellImg&(3)
  774.         ELSEIF INSTR(Pocket(2).special, "4") THEN
  775.             _PUTIMAGE (447, 286), SpellImg&(4)
  776.         ELSEIF INSTR(Pocket(2).special, "5") THEN
  777.             _PUTIMAGE (447, 286), SpellImg&(5)
  778.         END IF
  779.         PRINT _TRIM$(STR$(Pocket(2).ammount - 1)) + "/" + _TRIM$(STR$(calculateWandMaxCharges%(Pocket(2).lvl)))
  780.     ELSE
  781.         PRINT "-/-"
  782.     END IF
  783.  
  784.     _PUTIMAGE (328, 40), HUDImg&(3)
  785.     IF fingerIsOnSurface%(328, 40, 16, 16) AND inHand.lvl = -1 AND NOT menuMain` THEN
  786.         HUDpromt$ = "Back to game"
  787.         IF Finger.clickL THEN menuSpells` = FALSE
  788.     END IF
  789.  
  790. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  791. FUNCTION calculateNameOfHeroClass$ (heroClass%)
  792.     SELECT CASE heroClass%
  793.         CASE 0: calculateNameOfHeroClass$ = "Barbarian"
  794.         CASE 1: calculateNameOfHeroClass$ = "Clerig"
  795.         CASE 2: calculateNameOfHeroClass$ = "Assasin"
  796.         CASE 3: calculateNameOfHeroClass$ = "Wizard"
  797.     END SELECT
  798. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  799. SUB showTheStats () ' STILL HAVE TO: !!!ARROW FOR UPGRADING CAN'T APPEAR IF WE REACHED TOP OF SKILL FOR CLASS!!!!
  800.  
  801.     drawMenuBack 0, 32, 319, 383 '
  802.     'drawMenuBack 0, 384, 639, 479 ' ITEM
  803.     LOCATE 5, 18 '  ¿ TITLE
  804.     PRINT "STATS";
  805.  
  806.     _PUTIMAGE (297, 40), HUDImg&(3)
  807.     IF fingerIsOnSurface%(297, 40, 16, 16) AND inHand.lvl = -1 THEN
  808.         HUDpromt$ = "Back to game"
  809.         IF Finger.clickL THEN menuStats` = FALSE
  810.     END IF
  811.  
  812.     drawItemSlots 64, 96: _PUTIMAGE (64, 96), calculateHeroImg&(Hero.class, Hero.lvl)
  813.     drawItemSlots 144, 96: _PUTIMAGE (144, 104), LvlImg&(0): _PUTIMAGE (160, 104), LvlImg&(Hero.lvl)
  814.  
  815.     LOCATE 7, 28: PRINT Hero.id;
  816.     LOCATE 8, 28: PRINT calculateNameOfHeroClass$(Hero.class)
  817.  
  818.  
  819.     LOCATE 10, 19: PRINT "BASE NOW";
  820.  
  821.     'BASE
  822.     LOCATE 11, 12: PRINT "STRENGTH"; Hero.strength;
  823.     LOCATE 12, 13: PRINT "AGILITY"; Hero.agility;
  824.     LOCATE 13, 15: PRINT "POWER"; Hero.power;
  825.     LOCATE 14, 15: PRINT "VIGOR"; Hero.vigor;
  826.  
  827.     LOCATE 17, 6: PRINT "DAMAGE " + _TRIM$(STR$(calculateHeroBaseDmg%)) + " - " + _TRIM$(STR$(calculateHeroMaxDmg%));
  828.     LOCATE 17, 25: PRINT "TO HIT %"; calculateHeroChanceToHit%;
  829.     LOCATE 19, 17: PRINT "DEFENSE"; calculateHeroDefense%;
  830.     LOCATE 22, 14: PRINT "POINTS TO ADD"; Hero.attributePoints;
  831.  
  832.     IF Hero.attributePoints > 0 THEN ' if you have points
  833.  
  834.         _PUTIMAGE (184, 160), DirArrowImg&(4) ' strength         ¿
  835.         IF fingerIsOnSurface%(184, 160, 16, 16) THEN '           ³
  836.             printHUDpromt "Increase your strength" '             ³
  837.             IF Finger.clickL THEN '                              ³
  838.                 Hero.strength = Hero.strength + 1 '              ³
  839.                 Hero.attributePoints = Hero.attributePoints - 1
  840.             END IF '                                             ³
  841.         END IF '                                                 ³
  842.         _PUTIMAGE (184, 176), DirArrowImg&(4) ' agility          ³
  843.         IF fingerIsOnSurface%(184, 176, 16, 16) THEN '           ³
  844.             printHUDpromt "Increase your agility" '              ³
  845.             IF Finger.clickL THEN '                              ³
  846.                 Hero.agility = Hero.agility + 1 '                ³ ARROWS
  847.                 Hero.attributePoints = Hero.attributePoints - 1 '³ FOR
  848.             END IF '                                             ³ UPGRADING  <---------------Need to make functions for checking topStrength, topPower, etc... calculateHeroTopVigor
  849.         END IF '                                                 ³ SKILLS
  850.         _PUTIMAGE (184, 192), DirArrowImg&(4) ' power            ³
  851.         IF fingerIsOnSurface%(184, 192, 16, 16) THEN '           ³
  852.             printHUDpromt "Increase your power" '                ³
  853.             IF Finger.clickL THEN '                              ³
  854.                 Hero.power = Hero.power + 1 '                    ³
  855.                 Hero.attributePoints = Hero.attributePoints - 1
  856.             END IF '                                             ³
  857.         END IF '                                                 ³
  858.         _PUTIMAGE (184, 208), DirArrowImg&(4) ' vigor            ³
  859.         IF fingerIsOnSurface%(184, 208, 16, 16) THEN '           ³
  860.             printHUDpromt "Increase your vigor" '                ³
  861.             IF Finger.clickL THEN '                              ³
  862.                 Hero.vigor = Hero.vigor + 1 '                    ³
  863.                 Hero.attributePoints = Hero.attributePoints - 1
  864.             END IF '                                             ³
  865.         END IF '                                                 ¾
  866.     ELSE
  867.         'NOW
  868.         LOCATE 11, 23: PRINT calculateHeroActualStrength%;
  869.         LOCATE 12, 23: PRINT calculateHeroActualAgility%;
  870.         LOCATE 13, 23: PRINT calculateHeroActualPower%;
  871.         LOCATE 14, 23: PRINT calculateHeroActualVigor%;
  872.     END IF
  873.     LINE (179, 146)-(179, 219), GREEN1 ' separation line between BASE & NOW
  874.  
  875. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  876.  
  877. SUB lookAtMap () ' INCOMPLETE
  878.     drawMenuBack 16, 48, 624, 464
  879.     LOCATE 4, 38
  880.     PRINT "MAP"
  881.     'closeWindowButton 608, 52
  882. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  883.  
  884. SUB cleanYourHand () '°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°Û ITEMS Û°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
  885.     inHand.kind = -1
  886.     inHand.lvl = -1
  887.     inHand.ammount = 0
  888.     inHand.special = ""
  889. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  890. FUNCTION lookForSpaceInPocket% ()
  891.     DIM i%
  892.     FOR i% = 7 TO 22
  893.         IF Pocket(i%).kind = -1 THEN lookForSpaceInPocket% = i%: EXIT FUNCTION
  894.     NEXT i%
  895.     lookForSpaceInPocket% = FALSE
  896. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  897. SUB clearPocket ()
  898.     FOR i% = 0 TO 22
  899.         Pocket(i%).kind = -1
  900.         Pocket(i%).lvl = -1
  901.         Pocket(i%).ammount = 0
  902.         Pocket(i%).special = ""
  903.     NEXT i%
  904. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  905. SUB createItemInPocket (kind%, lvl%, ammount%, slot%, special$)
  906.     Pocket(slot%).kind = kind%
  907.     Pocket(slot%).lvl = lvl%
  908.     Pocket(slot%).ammount = ammount%
  909.     Pocket(slot%).special = special$
  910. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  911. SUB cleanOnePocketSlot (indexOfSlot%)
  912.     Pocket(indexOfSlot%).kind = -1
  913.     Pocket(indexOfSlot%).lvl = -1
  914.     Pocket(indexOfSlot%).ammount = 0
  915.     Pocket(indexOfSlot%).special = ""
  916. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  917. SUB drawItemsOnGround ()
  918.     FOR i% = 0 TO UBOUND(Items)
  919.         IF Items(i%).map = actualmapworking% THEN
  920.             _PUTIMAGE (Items(i%).x + 8, Items(i%).y + 8), calculateItemOnGroundImage&(Items(i%).kind)
  921.         END IF
  922.     NEXT i%
  923. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  924. SUB drawItemsInPocket ()
  925.     FOR i% = 0 TO 22
  926.         _PUTIMAGE (Pocket(i%).x, Pocket(i%).y), calculateItemImage&(Pocket(i%).kind, Pocket(i%).lvl)
  927.     NEXT i%
  928.     _PUTIMAGE (inHand.x - 16, inHand.y - 16), calculateItemImage&(inHand.kind, inHand.lvl)
  929. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  930. FUNCTION calculateItemOnGroundImage& (k%)
  931.     calculateItemOnGroundImage& = GndItemsImg&(k%)
  932. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  933. FUNCTION calculateItemImage& (kind%, lvl%) 'TO DO:case 18= history or special related items
  934.     SELECT CASE kind%
  935.         CASE -1: calculateItemImage& = BlankImg&
  936.         CASE 0: calculateItemImage& = KeyImg&(lvl%)
  937.         CASE 1: calculateItemImage& = PotionImg&(lvl%)
  938.         CASE 2: calculateItemImage& = PaperImg&(lvl%)
  939.         CASE 3: calculateItemImage& = BookImg&(lvl%)
  940.         CASE 4: calculateItemImage& = SwordImg&(lvl%)
  941.         CASE 5: calculateItemImage& = AxeImg&(lvl%)
  942.         CASE 6: calculateItemImage& = ThrowImg&(lvl%)
  943.         CASE 7: calculateItemImage& = BowImg&(lvl%)
  944.         CASE 8: calculateItemImage& = CrossbowImg&(lvl%)
  945.         CASE 9: calculateItemImage& = BombImg&(lvl%)
  946.         CASE 10: calculateItemImage& = ArrowImg&(lvl%)
  947.         CASE 11: calculateItemImage& = BoltImg&(lvl%)
  948.         CASE 12: calculateItemImage& = ArmorImg&(lvl%)
  949.         CASE 13: calculateItemImage& = HelmImg&(lvl%)
  950.         CASE 14: calculateItemImage& = ShieldImg&(lvl%)
  951.         CASE 15: calculateItemImage& = WandImg&(lvl%)
  952.         CASE 16: calculateItemImage& = MoneyImg&(lvl%)
  953.         CASE 17: calculateItemImage& = BijouImg&(lvl%)
  954.             'CASE 18: calculateItemImage& = WonderImg&(lvl%)
  955.     END SELECT
  956. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -.
  957. SUB actualizeMoneyAspect ()
  958.     FOR i% = 7 TO 22 '
  959.         IF Pocket(i%).kind = 16 AND Pocket(i%).lvl < 2 THEN '
  960.             IF Pocket(i%).ammount > 249 THEN '
  961.                 Pocket(i%).lvl = 1 '
  962.             ELSE '
  963.                 Pocket(i%).lvl = 0 '
  964.             END IF '
  965.         END IF '
  966.     NEXT i% '
  967.     IF inHand.kind = 16 AND inHand.lvl < 2 THEN '
  968.         IF inHand.ammount > 249 THEN '
  969.             inHand.lvl = 1 '
  970.         ELSE '
  971.             inHand.lvl = 0 '
  972.         END IF '
  973.     END IF '
  974. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  975. FUNCTION calculateWandMaxCharges% (lvl%)
  976.     calculateWandMaxCharges% = 20 + (lvl% * 5)
  977. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  978. FUNCTION calculateItemDefense% (kind%, lvl%, special$) 'TO DO:balance the game
  979.     DIM tmp%
  980.     tmp% = 0
  981.     SELECT CASE kind%
  982.         CASE 12: tmp% = 3 + 3 * lvl% ' ARMORS
  983.         CASE 13: tmp% = 1 + 1 * lvl% ' HELMS
  984.         CASE 14: tmp% = 2 + 2 * lvl% ' SHIELDS
  985.     END SELECT
  986.     IF special$ <> "" THEN
  987.         IF INSTR(special$, "d") THEN
  988.             tmp% = tmp% + VAL(RIGHT$(special$, 1))
  989.         END IF
  990.     END IF
  991.     calculateItemDefense% = tmp%
  992. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  993. FUNCTION calculateItemBaseDmg% (kind%, lvl%, special$) 'TO DO:balance the game
  994.     DIM tmp%
  995.     tmp% = 0
  996.     SELECT CASE kind%
  997.         CASE 4: tmp% = (lvl% + 1) * 2 '     SWORDS
  998.         CASE 5: tmp% = (lvl% + 1) * 3 '     AXES
  999.         CASE 6: tmp% = (lvl% + 1) '         THROWS
  1000.         CASE 7: tmp% = (lvl% + 1) * 2 '     BOWS
  1001.         CASE 8: tmp% = (lvl% + 1) * 3 '     CROSSBOWS
  1002.         CASE 9: tmp% = (lvl% + 1) * 15 '    BOMBS
  1003.         CASE 10: tmp% = (lvl% + 1) * 2 '    ARROWS
  1004.         CASE 11: tmp% = (lvl% + 1) * 3 '    BOLTS
  1005.         CASE 15: tmp% = (lvl% + 1) '        WANDS
  1006.     END SELECT
  1007.     IF special$ <> "" THEN
  1008.         IF INSTR(special$, "b") THEN
  1009.             tmp% = tmp% + VAL(RIGHT$(special$, 1))
  1010.         END IF
  1011.     END IF
  1012.     calculateItemBaseDmg% = tmp%
  1013. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1014. FUNCTION calculateItemMaxDmg% (kind%, lvl%, special$) 'TO DO: balance the game
  1015.     DIM k%
  1016.     DIM l%
  1017.     DIM s$
  1018.     DIM tmp%
  1019.     k% = kind%
  1020.     l% = lvl%
  1021.     s$ = special$
  1022.     SELECT CASE kind%
  1023.         CASE 4: tmp% = calculateItemBaseDmg%(k%, l%, s$) + 3 '              SWORDS
  1024.         CASE 5: tmp% = calculateItemBaseDmg%(k%, l%, s$) + 4 '              AXES
  1025.         CASE 6: tmp% = calculateItemBaseDmg%(k%, l%, s$) + 1 '              THROWS
  1026.         CASE 7: tmp% = calculateItemBaseDmg%(k%, l%, s$) + 2 '              BOWS
  1027.         CASE 8: tmp% = calculateItemBaseDmg%(k%, l%, s$) + 3 '              CROSSBOWS
  1028.         CASE 9: tmp% = calculateItemBaseDmg%(k%, l%, s$) + (l% + 1) * 5 '   BOMBS
  1029.         CASE 10: tmp% = calculateItemBaseDmg%(k%, l%, s$) + 1 '             ARROWS
  1030.         CASE 11: tmp% = calculateItemBaseDmg%(k%, l%, s$) + 2 '             BOLTS
  1031.         CASE 15: tmp% = calculateItemBaseDmg%(k%, l%, s$) + 1 '             WANDS
  1032.     END SELECT
  1033.     IF s$ <> "" THEN
  1034.         IF INSTR(s$, "m") THEN
  1035.             tmp% = tmp% + VAL(RIGHT$(s$, 1))
  1036.         END IF
  1037.     END IF
  1038.     calculateItemMaxDmg% = tmp%
  1039. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1040. FUNCTION nameAnItem$ (kind%, lvl%, special$) 'TO DO:case 18=history related items, scroll names?
  1041.  
  1042.     DIM tmp$
  1043.  
  1044.     SELECT CASE kind%
  1045.         CASE -1 ' nothing
  1046.             tmp$ = ""
  1047.         CASE 0 '  KEYS
  1048.             SELECT CASE lvl%
  1049.                 CASE 0: tmp$ = "Tiny"
  1050.                 CASE 1: tmp$ = "Elegant"
  1051.                 CASE 2: tmp$ = "Rare"
  1052.                 CASE 3: tmp$ = "Heavy"
  1053.                 CASE 4: tmp$ = "Criptyc"
  1054.                 CASE 5: tmp$ = "Twisted"
  1055.             END SELECT
  1056.             tmp$ = tmp$ + " key"
  1057.         CASE 1 '  POTIONS
  1058.             SELECT CASE lvl% '
  1059.                 CASE 0: tmp$ = "Minor"
  1060.                 CASE 1: tmp$ = "Light"
  1061.                 CASE 2: tmp$ = "Small"
  1062.                 CASE 3: tmp$ = "Medium"
  1063.                 CASE 4: nameAnItem$ = "Potion": EXIT FUNCTION
  1064.                 CASE 5: tmp$ = "Large"
  1065.                 CASE 6: tmp$ = "Big"
  1066.                 CASE 7: tmp$ = "Full"
  1067.             END SELECT
  1068.             tmp$ = tmp$ + " potion"
  1069.         CASE 2 '  PAPERS
  1070.             SELECT CASE lvl%
  1071.                 CASE 0: tmp$ = "Scroll"
  1072.                 CASE 1: tmp$ = "Map"
  1073.             END SELECT
  1074.         CASE 3 '  BOOKS
  1075.             SELECT CASE lvl%
  1076.                 CASE 0: tmp$ = "Ancient book"
  1077.                 CASE 1: tmp$ = "Old book"
  1078.                 CASE 2: tmp$ = "Tome"
  1079.                 CASE 3: tmp$ = "Enciclopedy"
  1080.             END SELECT
  1081.         CASE 4 '  SWORDS
  1082.             SELECT CASE lvl%
  1083.                 CASE 0: tmp$ = "Small"
  1084.                 CASE 1: tmp$ = "Curve"
  1085.                 CASE 2: tmp$ = "Templed"
  1086.                 CASE 3: tmp$ = "Medium"
  1087.                 CASE 4: nameAnItem$ = "Sabre" + itemSpecialSuffix$(special$): EXIT FUNCTION
  1088.                 CASE 5: tmp$ = "Sharpened"
  1089.                 CASE 6: tmp$ = "Celestial"
  1090.                 CASE 7: tmp$ = "Demoniac"
  1091.             END SELECT
  1092.             tmp$ = tmp$ + " sword"
  1093.         CASE 5 '  AXES
  1094.             SELECT CASE lvl%
  1095.                 CASE 0: tmp$ = "Bushcraft"
  1096.                 CASE 1: tmp$ = "Small"
  1097.                 CASE 2: nameAnItem$ = "Bardiche" + itemSpecialSuffix$(special$): EXIT FUNCTION
  1098.                 CASE 3: tmp$ = "Medium"
  1099.                 CASE 4: tmp$ = "Double"
  1100.                 CASE 5: tmp$ = "Sharp double"
  1101.                 CASE 6: tmp$ = "War"
  1102.                 CASE 7: tmp$ = "Demoniac"
  1103.             END SELECT
  1104.             tmp$ = tmp$ + " axe"
  1105.         CASE 6 '  THROWS
  1106.             SELECT CASE lvl%
  1107.                 CASE 0: tmp$ = "Light"
  1108.                 CASE 1: tmp$ = "Heavy"
  1109.                 CASE 2: nameAnItem$ = "Throwin knives": EXIT FUNCTION
  1110.             END SELECT
  1111.             tmp$ = tmp$ + " shurikens"
  1112.         CASE 7 '  BOWS
  1113.             SELECT CASE lvl%
  1114.                 CASE 0: tmp$ = "Hunter"
  1115.                 CASE 1: tmp$ = "Composite"
  1116.                 CASE 2: tmp$ = "War"
  1117.             END SELECT
  1118.             tmp$ = tmp$ + " bow"
  1119.         CASE 8 '  CROSSBOWS
  1120.             SELECT CASE lvl%
  1121.                 CASE 0: tmp$ = "Light"
  1122.                 CASE 1: tmp$ = "Heavy"
  1123.             END SELECT
  1124.             tmp$ = tmp$ + " crossbow"
  1125.         CASE 9 '  BOMBS
  1126.             SELECT CASE lvl%
  1127.                 CASE 0: tmp$ = "Small"
  1128.                 CASE 1: tmp$ = "Medium"
  1129.                 CASE 2: tmp$ = "Large"
  1130.             END SELECT
  1131.             tmp$ = tmp$ + " bombs"
  1132.         CASE 10 ' ARROWS
  1133.             SELECT CASE lvl%
  1134.                 CASE 0: tmp$ = "Light"
  1135.                 CASE 1: tmp$ = "Sharp"
  1136.                 CASE 2: tmp$ = "Heavy"
  1137.             END SELECT
  1138.             tmp$ = tmp$ + " arrows"
  1139.         CASE 11 ' BOLTS
  1140.             SELECT CASE lvl%
  1141.                 CASE 0: tmp$ = "Light"
  1142.                 CASE 1: tmp$ = "Heavy"
  1143.             END SELECT
  1144.             tmp$ = tmp$ + " bolts"
  1145.         CASE 12 ' ARMORS
  1146.             SELECT CASE lvl%
  1147.                 CASE 0: nameAnItem$ = "Leather vest" + itemSpecialSuffix$(special$): EXIT FUNCTION
  1148.                 CASE 1: nameAnItem$ = "Leather armor" + itemSpecialSuffix$(special$): EXIT FUNCTION
  1149.                 CASE 2: nameAnItem$ = "Ring mail" + itemSpecialSuffix$(special$): EXIT FUNCTION
  1150.                 CASE 3: tmp$ = "Small"
  1151.                 CASE 4: tmp$ = "Medium"
  1152.                 CASE 5: tmp$ = "Heavy"
  1153.                 CASE 6: tmp$ = "War"
  1154.                 CASE 7: tmp$ = "Full"
  1155.             END SELECT
  1156.             tmp$ = tmp$ + " plate"
  1157.         CASE 13 ' HELMS
  1158.             SELECT CASE lvl%
  1159.                 CASE 0: tmp$ = "Small"
  1160.                 CASE 1: tmp$ = "Medium"
  1161.                 CASE 2: tmp$ = "Full"
  1162.                 CASE 3: nameAnItem$ = "Half helm" + itemSpecialSuffix$(special$): EXIT FUNCTION
  1163.                 CASE 4: nameAnItem$ = "Full helm" + itemSpecialSuffix$(special$): EXIT FUNCTION
  1164.                 CASE 5: nameAnItem$ = "Small Helmet" + itemSpecialSuffix$(special$): EXIT FUNCTION
  1165.                 CASE 6: nameAnItem$ = "Great healmet" + itemSpecialSuffix$(special$): EXIT FUNCTION
  1166.                 CASE 7: nameAnItem$ = "Hellking Crown" + itemSpecialSuffix$(special$): EXIT FUNCTION
  1167.             END SELECT
  1168.             tmp$ = tmp$ + " cap"
  1169.         CASE 14 ' SHIELDS
  1170.             SELECT CASE lvl%
  1171.                 CASE 0: tmp$ = "Small"
  1172.                 CASE 1: tmp$ = "Medium"
  1173.                 CASE 2: tmp$ = "Large"
  1174.                 CASE 3: tmp$ = "Great"
  1175.                 CASE 4: tmp$ = "Bronze"
  1176.                 CASE 5: tmp$ = "Iron"
  1177.                 CASE 6: tmp$ = "Steel"
  1178.                 CASE 7: tmp$ = "War"
  1179.             END SELECT
  1180.             tmp$ = tmp$ + " shield"
  1181.         CASE 15 ' WANDS
  1182.             SELECT CASE lvl%
  1183.                 CASE 0: tmp$ = "Apprentice"
  1184.                 CASE 1: tmp$ = "Initiate"
  1185.                 CASE 2: tmp$ = "Learner"
  1186.                 CASE 3: tmp$ = "Academic"
  1187.                 CASE 4: tmp$ = "Sacred"
  1188.                 CASE 5: tmp$ = "Dark"
  1189.                 CASE 6: tmp$ = "Egiptian"
  1190.                 CASE 7: tmp$ = "Voodoo"
  1191.             END SELECT
  1192.             tmp$ = tmp$ + " wand"
  1193.         CASE 16 ' MONEY
  1194.             SELECT CASE lvl%
  1195.                 CASE 0: tmp$ = "Coins"
  1196.                 CASE 1: tmp$ = "Many coins"
  1197.                 CASE 2: tmp$ = "Crude gemstones"
  1198.                 CASE 3: tmp$ = "Gemstone"
  1199.             END SELECT
  1200.         CASE 17 ' BIJOUTERY
  1201.             SELECT CASE lvl%
  1202.                 CASE 0: tmp$ = "Circlet"
  1203.                 CASE 1: tmp$ = "Ring"
  1204.                 CASE 2: tmp$ = "Said"
  1205.                 CASE 3: tmp$ = "Necklace"
  1206.             END SELECT
  1207.             'CASE 18 '
  1208.             '    SELECT CASE lvl%
  1209.             '        CASE 0: tmp$ = "Dyran crystals"
  1210.             '        CASE 1: tmp$ = "The Orb"
  1211.             '    END SELECT
  1212.     END SELECT
  1213.     nameAnItem$ = tmp$ + itemSpecialSuffix$(special$)
  1214. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1215. FUNCTION itemSpecialSuffix$ (s$)
  1216.  
  1217.     DIM tmp$
  1218.  
  1219.     IF s$ <> "" THEN
  1220.         IF INSTR(s$, "s") THEN ' adds to STR
  1221.             SELECT CASE VAL(RIGHT$(s$, 1))
  1222.                 CASE 1: tmp$ = "might"
  1223.                 CASE 2: tmp$ = "warriors"
  1224.                 CASE 3: tmp$ = "titans"
  1225.             END SELECT
  1226.         ELSEIF INSTR(s$, "a") THEN ' adds to AGI
  1227.             SELECT CASE VAL(RIGHT$(s$, 1))
  1228.                 CASE 1: tmp$ = "reflex"
  1229.                 CASE 2: tmp$ = "swiftness"
  1230.                 CASE 3: tmp$ = "martiality"
  1231.             END SELECT
  1232.         ELSEIF INSTR(s$, "p") THEN ' adds to PWR
  1233.             SELECT CASE VAL(RIGHT$(s$, 1))
  1234.                 CASE 1: tmp$ = "ilusionism"
  1235.                 CASE 2: tmp$ = "invocation"
  1236.                 CASE 3: tmp$ = "necromancy"
  1237.             END SELECT
  1238.         ELSEIF INSTR(s$, "v") THEN ' adds to VIG
  1239.             SELECT CASE VAL(RIGHT$(s$, 1))
  1240.                 CASE 1: tmp$ = "youthness"
  1241.                 CASE 2: tmp$ = "longevity"
  1242.                 CASE 3: tmp$ = "eternity"
  1243.             END SELECT
  1244.         ELSEIF INSTR(s$, "d") THEN ' adds to DEF
  1245.             SELECT CASE VAL(RIGHT$(s$, 1))
  1246.                 CASE 1: tmp$ = "protection"
  1247.                 CASE 2: tmp$ = "guardian"
  1248.                 CASE 3: tmp$ = "angels"
  1249.             END SELECT
  1250.         ELSEIF INSTR(s$, "m") THEN ' adds to MAX DMG
  1251.             SELECT CASE VAL(RIGHT$(s$, 1))
  1252.                 CASE 1: tmp$ = "fatality"
  1253.                 CASE 2: tmp$ = "brutality"
  1254.                 CASE 3: tmp$ = "animality"
  1255.             END SELECT
  1256.         ELSEIF INSTR(s$, "b") THEN ' adds to BASE DMG
  1257.             SELECT CASE VAL(RIGHT$(s$, 1))
  1258.                 CASE 1: tmp$ = "craftmanship"
  1259.                 CASE 2: tmp$ = "technicism"
  1260.                 CASE 3: tmp$ = "engineering"
  1261.             END SELECT
  1262.         ELSEIF INSTR(s$, "c") THEN ' adds to TO HIT%
  1263.             SELECT CASE VAL(RIGHT$(s$, 1))
  1264.                 CASE 1: tmp$ = "aiming"
  1265.                 CASE 2: tmp$ = "exactitud"
  1266.                 CASE 3: tmp$ = "precision"
  1267.             END SELECT
  1268.         ELSEIF INSTR(s$, "t") OR INSTR(s$, "r") THEN ' teaches or can cast some spell
  1269.             SELECT CASE VAL(RIGHT$(s$, 1))
  1270.                 CASE 0: tmp$ = "firebolt"
  1271.                 CASE 1: tmp$ = "blessing"
  1272.                 CASE 2: tmp$ = "infravision"
  1273.                 CASE 3: tmp$ = "teleport"
  1274.                 CASE 4: tmp$ = "healing"
  1275.                 CASE 5: tmp$ = "mana shield"
  1276.             END SELECT
  1277.         ELSEIF INSTR(s$, "u") THEN ' unidentified
  1278.             itemSpecialSuffix$ = " (Unidentified)": EXIT FUNCTION
  1279.         END IF
  1280.         itemSpecialSuffix$ = " of " + tmp$
  1281.     ELSE
  1282.         itemSpecialSuffix$ = ""
  1283.     END IF
  1284.  
  1285. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1286. SUB fromPocketToHand (slotIndex%)
  1287.     inHand.kind = Pocket(slotIndex%).kind
  1288.     inHand.lvl = Pocket(slotIndex%).lvl
  1289.     inHand.ammount = Pocket(slotIndex%).ammount
  1290.     inHand.special = Pocket(slotIndex%).special
  1291.     cleanOnePocketSlot slotIndex%
  1292. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1293. SUB fromHandToPocket (slotIndex%)
  1294.     Pocket(slotIndex%).kind = inHand.kind
  1295.     Pocket(slotIndex%).lvl = inHand.lvl
  1296.     Pocket(slotIndex%).ammount = inHand.ammount
  1297.     Pocket(slotIndex%).special = inHand.special
  1298.     cleanYourHand
  1299. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1300. SUB dropItemToGround ()
  1301.     REDIM _PRESERVE Items(UBOUND(items) + 1) AS OBJECT ' increase the Items array index by one
  1302.     Items(UBOUND(Items)).x = Hero.x '
  1303.     Items(UBOUND(Items)).y = Hero.y '
  1304.     Items(UBOUND(Items)).kind = inHand.kind '
  1305.     Items(UBOUND(Items)).lvl = inHand.lvl '
  1306.     Items(UBOUND(Items)).ammount = inHand.ammount '
  1307.     Items(UBOUND(Items)).special = inHand.special '
  1308.     Items(UBOUND(Items)).map = actualMapWorking%% '
  1309.     cleanYourHand
  1310. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1311. SUB pickItemFromGround (indexOfItem%)
  1312.     IF lookForSpaceInPocket% THEN '                                                 if theres place in your pocket
  1313.         IF indexOfItem% = UBOUND(Items) THEN '                                      and that item is the last one of the array
  1314.             Pocket(lookForSpaceInPocket%).kind = Items(idexOfItem%).kind '      ¿
  1315.             Pocket(lookForSpaceInPocket%).lvl = Items(idexOfItem%).lvl '        ³   Transfer the data of the item to
  1316.             Pocket(lookForSpaceInPocket%).ammount = Items(idexOfItem%).ammount '³   the free place on Pocket
  1317.             Pocket(lookForSpaceInPocket%).special = Items(idexOfItem%).special
  1318.             REDIM _PRESERVE Items(UBOUND(Items) - 1) AS OBJECT '                    and reduce the array by one (destroying the last one)
  1319.         ELSE ' but if the item is not the last one of the array
  1320.             Pocket(lookForSpaceInPocket%).kind = Items(idexOfItem%).kind '      ¿
  1321.             Pocket(lookForSpaceInPocket%).lvl = Items(idexOfItem%).lvl '        ³   Transfer the data of the item to
  1322.             Pocket(lookForSpaceInPocket%).ammount = Items(idexOfItem%).ammount '³   the free place on Pocket
  1323.             Pocket(lookForSpaceInPocket%).special = Items(idexOfItem%).special
  1324.             Items(indexOfItem%).x = Items(UBOUND(Items)).x '                    ¿
  1325.             Items(indexOfItem%).y = Items(UBOUND(Items)).y '                    ³
  1326.             Items(indexOfItem%).kind = Items(UBOUND(Items)).kind '              ³   copy all the data of the last item
  1327.             Items(indexOfItem%).lvl = Items(UBOUND(Items)).lvl '                ³   in the array to this index of the array,
  1328.             Items(indexOfItem%).ammount = Items(UBOUND(Items)).ammount '        ³   overwriting the item we just picked
  1329.             Items(indexOfItem%).special = Items(UBOUND(Items)).special '        ³
  1330.             Items(indexOfItem%).map = Items(UBOUND(Items)).map '                ¾
  1331.             REDIM _PRESERVE Items(UBOUND(Items) - 1) AS OBJECT '                    now we can eliminate the last item of the array (it has been copied to the picked item index)
  1332.         END IF
  1333.     ELSE '                                                                          if you have no room in pocket
  1334.         HUDpromt$ = "You have no room on your pocket" '                             you should be aware of it
  1335.     END IF
  1336. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1337. SUB itemManipulation () 'TO DO: reading scrolls
  1338.     DIM i%
  1339.     DIM special$
  1340.     DIM specialNum%
  1341.  
  1342.     FOR i% = 7 TO 22 ' INVENTORY
  1343.         IF fingerIsOnSurface%(Pocket(i%).x, Pocket(i%).y, 32, 32) THEN
  1344.             IF NOT itemRequirementsMet%(i%) THEN HUDpromt$ = "Requirements don't met"
  1345.             IF Finger.clickL AND (Pocket(i%).lvl <> -1 AND inHand.lvl = -1) THEN 'grabbing an item from a slot
  1346.                 fromPocketToHand i%
  1347.             ELSEIF Finger.clickL AND (Pocket(i%).lvl = -1 AND inHand.lvl <> -1) THEN 'droping an item into an empty slot
  1348.                 fromHandToPocket i%
  1349.             ELSEIF Finger.clickL AND inHand.lvl <> -1 AND Pocket(i%).kind = inHand.kind THEN 'trying to add multiple instances of the same thing
  1350.                 checkForAddingAmmounts i%
  1351.             END IF
  1352.             IF Finger.clickR THEN ' if RIGHT click
  1353.                 SELECT CASE Pocket(i%).kind
  1354.                     CASE 1 ' potions
  1355.                         SOUND 440, 1
  1356.                         Hero.life = Hero.life + (Pocket(i%).lvl + 1) * 5 ' increase helth ¿ DRINKING A POTION
  1357.                         cleanOnePocketSlot i% '                      and destroy the item ¾
  1358.                     CASE 2 ' papers
  1359.                         IF Pocket(i%).lvl = 1 THEN '¿
  1360.                             menuPocket` = FALSE '   ³ READING THE MAP
  1361.                             menuSpells` = FALSE '   ³
  1362.                             menuStats` = FALSE '    ³
  1363.                             menuMap` = TRUE '       ¾
  1364.                         ELSEIF Pocket(i%).lvl = 0 THEN '¿
  1365.                             '                           ³ TO DO: reading a scroll
  1366.                         END IF '                        ¾
  1367.  
  1368.                     CASE 3 'books
  1369.                         IF itemRequirementsMet%(i%) THEN
  1370.                             specialNum% = VAL(RIGHT$(Pocket(i%).special, 1)) 'convert the second digit of special into a value and the CASE SELECT it for adding 1 to the corrresponding spell, if is't less than 10
  1371.                             SELECT CASE specialNum%
  1372.                                 CASE 0: IF SpellsIknow%%(0) < 10 THEN SpellsIknow%%(0) = spellsiknow%% + 1
  1373.                                 CASE 1: IF SpellsIknow%%(1) < 10 THEN SpellsIknow%%(1) = spellsiknow%% + 1
  1374.                                 CASE 2: IF SpellsIknow%%(2) < 10 THEN SpellsIknow%%(2) = spellsiknow%% + 1
  1375.                                 CASE 3: IF SpellsIknow%%(3) < 10 THEN SpellsIknow%%(3) = spellsiknow%% + 1
  1376.                                 CASE 4: IF SpellsIknow%%(4) < 10 THEN SpellsIknow%%(4) = spellsiknow%% + 1
  1377.                                 CASE 5: IF SpellsIknow%%(5) < 10 THEN SpellsIknow%%(5) = spellsiknow%% + 1
  1378.                             END SELECT
  1379.                             cleanOnePocketSlot i% '                         and destroy the item
  1380.                         ELSE '                                              if requirements aren't met or spell is lvl 10 already
  1381.                             SOUND 220, 1 '                                  play "booooooo" sound
  1382.                         END IF
  1383.                 END SELECT
  1384.             END IF
  1385.         END IF
  1386.     NEXT i%
  1387.  
  1388.     FOR i% = 0 TO 6 ' EQUIPPED
  1389.         IF fingerIsOnSurface%(Pocket(i%).x, Pocket(i%).y, 32, 32) THEN
  1390.             IF Finger.clickL AND (Pocket(i%).lvl <> -1 AND inHand.lvl = -1) THEN
  1391.                 fromPocketToHand i% ' if LEFT click grab an item from a slot. No big deal on this
  1392.             ELSEIF Finger.clickL AND inHand.lvl <> -1 AND Pocket(i%).kind = inHand.kind AND Pocket(i%).lvl = inHand.lvl THEN 'trying to add multiple instances of the same thing
  1393.                 checkForAddingAmmounts i%
  1394.             ELSEIF Pocket(i%).lvl = -1 AND inHand.lvl <> -1 THEN 'droping an item into a slot needs to check and inform some things
  1395.                 IF itemFitsEquipmentSlot%(i%) THEN
  1396.                     IF itemRequirementsMet%(0) THEN
  1397.                         IF Finger.clickL THEN fromHandToPocket i%
  1398.                     ELSE
  1399.                         HUDpromt$ = "Requirements not met"
  1400.                     END IF
  1401.                 END IF
  1402.             END IF
  1403.         END IF
  1404.     NEXT i%
  1405.     IF Finger.clickL AND inHand.kind <> -1 AND fingerIsOnSurface%(0, 32, 319, 384) THEN dropItemToGround
  1406. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1407. SUB checkForAddingAmmounts (indexOfSlot%) ' in a single slot you can fir: 500 coins; 100 throws; 75 arrows, 50 bolts or 6 bombs
  1408.     DIM tmp1%
  1409.     IF Pocket(indexOfSlot%).lvl = inHand.lvl THEN
  1410.         SELECT CASE inHand.kind
  1411.             CASE 6 '                                                                                    throws
  1412.                 IF inHand.ammount + Pocket(indexOfSlot%).ammount > 100 THEN
  1413.                     tmp1% = 100 - Pocket(indexOfSlot%).ammount
  1414.                     Pocket(indexOfSlot%).ammount = Pocket(indexOfSlot%).ammount + tmp1%
  1415.                     inHand.ammount = inHand.ammount - tmp1%
  1416.                 ELSE
  1417.                     Pocket(indexOfSlot%).ammount = Pocket(indexOfSlot%).ammount + inHand.ammount
  1418.                     cleanYourHand
  1419.                 END IF
  1420.             CASE 9 '                                                                                    bombs
  1421.                 IF inHand.ammount + Pocket(indexOfSlot%).ammount > 6 THEN
  1422.                     tmp1% = 6 - Pocket(indexOfSlot%).ammount
  1423.                     Pocket(indexOfSlot%).ammount = Pocket(indexOfSlot%).ammount + tmp1%
  1424.                     inHand.ammount = inHand.ammount - tmp1%
  1425.                 ELSE
  1426.                     Pocket(indexOfSlot%).ammount = Pocket(indexOfSlot%).ammount + inHand.ammount
  1427.                     cleanYourHand
  1428.                 END IF
  1429.             CASE 10 '                                                                                   arrows
  1430.                 IF inHand.ammount + Pocket(indexOfSlot%).ammount > 75 THEN
  1431.                     tmp1% = 75 - Pocket(indexOfSlot%).ammount
  1432.                     Pocket(indexOfSlot%).ammount = Pocket(indexOfSlot%).ammount + tmp1%
  1433.                     inHand.ammount = inHand.ammount - tmp1%
  1434.                 ELSE
  1435.                     Pocket(indexOfSlot%).ammount = Pocket(indexOfSlot%).ammount + inHand.ammount
  1436.                     cleanYourHand
  1437.                 END IF
  1438.             CASE 11 '                                                                                   bolts
  1439.                 IF inHand.ammount + Pocket(indexOfSlot%).ammount > 50 THEN
  1440.                     tmp1% = 50 - Pocket(indexOfSlot%).ammount
  1441.                     Pocket(indexOfSlot%).ammount = Pocket(indexOfSlot%).ammount + tmp1%
  1442.                     inHand.ammount = inHand.ammount - tmp1%
  1443.                 ELSE
  1444.                     Pocket(indexOfSlot%).ammount = Pocket(indexOfSlot%).ammount + inHand.ammount
  1445.                     cleanYourHand
  1446.                 END IF
  1447.         END SELECT
  1448.     END IF
  1449.     IF inHand.kind = 16 AND inHand.lvl < 2 AND Pocket(indexOfSlot%).lvl < 2 THEN '                      money
  1450.         IF inHand.ammount + Pocket(indexOfSlot%).ammount > 500 THEN
  1451.             tmp1% = 500 - Pocket(indexOfSlot%).ammount
  1452.             Pocket(indexOfSlot%).ammount = Pocket(indexOfSlot%).ammount + tmp1%
  1453.             inHand.ammount = inHand.ammount - tmp1%
  1454.         ELSE
  1455.             Pocket(indexOfSlot%).ammount = Pocket(indexOfSlot%).ammount + inHand.ammount
  1456.             cleanYourHand
  1457.         END IF
  1458.     END IF
  1459. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1460. FUNCTION itemRequirementsMet% (P%)
  1461.     IF P% > 0 THEN '  0= HAND, other number=index of POCKET
  1462.         IF calculateHeroActualStrength% >= calculateItemReqStrength%(Pocket(P%).kind, Pocket(P%).lvl) _
  1463.         AND calculateHeroActualAgility% >= calculateItemReqAgility%(Pocket(P%).kind, Pocket(P%).lvl) _
  1464.         AND calculateHeroActualPower% >= calculateItemReqPower%(Pocket(P%).kind, Pocket(P%).lvl, Pocket(P%).special) THEN
  1465.             itemRequirementsMet% = TRUE: EXIT FUNCTION
  1466.         END IF
  1467.     ELSE
  1468.         IF calculateHeroActualStrength% >= calculateItemReqStrength%(inHand.kind, inHand.lvl) _
  1469.         AND calculateHeroActualAgility% >= calculateItemReqAgility%(inHand.kind, inHand.lvl) _
  1470.         AND calculateHeroActualPower% >= calculateItemReqPower%(inHand.kind, inHand.lvl, inHand.special) THEN
  1471.             itemRequirementsMet% = TRUE: EXIT FUNCTION
  1472.         END IF
  1473.     END IF
  1474.     itemRequirementsMet% = FALSE
  1475. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1476. FUNCTION calculateItemReqStrength% (k%, l%)
  1477.     SELECT CASE k%
  1478.         CASE 4: IF l% > 0 THEN calculateItemReqStrength% = 15 + l% * 2: EXIT FUNCTION ' swords
  1479.         CASE 5: IF l% > 0 THEN calculateItemReqStrength% = 15 + l% * 3: EXIT FUNCTION ' axes
  1480.         CASE 7: calculateItemReqStrength% = 10 + l% * 2: EXIT FUNCTION '                bows
  1481.         CASE 8: calculateItemReqStrength% = 10 + l% * 3: EXIT FUNCTION '                crossbows
  1482.         CASE 12: IF l% > 0 THEN calculateItemReqStrength% = 5 + l% * 4: EXIT FUNCTION ' armors
  1483.         CASE 13: IF l% > 0 THEN calculateItemReqStrength% = 5 + l% * 2: EXIT FUNCTION ' helms
  1484.         CASE 14: IF l% > 0 THEN calculateItemReqStrength% = 5 + l% * 3: EXIT FUNCTION ' shields
  1485.     END SELECT
  1486.     calculateItemReqStrength% = 0
  1487. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1488. FUNCTION calculateItemReqAgility% (k%, l%)
  1489.     SELECT CASE k%
  1490.         CASE 5: IF l% > 0 THEN calculateItemReqAgility% = 10 + l% * 2: EXIT FUNCTION '  axes
  1491.         CASE 6: IF l% > 0 THEN calculateItemReqAgility% = 15 + l% * 3: EXIT FUNCTION '  throws
  1492.         CASE 7: calculateItemReqAgility% = 20 + l% * 4: EXIT FUNCTION '                 bows
  1493.         CASE 8: calculateItemReqAgility% = 20 + l% * 8: EXIT FUNCTION '                 crossbows
  1494.         CASE 12: IF l% > 0 THEN calculateItemReqAgility% = 5 + l% * 2: EXIT FUNCTION '  armors
  1495.         CASE 13: IF l% > 0 THEN calculateItemReqAgility% = 5 + l%: EXIT FUNCTION '      helms
  1496.         CASE 14: IF l% > 0 THEN calculateItemReqAgility% = 5 + l% * 3: EXIT FUNCTION '  shields
  1497.     END SELECT
  1498.     calculateItemReqAgility% = 0
  1499. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1500. FUNCTION calculateItemReqPower% (k%, l%, s$)
  1501.     SELECT CASE k%
  1502.         CASE 2 ' scrolls only, lvl0
  1503.             IF l% = 0 THEN
  1504.                 IF INSTR(s$, "0") THEN
  1505.                     calculateItemReqPower% = 17: EXIT FUNCTION
  1506.                 ELSEIF INSTR(s$, "1") THEN
  1507.                     calculateItemReqPower% = 25: EXIT FUNCTION
  1508.                 ELSEIF INSTR(s$, "2") THEN
  1509.                     calculateItemReqPower% = 32: EXIT FUNCTION
  1510.                 ELSEIF INSTR(s$, "3") THEN
  1511.                     calculateItemReqPower% = 40: EXIT FUNCTION
  1512.                 ELSEIF INSTR(s$, "4") THEN
  1513.                     calculateItemReqPower% = 50: EXIT FUNCTION
  1514.                 ELSEIF INSTR(s$, "5") THEN
  1515.                     calculateItemReqPower% = 60: EXIT FUNCTION
  1516.                 END IF
  1517.             END IF
  1518.         CASE 3 ' books, need to check spellsIkonw
  1519.             IF INSTR(s$, "0") THEN
  1520.                 calculateItemReqPower% = SpellsIknow%%(0) * 4 + 17: EXIT FUNCTION
  1521.             ELSEIF INSTR(s$, "1") THEN
  1522.                 calculateItemReqPower% = SpellsIknow%%(1) * 4 + 17: EXIT FUNCTION
  1523.             ELSEIF INSTR(s$, "2") THEN
  1524.                 calculateItemReqPower% = SpellsIknow%%(2) * 4 + 17: EXIT FUNCTION
  1525.             ELSEIF INSTR(s$, "3") THEN
  1526.                 calculateItemReqPower% = SpellsIknow%%(3) * 4 + 17: EXIT FUNCTION
  1527.             ELSEIF INSTR(s$, "4") THEN
  1528.                 calculateItemReqPower% = SpellsIknow%%(4) * 4 + 17: EXIT FUNCTION
  1529.             ELSEIF INSTR(s$, "5") THEN
  1530.                 calculateItemReqPower% = SpellsIknow%%(5) * 4 + 17: EXIT FUNCTION
  1531.             END IF
  1532.         CASE 15: calculateItemReqPower% = 17 + ((l% + 1) * 3): EXIT FUNCTION ' WANDS
  1533.     END SELECT
  1534.     calculateItemReqPower% = 0
  1535. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1536. FUNCTION itemFitsEquipmentSlot% (indexOfSlot%)
  1537.     SELECT CASE indexOfSlot% ' we are checking where you wanna put the item
  1538.         CASE 0 ' head
  1539.             IF inHand.kind = 13 THEN itemFitsEquipmentSlot% = TRUE: EXIT FUNCTION ' if you holding a helm
  1540.         CASE 1 ' neck
  1541.             IF inHand.kind = 17 AND inHand.lvl >= 2 THEN itemFitsEquipmentSlot% = TRUE: EXIT FUNCTION
  1542.         CASE 2 ' right hand
  1543.             SELECT CASE inHand.kind
  1544.                 CASE 4, 5, 6, 9, 15: itemFitsEquipmentSlot% = TRUE: EXIT FUNCTION 'if in hand you have: swords,axes,throws,bombs or wands
  1545.                 CASE 7, 8 ' if a bow or crossbow in hand
  1546.                     IF Pocket(4).kind <> -1 THEN '& left hand is occupied
  1547.                         HUDpromt$ = "Left hand is occupied"
  1548.                     ELSE
  1549.                         itemFitsEquipmentSlot% = TRUE: EXIT FUNCTION
  1550.                     END IF
  1551.             END SELECT
  1552.         CASE 3 ' torso
  1553.             IF inHand.kind = 12 THEN itemFitsEquipmentSlot% = TRUE: EXIT FUNCTION ' if you holding an armor
  1554.         CASE 4 ' left hand
  1555.             SELECT CASE inHand.kind
  1556.                 CASE 14 ' if you have a shield in hand
  1557.                     IF (Pocket(2).kind = 7 OR Pocket(2).kind = 8) THEN ' &  on right hand you have a two handed weapon
  1558.                         HUDpromt$ = "Can't use it with a two handed weapon"
  1559.                     ELSE
  1560.                         itemFitsEquipmentSlot% = TRUE: EXIT FUNCTION
  1561.                     END IF
  1562.                 CASE 10 'and you have arrows in hand
  1563.                     IF Pocket(2).kind = 7 THEN '  & a bow equiped
  1564.                         itemFitsEquipmentSlot% = TRUE: EXIT FUNCTION
  1565.                     ELSE
  1566.                         HUDpromt$ = "You need to equip a bow"
  1567.                     END IF
  1568.                 CASE 11 ' if you have bolts in hand
  1569.                     IF Pocket(2).kind = 8 THEN ' and a crossbow equiped
  1570.                         itemFitsEquipmentSlot% = TRUE: EXIT FUNCTION
  1571.                     ELSE
  1572.                         HUDpromt$ = "You need to equip a crossbow"
  1573.                     END IF
  1574.             END SELECT
  1575.         CASE 5, 6 ' fingers
  1576.             IF inHand.kind = 17 AND inHand.lvl <= 1 THEN itemFitsEquipmentSlot% = TRUE: EXIT FUNCTION
  1577.     END SELECT
  1578.  
  1579.     itemFitsEquipmentSlot% = FALSE
  1580.  
  1581. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1582. SUB itemInformation (whichOfTheSlots%) ' TO DO: show requirements of items, organize how the info is seen acording to kind of item, add info for r special variable on items
  1583.     ' i can use lines 26, 27, 28, 29
  1584.     DIM kindOfItem%
  1585.     DIM lvlOfItem%
  1586.     DIM specialOfItem$
  1587.     DIM tmp$
  1588.  
  1589.     kindOfItem% = Pocket(whichOfTheSlots%).kind
  1590.     lvlOfItem% = Pocket(whichOfTheSlots%).lvl
  1591.     specialOfItem$ = Pocket(whichOfTheSlots%).special
  1592.  
  1593.     '1rst LINE = NAME OF ITEM OR BODY SLOT
  1594.     IF whichOfTheSlots% < 7 AND kindOfItem% = -1 THEN
  1595.         SELECT CASE whichOfTheSlots%
  1596.             CASE 0: tmp$ = "Head"
  1597.             CASE 1: tmp$ = "Neck"
  1598.             CASE 2: tmp$ = "Right hand"
  1599.             CASE 3: tmp$ = "Torso"
  1600.             CASE 4: tmp$ = "Left hand"
  1601.             CASE 5: tmp$ = "Right finger"
  1602.             CASE 6: tmp$ = "Left finger"
  1603.         END SELECT
  1604.     ELSE
  1605.         tmp$ = nameAnItem$(kindOfItem%, lvlOfItem%, specialOfItem$)
  1606.     END IF
  1607.     LOCATE 26, 40 - (LEN(tmp$) \ 2)
  1608.     PRINT tmp$;
  1609.  
  1610.     '2nd LINE
  1611.     tmp$ = "" ' kill me after testing!!!!!!!
  1612.     SELECT CASE kindOfItem%
  1613.         CASE 0: tmp$ = "Opens some door" 'keys
  1614.         CASE 1: tmp$ = "Heals" + STR$((lvlOfItem% + 1) * 5) + " points" ' potions
  1615.         CASE 2: tmp$ = "Right click for read" ' papers
  1616.         CASE 3: tmp$ = "Learn about this spell" 'books
  1617.         CASE 4, 5, 7, 8, 15: tmp$ = "Damage: " + _TRIM$(STR$(calculateItemBaseDmg%(kindOfItem%, lvlOfItem%, specialOfItem$))) + " - " + _TRIM$(STR$(calculateItemMaxDmg%(kindOfItem%, lvlOfItem%, specialOfItem$))) ' weapons
  1618.         CASE 6, 9, 10, 11: tmp$ = "Damage: " + _TRIM$(STR$(calculateItemBaseDmg%(kindOfItem%, lvlOfItem%, specialOfItem$))) + " - " + _TRIM$(STR$(calculateItemMaxDmg%(kindOfItem%, lvlOfItem%, specialOfItem$))) 'ammunitions + throws
  1619.         CASE 12, 13, 14: tmp$ = "Defense:" + STR$(calculateItemDefense%(kindOfItem%, lvlOfItem%, specialOfItem$)) ' armors, helms & shields
  1620.         CASE 16: tmp$ = "Ammount:" + STR$(Pocket(whichOfTheSlots%).ammount) ' money
  1621.         CASE 17 ' jewlery
  1622.             IF lvlOfItem% < 2 THEN
  1623.                 tmp$ = "You can wear it on your finger"
  1624.             ELSE
  1625.                 tmp$ = "You can wear it on your neck"
  1626.             END IF
  1627.     END SELECT
  1628.     LOCATE 27, 40 - (LEN(tmp$) \ 2)
  1629.     PRINT tmp$;
  1630.  
  1631.     '3rd LINE
  1632.     tmp$ = "" ' kill me after testing!!!!!!!
  1633.     IF specialOfItem$ <> "" THEN
  1634.         IF NOT INSTR(specialOfItem$, "u") THEN ' it¿'s unidentified
  1635.             tmp$ = "+" + RIGHT$(specialOfItem$, 1) + " to "
  1636.             IF INSTR(specialOfItem$, "s") THEN ' adds to strenght
  1637.                 tmp$ = tmp$ + "strenght"
  1638.             ELSEIF INSTR(specialOfItem$, "a") THEN ' adds to agility
  1639.                 tmp$ = tmp$ + "agility"
  1640.             ELSEIF INSTR(specialOfItem$, "p") THEN ' adds to power
  1641.                 tmp$ = tmp$ + "power"
  1642.             ELSEIF INSTR(specialOfItem$, "v") THEN ' adds to vigor
  1643.                 tmp$ = tmp$ + "vigor"
  1644.             ELSEIF INSTR(specialOfItem$, "d") THEN ' adds to defense
  1645.                 tmp$ = tmp$ + "defense"
  1646.             ELSEIF INSTR(specialOfItem$, "t") THEN ' it teaches some spell
  1647.                 tmp$ = ""
  1648.             END IF
  1649.         ELSE
  1650.             tmp$ = ""
  1651.         END IF
  1652.     ELSE
  1653.         SELECT CASE kindOfItem%
  1654.             CASE 1: tmp$ = "Right click for drink" ' potions
  1655.             CASE 3: tmp$ = "Right click for read" ' books
  1656.             CASE 6, 9, 10, 11: tmp$ = "Ammount:" + STR$(Pocket(whichOfTheSlots%).ammount) ' ammo
  1657.         END SELECT
  1658.     END IF
  1659.     LOCATE 28, 40 - (LEN(tmp$) \ 2)
  1660.     PRINT tmp$;
  1661.  
  1662. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1663. SUB equipOurHero () ' remove test items
  1664.     SELECT CASE Hero.class
  1665.         CASE 0 ' "Barbarian" ' you get an axe, a shield, a potion and 100$
  1666.             createItemInPocket 5, 0, 1, 2, "" ' axe
  1667.             createItemInPocket 14, 0, 1, 4, "" ' shield
  1668.  
  1669.  
  1670.             '°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°TESTING
  1671.             createItemInPocket 12, 2, 1, 7, "a2" '  armor
  1672.             createItemInPocket 13, 3, 1, 8, "v3" '  helm
  1673.             createItemInPocket 7, 0, 1, 9, "" ' bow
  1674.             createItemInPocket 2, 1, 1, 10, "" ' map
  1675.             createItemInPocket 17, 0, 1, 11, "p2" ' ring
  1676.             createItemInPocket 10, 0, 50, 12, "" ' 50 arrows
  1677.             createItemInPocket 17, 2, 1, 13, "d2" ' SAID for test!!!!!!!!!!
  1678.             createItemInPocket 16, 0, 100, 14, "" ' 100 coins
  1679.             createItemInPocket 16, 0, 100, 15, "" ' 100 coins
  1680.             createItemInPocket 16, 0, 100, 16, "" ' 100 coins
  1681.             createItemInPocket 10, 0, 50, 17, "" ' 50 arrows
  1682.             createItemInPocket 16, 0, 123, 18, "" ' 100 coins
  1683.             '°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
  1684.  
  1685.  
  1686.         CASE 1 ' "Clerig" 'you get a sword, a shield, a potion and 100$
  1687.             createItemInPocket 4, 0, 1, 2, "" '     sword
  1688.             createItemInPocket 14, 0, 1, 4, "" '    shield
  1689.         CASE 2 ' "Assasin" ' you get a bow, 50 arrows, a potion and 100$
  1690.             createItemInPocket 7, 0, 1, 2, "" '     bow
  1691.             createItemInPocket 10, 0, 50, 4, "" '   50 arrows
  1692.  
  1693.             '°°°°°°°°°°°°°°°
  1694.             createItemInPocket 10, 0, 50, 17, "" ' 50 arrows
  1695.             createItemInPocket 16, 3, 1, 18, "" ' gem
  1696.             createItemInPocket 11, 0, 27, 19, "" '  bolts
  1697.             createItemInPocket 11, 0, 43, 20, "" '  bolts
  1698.             createItemInPocket 9, 0, 4, 8, "" '  bombs
  1699.             createItemInPocket 9, 0, 4, 7, "" '  bombs
  1700.             '°°°°°°°°°°
  1701.  
  1702.         CASE 3 '"Wizard" ' you get a wand, a book, a potion and 100$
  1703.             createItemInPocket 15, 0, 21, 2, "r0" '    wand
  1704.             createItemInPocket 3, 0, 1, 20, "t0" '  book
  1705.     END SELECT
  1706.     createItemInPocket 1, 0, 1, 21, "" ' potion
  1707.     createItemInPocket 16, 0, 100, 22, "" ' 100 coins
  1708.  
  1709. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1710. FUNCTION calculateHeroActualAgility% () '°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°Û HERO Û°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
  1711.     DIM i%
  1712.     DIM tmp%
  1713.     tmp% = 0
  1714.     FOR i% = 0 TO 6
  1715.         IF Pocket(i%).special <> "" AND INSTR(Pocket(i%).special, "a") THEN
  1716.             tmp% = tmp% + VAL(RIGHT$(Pocket(i%).special, 1))
  1717.         END IF
  1718.     NEXT i%
  1719.     calculateHeroActualAgility% = Hero.agility + tmp%
  1720. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1721. FUNCTION calculateHeroActualStrength% ()
  1722.     DIM i%
  1723.     DIM tmp%
  1724.     tmp% = 0
  1725.     FOR i% = 0 TO 6
  1726.         IF Pocket(i%).special <> "" AND INSTR(Pocket(i%).special, "s") THEN
  1727.             tmp% = tmp% + VAL(RIGHT$(Pocket(i%).special, 1))
  1728.         END IF
  1729.     NEXT i%
  1730.     calculateHeroActualStrength% = Hero.strength + tmp%
  1731. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1732. FUNCTION calculateHeroActualPower% ()
  1733.     DIM i%
  1734.     DIM tmp%
  1735.     tmp% = 0
  1736.     FOR i% = 0 TO 6
  1737.         IF Pocket(i%).special <> "" AND INSTR(Pocket(i%).special, "p") THEN
  1738.             tmp% = tmp% + VAL(RIGHT$(Pocket(i%).special, 1))
  1739.         END IF
  1740.     NEXT i%
  1741.     calculateHeroActualPower% = Hero.power + tmp%
  1742. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1743. FUNCTION calculateHeroActualVigor% ()
  1744.     DIM i%
  1745.     DIM tmp%
  1746.     tmp% = 0
  1747.     FOR i% = 0 TO 6
  1748.         IF Pocket(i%).special <> "" AND INSTR(Pocket(i%).special, "v") THEN
  1749.             tmp% = tmp% + VAL(RIGHT$(Pocket(i%).special, 1))
  1750.         END IF
  1751.     NEXT i%
  1752.     calculateHeroActualVigor% = Hero.vigor + tmp%
  1753. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1754. FUNCTION calculateHeroChanceToHit% ()
  1755.     DIM i%
  1756.     DIM tmp%
  1757.     tmp% = 0
  1758.     FOR i% = 0 TO 6
  1759.         IF Pocket(i%).special <> "" AND INSTR(Pocket(i%).special, "c") THEN
  1760.             tmp% = tmp% + (VAL(RIGHT$(Pocket(i%).special, 1)) * 7)
  1761.         END IF
  1762.     NEXT i%
  1763.     calculateHeroChanceToHit% = INT(calculateHeroActualAgility * 1.15) + 20 + tmp%
  1764. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1765. FUNCTION calculateHeroDefense% ()
  1766.     DIM i%
  1767.     DIM tmp%
  1768.     tmp% = 0
  1769.     FOR i% = 0 TO 6
  1770.         tmp% = tmp% + calculateItemDefense%(Pocket(i%).kind, Pocket(i%).lvl, Pocket(i%).special)
  1771.     NEXT i%
  1772.     calculateHeroDefense% = tmp%
  1773. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1774. FUNCTION calculateHeroBaseDmg% () 'i should watch the case of no ammo, returning 0 IN PROCCES. Also should be affected by Strength, except if throw
  1775.     DIM i%
  1776.     DIM tmp%
  1777.     tmp% = 0
  1778.     IF Pocket(2).kind = -1 THEN ' if empty right hand
  1779.         calculateHeroBaseDmg% = tmp%: EXIT FUNCTION
  1780.     ELSE
  1781.         IF Pocket(2).kind = 7 AND Pocket(4).kind <> 10 THEN ' if in right hand a bow and in left hand something different than arrows
  1782.             calculateHeroBaseDmg% = 0: EXIT FUNCTION
  1783.         ELSEIF Pocket(2).kind = 8 AND Pocket(4).kind <> 11 THEN ' if in right hand a crossbow and in left hand something different than bolts
  1784.             calculateHeroBaseDmg% = 0: EXIT FUNCTION
  1785.         ELSE
  1786.             FOR i% = 0 TO 6
  1787.                 tmp% = tmp% + calculateItemBaseDmg%(Pocket(i%).kind, Pocket(i%).lvl, Pocket(i%).special)
  1788.             NEXT i%
  1789.             calculateHeroBaseDmg% = tmp%
  1790.         END IF
  1791.     END IF
  1792. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1793. FUNCTION calculateHeroMaxDmg% () ' i should watch the case of no ammo, returning 0. Also should be affected by Strength, except if throw
  1794.     DIM i%
  1795.     DIM tmp%
  1796.     tmp% = 0
  1797.     IF Pocket(2).kind = -1 THEN ' if empty right hand
  1798.         calculateHeroMaxDmg% = tmp% + 1: EXIT FUNCTION
  1799.     ELSE
  1800.         IF Pocket(2).kind = 7 AND Pocket(4).kind <> 10 THEN ' if in right hand a bow and in left hand something different than arrows
  1801.             calculateHeroMaxDmg% = 0: EXIT FUNCTION
  1802.         ELSEIF Pocket(2).kind = 8 AND Pocket(4).kind <> 11 THEN ' if in right hand a crossbow and in left hand something different than bolts
  1803.             calculateHeroMaxDmg% = 0: EXIT FUNCTION
  1804.         ELSE
  1805.             FOR i% = 0 TO 6
  1806.                 tmp% = tmp% + calculateItemMaxDmg%(Pocket(i%).kind, Pocket(i%).lvl, Pocket(i%).special)
  1807.             NEXT i%
  1808.             calculateHeroMaxDmg% = tmp%
  1809.         END IF
  1810.     END IF
  1811. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1812. FUNCTION calculateMaxLife% ()
  1813.     calculateMaxLife% = INT(calculateHeroActualVigor% * 2.75)
  1814. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1815. FUNCTION calculateMaxMana% ()
  1816.     calculateMaxMana% = INT(calculateHeroActualPower% * 3.25)
  1817. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1818. SUB drawHero ()
  1819.     _PUTIMAGE (Hero.x, Hero.y), calculateHeroImg&(Hero.class, Hero.lvl)
  1820. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1821. FUNCTION calculateHeroImg& (classOfHero%, lvlOfHero%)
  1822.     IF lvlOfHero% <= 5 THEN
  1823.         SELECT CASE classOfHero%
  1824.             CASE 0: calculateHeroImg& = HeroImg&(0)
  1825.             CASE 1: calculateHeroImg& = HeroImg&(2)
  1826.             CASE 2: calculateHeroImg& = HeroImg&(4)
  1827.             CASE 3: calculateHeroImg& = HeroImg&(6)
  1828.         END SELECT
  1829.     ELSE
  1830.         SELECT CASE classOfHero%
  1831.             CASE 0: calculateHeroImg& = HeroImg&(1)
  1832.             CASE 1: calculateHeroImg& = HeroImg&(3)
  1833.             CASE 2: calculateHeroImg& = HeroImg&(5)
  1834.             CASE 3: calculateHeroImg& = HeroImg&(7)
  1835.         END SELECT
  1836.     END IF
  1837. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1838.  
  1839.  
  1840. SUB drawEnemies () '°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°Û ENEMIES Û°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
  1841.     FOR i% = 0 TO UBOUND(Enemy)
  1842.         IF Enemy(i%).map = actualMapWorking%% THEN
  1843.             _PUTIMAGE (Enemy(i%).x, Enemy(i%).y), EnemyImg&(Enemy(i%).lvl)
  1844.         END IF
  1845.     NEXT i%
  1846. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1847. FUNCTION calculateEnemyBaseDmg% (lvl%) ' INCOMPLETE
  1848.     calculateEnemyBaseDmg% = (lvl% + 1) * 5
  1849. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1850. FUNCTION calculateEnemyScore% (lvl%) ' UNDONE
  1851. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1852.  
  1853. SUB loadEnemiesInitialVariables () ' <---- I SHOULD RANDOM CREATE THEM AND THEIR ARRAY SHOULD ONLY BE FOR THE ONES ON actualMapWorking%  , the rest should be on file .txt
  1854.     Enemy(3).map = 0
  1855.     Enemy(3).x = 8 * 32
  1856.     Enemy(3).y = 2 * 32 + 32
  1857.     Enemy(3).lvl = 0
  1858.     Enemy(3).life = 8
  1859.  
  1860.     Enemy(1).map = 0
  1861.     Enemy(1).x = 5 * 32
  1862.     Enemy(1).y = 2 * 32 + 32
  1863.     Enemy(1).lvl = 0
  1864.     Enemy(1).life = 8
  1865.  
  1866.     Enemy(2).map = 1
  1867.     Enemy(2).x = 7 * 32
  1868.     Enemy(2).y = 8 * 32 + 32
  1869.     Enemy(2).lvl = 0
  1870.     Enemy(2).life = 8
  1871.  
  1872. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1873.  
  1874. FUNCTION nameAnEnemy$ (lvl%)
  1875.     SELECT CASE lvl%
  1876.         CASE 0: nameAnEnemy$ = "rat"
  1877.         CASE 1: nameAnEnemy$ = "spiders"
  1878.         CASE 2: nameAnEnemy$ = "lizard"
  1879.         CASE 3: nameAnEnemy$ = "tarantula"
  1880.         CASE 4: nameAnEnemy$ = "frog"
  1881.         CASE 5: nameAnEnemy$ = "beatle"
  1882.         CASE 6: nameAnEnemy$ = "bug"
  1883.         CASE 7: nameAnEnemy$ = "dragon"
  1884.         CASE 8: nameAnEnemy$ = "living mushrooms"
  1885.         CASE 9: nameAnEnemy$ = "rabbit"
  1886.         CASE 10: nameAnEnemy$ = "small bat"
  1887.         CASE 11: nameAnEnemy$ = "big bat"
  1888.         CASE 12: nameAnEnemy$ = "snake"
  1889.         CASE 13: nameAnEnemy$ = "wolf"
  1890.         CASE 14: nameAnEnemy$ = "jabali"
  1891.         CASE 15: nameAnEnemy$ = "bear"
  1892.         CASE 16: nameAnEnemy$ = "stuffs"
  1893.         CASE 17: nameAnEnemy$ = "big stuff"
  1894.         CASE 18: nameAnEnemy$ = "scorpion"
  1895.         CASE 19: nameAnEnemy$ = "octopus"
  1896.         CASE 20: nameAnEnemy$ = "vampire"
  1897.         CASE 21: nameAnEnemy$ = "mummy"
  1898.         CASE 22: nameAnEnemy$ = "ghost"
  1899.         CASE 23: nameAnEnemy$ = "hidra"
  1900.         CASE 24: nameAnEnemy$ = "goblin"
  1901.         CASE 25: nameAnEnemy$ = "zombie"
  1902.         CASE 26: nameAnEnemy$ = "skeleton"
  1903.         CASE 27: nameAnEnemy$ = "orc"
  1904.         CASE 28: nameAnEnemy$ = "ciclope"
  1905.         CASE 29: nameAnEnemy$ = "baron of hell"
  1906.         CASE 30: nameAnEnemy$ = "stone golem"
  1907.         CASE 31: nameAnEnemy$ = "Lord of the Dark"
  1908.     END SELECT
  1909. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1910. SUB enemyAI (enemyFromArray%) '<------------- I must build the AI for enemies' cosider particular cases later
  1911.  
  1912.  
  1913. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1914. FUNCTION enemySearchHero% (i%)
  1915.     IF Enemy(indexFromArray%).x <> Hero.x THEN
  1916.         IF Enemy(i%).x > Hero.x THEN Enemy(i%).x = Enemy(i%).x - 32
  1917.         IF Enemy(i%).x < Hero.x THEN Enemy(i%).x = Enemy(i%).x + 32
  1918.     END IF
  1919.  
  1920.     IF Enemy(indexFromArray%).y <> Hero.y THEN
  1921.  
  1922.     END IF
  1923.  
  1924.  
  1925.  
  1926. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1927.  
  1928. SUB drawMechs () '°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°Û WORLD & MECHS Û°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
  1929.     _PUTIMAGE (Mechs(0).x, Mechs(0).y), UtileryImg&(5) ' PROVISORY
  1930.  
  1931. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1932. SUB drawWorld () ' <-  if i could came up with a random generator... geez
  1933.  
  1934.     DIM i%
  1935.     DIM j%
  1936.     DIM tmp%%
  1937.     DIM orgFile&
  1938.     DIM destFile&
  1939.     DIM tmpWorlds&
  1940.  
  1941.     IF NOT _FILEEXISTS("tmpWorlds.txt") THEN '              if this file dosn't exists means that we started a new game. We must create the first map of the game, wich is a pre-arranged map of the Town
  1942.         CHDIR ".\.." '                                      we are @ Fantasy\data\
  1943.         CHDIR ".\worlds" '                                  we are @ Fantasy\data\wolrds\
  1944.         orgFile& = FREEFILE '                               we need two filehandles: one for origin file,
  1945.         destFile& = FREEFILE '                              and another for destination file
  1946.         OPEN "town.txt" FOR INPUT AS #orgFile& '            we will extract info from this file
  1947.         OPEN "tmp.txt" FOR OUTPUT AS #destFile& '           and place it into this one
  1948.         WHILE NOT EOF(orgFile&) '                           we make sure we read the full file
  1949.             INPUT #orgFile&, tmp%% '    ¿ <---------------- DATA TRANSFER
  1950.             PRINT #destFile&, tmp%% '   ¾
  1951.         WEND '                                              done with that thing
  1952.         CLOSE #orgFile& '  ¿ <----------------------------- close files
  1953.         CLOSE #destFile& ' ¾
  1954.         CHDIR ".\.." '                                      we are @ Fantasy\data\
  1955.         NAME ".\worlds\tmp.txt" AS ".\tmp\tmpWorlds.txt" '  now we extract the file from worlds folder and put it on tmp folder with the right name
  1956.         CHDIR ".\tmp" '                                     we are @ Fantasy\data\tmp\
  1957.     END IF
  1958.  
  1959.     IF lastMapWorking%% <> actualMapWorking%% THEN '        if map has changed we need to actualize the WolrdTiles%% array
  1960.         tmpWorlds& = FREEFILE '                             get a handle
  1961.         OPEN "tmpWorlds.txt" FOR INPUT AS #tmpWorlds& '     we will extract data from this file
  1962.         INPUT #tmpWorlds&, tmp%% '                          we check the first number of the file
  1963.         WHILE tmp%% <> actualMapWorking%% '                 if it isn't the number of the level we need to know
  1964.             FOR i% = 0 TO 279 '            ¿
  1965.                 INPUT #tmpWorlds&, tmp%% ' ³ <------------ walk over the info of this map (which is not what we need to know, but we skip that data)
  1966.             NEXT i% '                      ¾
  1967.             INPUT #tmpWorlds&, tmp%% '                      and get the next number for evaluate again (that should be the number of next map)
  1968.         WEND '                                              keep doing this untill the right map number has been found
  1969.         FOR j% = 0 TO 13 '                    ¿
  1970.             FOR i% = 0 TO 19 '                ³
  1971.                 INPUT #tmpWorlds&, tmp%% '    ³ <---------- then extract the data we need
  1972.                 WorldTiles%%(i%, j%) = tmp%% '³             and load it into WorldTiles%% array !
  1973.             NEXT i% '                         ³
  1974.         NEXT j% '                             ¾
  1975.         CLOSE #tmpWorlds& '                                 close the file
  1976.         lastMapWorking%% = actualMapWorking%% '             and actualize map situation, so no need for reload until the map changes
  1977.     END IF
  1978.  
  1979.     FOR j% = 0 TO 13 '                                                          ¿
  1980.         FOR i% = 0 TO 19 '                                                      ³
  1981.             _PUTIMAGE (i% * 32, j% * 32 + 32), WorldImg&(WorldTiles%%(i%, j%)) '³ actual drawing
  1982.         NEXT i% '                                                               ³
  1983.     NEXT j% '                                                                   ¾
  1984.  
  1985. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1986. SUB loadMechsInitialVariables () ' PROVISORY, load them from a CSV as maps later
  1987.  
  1988.     Mechs(0).x = 128
  1989.     Mechs(0).y = 128
  1990.     Mechs(0).kind = 0
  1991.     Mechs(0).map = 0
  1992.     Mechs(0).state = 0
  1993.  
  1994. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1995. SUB getMouseData () ''°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°Û PLAYER INPUTS Û°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
  1996.  
  1997.     DO WHILE _MOUSEINPUT: LOOP '               ¿
  1998.     Finger.x = _MOUSEX '                       ³ get
  1999.     Finger.y = _MOUSEY '                       ³ mouse
  2000.     Finger.tmpClickL = _MOUSEBUTTON(1) '       ³ info
  2001.     Finger.tmpClickR = _MOUSEBUTTON(2) '       Ù
  2002.  
  2003.     IF Finger.tmpClickL AND NOT Finger.oldClickL THEN '¿
  2004.         Finger.clickL = TRUE '                            ³ DEBOUNCE
  2005.     ELSE '                                             ³ LEFT
  2006.         Finger.clickL = FALSE '                            ³ CLICK
  2007.     END IF '                                           ³
  2008.     Finger.oldClickL = Finger.tmpClickL '              Ù
  2009.  
  2010.     IF Finger.tmpClickR AND NOT Finger.oldClickR THEN '¿
  2011.         Finger.clickR = TRUE '                            ³ DEBOUNCE
  2012.     ELSE '                                             ³ RIGHT
  2013.         Finger.clickR = FALSE '                            ³ CLICK
  2014.     END IF '                                           ³
  2015.     Finger.oldClickR = Finger.tmpClickR '              Ù
  2016.  
  2017.     inHand.x = Finger.x
  2018.     inHand.y = Finger.y
  2019.  
  2020. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  2021. SUB playerInputs ()
  2022.     getMouseData
  2023.     keyboardInputs
  2024. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  2025.  
  2026. SUB keyboardInputs () ' <-------------------------------------------------------No more keyboard inputs of any kind? Think in playability
  2027.  
  2028.     DIM keyPress$
  2029.     DIM mapOnPocket%
  2030.     DIM i%
  2031.  
  2032.     'hold CTRL for throw an attack (long distance) YOU NEED TO HAVE A THROW WEAPON ON Pocket(2)!!!! AND AMMO IN Pocket(4)!!!! else should draw the cross, and if i can display "No ammo"... great. Also have to check the case of BOMBS & THROWS
  2033.     'hold SHIFT for launching same spell as before, if no spell "?" sign and HUDpromt, if no mana then cross and HUDpromt too
  2034.     'hold ALT to force a movement over an item instead of picking..... or maybe for the Rest One TURN ?
  2035.     'SPACEBAR could accelerate the action... maybe
  2036.  
  2037.     '°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
  2038.     '° what's the best way for motion? ° numpad? QWEASDZXC? some way with
  2039.     '°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
  2040.     'F1 for help
  2041.     'F2 for new game
  2042.     'F3 for save game
  2043.     'F4 for load game
  2044.  
  2045.  
  2046.     keyPress$ = INKEY$
  2047.     IF keyPress$ <> "" AND playerTurn` = TRUE THEN
  2048.  
  2049.         IF ASC(keyPress$) = 27 THEN '                             ¿
  2050.             IF menuMain` = TRUE THEN '                            ³
  2051.                 menuMain` = FALSE '                               ³
  2052.             ELSEIF menuPocket` OR menuStats` OR menuSpells` THEN
  2053.                 menuPocket` = FALSE '                             ³ ESC key
  2054.                 menuStats` = FALSE '                              ³
  2055.                 menuSpells` = FALSE '                             ³
  2056.             ELSEIF menuMain` = FALSE THEN '                       ³
  2057.                 menuMain` = TRUE '                                ³
  2058.             END IF '                                              ³
  2059.         END IF '                                                  ¾
  2060.  
  2061.         IF menuMain` = FALSE THEN
  2062.  
  2063.             IF keyPress$ = "1" THEN '           ¿
  2064.                 IF menuPocket` = FALSE THEN '   ³
  2065.                     menuSpells` = FALSE '       ³
  2066.                     menuPocket` = TRUE '        ³
  2067.                 ELSEIF menuPocket` = TRUE THEN '³ number 1
  2068.                     menuPocket` = FALSE '       ³
  2069.                 END IF '                        ³
  2070.             END IF '                            ¾
  2071.  
  2072.             IF keyPress$ = "2" THEN '           ¿
  2073.                 IF menuSpells` = FALSE THEN '   ³
  2074.                     menuPocket` = FALSE '       ³
  2075.                     menuSpells` = TRUE '        ³
  2076.                 ELSEIF menuSpells` = TRUE THEN '³ number 2
  2077.                     menuSpells` = FALSE '       ³
  2078.                 END IF '                        ³
  2079.             END IF '                            ¾
  2080.  
  2081.             IF keyPress$ = "3" THEN '           ¿
  2082.                 IF menuStats` = FALSE THEN '    ³
  2083.                     menuStats` = TRUE '         ³
  2084.                 ELSEIF menuStats` = TRUE THEN ' ³ number 3
  2085.                     menuStats` = FALSE '        ³
  2086.                 END IF '                        ³
  2087.             END IF '                            ¾
  2088.  
  2089.             FOR i% = 7 TO 22 '                                      ¿
  2090.                 IF Pocket(i%).kind = 2 AND Pocket(i%).lvl = 1 THEN
  2091.                     mapOnPocket% = TRUE '                           ³
  2092.                 ELSE '                                              ³check if map is on inventory
  2093.                     mapOnPocket% = FALSE '                          ³
  2094.                 END IF '                                            ³
  2095.             NEXT i% '                                               ¾
  2096.  
  2097.             IF ASC(keyPress$) = 9 AND mapOnPocket% = TRUE THEN '¿
  2098.                 IF menuMap` = FALSE THEN '                      ³
  2099.                     menuPocket` = FALSE '                       ³
  2100.                     menuSpells` = FALSE '                       ³ TAB for map
  2101.                     menuStats` = FALSE '                        ³
  2102.                     menuMap` = TRUE '                           ³
  2103.                 ELSEIF menmumap` = TRUE THEN '                  ³
  2104.                     menuMap` = FALSE '                          ³
  2105.                 END IF '                                        ³
  2106.             END IF '                                            ¾
  2107.  
  2108.         END IF
  2109.  
  2110.     END IF
  2111. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  2112. '°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°Û GENERAL PROGRAM Û°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
  2113.  
  2114. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  2115. SUB drawHUD ()
  2116.  
  2117.     DIM lifeAsPercent%
  2118.     DIM manaAsPercent%
  2119.     DIM xpAsPercent%
  2120.  
  2121.     LINE (0, 0)-(639, 31), GREEN4, BF 'background line/box ¿
  2122.     LINE (0, 15)-(639, 15), GREEN1 '                       ³
  2123.     LOCATE 1, 17: PRINT CHR$(179); '¿                      ³  BACK
  2124.     LOCATE 1, 34: PRINT CHR$(179); '³ separation           ³
  2125.     LOCATE 1, 55: PRINT CHR$(179); 'Ù lines                Ù
  2126.  
  2127.     _PUTIMAGE (8, 0), HUDImg&(0) ' big heart image                        ¿
  2128.     lifeAsPercent% = CINT((Hero.life * 100) / calculateMaxLife%) '        ³
  2129.     drawFourHeartAsPercentage 32, 3, lifeAsPercent% '                     ³ HEALTH
  2130.     LOCATE 1, 10 ' written values on screen                               ³
  2131.     PRINT _TRIM$(STR$(Hero.life)); "/"; _TRIM$(STR$(calculateMaxLife%));
  2132.  
  2133.     _PUTIMAGE (144, 0), HUDImg&(1) ' big star image                       ¿
  2134.     manaAsPercent% = CINT((Hero.mana * 100) / calculateMaxMana%) '        ³
  2135.     barShowingPercentage 160, 4, manaAsPercent% '                         ³  MANA
  2136.     LOCATE 1, 27 '                                                        ³
  2137.     PRINT _TRIM$(STR$(Hero.mana)); "/"; _TRIM$(STR$(calculateMaxMana%));
  2138.  
  2139.     _PUTIMAGE (280, 0), HUDImg&(2) ' little flag image                                           ¿
  2140.     xpAsPercent% = CINT(((Hero.xp - Hero.prevNextXp) * 100) / (Hero.nextXp - Hero.prevNextXp)) ' ³
  2141.     barShowingPercentage 296, 4, xpAsPercent% '                                                  ³  EXPERIENCE
  2142.     LOCATE 1, 44 '                                                                               ³
  2143.     PRINT _TRIM$(STR$(Hero.xp)); "/"; _TRIM$(STR$(Hero.nextXp)); '                               Ù
  2144.  
  2145.     IF inHand.lvl = -1 AND playerTurn` = TRUE AND menuMain` = FALSE THEN ' no items in hand, and it has to be your turn. Also can't work if Main Menu open
  2146.         IF fingerIsOnSurface%(440, 0, 48, 16) THEN '
  2147.             HUDpromt$ = "Look at you inventory" '
  2148.             COLOR GREEN4, GREEN1 '
  2149.             IF menuPocket` = FALSE THEN
  2150.                 IF Finger.clickL THEN
  2151.                     menuSpells` = FALSE
  2152.                     menuPocket` = TRUE
  2153.                 END IF
  2154.             ELSE
  2155.                 IF Finger.clickL THEN menuPocket` = FALSE
  2156.             END IF
  2157.         ELSE '
  2158.             COLOR GREEN1, GREEN4 '
  2159.         END IF '
  2160.         LOCATE 1, 56 '
  2161.         PRINT "POCKET"; '
  2162.  
  2163.         IF fingerIsOnSurface%(496, 0, 48, 16) THEN '
  2164.             HUDpromt$ = "Select a spell to perform" '
  2165.             COLOR GREEN4, GREEN1 '
  2166.             IF menuSpells` = FALSE THEN
  2167.                 IF Finger.clickL THEN
  2168.                     menuPocket` = FALSE
  2169.                     menuSpells` = TRUE
  2170.                 END IF
  2171.             ELSE
  2172.                 IF Finger.clickL THEN menuSpells` = FALSE
  2173.             END IF
  2174.         ELSE '
  2175.             COLOR GREEN1, GREEN4 '
  2176.         END IF '
  2177.         LOCATE 1, 63 '
  2178.         PRINT "SPELLS"; '
  2179.  
  2180.         IF fingerIsOnSurface%(552, 0, 40, 16) THEN '
  2181.             HUDpromt$ = "Character statistics" '
  2182.             COLOR GREEN4, GREEN1 '
  2183.             IF menuStats` = FALSE THEN
  2184.                 IF Finger.clickL THEN menuStats` = TRUE
  2185.             ELSE
  2186.                 IF Finger.clickL THEN menuStats` = FALSE
  2187.             END IF
  2188.         ELSE '
  2189.             COLOR GREEN1, GREEN4 '
  2190.         END IF '
  2191.         LOCATE 1, 70 '
  2192.         PRINT "STATS"; '
  2193.  
  2194.         IF fingerIsOnSurface%(600, 0, 32, 16) THEN '
  2195.             HUDpromt$ = "Game main menu" '
  2196.             COLOR GREEN4, GREEN1 '
  2197.             IF Finger.clickL THEN menuMain` = TRUE
  2198.         ELSE '
  2199.             COLOR GREEN1, GREEN4 '
  2200.         END IF '
  2201.         LOCATE 1, 76 '
  2202.         PRINT "MENU"; '
  2203.     ELSE '                                 ¿
  2204.         COLOR GREEN1, GREEN4 '             ³ not players turn or
  2205.         LOCATE 1, 56 '                     ³ he's grabbing something,
  2206.         PRINT "POCKET SPELLS STATS MENU"; '³ decive him
  2207.     END IF '                               ¾
  2208.     LINE (0, 15)-(639, 15), GREEN1 ' divisory line between upper half and lower half of HUD
  2209.  
  2210.     IF Hero.attributePoints > 0 THEN lvlUpHUDButton 600, 17
  2211.  
  2212.     COLOR GREEN1, GREEN4 ' leave normal printing color before leaving, so we don't conflictuate with other stuff
  2213.  
  2214.  
  2215. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  2216. SUB printHUDpromt (whatDoIPrint$)
  2217.     LOCATE 2, 1 '               promt line position
  2218.     COLOR GREEN1, GREEN4 '      always normal color for writing
  2219.     PRINT whatDoIPrint$;
  2220. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  2221. SUB lvlUpHUDButton (x%, y%)
  2222.     _PUTIMAGE (x%, y%), LvlImg&(0) '                                                    draw Lvl image
  2223.     _PUTIMAGE (x% + 16, y%), DirArrowImg&(4) '                                          draw DirArrow upside
  2224.     IF fingerIsOnSurface%(x%, y%, 32, 16) AND inHand.lvl = -1 AND NOT menuMain` THEN '  if the mouse is over this images, no items held on hand and not main menu open
  2225.         HUDpromt$ = "Increase your attributes" '                                        inform user
  2226.         IF Finger.clickL THEN menuStats` = TRUE '                                       and if you click in it, then open the stats menu
  2227.     END IF
  2228. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  2229.  
  2230. SUB showHistory (momentOfHistory%) 'dude, use your fantasy
  2231.     COLOR GREEN1, GREEN4
  2232.     CLS , GREEN4
  2233.     SELECT CASE momentOfHistory%
  2234.         CASE 0
  2235.             drawItemSlots 16, 24
  2236.             _PUTIMAGE (16, 24), calculateHeroImg&(Hero.class, Hero.lvl)
  2237.             PRINTslowly 2, 8, Hero.id + "'s history starts here:"
  2238.             PRINTslowly 3, 8, "During the year 634 a.k. the crisis of the water increased and the"
  2239.             PRINTslowly 4, 8, "habitants of Natrium were in the need to find new places to extract"
  2240.             PRINTslowly 5, 2, "the precius liquid, and bring it to the city to overome the problem."
  2241.             PRINTslowly 6, 2, "Our hero was one of these scouts, who reached a land called:"
  2242.             PRINTslowly 8, 36, "FANTASYLAND"
  2243.             PRINTslowly 10, 2, "a strange place indeed, poorly explored by the habitants of Natrium."
  2244.             PRINTslowly 11, 2, "And something strange is happening there: after renting a room in the"
  2245.             PRINTslowly 12, 2, "town central plaza, and in his first night trying to sleep there"
  2246.             PRINTslowly 13, 2, Hero.id + " heard some very strange noises. And as a good scout"
  2247.             PRINTslowly 14, 2, "he went to investigate..."
  2248.             SLEEP
  2249.             CLS , GREEN4
  2250.             PRINTslowly 14, 20, "What he found was disturbing..."
  2251.             SLEEP
  2252.     END SELECT
  2253. ' this history sucks XD
  2254. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  2255. SUB loadProgramInitialVariables ()
  2256.     DIM x%
  2257.     DIM y%
  2258.     DIM i%
  2259.  
  2260.     actualMapWorking%% = -1 '               with no map yet
  2261.     lastMapWorking%% = actualMapWorking%% ' for drawMap check
  2262.     menuMain` = TRUE '                      program starts leading to the main menu
  2263.     playerTurn` = TRUE '                    Of course, the player starts
  2264.     menuPocket` = FALSE '¿
  2265.     menuSpells` = FALSE '³ <---------------  all menus at start must be closed
  2266.     menuStats` = FALSE ' ¾
  2267.  
  2268.     'initialize mouse variables
  2269.     Finger.x = 319
  2270.     Finger.y = 239
  2271.     Finger.image = FingerImg&(0)
  2272.  
  2273.     ' EQUIPPED positions
  2274.     Pocket(0).x = 542: Pocket(0).y = 136 '  head
  2275.     Pocket(1).x = 582: Pocket(1).y = 147 '  neck
  2276.     Pocket(2).x = 498: Pocket(2).y = 191 '  right hand
  2277.     Pocket(3).x = 542: Pocket(3).y = 191 '  torso
  2278.     Pocket(4).x = 586: Pocket(4).y = 191 '  right hand
  2279.     Pocket(5).x = 514: Pocket(5).y = 244 '  right finger
  2280.     Pocket(6).x = 569: Pocket(6).y = 244 '  left finger
  2281.  
  2282.  
  2283.     ' POCKET positions
  2284.     x% = 332
  2285.     y% = 136
  2286.     FOR i% = 7 TO 10
  2287.         Pocket(i%).x = x% + (i% - 7) * 36
  2288.         Pocket(i%).y = y%
  2289.         Pocket(i% + 4).x = x% + (i% - 7) * 36
  2290.         Pocket(i% + 4).y = y% + 36
  2291.         Pocket(i% + 8).x = x% + (i% - 7) * 36
  2292.         Pocket(i% + 8).y = y% + 72
  2293.         Pocket(i% + 12).x = x% + (i% - 7) * 36
  2294.         Pocket(i% + 12).y = y% + 108
  2295.     NEXT i%
  2296.  
  2297.     'let's also set some variables of the hand
  2298.     inHand.x = Finger.x
  2299.     inHand.y = Finger.y
  2300.     cleanYourHand
  2301.  
  2302.     FOR i% = 0 TO 22 '        ¿
  2303.         Pocket(i%).map = -1 ' ³ during all game .map for
  2304.     NEXT i% '                 ³ pocket and inHand is always -1
  2305.     inHand.map = -1 '         ¾
  2306.  
  2307. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  2308. SUB drawFourHeartAsPercentage (x%, y%, percent%)
  2309.     IF percent% > 99 THEN '                     ¿
  2310.         _PUTIMAGE (x%, y%), HeartImg&(0) '      ³ full
  2311.         _PUTIMAGE (x% + 8, y%), HeartImg&(0) '  ³ health
  2312.         _PUTIMAGE (x% + 16, y%), HeartImg&(0) ' ³
  2313.         _PUTIMAGE (x% + 24, y%), HeartImg&(0) ' Ù
  2314.     ELSEIF percent% > 74 THEN '                                   ¿
  2315.         _PUTIMAGE (x%, y%), HeartImg&(0) '                        ³
  2316.         _PUTIMAGE (x% + 8, y%), HeartImg&(0) '                    ³
  2317.         _PUTIMAGE (x% + 16, y%), HeartImg&(0) '                   ³ 99 to 75 %
  2318.         SELECT CASE percent% '                                    ³ health
  2319.             CASE 95 TO 99: _PUTIMAGE (x% + 24, y%), HeartImg&(1)
  2320.             CASE 90 TO 94: _PUTIMAGE (x% + 24, y%), HeartImg&(2)
  2321.             CASE 85 TO 89: _PUTIMAGE (x% + 24, y%), HeartImg&(3)
  2322.             CASE 80 TO 84: _PUTIMAGE (x% + 24, y%), HeartImg&(4)
  2323.             CASE 75 TO 79: _PUTIMAGE (x% + 24, y%), HeartImg&(5)
  2324.         END SELECT '                                              Ù
  2325.     ELSEIF percent% > 49 THEN '                                   ¿
  2326.         _PUTIMAGE (x%, y%), HeartImg&(0) '                        ³
  2327.         _PUTIMAGE (x% + 8, y%), HeartImg&(0) '                    ³
  2328.         _PUTIMAGE (x% + 24, y%), HeartImg&(5) '                   ³
  2329.         SELECT CASE percent% '                                    ³ 74 to 50 %
  2330.             CASE 70 TO 74: _PUTIMAGE (x% + 16, y%), HeartImg&(1) '³ health
  2331.             CASE 65 TO 69: _PUTIMAGE (x% + 16, y%), HeartImg&(2)
  2332.             CASE 60 TO 64: _PUTIMAGE (x% + 16, y%), HeartImg&(3)
  2333.             CASE 55 TO 59: _PUTIMAGE (x% + 16, y%), HeartImg&(4)
  2334.             CASE 50 TO 54: _PUTIMAGE (x% + 16, y%), HeartImg&(5)
  2335.         END SELECT '                                              Ù
  2336.     ELSEIF percent% > 24 THEN '                                   ¿
  2337.         _PUTIMAGE (x%, y%), HeartImg&(0) '                        ³
  2338.         _PUTIMAGE (x% + 16, y%), HeartImg&(5) '                   ³
  2339.         _PUTIMAGE (x% + 24, y%), HeartImg&(5) '                   ³
  2340.         SELECT CASE percent% '                                    ³ 49 to 25 %
  2341.             CASE 45 TO 49: _PUTIMAGE (x% + 8, y%), HeartImg&(1) ' ³ health
  2342.             CASE 40 TO 44: _PUTIMAGE (x% + 8, y%), HeartImg&(2) ' ³
  2343.             CASE 35 TO 39: _PUTIMAGE (x% + 8, y%), HeartImg&(3) ' ³
  2344.             CASE 30 TO 34: _PUTIMAGE (x% + 8, y%), HeartImg&(4) ' ³
  2345.             CASE 25 TO 29: _PUTIMAGE (x% + 8, y%), HeartImg&(5) ' ³
  2346.         END SELECT '                                              Ù
  2347.     ELSE '                                                        ¿
  2348.         _PUTIMAGE (x% + 8, y%), HeartImg&(5) '                    ³
  2349.         _PUTIMAGE (x% + 16, y%), HeartImg&(5) '                   ³
  2350.         _PUTIMAGE (x% + 24, y%), HeartImg&(5) '                   ³
  2351.         SELECT CASE percent% '                                    ³ 25 to 0 %
  2352.             CASE 20 TO 24: _PUTIMAGE (x%, y%), HeartImg&(1) '     ³ health
  2353.             CASE 15 TO 19: _PUTIMAGE (x%, y%), HeartImg&(2) '     ³
  2354.             CASE 10 TO 14: _PUTIMAGE (x%, y%), HeartImg&(3) '     ³
  2355.             CASE 5 TO 9: _PUTIMAGE (x%, y%), HeartImg&(4) '       ³
  2356.             CASE 0 TO 4: _PUTIMAGE (x%, y%), HeartImg&(5) '       ³
  2357.         END SELECT '                                              ³
  2358.     END IF '                                                      Ù
  2359.  
  2360. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  2361. SUB barShowingPercentage (x%, y%, percent%)
  2362.  
  2363.     _PUTIMAGE (x%, y%), BarImg&(0) ' opening bar
  2364.     _PUTIMAGE (x% + 40, y%), BarImg&(6) ' closing bar
  2365.     '
  2366.     IF percent% > 99 THEN '                  ¿
  2367.         _PUTIMAGE (x% + 8, y%), BarImg&(1) ' ³ 100%
  2368.         _PUTIMAGE (x% + 16, y%), BarImg&(1)
  2369.         _PUTIMAGE (x% + 24, y%), BarImg&(1)
  2370.         _PUTIMAGE (x% + 32, y%), BarImg&(1)
  2371.     ELSEIF percent% > 74 THEN '                                 ¿
  2372.         _PUTIMAGE (x% + 8, y%), BarImg&(1) '                    ³
  2373.         _PUTIMAGE (x% + 16, y%), BarImg&(1) '                   ³
  2374.         _PUTIMAGE (x% + 24, y%), BarImg&(1) '                   ³
  2375.         SELECT CASE percent% '                                  ³ 99 to 75 %
  2376.             CASE 95 TO 99: _PUTIMAGE (x% + 32, y%), BarImg&(1)
  2377.             CASE 90 TO 94: _PUTIMAGE (x% + 32, y%), BarImg&(2)
  2378.             CASE 85 TO 89: _PUTIMAGE (x% + 32, y%), BarImg&(3)
  2379.             CASE 80 TO 84: _PUTIMAGE (x% + 32, y%), BarImg&(4)
  2380.             CASE 75 TO 79: _PUTIMAGE (x% + 32, y%), BarImg&(5)
  2381.         END SELECT '                                            Ù
  2382.     ELSEIF percent% > 49 THEN '                                 ¿
  2383.         _PUTIMAGE (x% + 8, y%), BarImg&(1) '                    ³
  2384.         _PUTIMAGE (x% + 16, y%), BarImg&(1) '                   ³
  2385.         _PUTIMAGE (x% + 32, y%), BarImg&(5) '                   ³ 74 to 50 %
  2386.         SELECT CASE percent% '                                  ³
  2387.             CASE 70 TO 74: _PUTIMAGE (x% + 24, y%), BarImg&(1)
  2388.             CASE 65 TO 69: _PUTIMAGE (x% + 24, y%), BarImg&(2)
  2389.             CASE 60 TO 64: _PUTIMAGE (x% + 24, y%), BarImg&(3)
  2390.             CASE 55 TO 59: _PUTIMAGE (x% + 24, y%), BarImg&(4)
  2391.             CASE 50 TO 54: _PUTIMAGE (x% + 24, y%), BarImg&(5)
  2392.         END SELECT '                                            Ù
  2393.     ELSEIF percent% > 24 THEN '                                 ¿
  2394.         _PUTIMAGE (x% + 8, y%), BarImg&(1) '                    ³
  2395.         _PUTIMAGE (x% + 24, y%), BarImg&(5) '                   ³
  2396.         _PUTIMAGE (x% + 32, y%), BarImg&(5) '                   ³
  2397.         SELECT CASE percent% '                                  ³ 49 to 25 %
  2398.             CASE 45 TO 49: _PUTIMAGE (x% + 16, y%), BarImg&(1)
  2399.             CASE 40 TO 44: _PUTIMAGE (x% + 16, y%), BarImg&(2)
  2400.             CASE 35 TO 39: _PUTIMAGE (x% + 16, y%), BarImg&(3)
  2401.             CASE 30 TO 34: _PUTIMAGE (x% + 16, y%), BarImg&(4)
  2402.             CASE 25 TO 29: _PUTIMAGE (x% + 16, y%), BarImg&(5)
  2403.         END SELECT '                                            Ù
  2404.     ELSE '                                                      ¿
  2405.         _PUTIMAGE (x% + 16, y%), BarImg&(5) '                   ³
  2406.         _PUTIMAGE (x% + 24, y%), BarImg&(5) '                   ³
  2407.         _PUTIMAGE (x% + 32, y%), BarImg&(5) '                   ³
  2408.         SELECT CASE percent% '                                  ³
  2409.             CASE 20 TO 24: _PUTIMAGE (x% + 8, y%), BarImg&(1) ' ³ 25 to 0 %
  2410.             CASE 15 TO 19: _PUTIMAGE (x% + 8, y%), BarImg&(2) ' ³
  2411.             CASE 10 TO 14: _PUTIMAGE (x% + 8, y%), BarImg&(3) ' ³
  2412.             CASE 5 TO 9: _PUTIMAGE (x% + 8, y%), BarImg&(4) '   ³
  2413.             CASE 0 TO 4: _PUTIMAGE (x% + 8, y%), BarImg&(5) '   ³
  2414.         END SELECT '                                            ³
  2415.     END IF '                                                    Ù
  2416.  
  2417. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  2418. SUB drawMenuBack (strX%, strY%, endX%, endY%)
  2419.     LINE (strX%, strY%)-(endX%, endY%), GREEN4, B
  2420.     LINE (strX% + 1, strY% + 1)-(endX% - 1, endY% - 1), GREEN3, B
  2421.     LINE (strX% + 2, strY% + 2)-(endX% - 2, endY% - 2), GREEN2, B
  2422.     LINE (strX% + 3, strY% + 3)-(endX% - 3, endY% - 3), GREEN1, B
  2423.     LINE (strX% + 4, strY% + 4)-(endX% - 4, endY% - 4), GREEN2, B
  2424.     LINE (strX% + 5, strY% + 5)-(endX% - 5, endY% - 5), GREEN3, B
  2425.     LINE (strX% + 6, strY% + 6)-(endX% - 6, endY% - 6), GREEN4, BF
  2426. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  2427. SUB drawItemSlots (begX, begY)
  2428.     LINE (begX, begY)-(begX + 32, begY + 32), GREEN1, B
  2429.     LINE (begX + 1, begY + 1)-(begX + 31, begY + 31), GREEN2, BF
  2430. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  2431. FUNCTION fingerIsOnSurface% (begX%, begY%, imagePixelsX%, imagePixelsY%)
  2432.     IF ((Finger.x >= begX% AND Finger.x <= begX% + (imagePixelsX% - 1)) AND (Finger.y >= begY% AND Finger.y <= begY% + (imagePixelsY% - 1))) THEN
  2433.         fingerIsOnSurface% = TRUE
  2434.     ELSE
  2435.         fingerIsOnSurface% = FALSE
  2436.     END IF
  2437. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  2438. SUB PRINTslowly (originY%, originX%, message$)
  2439.     DIM i%
  2440.     i% = 0 '                                                Ä¿
  2441.     DO '                                                     ³
  2442.         _DELAY .05 '                                         ³
  2443.         i% = i% + 1 '                                        ³ print message$
  2444.         buildingMessage$ = LEFT$(message$, i%) + CHR$(219) ' ³ character by character
  2445.         LOCATE originY%, originX% '                          ³ and erease the cursor
  2446.         PRINT buildingMessage$; '                            ³
  2447.     LOOP UNTIL LEN(buildingMessage$) = LEN(message$) + 1 '  ÄÙ
  2448.     LOCATE CSRLIN, originX% + LEN(message$): PRINT " "; ' erease cursor
  2449. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  2450. SUB drawMyFantasy ()
  2451.     drawWorld
  2452.     'drawPortals
  2453.     drawItemsOnGround
  2454.     'drawMechs
  2455.     drawHero
  2456.     drawEnemies
  2457.     'drawFlyingObjectOrExplosion
  2458. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  2459. SUB TESTER () ' <KILL ME AFTER TESTINGS>
  2460.     COLOR GREEN1, GREEN4
  2461.     LOCATE 27, 1
  2462.     PRINT (Finger.y \ 16) + 1; ","; (Finger.x \ 8) + 1
  2463.     LOCATE 28, 1
  2464.     PRINT "x="; Finger.x;
  2465.     LOCATE 29, 1
  2466.     PRINT "y="; Finger.y;
  2467.     PSET (Finger.x, Finger.y), _RGB32(255, 0, 0) '
  2468. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  2469. SUB checkForAssets ()
  2470.     IF NOT _DIREXISTS(".\data") THEN fatalError "data folder"
  2471.     CHDIR ".\data" 'we are @ Fantasy\data\
  2472.     IF NOT _DIREXISTS(".\images") THEN fatalError "images folder"
  2473.     IF NOT _DIREXISTS(".\sounds") THEN fatalError "sounds folder"
  2474.     IF NOT _DIREXISTS(".\worlds") THEN fatalError "worlds folder"
  2475.     IF NOT _DIREXISTS(".\saved") THEN fatalError "saved folder"
  2476.     'if no more directories for check then check the images
  2477.     CHDIR ".\images" 'we are @ Fantasy\data\images\
  2478.     IF NOT _FILEEXISTS(".\armor.png") THEN fatalError "armor.png"
  2479.     IF NOT _FILEEXISTS(".\arrow.png") THEN fatalError "arrow.png"
  2480.     IF NOT _FILEEXISTS(".\axe.png") THEN fatalError "axe.png"
  2481.     IF NOT _FILEEXISTS(".\bar.png") THEN fatalError "bar.png"
  2482.     IF NOT _FILEEXISTS(".\bijou.png") THEN fatalError "bijou.png"
  2483.     IF NOT _FILEEXISTS(".\bolt.png") THEN fatalError "bolt.png"
  2484.     IF NOT _FILEEXISTS(".\bomb.png") THEN fatalError "bomb.png"
  2485.     IF NOT _FILEEXISTS(".\book.png") THEN fatalError "book.png"
  2486.     IF NOT _FILEEXISTS(".\bow.png") THEN fatalError "bow.png"
  2487.     IF NOT _FILEEXISTS(".\chest.png") THEN fatalError "chest.png"
  2488.     IF NOT _FILEEXISTS(".\crossbow.png") THEN fatalError "crossbow.png"
  2489.     IF NOT _FILEEXISTS(".\dirArrow.png") THEN fatalError "dirArrow.png"
  2490.     IF NOT _FILEEXISTS(".\enemy.png") THEN fatalError "enemy.png"
  2491.     IF NOT _FILEEXISTS(".\finger.png") THEN fatalError "finger.png"
  2492.     IF NOT _FILEEXISTS(".\gndItems.png") THEN fatalError "gndItems.png"
  2493.     IF NOT _FILEEXISTS(".\heart.png") THEN fatalError "heart.png"
  2494.     IF NOT _FILEEXISTS(".\helm.png") THEN fatalError "helm.png"
  2495.     IF NOT _FILEEXISTS(".\hero.png") THEN fatalError "hero.png"
  2496.     IF NOT _FILEEXISTS(".\hud.png") THEN fatalError "hud.png"
  2497.     IF NOT _FILEEXISTS(".\key.png") THEN fatalError "key.png"
  2498.     IF NOT _FILEEXISTS(".\light.png") THEN fatalError "light.png"
  2499.     IF NOT _FILEEXISTS(".\lvl.png") THEN fatalError "lvl.png"
  2500.     IF NOT _FILEEXISTS(".\money.png") THEN fatalError "money.png"
  2501.     IF NOT _FILEEXISTS(".\paper.png") THEN fatalError "paper.png"
  2502.     IF NOT _FILEEXISTS(".\portal.png") THEN fatalError "portal.png"
  2503.     IF NOT _FILEEXISTS(".\potion.png") THEN fatalError "potion.png"
  2504.     IF NOT _FILEEXISTS(".\shield.png") THEN fatalError "shield.png"
  2505.     IF NOT _FILEEXISTS(".\spell.png") THEN fatalError "spell.png"
  2506.     IF NOT _FILEEXISTS(".\sword.png") THEN fatalError "sword.png"
  2507.     IF NOT _FILEEXISTS(".\throw.png") THEN fatalError "throw.png"
  2508.     IF NOT _FILEEXISTS(".\wand.png") THEN fatalError "wand.png"
  2509.     IF NOT _FILEEXISTS(".\world.png") THEN fatalError "world.png"
  2510.     CHDIR ".\.." 'we are @ Fantasy\data\
  2511.  
  2512. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  2513. SUB fatalError (thingNotFound$)
  2514.     CLS , GREEN4
  2515.     LOCATE 2, 2
  2516.     COLOR GREEN1, GREEN4
  2517.     PRINT "Fatal error: " + thingNotFound$ + " not found"
  2518.     SLEEP
  2519.     SYSTEM
  2520. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  2521. SUB loadImages ()
  2522.     DIM tmpImg&
  2523.     DIM i%
  2524.     CHDIR ".\images"
  2525.     'we are @ Fantasy\data\images\
  2526.     tmpImg& = _LOADIMAGE(".\armor.png", 32): FOR i% = 0 TO 7: ArmorImg&(i%) = _NEWIMAGE(32, 32, 32): _PUTIMAGE (0, 0), tmpImg&, ArmorImg&(i%), (i% * 32, 0)-(i% * 32 + 31, 31): NEXT i%: _FREEIMAGE tmpImg&
  2527.     tmpImg& = _LOADIMAGE(".\arrow.png", 32): FOR i% = 0 TO 2: ArrowImg&(i%) = _NEWIMAGE(32, 32, 32): _PUTIMAGE (0, 0), tmpImg&, ArrowImg&(i%), (i% * 32, 0)-(i% * 32 + 31, 31): NEXT i%: _FREEIMAGE tmpImg&
  2528.     tmpImg& = _LOADIMAGE(".\axe.png", 32): FOR i% = 0 TO 7: AxeImg&(i%) = _NEWIMAGE(32, 32, 32): _PUTIMAGE (0, 0), tmpImg&, AxeImg&(i%), (i% * 32, 0)-(i% * 32 + 31, 31): NEXT i%: _FREEIMAGE tmpImg&
  2529.     tmpImg& = _LOADIMAGE(".\bar.png", 32): FOR i% = 0 TO 6: BarImg&(i%) = _NEWIMAGE(8, 8, 32): _PUTIMAGE (0, 0), tmpImg&, BarImg&(i%), (i% * 8, 0)-(i% * 8 + 7, 7): NEXT i%: _FREEIMAGE tmpImg&
  2530.     tmpImg& = _LOADIMAGE(".\bijou.png", 32): FOR i% = 0 TO 3: BijouImg&(i%) = _NEWIMAGE(32, 32, 32): _PUTIMAGE (0, 0), tmpImg&, BijouImg&(i%), (i% * 32, 0)-(i% * 32 + 31, 31): NEXT i%: _FREEIMAGE tmpImg&
  2531.     tmpImg& = _LOADIMAGE(".\bolt.png", 32): FOR i% = 0 TO 1: BoltImg&(i%) = _NEWIMAGE(32, 32, 32): _PUTIMAGE (0, 0), tmpImg&, BoltImg&(i%), (i% * 32, 0)-(i% * 32 + 31, 31): NEXT i%: _FREEIMAGE tmpImg&
  2532.     tmpImg& = _LOADIMAGE(".\bomb.png", 32): FOR i% = 0 TO 2: BombImg&(i%) = _NEWIMAGE(32, 32, 32): _PUTIMAGE (0, 0), tmpImg&, BombImg&(i%), (i% * 32, 0)-(i% * 32 + 31, 31): NEXT i%: _FREEIMAGE tmpImg&
  2533.     tmpImg& = _LOADIMAGE(".\book.png", 32): FOR i% = 0 TO 3: BookImg&(i%) = _NEWIMAGE(32, 32, 32): _PUTIMAGE (0, 0), tmpImg&, BookImg&(i%), (i% * 32, 0)-(i% * 32 + 31, 31): NEXT i%: _FREEIMAGE tmpImg&
  2534.     tmpImg& = _LOADIMAGE(".\bow.png", 32): FOR i% = 0 TO 2: BowImg&(i%) = _NEWIMAGE(32, 32, 32): _PUTIMAGE (0, 0), tmpImg&, BowImg&(i%), (i% * 32, 0)-(i% * 32 + 31, 31): NEXT i%: _FREEIMAGE tmpImg&
  2535.     tmpImg& = _LOADIMAGE(".\chest.png", 32): FOR i% = 0 TO 1: ChestImg&(i%) = _NEWIMAGE(32, 32, 32): _PUTIMAGE (0, 0), tmpImg&, ChestImg&(i%), (i% * 32, 0)-(i% * 32 + 31, 31): NEXT i%: _FREEIMAGE tmpImg&
  2536.     tmpImg& = _LOADIMAGE(".\crossbow.png", 32): FOR i% = 0 TO 1: CrossbowImg&(i%) = _NEWIMAGE(32, 32, 32): _PUTIMAGE (0, 0), tmpImg&, CrossbowImg&(i%), (i% * 32, 0)-(i% * 32 + 31, 31): NEXT i%: _FREEIMAGE tmpImg&
  2537.     tmpImg& = _LOADIMAGE(".\dirArrow.png", 32): FOR i% = 0 TO 12: DirArrowImg&(i%) = _NEWIMAGE(16, 16, 32): _PUTIMAGE (0, 0), tmpImg&, DirArrowImg&(i%), (i% * 16, 0)-(i% * 16 + 15, 15): NEXT i%: _FREEIMAGE tmpImg&
  2538.     tmpImg& = _LOADIMAGE(".\enemy.png", 32)
  2539.     FOR i% = 0 TO 7
  2540.         EnemyImg&(i%) = _NEWIMAGE(32, 32, 32): _PUTIMAGE (0, 0), tmpImg&, EnemyImg&(i%), (i% * 32, 0)-(i% * 32 + 31, 31)
  2541.         EnemyImg&(i% + 8) = _NEWIMAGE(32, 32, 32): _PUTIMAGE (0, 0), tmpImg&, EnemyImg&(i% + 8), (i% * 32, 32)-(i% * 32 + 31, 63)
  2542.         EnemyImg&(i% + 16) = _NEWIMAGE(32, 32, 32): _PUTIMAGE (0, 0), tmpImg&, EnemyImg&(i% + 16), (i% * 32, 64)-(i% * 32 + 31, 95)
  2543.         EnemyImg&(i% + 24) = _NEWIMAGE(32, 32, 32): _PUTIMAGE (0, 0), tmpImg&, EnemyImg&(i% + 24), (i% * 32, 96)-(i% * 32 + 31, 127)
  2544.     NEXT i%: _FREEIMAGE tmpImg&
  2545.     tmpImg& = _LOADIMAGE(".\finger.png", 32): FOR i% = 0 TO 8: FingerImg&(i%) = _NEWIMAGE(16, 16, 32): _PUTIMAGE (0, 0), tmpImg&, FingerImg&(i%), (i% * 16, 0)-(i% * 16 + 15, 15): NEXT i%: _FREEIMAGE tmpImg&
  2546.     tmpImg& = _LOADIMAGE(".\gndItems.png", 32): FOR i% = 0 TO 17: GndItemsImg&(i%) = _NEWIMAGE(16, 16, 32): _PUTIMAGE (0, 0), tmpImg&, GndItemsImg&(i%), (i% * 16, 0)-(i% * 16 + 15, 15): NEXT i%: _FREEIMAGE tmpImg&
  2547.     tmpImg& = _LOADIMAGE(".\heart.png", 32): FOR i% = 0 TO 5: HeartImg&(i%) = _NEWIMAGE(8, 8, 32): _PUTIMAGE (0, 0), tmpImg&, HeartImg&(i%), (i% * 8, 0)-(i% * 8 + 7, 7): NEXT i%: _FREEIMAGE tmpImg&
  2548.     tmpImg& = _LOADIMAGE(".\helm.png", 32): FOR i% = 0 TO 7: HelmImg&(i%) = _NEWIMAGE(32, 32, 32): _PUTIMAGE (0, 0), tmpImg&, HelmImg&(i%), (i% * 32, 0)-(i% * 32 + 31, 31): NEXT i%: _FREEIMAGE tmpImg&
  2549.     tmpImg& = _LOADIMAGE(".\hero.png", 32): FOR i% = 0 TO 7: HeroImg&(i%) = _NEWIMAGE(32, 32, 32): _PUTIMAGE (0, 0), tmpImg&, HeroImg&(i%), (i% * 32, 0)-(i% * 32 + 31, 31): NEXT i%: _FREEIMAGE tmpImg&
  2550.     tmpImg& = _LOADIMAGE(".\hud.png", 32): FOR i% = 0 TO 3: HUDImg&(i%) = _NEWIMAGE(16, 16, 32): _PUTIMAGE (0, 0), tmpImg&, HUDImg&(i%), (i% * 16, 0)-(i% * 16 + 15, 15): NEXT i%: _FREEIMAGE tmpImg&
  2551.     tmpImg& = _LOADIMAGE(".\key.png", 32): FOR i% = 0 TO 5: KeyImg&(i%) = _NEWIMAGE(32, 32, 32): _PUTIMAGE (0, 0), tmpImg&, KeyImg&(i%), (i% * 32, 0)-(i% * 32 + 31, 31): NEXT i%: _FREEIMAGE tmpImg&
  2552.     tmpImg& = _LOADIMAGE(".\light.png", 32): FOR i% = 0 TO 7: LightImg&(i%) = _NEWIMAGE(32, 32, 32): _PUTIMAGE (0, 0), tmpImg&, LightImg&(i%), (i% * 32, 0)-(i% * 32 + 31, 31): NEXT i%: _FREEIMAGE tmpImg&
  2553.     tmpImg& = _LOADIMAGE(".\lvl.png", 32): FOR i% = 0 TO 10: LvlImg&(i%) = _NEWIMAGE(16, 16, 32): _PUTIMAGE (0, 0), tmpImg&, LvlImg&(i%), (i% * 16, 0)-(i% * 16 + 15, 15): NEXT i%: _FREEIMAGE tmpImg&
  2554.     tmpImg& = _LOADIMAGE(".\money.png", 32): FOR i% = 0 TO 3: MoneyImg&(i%) = _NEWIMAGE(32, 32, 32): _PUTIMAGE (0, 0), tmpImg&, MoneyImg&(i%), (i% * 32, 0)-(i% * 32 + 31, 31): NEXT i%: _FREEIMAGE tmpImg&
  2555.     tmpImg& = _LOADIMAGE(".\paper.png", 32): FOR i% = 0 TO 1: PaperImg&(i%) = _NEWIMAGE(32, 32, 32): _PUTIMAGE (0, 0), tmpImg&, PaperImg&(i%), (i% * 32, 0)-(i% * 32 + 31, 31): NEXT i%: _FREEIMAGE tmpImg&
  2556.     tmpImg& = _LOADIMAGE(".\portal.png", 32): FOR i% = 0 TO 7: PortalImg&(i%) = _NEWIMAGE(32, 32, 32): _PUTIMAGE (0, 0), tmpImg&, PortalImg&(i%), (i% * 32, 0)-(i% * 32 + 31, 31): NEXT i%: _FREEIMAGE tmpImg&
  2557.     tmpImg& = _LOADIMAGE(".\potion.png", 32): FOR i% = 0 TO 7: PotionImg&(i%) = _NEWIMAGE(32, 32, 32): _PUTIMAGE (0, 0), tmpImg&, PotionImg&(i%), (i% * 32, 0)-(i% * 32 + 31, 31): NEXT i%: _FREEIMAGE tmpImg&
  2558.     tmpImg& = _LOADIMAGE(".\shield.png", 32): FOR i% = 0 TO 7: ShieldImg&(i%) = _NEWIMAGE(32, 32, 32): _PUTIMAGE (0, 0), tmpImg&, ShieldImg&(i%), (i% * 32, 0)-(i% * 32 + 31, 31): NEXT i%: _FREEIMAGE tmpImg&
  2559.     tmpImg& = _LOADIMAGE(".\spell.png", 32): FOR i% = 0 TO 5: SpellImg&(i%) = _NEWIMAGE(32, 32, 32): _PUTIMAGE (0, 0), tmpImg&, SpellImg&(i%), (i% * 32, 0)-(i% * 32 + 31, 31): NEXT i%: _FREEIMAGE tmpImg&
  2560.     tmpImg& = _LOADIMAGE(".\sword.png", 32): FOR i% = 0 TO 7: SwordImg&(i%) = _NEWIMAGE(32, 32, 32): _PUTIMAGE (0, 0), tmpImg&, SwordImg&(i%), (i% * 32, 0)-(i% * 32 + 31, 31): NEXT i%: _FREEIMAGE tmpImg&
  2561.     tmpImg& = _LOADIMAGE(".\throw.png", 32): FOR i% = 0 TO 2: ThrowImg&(i%) = _NEWIMAGE(32, 32, 32): _PUTIMAGE (0, 0), tmpImg&, ThrowImg&(i%), (i% * 32, 0)-(i% * 32 + 31, 31): NEXT i%: _FREEIMAGE tmpImg&
  2562.     tmpImg& = _LOADIMAGE(".\wand.png", 32): FOR i% = 0 TO 7: WandImg&(i%) = _NEWIMAGE(32, 32, 32): _PUTIMAGE (0, 0), tmpImg&, WandImg&(i%), (i% * 32, 0)-(i% * 32 + 31, 31): NEXT i%: _FREEIMAGE tmpImg&
  2563.     tmpImg& = _LOADIMAGE(".\world.png", 32)
  2564.     FOR i% = 0 TO 7
  2565.         WorldImg&(i%) = _NEWIMAGE(32, 32, 32): _PUTIMAGE (0, 0), tmpImg&, WorldImg&(i%), (i% * 32, 0)-(i% * 32 + 31, 31)
  2566.         WorldImg&(i% + 8) = _NEWIMAGE(32, 32, 32): _PUTIMAGE (0, 0), tmpImg&, WorldImg&(i% + 8), (i% * 32, 32)-(i% * 32 + 31, 63)
  2567.         WorldImg&(i% + 16) = _NEWIMAGE(32, 32, 32): _PUTIMAGE (0, 0), tmpImg&, WorldImg&(i% + 16), (i% * 32, 64)-(i% * 32 + 31, 95)
  2568.     NEXT i%: _FREEIMAGE tmpImg&
  2569.     BlankImg& = _NEWIMAGE(1, 1, 32)
  2570.     CHDIR ".\.." ' back to data
  2571.     'we are @ Fantasy\data\
  2572. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  2573. SUB unloadImages ()
  2574.     DIM i%
  2575.     FOR i% = 0 TO 7: _FREEIMAGE ArmorImg&(i%): NEXT i%
  2576.     FOR i% = 0 TO 2: _FREEIMAGE ArrowImg&(i%): NEXT i%
  2577.     FOR i% = 0 TO 7: _FREEIMAGE AxeImg&(i%): NEXT i%
  2578.     FOR i% = 0 TO 6: _FREEIMAGE BarImg&(i%): NEXT i%
  2579.     FOR i% = 0 TO 3: _FREEIMAGE BijouImg&(i%): NEXT i%
  2580.     FOR i% = 0 TO 1: _FREEIMAGE BoltImg&(i%): NEXT i%
  2581.     FOR i% = 0 TO 2: _FREEIMAGE BombImg&(i%): NEXT i%
  2582.     FOR i% = 0 TO 3: _FREEIMAGE BookImg&(i%): NEXT i%
  2583.     FOR i% = 0 TO 2: _FREEIMAGE BowImg&(i%): NEXT i%
  2584.     FOR i% = 0 TO 1: _FREEIMAGE ChestImg&(i%): NEXT i%
  2585.     FOR i% = 0 TO 1: _FREEIMAGE CrossbowImg&(i%): NEXT i%
  2586.     FOR i% = 0 TO 12: _FREEIMAGE DirArrowImg&(i%): NEXT i%
  2587.     FOR i% = 0 TO 31: _FREEIMAGE EnemyImg&(i%): NEXT i%
  2588.     FOR i% = 0 TO 8: _FREEIMAGE FingerImg&(i%): NEXT i%
  2589.     FOR i% = 0 TO 17: _FREEIMAGE GndItemsImg&(i%): NEXT i%
  2590.     FOR i% = 0 TO 5: _FREEIMAGE HeartImg&(i%): NEXT i%
  2591.     FOR i% = 0 TO 7: _FREEIMAGE HelmImg&(i%): NEXT i%
  2592.     FOR i% = 0 TO 7: _FREEIMAGE HeroImg&(i%): NEXT i%
  2593.     FOR i% = 0 TO 3: _FREEIMAGE HUDImg&(i%): NEXT i%
  2594.     FOR i% = 0 TO 5: _FREEIMAGE KeyImg&(i%): NEXT i%
  2595.     FOR i% = 0 TO 7: _FREEIMAGE LightImg&(i%): NEXT i%
  2596.     FOR i% = 0 TO 10: _FREEIMAGE LvlImg&(i%): NEXT i%
  2597.     FOR i% = 0 TO 3: _FREEIMAGE MoneyImg&(i%): NEXT i%
  2598.     FOR i% = 0 TO 1: _FREEIMAGE PaperImg&(i%): NEXT i%
  2599.     FOR i% = 0 TO 7: _FREEIMAGE PortalImg&(i%): NEXT i%
  2600.     FOR i% = 0 TO 7: _FREEIMAGE PotionImg&(i%): NEXT i%
  2601.     FOR i% = 0 TO 7: _FREEIMAGE ShieldImg&(i%): NEXT i%
  2602.     FOR i% = 0 TO 5: _FREEIMAGE SpellImg&(i%): NEXT i%
  2603.     FOR i% = 0 TO 7: _FREEIMAGE SwordImg&(i%): NEXT i%
  2604.     FOR i% = 0 TO 2: _FREEIMAGE ThrowImg&(i%): NEXT i%
  2605.     FOR i% = 0 TO 7: _FREEIMAGE WandImg&(i%): NEXT i%
  2606.     FOR i% = 0 TO 23: _FREEIMAGE WorldImg&(i%): NEXT i%
  2607.     _FREEIMAGE BlankImg&
  2608. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  2609.  
* Fantasy.rar (Filesize: 62.32 KB, Downloads: 81)

Offline NOVARSEG

  • Forum Resident
  • Posts: 509
    • View Profile
Re: Fantasy
« Reply #19 on: June 24, 2021, 10:55:49 pm »

Hi Juan Tamarit

This is just a guess because I have not tested the code

Quote
  • orgFile& = FREEFILE 'we need two filehandles: one for origin file,
            destFile& = FREEFILE '       and another for destination file
            OPEN "town.txt" FOR INPUT AS #orgFile& '    e will extract info from this file
            OPEN "tmp.txt" FOR OUTPUT AS #destFile& '
[/size]


orgFile& = FREEFILE 'we need two filehandles: one for origin file,
       
OPEN "town.txt" FOR INPUT AS #orgFile& '    e will extract info from this file
       
destFile& = FREEFILE '       and another for destination file

OPEN "tmp.txt" FOR OUTPUT AS #destFile& '



FellippeHeitor

  • Guest
Re: Fantasy
« Reply #20 on: June 24, 2021, 11:01:01 pm »
NOVARSEG is correct. The FREEFILE function won't return a new handle unless the previous one it output is actually used to open a file.

Offline NOVARSEG

  • Forum Resident
  • Posts: 509
    • View Profile
Re: Fantasy
« Reply #21 on: June 24, 2021, 11:15:37 pm »
The clue was here

Quote
I'm having an error that stands "file already open", particularly in line "OPEN "tmp.txt" FOR OUTPUT AS #destFile&".




Offline Juan Tamarit

  • Newbie
  • Posts: 53
    • View Profile
Re: Fantasy
« Reply #22 on: June 25, 2021, 12:57:00 am »
Thank you guys. I solved it. Just a +1 after the second FREEFILE. But i understand what you say: until i don't use the handle for opening the file it won't give me a new one, right? That's why this +1 trick works, isn't it? Ok, i'll switch the order for fitting. Thanks again
« Last Edit: June 25, 2021, 01:01:37 am by Juan Tamarit »

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Re: Fantasy
« Reply #23 on: June 25, 2021, 11:12:35 pm »
very NES Zelda-esk looking.
Question that came up to my mind: do i need to have all these images loaded in variable arrays? Or is there a better an more efficient way to do this? I tried using a function where i loaded a main image, assign what i needed to a tmp&() array, coded the series of decision to choose wich of the indexes i wanted, assign that handle to the function, _freeing the file and exit the function... i didn't worked. Guess that _FREEIMAGE the handle and leaving the function leaves the function without nothing, right?

as with the Bman  I'm not totally sure what your getting at, unless of course you are old skool GETing and PUTing the sprites with an array?!
Granted after becoming radioactive I only have a half-life!

Offline Juan Tamarit

  • Newbie
  • Posts: 53
    • View Profile
Re: Fantasy
« Reply #24 on: June 27, 2021, 04:51:31 am »
Yo dear bro Cobalt. Yes, i'm using an array of longs to place the images. I was asking if there was real need for doing so. b+ mentioned that yes, it was necessary, but also a function could be done with a unique tileset. But for the moment the various arrays for each kind of image makes the code more redable.

Thanks again to all you people for the help and support, even in the most silly questions.

Now, i have new doubts and problems. I'll try to be as much clear as i can: theres an UDT (User Data Type) array called Items, with and index length of just 1, index 0, and its global (SHARED on main module). When the SUB dropItemToGround happens the idea was to increase this array size by one and _PRESERVE, getting a UBOUND(Items) of 1, and then variables of the item that was holded by the hand (inHand is a variable used to manipulate items on the inventory) should suposed to be copied to this new array index. That seems to be working just fine, the item once it's on the ground outputs the rigth data (name, etc.)...

BUT, and here's the trouble, the SUB pickItemFromGround was suposed to do exactly the oposite, transfer the "item on the ground" data to a free slot in the inventory (determined by the FUNCTION lookForSpaceInPocket%, that retrieves the slot number if there's any, or 0 if not). After that the array should be reduced by one (there is some checking for case of last item in the array, but nothing very differrent from other case).
Code: QB64: [Select]
  1. SUB dropItemToGround ()
  2.     REDIM _PRESERVE Items(UBOUND(Items) + 1) AS OBJECT 'Increase the Items array index by one
  3.     Items(UBOUND(Items)).x = Hero.x '¿                  Item will be dropped
  4.     Items(UBOUND(Items)).y = Hero.y '¾                  at players feet
  5.     Items(UBOUND(Items)).kind = inHand.kind '      ¿
  6.     Items(UBOUND(Items)).lvl = inHand.lvl '        ³    We place in this new index
  7.     Items(UBOUND(Items)).ammount = inHand.ammount '³    all the data
  8.     Items(UBOUND(Items)).special = inHand.special '³    relataed to the item
  9.     Items(UBOUND(Items)).map = actualMapWorking%%
  10.     cleanYourHand '                                     And clean all the variables from the "hand"
  11. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  12. SUB pickItemFromGround (indexOfItem%)
  13.     IF lookForSpaceInPocket% THEN '                                                 if theres place in your pocket
  14.         IF indexOfItem% = UBOUND(Items) THEN '                                      and that item is the last one of the array
  15.             Pocket(lookForSpaceInPocket%).kind = Items(idexOfItem%).kind '      ¿
  16.             Pocket(lookForSpaceInPocket%).lvl = Items(idexOfItem%).lvl '        ³   Transfer the data of the item to
  17.             Pocket(lookForSpaceInPocket%).ammount = Items(idexOfItem%).ammount '³   the free place on Pocket
  18.             Pocket(lookForSpaceInPocket%).special = Items(idexOfItem%).special
  19.             REDIM _PRESERVE Items(UBOUND(Items) - 1) AS OBJECT '                    and reduce the array by one (destroying the last one)
  20.         ELSE ' but if the item is not the last one of the array
  21.             Pocket(lookForSpaceInPocket%).kind = Items(idexOfItem%).kind '      ¿
  22.             Pocket(lookForSpaceInPocket%).lvl = Items(idexOfItem%).lvl '        ³   Transfer the data of the item to
  23.             Pocket(lookForSpaceInPocket%).ammount = Items(idexOfItem%).ammount '³   the free place on Pocket
  24.             Pocket(lookForSpaceInPocket%).special = Items(idexOfItem%).special
  25.             Items(indexOfItem%).x = Items(UBOUND(Items)).x '                    ¿
  26.             Items(indexOfItem%).y = Items(UBOUND(Items)).y '                    ³
  27.             Items(indexOfItem%).kind = Items(UBOUND(Items)).kind '              ³   copy all the data of the last item
  28.             Items(indexOfItem%).lvl = Items(UBOUND(Items)).lvl '                ³   in the array to this index of the array,
  29.             Items(indexOfItem%).ammount = Items(UBOUND(Items)).ammount '        ³   overwriting the item we just picked
  30.             Items(indexOfItem%).special = Items(UBOUND(Items)).special '        ³
  31.             Items(indexOfItem%).map = Items(UBOUND(Items)).map '                ¾
  32.             REDIM _PRESERVE Items(UBOUND(Items) - 1) AS OBJECT '                    now we can eliminate the last item of the array (it has been copied to the picked item index)
  33.         END IF
  34.     ELSE '                                                                          if you have no room in pocket
  35.         HUDpromt$ = "You have no room on your pocket" '                             you should be aware of it
  36.     END IF
Running the program the item can be dropped to ground and picked up, but when you wan't to see it's image the function that is suposed to calculate such image brings an error "Subscript out of range", and it confuses completly wich image should be shown, as if the item variables were not copied back to the inventory.

What can be possibly wrong here? This sounded like perfect sense to me when i wrote it... what do you guys think? Is the problem clear or more specifications are required?

Cheers bros.
« Last Edit: June 27, 2021, 05:02:05 am by Juan Tamarit »

Offline Juan Tamarit

  • Newbie
  • Posts: 53
    • View Profile
Re: Fantasy
« Reply #25 on: July 02, 2021, 03:47:59 am »
Hello again. Well, i found the issue: the FUNCTION lookForSpaceInPocket% uses the variable .kind of the Items array, so i was wrong by changing it first to the inventory, has to be the last data trasfered. This avois collapse, but now the item identity is changing and by some reason Pocket().kind and Pocket().lvl are both equal to 0. I will have to find why the data is not being transfered.  Wish me luck on that.

I also added motion to the character based on the WorldTiles%%(), checked the different diection from ehre the character can approach the new position and display arrow accordingly.

I was thinking that maybe the items should work as a stack, since im stacking them when i drop them to the ground, but i don't know how to implement a structure of First In-Last Out.

I also changed the asset wolrd.png to better suit the code and future tile draws that i fell there are missing for more possible ambients (very Mendeleiev style).

I will mention any other advances i'll make. For the moment i have to fix these thing.

Cheers bros, and thanks anyway for the help.


Offline Juan Tamarit

  • Newbie
  • Posts: 53
    • View Profile
Re: Fantasy
« Reply #26 on: July 02, 2021, 04:10:07 am »
WOW! Just found the problem! =) wrong spelling of a variable name and solved. Wroted "idexOfItem%" instead of "indexOfItem%". Sometimes i scare myself. So items can be dropped an picked from the ground, no problems. I'll keep up if theres any more news. Cheeeeers!

Offline Juan Tamarit

  • Newbie
  • Posts: 53
    • View Profile
Re: Fantasy
« Reply #27 on: July 19, 2021, 10:19:30 pm »
Hello nice people from the QB64 forum! Me again with a new doubt i can't figure, but i have a guess. In the following pice of code:

Code: QB64: [Select]
  1. DIM tmp$
  2.  
  3.     CLS
  4.     tmp$ = ""
  5.     IF _KEYDOWN(19200) AND _KEYDOWN(20480) THEN
  6.         tmp$ = "Down & left"
  7.     ELSEIF _KEYDOWN(19712) AND _KEYDOWN(20480) THEN
  8.         tmp$ = "Down & right"
  9.     ELSEIF _KEYDOWN(19200) AND _KEYDOWN(18432) THEN
  10.         tmp$ = "Up & left"
  11.     ELSEIF _KEYDOWN(19712) AND _KEYDOWN(18432) THEN
  12.         tmp$ = "Up & right"
  13.     ELSEIF _KEYDOWN(20480) THEN
  14.         tmp$ = "Down"
  15.     ELSEIF _KEYDOWN(19200) THEN
  16.         tmp$ = "Left"
  17.     ELSEIF _KEYDOWN(19712) THEN
  18.         tmp$ = "Right"
  19.     ELSEIF _KEYDOWN(18432) THEN
  20.         tmp$ = "Up"
  21.     END IF
  22.     IF _KEYDOWN(32) THEN tmp$ = tmp$ + " Spacebar"
  23.     PRINT tmp$;
  24.     _DISPLAY
  25.     _LIMIT 60

I can never get the phrase "Down & left Spacebar" OR "Down & right Spacebar" OR "Up & left Spacebar" OR "Up & right Spacebar"

My guessing: _KEYDOWN() can't read more that two keys at the same time... otherwise i can't figure what is happening. I'll wait for your opinions, suggestions, critics, press rolls or whatever.

On the other hand and good news: the project still advancing at good peace. There's already a commerce system for the items, recharging wands and identifying unidientified objects (of course, lol). A crude system of motion, interaction with some chests and stuff and we can combat with monsters with a ridiculous AI, but functional. I'll promise that ' will upload it as soon as have the "basic engine" working (i started to feel a bit wrong to bother you people with every single advance i make, even if it is very significative or surpraising to me). The game is ABSOLUTLY unbalanced, and i'm working hard on the commenting, so can be as much clear possible to everyone trying to read it.

By the way, i just downloaded the QB64 version 1.5, it's neat! Thanks again to the developers for creating this powerful and beatiful tool, and allowing people to download it. I really feel that with this compiler you can build ANYTHING. Be sure: you will be in the credits of the project, lol.

Ok, so i'll wait for your replies. Thanks before hand and cheers to all.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Fantasy
« Reply #28 on: July 20, 2021, 07:52:56 am »
Confirm spacebar not always showing up. For me, down left spacebar does show but not down right spacebar.

Have you tried _KEYHIT or combos of _KEYDOWN and _KEYHIT?

@SMcNeill has worked up alternate key system(s) fixes try searching?


Offline Juan Tamarit

  • Newbie
  • Posts: 53
    • View Profile
Re: Fantasy
« Reply #29 on: July 21, 2021, 12:56:16 am »
Dear bro bPlus, thanks for your reply. I have tried these different methods. Excuse me if they aren't very smart, but they matches their author:

Code: QB64: [Select]
  1. 'Problem with combination of arrows, Ctrl, Shift, Alt and the Spacebar
  2.  
  3. CONST FALSE = 0: CONST TRUE = NOT FALSE
  4. '° CASE 0 °- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  5.  
  6. DIM SHARED tmp$
  7.  
  8. DIM SHARED Spacebar%
  9. DIM SHARED Ctrl%
  10. DIM SHARED Shift%
  11. DIM SHARED Alt%
  12.  
  13.  
  14. DIM SHARED left%
  15. DIM SHARED right%
  16. DIM SHARED down%
  17.  
  18. 'FUNNY: in all cases "Up & right" seems to work okay with any other key, what's wrong with the others?
  19.  
  20.     CLS
  21.     key$ = ""
  22.     tmp$ = ""
  23.     Spacebar% = FALSE
  24.     Ctrl% = FALSE
  25.     Shift% = FALSE
  26.     Alt% = FALSE
  27.  
  28.     registerArrows
  29.  
  30.  
  31.  
  32.     'CHANGE MY NUMBER to see different methods
  33.     method5
  34.  
  35.     IF Spacebar% THEN
  36.         tmp$ = tmp$ + " + Spacebar"
  37.     ELSEIF Ctrl% THEN
  38.         tmp$ = tmp$ + " + Ctrl"
  39.     ELSEIF Shift% THEN
  40.         tmp$ = tmp$ + " + Shift"
  41.     ELSEIF Alt% THEN
  42.         tmp$ = tmp$ + " + Alt"
  43.     END IF
  44.  
  45.     PRINT tmp$;
  46.     _DISPLAY
  47.     _LIMIT 60
  48. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  49. SUB method5 () 'using _KEYHIT, using the long to decide what's TRUE
  50.  
  51.     DIM keyhitLong&
  52.  
  53.     keyhitLong& = _KEYHIT
  54.  
  55.     IF keyhitLong& = 32 THEN Spacebar% = TRUE
  56.     IF keyhitLong& = 100306 THEN Ctrl% = TRUE
  57.     IF keyhitLong& = 100304 THEN Shift% = TRUE
  58.     IF keyhitLong& = 100308 THEN Alt% = TRUE
  59.  
  60.     'Same result as method2, but with some flickering and  not continuous
  61.  
  62. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  63. SUB method4 () 'using _KEYDOWN directly as the variable%, but with _KEYCLEAR before
  64.  
  65.     _KEYCLEAR ' MAYBE CLEARING THE BUFFER BEFORE?
  66.  
  67.     Spacebar% = _KEYDOWN(32)
  68.     Ctrl% = _KEYDOWN(100306)
  69.     Shift% = _KEYDOWN(100304)
  70.     Alt% = _KEYDOWN(100308)
  71.  
  72.     'Combinations that didn't worked in this case:
  73.     '   "Left & down + Spacebar"
  74.     '   "Left & up + Alt"
  75.     '   "Left & up + Spacebar"
  76.     '   "Right & down + Spacebar"
  77.  
  78.     'Same result as method2, _KEYCLEAR seem to clear the buffer readed by INKEY$, but _KEYDOWN() takes directly from keyboiard hardware?
  79. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  80. SUB method3 () 'using _KEYDOWN directly as the variable%
  81.  
  82.     Spacebar% = _KEYDOWN(32)
  83.     Ctrl% = _KEYDOWN(100306)
  84.     Shift% = _KEYDOWN(100304)
  85.     Alt% = _KEYDOWN(100308)
  86.  
  87.     'Combinations that didn't worked in this case:
  88.     '   "Left & down + Spacebar"
  89.     '   "Left & up + Alt"
  90.     '   "Left & up + Spacebar"
  91.     '   "Right & down + Spacebar"
  92.  
  93.     'Same result as method2
  94. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  95. SUB method2 () 'using _KEYDOWN to change variables%
  96.  
  97.     IF _KEYDOWN(32) THEN Spacebar% = TRUE
  98.     IF _KEYDOWN(100306) THEN Ctrl% = TRUE
  99.     IF _KEYDOWN(100304) THEN Shift% = TRUE
  100.     IF _KEYDOWN(100308) THEN Alt% = TRUE
  101.  
  102.     'Combinations that didn't worked in this case:
  103.     '   "Left & down + Spacebar"
  104.     '   "Left & up + Alt"
  105.     '   "Left & up + Spacebar"
  106.     '   "Right & down + Spacebar"
  107.  
  108. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  109. SUB method1 () ' using INKEY$ to see the spacebar
  110.  
  111.     key$ = INKEY$
  112.     IF key$ <> "" THEN
  113.         IF key$ = CHR$(32) THEN
  114.             Spacebar% = TRUE
  115.         END IF
  116.     END IF
  117.  
  118.     'Combinations that didn't worked in this case:
  119.     '   "Up & left + Spacebar"
  120.     '   "Down & left + Spacebar"
  121.     '   "Down & right + Spacebar"
  122.  
  123. '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  124. SUB registerArrows ()
  125.  
  126.     IF _KEYDOWN(19200) THEN ' left
  127.     left% = TRUE: ELSE: left% = FALSE: END IF
  128.     IF _KEYDOWN(19712) THEN ' right
  129.     right% = TRUE: ELSE: right% = FALSE: END IF
  130.     IF _KEYDOWN(18432) THEN ' up
  131.     up% = TRUE: ELSE: up% = FALSE: END IF
  132.     IF _KEYDOWN(20480) THEN ' down
  133.     down% = TRUE: ELSE: down% = FALSE: END IF
  134.     IF left% AND up% THEN
  135.         tmp$ = "Left & Up"
  136.     ELSEIF left% AND down% THEN: tmp$ = "Left & Down"
  137.     ELSEIF right% AND up% THEN: tmp$ = "Right & Up"
  138.     ELSEIF right% AND down% THEN: tmp$ = "Right & Down"
  139.     ELSEIF left% THEN: tmp$ = "Left"
  140.     ELSEIF right% THEN: tmp$ = "Right"
  141.     ELSEIF up% THEN: tmp$ = "Up"
  142.     ELSEIF down% THEN: tmp$ = "Down": END IF
  143.     '_KEYCLEAR ' this didn't changed anything

I wasn't aware about the McNeil post, i will check them and come back if i find anything related to this. Thanks again.