• Print

Author Topic: Use qb64 to help realtime development of better game and interactive strategies  (Read 327 times)

OlDosLover

  • Hero Member
  • *****
  • Posts: 3859
  • OlDosLover
    • Email
Re: Use qb64 to help realtime development of better game and interactive strategies
« Reply #15 on: February 18, 2013, 07:21:59 AM »
Hi all,
    Might be On Key. Tried this in SDL and it works. Tried this in GL and it hangs. Give it a try plz and report back.
Code: [Select]
REM
SCREEN 12

KEY(1) ON '    <--- F1
ON KEY(1) GOSUB EntryKey

DO

LOOP UNTIL _KEYDOWN(27)

EntryKey:
PRINT "HELP"
RETURN
OlDosLover.

Billbo

  • Sr. Member
  • ****
  • Posts: 286
    • Email
Re: Use qb64 to help realtime development of better game and interactive strategies
« Reply #16 on: February 18, 2013, 10:16:24 AM »
OlDosLover,

It compiled and ran in 0.974. Every time I press F1 I get HELP, like the program indicates.

Since this works, what do I do now to your program to get it to compile? I hope I don't
sound stupid.

Bill
« Last Edit: February 18, 2013, 10:29:36 AM by Billbo »

OlDosLover

  • Hero Member
  • *****
  • Posts: 3859
  • OlDosLover
    • Email
Re: Use qb64 to help realtime development of better game and interactive strategies
« Reply #17 on: February 18, 2013, 05:20:10 PM »
Hi all,
    I usually work in SDL. I have GL version 5. I dont have access to the repository. I'll try my code in my Gl version and it compiles. Try compiling it in GL 5. Other than that i carnt make a guess as i simply dont know. Thanks for trying it out Billbo.
OlDosLover.

OlDosLover

  • Hero Member
  • *****
  • Posts: 3859
  • OlDosLover
    • Email
Re: Use qb64 to help realtime development of better game and interactive strategies
« Reply #18 on: February 18, 2013, 05:28:16 PM »
Hi all,
    Here's another version of my program expanded to 20 variables and uses mouse to select what data is to be changed. Try it out and report back any bugs please for me to fix. Later on i'll make this more expansive and a bit more user friendly. Composed in SDL.
Code: [Select]
REM
DEFLNG A-Z

CONST True = -1, False = 0

DIM SHARED Value(1 TO 20) AS INTEGER
DIM SHARED mx%, my%, mbl%, mbm%, mbr%
DIM SHARED MenuLines(1 TO 20) AS INTEGER

ForeGround& = _NEWIMAGE(640, 480, 32)
BackGround& = _NEWIMAGE(640, 480, 32)

GOSUB DefineKeys

SCREEN ForeGround&
PRINT "HERE is your Program."
PRINT "Press F11 to enter [immediate window] then F12 to return to this screen"
_MOUSESHOW
GOSUB SetupDim

DO
  _LIMIT 30
  IF Stuck = True THEN
    CLS
    MousePoll
    LOCATE 1, 1: PRINT mx%, my%, mbl%, mbm%, mbr%
    GOSUB SetupScreen
    GOSUB Region
    GOSUB MenuSelected
    LOCATE 27, 5: PRINT "WE can only change the first 20 values in our dim with the Mouse"
    LOCATE 28, 5: PRINT "Left click on a menu , then enter in numbers then press return key"
  END IF
  _DISPLAY
LOOP UNTIL _KEYDOWN(27) ' <-- if NOT mice button down then we will exit
SLEEP
SYSTEM
'------------------------------------------------------------------------------------------

SetupDim: '           <-- used to discern what row mouse is on
y = 48 '              <-- initialise 1st menu line to this
FOR T = 1 TO 20
  MenuLines(T) = y '  <-- assign top coord of menu line
  y = y + 16 '        <-- increment menu line by 16
NEXT T
RETURN

SetupScreen: '                                                   <-- draws our entire menu
y = 48 '                                                         <-- initialise 1st menu line to this
FOR T = 1 TO 20 '
  num$ = LTRIM$(STR$(T)) '                                       <-- convert FOR variable to string
  Label$ = "Value(" + num$ + ") = " '                            <-- build our display string
  _PRINTSTRING (16, y), Label$ '                                 <-- print our sisplay string
  Value$ = STR$(Value(T)) '                                      <-- convert corresponding dim element numerical value to string
  _PRINTSTRING (120, y), Value$ '                                <-- print this value
  LINE (8, y)-(400, y + 15), _RGB32(255, 255, 0), B '            <-- draw a box around printed screen line
  y = y + 16 '                                                   <-- increment menu line by 16
NEXT T
RETURN

Region: '                                      <-- see if mouse over menu area
FOR T = 1 TO 20
  SELECT CASE my%
    CASE MenuLines(T) TO MenuLines(T) + 15 '   <-- range of 16
      Highlight = T '                          <-- if TRUE set highlight variable to FOR variable
      EXIT FOR '                               <-- exit FOR ... NEXT loop
    CASE ELSE
      Highlight = 0 '                          <-- if FALSE set highlight variable to zero
  END SELECT
