Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - johannhowitzer

Pages: [1] 2 3 ... 8
1
QB64 Discussion / Optional subroutine parameters?
« on: January 13, 2022, 11:27:26 pm »
Is it possible to make one or more parameters at the end of a sub or function optional when calling, and then those would just have default values in the subroutine?  For example

call example(10, 20)

sub example(x, y, text$)
...
end sub

And then in the call, text$ is an empty string?

2
QB64 Discussion / Re: IF THEN issue using AND, I think I'm losing my mind!
« on: December 16, 2021, 01:24:02 am »
What I do is put

const true = -1
const false = 0

at the top of every program I write.  And I've always been in the habit of writing if n <> false, instead of just if n.  So I would write

if n <> false and p <> false then

This has saved me countless headaches.

3
Programs / Re: Graphics Test #2 - are you certifiable?
« on: December 01, 2021, 06:48:09 pm »
Code: QB64: [Select]
  1.  
  2. type node_structure
  3.    angle  as single
  4.    ring   as byte    ' Which ring to draw on
  5.    parent as integer ' Parent node
  6. dim shared node(65535) as node_structure
  7. dim shared node_count as integer
  8.  
  9. input "Number of rings:    ", rings
  10. input "Number of branches: ", branches
  11.  
  12. for ring = 1 to rings
  13.    new_branches = branches ^ ring
  14.  
  15.    for n = 1 to new_branches
  16.       node_count = node_count + 1
  17.       node(node_count).angle  = (8 * atn(1)) * (n / new_branches)
  18.       node(node_count).ring   = ring
  19.       node(node_count).parent = first_parent + int((n - 1) / branches)
  20.    next n
  21.  
  22.    first_parent = first_parent + int(new_branches / branches)
  23. next ring
  24.  
  25. for n = 1 to node_count
  26.    p = node(n).parent
  27.    v1 = 240 * (node(n).ring / rings)
  28.    v2 = 240 * (node(p).ring / rings)
  29.    line(320 + (v1 * cos(node(n).angle)), 240 + (v1 * sin(node(n).angle)))-_
  30.        (320 + (v2 * cos(node(p).angle)), 240 + (v2 * sin(node(p).angle))), 15
  31.  

Without looking at others' code, while I was in some downtime at work I glanced at the OP, and threw this together in about ten minutes.  I see I took a different approach; while others seem to be going straight to the drawing step, I started by building a network of references, and letting the user input the number of rings, as well as the number of branches from each node.

My result is a little different, because the new ring of nodes are grouping up to the previous ring via an int() modifier on the stack index.  But I think this looks even cooler, and since all the nodes are saved, I can do more things to them if I want.  Fun challenge!

 
stargen.png

4
Programs / Re: Language
« on: November 15, 2021, 11:18:48 pm »
This is why I always ALWAYS use parentheses in everything, both in programming and in math on paper.  Never leave it up to order of operations confusion when you never have to.

5
Programs / Re: QB64 Surabikku-like puzzle.
« on: October 23, 2021, 09:57:08 pm »
Quote
It's harder to pronounce the puzzle name probably.

Soo-rah-beak-oo.  Japanese has similar vowels to Spanish, and when you see a double-consonant, you jump to that consonant quicker.  It's the romaji (english characters) representation of the Japanese small "tsu."

The method bplus describes is pretty much how my sprite sheet slicer routine works.  One big image, and the routine goes through and hunts for detector pixels and stores where each sprite is, then you just store the reference for the sprite in each object, and when you go to draw, you can call up the location of the sprite from the object's data.

6
Programs / Re: Stereospace 3 Teaser
« on: October 23, 2021, 09:26:40 pm »
I'm getting flashes of some other game I've seen before by watching this, but I can't think of what it is.  Catchy framework you've produced so far, as a fellow enthusiast and developer in the shmup genre, I'm interested to see what kind of gameplay you hang on this framework.

7
QB64 Discussion / Re: Mouse input lag
« on: October 22, 2021, 03:23:56 pm »
I didn't put double click tracking in there yet, but my code does support dragging, as it not only tracks press and release, but where each happened.  This is partly so I can make sure both happened over the same hotspot - so if you click a button, hold, then release the mouse while not over the button, it won't activate it.

8
QB64 Discussion / Re: Mouse input lag
« on: October 22, 2021, 05:09:41 am »
Code: QB64: [Select]
  1. sub update_inputs
  2.  
  3. call detect_devices
  4.  
  5. if dev_mouse = false then exit sub
  6.  
  7. dim mb(3)
  8. for b = 1 to 3
  9.    mb(b) = mouse_press(b)
  10.  
  11. mouse_change = false
  12. do while mouseinput <> false and mouse_change = false
  13.    mx = mousex
  14.    my = mousey
  15.    for b = 1 to 3
  16.       mb(b) = mousebutton(b)
  17.       if mb(b) <> mouse_press(b) then mouse_change = true
  18.    next b
  19.  
  20. for b = 1 to 3
  21.    mouse_hold(b) = mouse_press(b)
  22.    mouse_press(b) = mb(b)
  23.  
  24.    if mouse_press(b) = true and mouse_hold(b) = false then
  25.       mouse_press_x(b) = mx ' Store position mouse button was pressed
  26.       mouse_press_y(b) = my
  27.    elseif mouse_press(b) = false and mouse_hold(b) = true then
  28.       mouse_release_x(b) = mx ' Store position mouse button was released
  29.       mouse_release_y(b) = my
  30.    end if
  31.  
  32.  

After reading up on all this, here's the changes I made to the routine.  As I drain mouseinput, I stop it short whenever there's a change in one of the three button states, this way it keeps up, even in limit 60, but it also doesn't miss any clicks - which I read was a concern.  This appears to have no issues at all.

9
QB64 Discussion / Re: Mouse input lag
« on: October 20, 2021, 04:06:45 am »
Thanks, that's exactly what I was looking for.  My solution probably didn't work perfectly because due to rounding, there would be some back to back identical coordinate pairs in the stream of mouse data.  I read the more in-depth stuff, and I'll add in the button state change catch too.

First time using mouse in anything qbasic related!  In the past I've only ever cared about keyboard and gamepad, but I'm trying to make a manual-input tracker for a game, and clicking is way more user-friendly for that.

10
QB64 Discussion / Mouse input lag
« on: October 20, 2021, 12:41:11 am »
Is there a way in a _limit 60 loop to have the mouse input data keep current?