NEXT T
RETURN

MenuSelected: '                                                     <--  see if left mice button down and we over a menu line
IF mbl% = -1 THEN '                                                 <--  if left mice button down
  IF Highlight <> 0 THEN '                                          <-- if Highlight > zero
    temp = Highlight * 16 '                                         <-- calculate which menu line in pixels
    LINE (8, 32 + temp)-(400, 47 + temp), _RGB32(255, 0, 255), BF ' <-- draw filled box to show highlingt
    num$ = LTRIM$(STR$(Highlight)) '                                <-- convert highlight vatiable to string
    Label$ = "Value(" + num$ + ") = " '                             <--  build our display string
    _PRINTMODE _KEEPBACKGROUND , BackGround& '                      <-- keep background color
    _PRINTSTRING (16, 32 + temp), Label$ '                          <-- print our display string
    GOSUB GetINPUT '                                                <-- special INPUT routine for _printstring
  END IF
END IF
RETURN

GetINPUT:
Done = False: BuildString$ = "" '                          <-- initialise variables
WHILE Done = False '                                       <-- create condition loop
  a$ = UCASE$(INKEY$) '                                    <-- check for key press
  IF a$ = CHR$(13) AND LEN(BuildString$) THEN EXIT WHILE ' <-- check for enter key and NOT empty return string
  IF LEN(a$) THEN '                                        <-- if NOT empty INKEY string
    temp1% = VAL(a$) '                                     <-- convert inkey string to numerical value
    IF temp1% THEN '                                       <-- if numerical value NOT zero
      BuildString$ = BuildString$ + a$ '                   <-- add this key press to our return string
      _PRINTMODE _KEEPBACKGROUND , BackGround& '           <-- keep background
      _PRINTSTRING (120, 32 + temp), BuildString$ '        <-- update build string to screen 4 feedback
    END IF
  END IF
  _AUTODISPLAY
WEND
Value(Highlight) = VAL(BuildString$) '                     <-- assign numerical value into correct dim element
RETURN

DefineKeys: '                              <--  Set up the EntryKey
KEY(30) ON '                               <-- F11 is ON
ON KEY(30) GOSUB EntryKey '                <-- tell it where to go
Stuck = False
RETURN

EntryKey:
KEY(30) OFF '                              <-- turn entry key OFF as we dont want it to call itself
SCREEN BackGround& '                       <-- change screens
Stuck = True '                             <-- toggle our control variable
'                                          Set up the ExitKey
KEY(31) ON '                               <--- F12 is ON
ON KEY(31) GOSUB ExitKey '                 <-- tell it where to go
PRINT "we are in BACKGROUND "; Stuck
SOUND 800, 3
RETURN

ExitKey:
KEY(31) OFF '                             <-- turn exit key OFF as we dont want it to call itself
SCREEN ForeGround& '                      <-- change screens
Stuck = False '                           <-- toggle our control variable
PRINT "we are in FOREGROUND "; Stuck
SOUND 1200, 3
KEY(30) ON '                              <-- turn entry key back ON
RETURN


SUB MousePoll ()
DO WHILE _MOUSEINPUT
  mx% = _MOUSEX: my% = _MOUSEY: mbl% = _MOUSEBUTTON(1): mbr% = _MOUSEBUTTON(2): mbm% = _MOUSEBUTTON(3)
LOOP
END SUB

OlDosLover.

Billbo

  • Sr. Member
  • ****
  • Posts: 286
    • Email
Re: Use qb64 to help realtime development of better game and interactive strategies
« Reply #19 on: February 18, 2013, 08:34:45 PM »
Again, it compiles and runs in 0.971, but not the 0.974.

Tomorrow I'm going to see what I can do.

Bill

OlDosLover

  • Hero Member
  • *****
  • Posts: 3859
  • OlDosLover
    • Email
Re: Use qb64 to help realtime development of better game and interactive strategies
« Reply #20 on: February 19, 2013, 12:41:26 AM »
Hi all,
    Bill I posted a report in the GL section to draw it to Galleon's attention as it may be an inconsistency between the two different versions.
OlDosLover.
« Last Edit: February 19, 2013, 01:15:20 AM by OlDosLover »

Billbo

  • Sr. Member
  • ****
  • Posts: 286
    • Email
Re: Use qb64 to help realtime development of better game and interactive strategies
« Reply #21 on: February 19, 2013, 08:04:22 AM »
Hey, thanks. After my daily downloads, I'm going to look at the code.

Bill

OlDosLover

  • Hero Member
  • *****
  • Posts: 3859
  • OlDosLover
    • Email
Re: Use qb64 to help realtime development of better game and interactive strategies
« Reply #22 on: February 22, 2013, 05:52:57 AM »
Hi all,
    Here is my program , with an example program and both as a married program to illustrate the concept first asked for by MrWhy. I saw no reason to exclusively post it here as it would be of greater community benefit in the samples section. Here is a link to the finished and complete version.
http://www.qb64.net/forum/index.php?topic=10731.0
OlDosLover.

  • Print