Code: QB64: [Select]
  1. color 0, 15
  2.  
  3. const true = -1
  4. const false = 0
  5.  
  6. dim shared dev_keyboard as byte ' Store device index, to be re-checked whenever inputs are involved
  7. dim shared dev_gamepad  as byte
  8. dim shared dev_mouse    as byte
  9. const keyboard = 1
  10. const gamepad  = 2
  11. const mouse    = 3
  12.  
  13. dim shared mouse_press(3)     as byte
  14. dim shared mouse_hold(3)      as byte
  15. dim shared mouse_press_x(3)   as integer ' Records where mouse button press started
  16. dim shared mouse_press_y(3)   as integer
  17. dim shared mouse_release_x(3) as integer ' Records where mouse button was released
  18. dim shared mouse_release_y(3) as integer
  19.  
  20. call update_inputs
  21.  
  22.    limit 60
  23.    cls , 15
  24.  
  25.    r = 15
  26.    for b = 1 to 3
  27.       locate b: print mouse_press_x(b); mouse_press_y(b), , mouse_release_x(b); mouse_release_y(b)
  28.       print mousex, mousey
  29.       h = (b * 2) + 7
  30.  
  31.       x1 = mouse_press_x(b)
  32.       y1 = mouse_press_y(b)
  33.  
  34.       x2 = mouse_release_x(b)
  35.       y2 = mouse_release_y(b)
  36.  
  37.       circle(x1, y1), r, h
  38.       if mouse_press(b) = false and mouse_hold(b) = true then paint(x1, y1), 0, h
  39.  
  40.       circle(x2, y2), r, h + 1
  41.       if mouse_press(b) = false and mouse_hold(b) = true then paint(x2, y2), 0, h + 1
  42.    next b
  43.    display
  44.  
  45.    call update_inputs
  46.  
  47.  
  48. sub detect_devices
  49.  
  50. dev_keyboard = false
  51. dev_gamepad  = false
  52. dev_mouse    = false
  53.  
  54. d = devices
  55. for n = d to 1 step -1
  56.    if left$(device$(n), 10) = "[KEYBOARD]"   then dev_keyboard = n
  57.    if left$(device$(n), 12) = "[CONTROLLER]" then dev_gamepad  = n
  58.    if left$(device$(n),  7) = "[MOUSE]"      then dev_mouse    = n
  59.  
  60.  
  61.  
  62. sub update_inputs
  63.  
  64. call detect_devices
  65.  
  66. if dev_mouse <> false then
  67.    z = mouseinput
  68. '   z = deviceinput(dev_mouse)
  69.  
  70.    for b = 1 to 3
  71.       if b > lastbutton(dev_mouse) then exit for
  72.  
  73.       mouse_hold(b)  = mouse_press(b)
  74.       mouse_press(b) = mousebutton(b)
  75.  
  76.       ' Wait for mouse position read to catch up
  77.       x1 = mousex
  78.       y1 = mousey
  79.       do
  80. '         z = mouseinput
  81.          x2 = x1
  82.          y2 = y1
  83.          x1 = mousex
  84.          y1 = mousey
  85.       loop until x1 = x2 and y1 = y2
  86.  
  87.       if     mouse_press(b) = true and mouse_hold(b) = false then
  88.          mouse_press_x(b) = mousex
  89.          mouse_press_y(b) = mousey
  90.       elseif mouse_press(b) = false and mouse_hold(b) = true then
  91.          mouse_release_x(b) = mousex
  92.          mouse_release_y(b) = mousey
  93.       end if
  94.    next b
  95.  
  96.  

Running this, as you move the mouse around, you can see the numbers on row 4 lag way behind what the mouse is actually doing.  If I increase the limit to 30000, it stays current as far as user perception, but it will still be way behind for the same number of loops, it's just running too fast to see this.  It seems like data from mousex and mousey is just lagging behind for some reason, not actually returning the mouse's current position, but rather pulling the oldest value from a stack of position values.

In update_inputs, you can see I tried to counter this by waiting until the position information from subsequent calls was the same.  This does nothing without the z = mouseinput, if you uncomment that line, you can see it improves the speed dramatically, it still lags behind a bit, but catches up much faster.

Do you know of a way to make mousex and mousey be current on every frame, in a limit 60 loop?

11
QB64 Discussion / Re: How organized are you guys?
« on: October 04, 2021, 02:44:22 am »
I am compulsively organized, to a fault.  When I play video games, I make spreadsheets and notes and track everything by hand.  Right now I'm playing through Final Fantasy X for the nth time, and I have a spreadsheet showing instances remaining on each character's overdrive mode learning.  For each type.  So every time Lulu evades, I reduce the number by one in her "Dancer" row.  Every time Wakka lands a status effect, same thing for his "Tactician" row.  Sometimes when people watch me play games, it drives them crazy.  Makes for very thorough speedrun routing, though!

I'm sure some here by now are familiar with (and annoyed by) my use of Notepad to code my big game project, but it's what I have to use, since I often do coding during downtime at work, and I can't use outside software.  So I'm up around 6000 lines of code now, in Notepad.  You don't manage that kind of thing without strict organization.  All my routines are indexed and categorized, whitespace is used for visual clarity everywhere (the QB64 IDE would actually ruin this), and my folders are all where they are very much on purpose.

Being so organized takes time up front, but I reap pretty huge benefits later on.  When I have to debug, it takes me maybe an hour or two at most, since I've already built in quite a bit of tools to let me see how data is being handled - such as a good old fashioned "debug menu" where I can scroll through the spawned entities and watch their data, edit player health, ammo, available weapons, turn on hitbox display, all during runtime.  I even have a rudimentary level editor, minus some abstraction - it's really only meant for me to use.

12
QB64 Discussion / [video] How to Code a Text Adventure Game!
« on: July 18, 2021, 04:52:33 am »
This is a 20-minute tutorial on a smart way to code a text adventure in QB64.  Organizing your code in the way shown in this tutorial will make it much easier to keep track of things, and hopefully save you a lot of work.


13
Programs / Re: Modern-setting Text Adventure
« on: July 11, 2021, 10:11:14 pm »
The way I'm doing this, it's pretty light on the actual coding, very easy to add more flavor text, the systems are all organized to minimize programming time and headaches, so the bulk of the work is making the game.  I've just been inspired enough that I've kept on designing and writing, and with the prologue playable, haven't got around to going back and finishing those systems.

Maybe I should make a quick tutorial video on coding text adventures this way.

14
Programs / Re: Modern-setting Text Adventure
« on: July 11, 2021, 07:37:17 pm »
Nah, it's just not feature complete yet.  If you look at the code, you can see vestiges of a few simple systems, like examining inventory, and saving or loading games.  I'm throwing together a whole bunch of things at once here.

15
Programs / Modern-setting Text Adventure
« on: July 11, 2021, 04:03:42 am »
Way back in my teenage days on an IBM 286 desktop computer, I encountered a program I didn't understand, called QBasic.  We also had an old Commodore 64 and some random BASIC programming books I'd been curious about, and so at some point I tried making a text adventure.  This was a genre of game I knew I could tackle, and being super into game design since I was in preschool, making mario levels on graph paper, me and my childhood friend Jason established our own "game company," selling 3.5 floppies to our friends at church of little games we made, for a dollar or two.

The two biggest super-triple-A-battery releases we had were a lights-out clone called Temporal Archer (you've got a field of soldiers in front of your castle, you're a time traveler, and your arrows have blast radius?  Also the soldiers come back to life if you hit them when they're dead??), and a text adventure about robots I named Spike and Rocky, after two robots I liked to draw at the time.  Spike was made of cubes and rectangles, while Rocky was made of spheres and cylinders.

The code was super spaghetti, the sort you'd see on Commodore 64 with a tangled mess of line numbers and GOTO statements, and the text adventure mostly ended up being cool drawings I was always making of levels, in a notebook I carried around.


Well, as the only game I've really sunk any time into these days is my Big Secret Project(tm), as you can imagine, I started thinking about what other little projects I could work on, stuff I could actually share with the QB64 community.  So I've dusted off what I can remember of that old text adventure, scrapped almost all of the concepts in favor of stuff I like more nowadays, and actually coded it fairly well.

The prologue is done, and I've got another chapter all mapped out, with a few more concepts waiting to be worked on.  The challenge of course in a text adventure is to make it comprehensible to the player without being able to actually see anything, yet still challenging and engaging, and descriptive enough to be immersive, but not enough to be overwhelmingly wordy.

Here you go!  It's pretty short, however the chapter I'm now working on is over five times as large.  Just see what you think, leave gameplay concerns / places you got stuck / etc in the thread - if you want to try this, just don't read the thread beforehand.  And as is the case with text adventure code, reading the code before playing will be very spoilery.

Code: QB64: [Select]
  1.  
  2. screen 12 ' 80 characters wide
  3.  
  4. const true = -1
  5. const false = 0
  6.  
  7. q = chr$(34) ' *** Double quote
  8.  
  9. color 15, 0
  10. cls , 0
  11.  
  12.  
  13.  
  14.  
  15. ' ===== Flags =====
  16.  
  17. ' ----- Standard flag values -----
  18.  
  19. const no_item   = 0 ' Most items will start in this state
  20. const have_item = 1
  21. const used_item = 2 ' Generally used when an item is no longer in the inventory, and can't be re-acquired
  22.  
  23. const door_closed = 0
  24. const door_open   = 1
  25.  
  26. ' ----- Inventory items -----
  27.  
  28. ' Listed first as they will be listed in constant-numerical order when "inv" is typed
  29.  
  30. const i_sh_deadflashlight = 1 ' No batteries
  31. const i_sh_flashlight     = 2 ' Has batteries
  32.  
  33. const i_sh_batteries      = 4
  34.  
  35. const i_sh_drawerkey      = 6 ' When used_item, the drawer has been opened
  36. const i_sh_keyring        = 7 ' Car keys
  37. const i_sh_papers         = 8 ' Papers containing addresses of three destinations
  38.  
  39. const total_items         = 11
  40.  
  41. ' ----- Non-inventory flags -----
  42.  
  43. ' Things such as doors, lights, any state the game needs to keep track of
  44.  
  45. const f_sh_drawertop    = 12 ' Number of times drawer has been opened
  46. const f_sh_drawermiddle = 13 ' Middle drawer state
  47. const f_sh_bonk         = 14 ' Whether the player has run into the bedroom door
  48. const f_sh_doorbedroom  = 15 ' Bedroom door state
  49. const f_sh_doorfront    = 16 ' Front door state
  50. const f_sh_clearingseen = 17 ' Player has noticed the clearing in the grass
  51.  
  52. const total_flags          = 17
  53.  
  54. dim shared flag(total_flags) as byte ' All flag states stored here
  55. dim shared item_name$(total_items)   ' Names of items, for inventory display
  56.  
  57. item_name$(i_sh_deadflashlight) = "Flashlight without power"
  58. item_name$(i_sh_flashlight)     = "Flashlight"
  59. item_name$(i_sh_batteries)      = "Pack of D batteries"
  60. item_name$(i_sh_drawerkey)      = "Small aluminum key"
  61. item_name$(i_sh_keyring)        = "Keyring with red bell fob"
  62. item_name$(i_sh_papers)      = "Assorted papers"
  63.  
  64. ' ----- Location references -----
  65.  
  66. ' On title screen, player can choose new or resume.
  67. ' If resume, loaded file will contain this location value, and the flag() array.
  68.  
  69. const loc_home_bedroom   = 1
  70. const loc_home_hall      = 2
  71. const loc_home_table     = 3
  72. const loc_home_machinery = 4
  73. const loc_home_path      = 5
  74. const loc_home_road      = 6
  75. const loc_home_clearing  = 7
  76. const loc_home_car       = 8
  77.  
  78. dim shared location as integer ' Current location reference value
  79.  
  80. ' ----- Input handling -----
  81.  
  82. dim shared i$      ' Player input
  83. dim shared verb$   ' Verb separated
  84. dim shared object$ ' Object of verb
  85.  
  86. ' *** Title menu here should allow loading a saved game
  87.  
  88. goto home_bedroom
  89.  
  90. ' *** Following branch is used when finished loading
  91.  
  92.    case loc_home_bedroom:   goto home_bedroom
  93.    case loc_home_hall:      goto home_hall
  94.    case loc_home_table:     goto home_table
  95.    case loc_home_machinery: goto home_machinery
  96.    case loc_home_path:      goto home_path
  97.    case loc_home_road:      goto home_road
  98.    case loc_home_clearing:  goto home_clearing
  99.    case loc_home_car:       goto home_car
  100.  
  101.  
  102.  
  103.  
  104.  
  105. ' --------------------------------------------------
  106. ' ===== THE SCENT OF ADVENTURE: The Safe House =====
  107. ' --------------------------------------------------
  108.  
  109.  
  110.  
  111. home_bedroom:
  112.  
  113. ?"You wake up in bed.  This is surprising to no one.  It is also not surprising"
  114. ?"that this is the beginning of the game; it's almost like this was written with"
  115. ?"very little planning.  You stand up slowly, it feels like forever since you"
  116. ?"were awake."
  117. ?
  118. ?"You feel like typing 'look' would give you more information about this room."
  119.  
  120. location = loc_home_bedroom
  121.    call get_input
  122.  
  123.    select case verb$
  124.       case "look"
  125.          select case object$
  126.             case ""
  127.                ?"You are in a simple bedroom, with a small bed against the east wall."
  128.                ?"Bright sunlight is visible through the south window, above a chest of drawers."
  129.                ?"There is a door to the north."
  130.                ?
  131.                ?"You ponder the four compass directions.  North, east, south, west.  Each one"
  132.                ?"has its own starting letter!  This is convenient, since moving around won't"
  133.                ?"require you to type the whole word.  Just one letter will do."
  134.                ?
  135.                ?"Oh, also, you can type a word after 'look,' to examine something more closely."
  136.  
  137.             case "bed"
  138.                if flag(i_sh_drawerkey) = no_item then
  139.                   ?"A white-painted four poster bed with a blue coverlet.  It's set about a foot"
  140.                   ?"above the floor-- oh!  The sunlight is glinting off something on the floor"
  141.                   ?"next to the bed.  It's a small aluminum key."
  142.                else
  143.                   ?"A white-painted four poster bed with a blue coverlet.  It's set about a foot"
  144.                   ?"above the floor."
  145.                end if
  146.  
  147.             case "door"
  148.                ?"It's made of sturdy-looking wood, but isn't painted or varnished."
  149.  
  150.             case "window"
  151.                ?"A single-shutter affair, unpainted, with no curtains."
  152.                ?"The glass is glass-colored."
  153.  
  154.             case "chest"
  155.                ?"The chest is painted light blue and has three drawers."
  156.                ?"The bottom one has a keyhole between the handles."
  157.  
  158.             case "keyhole"
  159.                ?"Seems to be made of aluminum."
  160.          end select
  161.  
  162.       case "get"
  163.          select case object$
  164.             case "batteries"
  165.                if flag(i_sh_batteries) = no_item and flag(f_sh_drawermiddle) = true then
  166.                   ?"You've got the batteries.  To see your items, type 'inv.'  Why 'inv'?"
  167.                   ?"It's an abbreviation.  It stands for 'investigate.'  You use it to"
  168.                   ?"'investigate' your inventory."
  169.                   flag(i_sh_batteries) = have_item
  170.                end if
  171.  
  172.             case "key"
  173.                if flag(i_sh_drawerkey) = no_item then
  174.                   ?"You've got the key.  To see your items, type 'inv.'  Why 'inv'?"
  175.                   ?"It's an abbreviation.  It stands for 'inventive.'  You've got to be 'inventive'"
  176.                   ?"when deciding how to use your inventory."
  177.                   flag(i_sh_drawerkey) = have_item
  178.                end if
  179.          end select
  180.  
  181.       case "open"
  182.          select case object$
  183.             case "drawer"
  184.                ?"There are so many drawers here!  Top, middle, bottom."
  185.                ?"Why, there is even one more than two drawers here!"
  186.  
  187.             case "top"
  188.                if flag(f_sh_drawertop) < 4 then
  189.                   ?"It slides open easily, but there's nothing inside, so you close it again."
  190.                   flag(f_sh_drawertop) = flag(f_sh_drawertop) + 1
  191.                else
  192.                   ?"It slides open easily, but there's NOTHING INSIDE SO YOU CLOSE IT AGAIN.  Gosh."
  193.                end if
  194.  
  195.             case "middle"
  196.                if flag(f_sh_drawermiddle) = false then
  197.                   ?"It slides open easily.  There is a pack of D batteries inside, enough to power"
  198.                   ?"a large flashlight.  You can carry a lot of stuff, why not get these?"
  199.                   ?"'Get.'  Hey, that's another thing you can type!"
  200.                   flag(f_sh_drawermiddle) = true
  201.                else
  202.                   ?"That drawer is already open."
  203.                end if
  204.  
  205.             case "bottom"
  206.                if flag(i_sh_drawerkey) = no_item then
  207.                   ?"It won't open.  If you do find the key, just try opening the drawer again,"
  208.                   ?"unlocking is part of opening a locked thing."
  209.                elseif flag(i_sh_drawerkey) = have_item then
  210.                   ?"The key fits awkwardly into the chintzy lock, which takes some fiddling to pop"
  211.                   ?"open.  The drawer slides open, but there's nothing inside.  Is this the true"
  212.                   ?"meaning of 'tutorial'?"
  213.                   ?
  214.                   ?"You close the drawer with the key inside, then lock it again, just to screw"
  215.                   ?"with the next guy.  Though I'm not sure how you even did that."
  216.                   flag(i_sh_drawerkey) = used_item
  217.                elseif flag(i_sh_drawerkey) = used_item then
  218.                   ?"You already locked the key inside, remember?"
  219.                end if
  220.  
  221.             case "door"
  222.                if flag(f_sh_doorbedroom) = door_open then
  223.                   ?"It's already open."
  224.                elseif flag(f_sh_doorbedroom) = door_closed and flag(f_sh_bonk) = false then
  225.                   ?"You turn the handle and pull the door open.  It swings soundlessly."
  226.                   ?"The scent of adventure wafts into the room."
  227.                   flag(f_sh_doorbedroom) = door_open
  228.                elseif flag(f_sh_doorbedroom) = door_closed and flag(f_sh_bonk) = true then
  229.                   ?"You turn the handle and pull the door open.  It protests vehemently, hinges"
  230.                   ?"creaking loudly and several long splinters snapping off.  But at least it's"
  231.                   ?"open.  The scent of adventure wafts into the room."
  232.                   flag(f_sh_doorbedroom) = door_open
  233.                end if
  234.          end select
  235.  
  236.       case "north"
  237.          if flag(f_sh_doorbedroom) = door_closed then
  238.             ?"I think the door felt that more than you did.  Doors tend to turn into doorways"
  239.             ?"when you do something to them... I think it starts with 'O'?"
  240.             ?"(And you should be specific about what you want to 'open,' too.)"
  241.             flag(f_sh_bonk) = true
  242.          elseif flag(f_sh_doorbedroom) = door_open then
  243.             ?"You step out into the hall.  The morning sunlight shining through the east"
  244.             ?"window reveals quite a bit of dust in the air.  You continue to the west end"
  245.             ?"of the hallway."
  246.             goto home_hall
  247.          end if
  248.  
  249.    end select
  250.  
  251.  
  252.  
  253. home_hall:
  254.  
  255. location = loc_home_hall
  256.    call get_input
  257.  
  258.    select case verb$
  259.       case "look"
  260.          select case object$
  261.             case ""
  262.                ?"You're in a narrow east-west hallway.  The sun is casting a shaft of blinding"
  263.                ?"light through the east window, and the floor is coated in a thin layer of dust,"
  264.                ?"which kicks up into the air as you move.  Through the north door you can see"
  265.                ?"a room with a large table; the south door reveals a dark room almost completely"
  266.                ?"occupied with some intimidating machinery.  East leads back to the bedroom."
  267.                ?"The door at the west end, which is much older-looking than the others,"
  268.                if flag(f_sh_doorfront) = door_closed then ?"is closed."
  269.                if flag(f_sh_doorfront) = door_open then ?"is open."
  270.  
  271.             case "floor"
  272.                ?"Like the bedroom, there is no carpet or other flooring here, just a rough"
  273.                ?"wooden floor covered in dust.  There were no footprints in the dust, you now"
  274.                ?"realize."
  275.  
  276.             case "dust"
  277.                ?"It just seems to be ordinary dust that would accumulate anywhere."
  278.  
  279.             case "machinery"
  280.                ?"There are many dials and buttons, but to get a closer look, you'll have to"
  281.                ?"walk into the room."
  282.          end select
  283.  
  284.       case "open"
  285.          select case object$
  286.             case "door"
  287.                if flag(f_sh_doorfront) = door_closed then
  288.                   ?"The door opens on a small flight of three steps made of grey concrete, and a"
  289.                   ?"dirt path leads from the steps to a gate in a wooden post fence, along a small"
  290.                   ?"road.  West across the road is a thick, colorful forest.  The grass next to"
  291.                   ?"the path is almost knee-high, and has gone to seed."
  292.                   ?
  293.                   ?"A rotted chunk of the door's latch breaks off and falls into the weeds next to"
  294.                   ?"the steps.  The door swings itself wide and rests against the side of the"
  295.                   ?"house."
  296.                   flag(f_sh_doorfront) = door_open
  297.                end if
  298.          end select
  299.  
  300.       case "north"
  301.          ?"You step into the north room."
  302.          goto home_table
  303.  
  304.       case "east"
  305.          ?"You return to the bedroom."
  306.          goto home_bedroom
  307.  
  308.       case "south"
  309.          ?"You peer cautiously into the room filled with machines.  You hadn't noticed it"
  310.          ?"out in the hall, but there's a very faint humming sound."
  311.          goto home_machinery
  312.  
  313.       case "west"
  314.          if flag(f_sh_doorfront) = door_open then
  315.             ?"You step out into the glorious sun.  It's a brisk fall day, but not cold."
  316.             goto home_path
  317.          end if
  318.  
  319.    end select
  320.  
  321.  
  322.  
  323. home_table:
  324.  
  325. location = loc_home_table
  326.    call get_input
  327.  
  328.    select case verb$
  329.       case "look"
  330.          select case object$
  331.             case ""
  332.                ?"This room has a large, rounded oak table against the north and west walls,"
  333.                ?"it's a bit too big for this room, and there are no chairs.  The north wall"
  334.                ?"has another small window, which is blocked by tall grass, so the room isn't"
  335.                ?"very brightly lit."
  336.  
  337.             case "table"
  338.                if flag(i_sh_deadflashlight) = no_item and flag(i_sh_papers) = no_item then
  339.                   ?"On the table, there are some scattered papers, as well as a large flashlight."
  340.                elseif flag(i_sh_deadflashlight) <> no_item and flag(i_sh_papers) = no_item then
  341.                   ?"On the table, there are some scattered papers."
  342.                elseif flag(i_sh_deadflashlight) = no_item and flag(i_sh_papers) <> no_item then
  343.                   ?"On the table, there is a large flashlight."
  344.                elseif flag(i_sh_deadflashlight) <> no_item and flag(i_sh_papers) <> no_item then
  345.                   ?"There's nothing on the table."
  346.                end if
  347.  
  348.             case "flashlight"
  349.                if flag(i_sh_deadflashlight) = no_item then
  350.                   ?"It looks heavy, and is made of black-painted metal."
  351.                end if
  352.  
  353.             case "papers"
  354.                if flag(i_sh_papers) = no_item then
  355.                   ?"There's a lot to take in here.  There are pages with lists of numbers, pages"
  356.                   ?"with indecipherable handwriting, maps of various places, a few pamphlets to"
  357.                   ?"local attractions, some receipts for small purchases, and a thin, almost"
  358.                   ?"used-up pad of tear-off legal stationery."
  359.                end if
  360.          end select
  361.  
  362.       case "get"
  363.          select case object$
  364.             case "flashlight"
  365.                if flag(i_sh_deadflashlight) = no_item then
  366.                   ?"You've got the flashlight.  It's lighter than you expected and doesn't work;"
  367.                   ?"checking the battery compartment, you find there are no batteries.  If you find"
  368.                   ?"some, using the batteries is clear enough.  Generally, if you 'use' something,"
  369.                   ?"you'll know how to use it and what to use it on."
  370.                   flag(i_sh_deadflashlight) = have_item
  371.                end if
  372.  
  373.             case "papers"
  374.                if flag(i_sh_papers) = no_item then
  375.                   ?"You pick up the mass of papers, hold them vertically, and shake them briskly"
  376.                   ?"against the table to form a neat stack.  A lot of this information seems"
  377.                   ?"random and probably useless, but in your situation, anything can help."
  378.                   ?"Perhaps some of this will make more sense later."
  379.                   flag(i_sh_papers) = have_item
  380.                end if
  381.          end select
  382.  
  383.       case "south"
  384.          ?"You return to the hallway."
  385.          goto home_hall
  386.  
  387.    end select
  388.  
  389.  
  390.  
  391. home_machinery:
  392.  
  393. location = loc_home_machinery
  394.    call get_input
  395.  
  396.    select case verb$
  397.       case "look"
  398.          select case object$
  399.             case ""
  400.                ?"It's surprisingly dark in here, there are no windows.  The only light is coming"
  401.                ?"from the buttons and the hallway.  There don't seem to be any lights to turn on"
  402.                ?"here, either - all of the walls are bare."
  403.                ?
  404.                ?"Around the sides of the room are industrial-looking metal consoles.  There are"
  405.                ?"less buttons and such than you expected.  In one corner of the floor, you can"
  406.                ?"barely make out a thick metal disk, about two feet in diameter.  There is a"
  407.                ?"matching disk mounted to the ceiling above it.  These are both connected to the"
  408.                ?"main bulk of the technology by rubber-coated cables, as thick as your arm."
  409.                ?"The light emanating from the buttons is dim, and all of the display screens"
  410.                ?"are off."
  411.                if flag(i_sh_flashlight) = have_item and flag(i_sh_keyring) = no_item then
  412.                   ?
  413.                   ?"On top of one of the consoles is a small keyring, with two identical keys and"
  414.                   ?"a red bell fob."
  415.                end if
  416.  
  417.             case "disk"
  418.                ?"It just looks like a slab of solid metal.  Moving your hand close, you can"
  419.                ?"sense a slight throbbing.  Otherwise, it betrays no sign of its purpose."
  420.  
  421.             case "buttons"
  422.                ?"The buttons are mostly about finger-sized, and various colors.  Nothing"
  423.                ?"resembles a keyboard.  There are a few labels here and there, but mostly"
  424.                ?"numbers and a few letters, nothing intelligible.  Whatever these do, you"
  425.                ?"haven't a ghost of a clue how to use them."
  426.  
  427.             case "keyring"
  428.                if flag(i_sh_keyring) = no_item then
  429.                   ?"The keyring itself is about an inch wide, the keys are small and made of brass."
  430.                   ?"The red bell is about the same size as the keys.
  431.               end if
  432.         end select
  433.  
  434.      case "get"
  435.         select case object$
  436.            case "keyring"
  437.               if flag(i_sh_keyring) = no_item then
  438.                  ?"You've got the keyring.  The keys being the same, it won't matter which one"
  439.                   ?"you use.  The bell tinkles merrily."
  440.                   flag(i_sh_keyring) = have_item
  441.                end if
  442.          end select
  443.  
  444.       case "north"
  445.          ?"You return to the hallway."
  446.          goto home_hall
  447.  
  448.    end select
  449.  
  450.  
  451.  
  452. home_path:
  453.  
  454. location = loc_home_path
  455.    call get_input
  456.  
  457.    select case verb$
  458.       case "look"
  459.          select case object$
  460.             case ""
  461.                ?"There's a good breeze going, the trees are swaying a bit, but there are no"
  462.                ?"other sounds.  The grass gets even taller a few yards on either side of the"
  463.                ?"path, obscuring your view of the countryside.  The fence beside the road is"
  464.                ?"a simple post fence made of narrow logs, with a gate leading to the road,"
  465.                ?"which is paved with coarse gravel.  Behind the small house is another forest."
  466.                ?"The sky is a steely blue, with a few large clouds."
  467.  
  468.             case "house"
  469.                ?"The house is raised off the ground, with a crawlspace underneath, choked with"
  470.                ?"grass and weeds.  It's a simple rectangular shape with a sloped roof,"
  471.                ?"unpainted, the outer walls covered in smooth wood paneling.  Despite the"
  472.                ?"obvious age of the gate and front door, the rest of the house appears very new,"
  473.                ?"showing no signs of wear."
  474.  
  475.             case "crawlspace"
  476.                ?"It's too overgrown to explore.  On the right side, you can see a stack of"
  477.                ?"cinderblocks supporting the part of the floor under the room with the machines."
  478.  
  479.             case "road"
  480.                ?"There are no signs of traffic, and no mailbox.  You can't see much of the road"
  481.                ?"from here, due to the tall grass."
  482.  
  483.             case "gate"
  484.                ?"The gate has no latch, only a rusty pair of hinges.  Wedged into the hinges"
  485.                ?"is a folded, weatherworn flyer with colorful printing."
  486.  
  487.             case "flyer"
  488.                ?"You read, 'Old Uncle Tommy's BONA FIDE Robot Bounties!  Redeem your old useless"
  489.                ?"robots for cash in hand!  Sentient toaster giving you lip?  Show it what for,"
  490.                ?"call Uncle Tommy today!"
  491.                ?
  492.                ?"You feel a twinge of sympathy for the poor robots."
  493.          end select
  494.  
  495.       case "close"
  496.          select case object$
  497.             case "door"
  498.                ?"Swinging the door shut, you can see the words 'SAFE HOUSE' painted in black"
  499.                ?"on the side of the house where it was.  At first it seems machine printed,"
  500.                ?"as it's in a very neat typeface, but looking closer, you can see brush strokes."
  501.                ?
  502.                ?"With the latch broken, the door swings open again in the breeze, clattering"
  503.                ?"loudly against the house.  That was probably audible for a mile or so."
  504.          end select
  505.  
  506.       case "east"
  507.          ?"You go back inside the house."
  508.          goto home_hall
  509.  
  510.       case "west"
  511.          ?"You hop spryly over the gate, landing at the shoulder of the gravel road with"
  512.          ?"a crunch.  It winds north and south, disappearing before long around the trees."
  513.          goto home_road
  514.  
  515.       case "south"
  516.          ?"A part of you wants to go exploring in the tall grass, but the cold, rational"
  517.          ?"side of you realizes there are more likely ways to answer your pressing"
  518.          ?"questions."
  519.  
  520.       case "north"
  521.          if flag(f_sh_clearingseen) = false then
  522.             ?"A part of you wants to go exploring in the tall grass, but the cold, rational"
  523.             ?"side of you realizes there are more likely ways to answer your pressing"
  524.             ?"questions."
  525.          elseif flag(f_sh_clearingseen) = true then
  526.             ?"Wading through the tall stalks of grass for a while, you eventually come across"
  527.             ?"a small patch that has been leveled by the presence of a car!  Only the part"
  528.             ?"covered by the car is flattened, so the car is walled on all sides by grass."
  529.             goto home_clearing
  530.          end if
  531.  
  532.    end select
  533.  
  534.  
  535.  
  536. home_road:
  537.  
  538. location = loc_home_road
  539.    call get_input
  540.  
  541.    select case verb$
  542.       case "look"
  543.          select case object$
  544.             case ""
  545.                ?"The road is narrow, and could only accommodate one vehicle.  The forest to"
  546.                ?"the west is very thick and overgrown, the leaves an assortment of brilliant"
  547.                ?"colors.  Here and there, the first leaves are falling.  To the east is the"
  548.                ?"house you awoke in, with high grass to either side.  On the north side of"
  549.                ?"the house, the grass seems to thin out, as if there's a clearing just out"
  550.                ?"of sight."
  551.                flag(f_sh_clearingseen) = true
  552.  
  553.             case "forest"
  554.                ?"You can't see anything interesting among the trees, it's far too crowded."
  555.  
  556.             case "road"
  557.                ?"The road is old and narrow, and paved with dirt and gravel.  Any vehicles"
  558.                ?"using this road would cause a lot of noise and leave a cloud of dust."
  559.  
  560.             case "house"
  561.                ?"The house looks especially out of place from here.  All the surroundings are"
  562.                ?"thickly grown and untended, but the house appears recently built."
  563.  
  564.             case "grass"
  565.                ?"Yes, there's definitely an open area among the grass to the north, some yards"
  566.                ?"away from the house."
  567.          end select
  568.  
  569.       case "north"
  570.          ?"You venture north along the road for a few minutes, the perfect fall day putting"
  571.          ?"a spring in your step, but all you find is more road and more forest.  Perhaps"
  572.          ?"it would be best to find a faster mode of travel.  You return to the gate."
  573.  
  574.       case "south"
  575.          ?"You venture south along the road for a few minutes, as it's excellent weather for"
  576.          ?"a walk, but there isn't much to see, as the road seems to go on endlessly."
  577.          ?"Perhaps it would be best to find a faster mode of travel.  You return to the gate."
  578.  
  579.       case "east"
  580.          ?"You vault back over the gate onto the path."
  581.          goto home_path
  582.  
  583.       case "west"
  584.          ?"You see no reason to venture into the forest."
  585.  
  586.    end select
  587.  
  588.  
  589.  
  590. home_clearing:
  591.  
  592. location = loc_home_clearing
  593.    call get_input
  594.  
  595.    select case verb$
  596.       case "look"
  597.          select case object$
  598.             case ""
  599.                ?"You are standing in tall grass, with a car in front of you.  It's difficult"
  600.                ?"to see much else."
  601.  
  602.             case "car"
  603.                ?"It's an old brown coupe, it seems in decent working order from here, the paint"
  604.                ?"is weatherbeaten but not peeing, and you can't see any rust.  What you can see"
  605.                ?"of the tires says they are probably fine.  You're on the driver's side,"
  606.                ?"the car is pointing toward where the road should be.  The seats are a tacky"
  607.                ?"yellow flannel, so on second thought, the car should probably be condemned."
  608.          end select
  609.  
  610.       case "open"
  611.          select case object$
  612.             case "door"
  613.                if flag(i_sh_keyring) <> have_item then
  614.                   ?"With some difficulty pushing the grass aside, you slowly work the driver's"
  615.                   ?"side soor open and climb inside.  There are no keys in the ignition, neither"
  616.                   ?"in the glove box or anywhere else that you can see, so you climb back out."
  617.                elseif flag(i_sh_keyring) = have_item then
  618.                   ?"With some difficulty pushing the grass aside, you slowly work the driver's"
  619.                   ?"side door open and climb inside, closing the door behind you.  It closes on"
  620.                   ?"some of the grass, but there's not much point trying to get it completely"
  621.                   ?"clear.  Taking out the keyring, you insert one of the keys and give it a turn."
  622.                   ?"The engine sputters a bit, but starts on the first try."
  623.                   ?
  624.                   if flag(i_sh_papers) <> have_item then
  625.                      ?"However, the road ahead is likely to be long and confusing, and you don't have"
  626.                      ?"a good idea of where to go from here.  It would be a good idea to form a basic"
  627.                      ?"plan first.  You kill the motor and get back out."
  628.                   elseif flag(i_sh_papers) = have_item then
  629.                      ?"You should be able to get the car to move west from here onto the road."
  630.                      ?"You have a mind to check out some of the places described among the papers"
  631.                      ?"you found."
  632.                      goto home_car
  633.                   end if
  634.                end if
  635.          end select
  636.  
  637.       case "north"
  638.          ?"There's no reason to search past this point."
  639.       case "east"
  640.          ?"There's no reason to search past this point."
  641.       case "west"
  642.          ?"There's no reason to search past this point."
  643.  
  644.       case "south"
  645.          ?"You navigate the tall grass again and make your way back to the house."
  646.          goto home_path
  647.  
  648.    end select
  649.  
  650.  
  651.  
  652. home_car:
  653.  
  654. location = loc_home_car
  655.    call get_input
  656.  
  657.    select case verb$
  658.       case "look"
  659.          select case object$
  660.             case ""
  661.                ?"You're sitting in an old brown car facing roughly west, surrounded by tall"
  662.                ?"grass.  The car is running, and presumably the road is through the grass"
  663.                ?"in front of you."
  664.          end select
  665.  
  666.       case "north"
  667.          ?"The grass is thick, and it would be awkward and pointless to try to move that way."
  668.       case "east"
  669.          ?"The grass is thick, and it would be awkward and pointless to try to move that way."
  670.       case "south"
  671.          ?"The grass is thick, and it would be awkward and pointless to try to move that way."
  672.  
  673.       case "west"
  674.          ?"It takes some pumping the gas to get the car through the grass ahead, but after"
  675.          ?"a minute or so of coaxing, you emerge, the front of the car pointed onto the"
  676.          ?"road.  Each of the pamphlets shows an interesting location and lists an address"
  677.          ?"with a small map.  There's a bigger travel map in the glovebox, so while"
  678.          ?"navigating might be a bit touch and go at first, you're confident you can"
  679.          ?"figure it out.  Type one of the following to drive there:"
  680.          ?
  681.          ?"'drive 1' - Newport Theater, 544 Old Elanise Road"
  682.          ?"'drive 2' - Kenworthy Historical Estate, 1202 *** Avenue"
  683.          ?"'drive 3' - David H. Christopher Public Library, 4 Vicksburgh Circle"
  684.          ?
  685.          ?"Currently, none of these locations are implemented in the game."
  686.          ?"You've completed the teaser!"
  687.          ?
  688.          ?"This is a side project to my main game development project, so I will be"
  689.          ?"continuing it as I feel motivated to.  Thanks for playing!"
  690.          ?
  691.          ?"Press enter to exit."
  692.          ?
  693.          input "> ", i$
  694.          system
  695.  
  696.    end select
  697.  
  698.  
  699.  
  700.  
  701.  
  702.  
  703. ' --------------------
  704. ' ===== Routines =====
  705. ' --------------------
  706.  
  707. sub templates
  708.  
  709. ' This sub is never called, it contains templates.
  710.  
  711. ' --- Text width ruler, at location select case indent ---
  712.  
  713. '        ?"         1         2         3         4         5         6         7         8
  714. '        ?"12345678901234567890123456789012345678901234567890123456789012345678901234567890"
  715.  
  716. ' --- Location template ---
  717.  
  718. 'home_bedroom:
  719.  
  720. location = loc_home_bedroom
  721.    call get_input
  722.  
  723.    select case verb$
  724.       case "look"
  725.          select case object$
  726.             case ""
  727.          end select
  728.  
  729.       case "get"
  730.  
  731.       case "use"
  732.  
  733.       case "open"
  734.  
  735.       ' Other verbs as needed
  736.  
  737.       case "north"
  738.       case "east"
  739.       case "south"
  740.       case "west"
  741.  
  742.    end select
  743.  
  744.  
  745.  
  746. function letter(c$)
  747.  
  748. letter = false
  749. n = asc(lcase$(c$))
  750. if n = 32 then letter = true
  751. if n => 48 and n <= 57  then letter = true
  752. if n => 97 and n <= 122 then letter = true
  753.  
  754.  
  755.  
  756. sub get_input
  757.  
  758. color 14, 0
  759. ?
  760. input "> ", i$
  761.  
  762.  
  763. ' Process input into verb and object
  764.  
  765. i$ = lcase$(i$)
  766.  
  767. ' Remove all non-letter, non-space characters
  768. for p = len(i$) to 1 step -1
  769.    if letter(mid$(i$, p, 1)) = false then i$ = left$(i$, p - 1) + right$(i$, len(i$) - p)
  770.  
  771. ' Remove leading spaces
  772. do while left$(i$, 1) = " "
  773.    i$ = right$(i$, len(i$) - 1)
  774.  
  775. ' Extract first word to verb$
  776. p = instr(i$ + " ", " ")
  777. verb$ = left$(i$, p - 1)
  778. i$ = right$(i$, len(i$) - p)
  779.  
  780. ' Remove leading spaces
  781. do while left$(i$, 1) = " "
  782.    i$ = right$(i$, len(i$) - 1)
  783.  
  784. ' Extract second word to object$, use empty string if none
  785. p = instr(i$ + " ", " ")
  786. object$ = left$(i$, p - 1)
  787.  
  788.  
  789. ' Verb shortcut replacement
  790.  
  791. select case verb$
  792.    case "n": verb$ = "north"
  793.    case "e": verb$ = "east"
  794.    case "s": verb$ = "south"
  795.    case "w": verb$ = "west"
  796.  
  797.    case "h": verb$ = "help"
  798.    case "l": verb$ = "look"
  799.    case "g": verb$ = "get"
  800.    case "o": verb$ = "open"
  801.    case "u": verb$ = "use"
  802.  
  803.  
  804. '? "["; verb$; "] ["; object$; "]"
  805. ?
  806. color 15, 0
  807.  
  808.  
  809.  
  810. ' Global commands - can be used from anywhere
  811.  
  812.    select case verb$
  813.       case "help"
  814.          ?"[h or help] - Show this information"
  815.          ?"[l or look] - Look around, or at something specific"
  816.          ?"[o or open] - Open something, keys will be used automatically"
  817.          ?"[u or use] - Use something, can generally replace other verbs"
  818.          ?"[g or get] - Pick up an item, type [inv] to see your items"
  819.          ?"[n, e, s, w, or north, east, south, west] - Move around"
  820.          ?"[nw, se, northwest, southeast, etc] - Move around some more"
  821.          ?
  822.          ?"These are only the most common commands.  Some situations will"
  823.          ?"require others.  However, you will never need more than a verb"
  824.          ?"followed by a thing."
  825.  
  826.       case "inv"
  827.          ?"--- INVENTORY ---"
  828.          for n = 1 to total_items
  829.             if flag(n) = have_item then ? item_name$(n)
  830.          next n
  831.  
  832.       case "use"
  833.          select case object$
  834.             case "batteries"
  835.                if flag(i_sh_batteries) = have_item and flag(i_sh_deadflashlight) = have_item then
  836.                   ?"You open the package and pop the batteries into the handle of the flashlight."
  837.                   ?"Testing the switch, it's now powered and will last as long as you'll need."
  838.                   flag(i_sh_batteries)      = used_item
  839.                   flag(i_sh_deadflashlight) = used_item
  840.                   flag(i_sh_flashlight)     = have_item
  841.                end if
  842.  
  843.          end select
  844.  
  845.       ' Looking at items in inventory
  846.  
  847.       case "look"
  848.          select case object$
  849.             case "flashlight"
  850.             case "batteries"
  851.             case "key"
  852.                ' Only one key in this intro chapter, but multiple keys possible later
  853.             case "keyring"
  854.             case "papers"
  855.                ' These papers may reveal more later on, so the text will depend on progress
  856.          end select
  857.    end select
  858.  
  859.  
  860.  
  861. sub save_game
  862. open "save.sav" for binary as #1
  863. put #1, 1, location
  864. put #1, , flag()
  865.  
  866.  
  867. sub load_game
  868. open "save.sav" for binary as #1
  869. get #1, 1, location
  870. get #1, , flag()
  871.  

Pages: [1] 2 3 ... 8