Qbasicnews.com
March 28, 2020, 06:03:50 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: [1] 2 3 4
  Print  
Author Topic: Creating my own text world Help  (Read 9122 times)
Storymaster
New Member

Posts: 7


« on: March 05, 2005, 02:37:09 PM »


I would like to say Hello to all of you fine people in this great community dedicated into the great world of QB. I have played a ton of text based games from Atlantis to Zork and have always been loving it. My question is that how could I create my own world of text. I have tried in the past with no light at the end of the tunnel. For anyone out there in this great metropolis of text who can help by sending me some open source text based games I can use as reference or even tips or some sites that may help. Thank.

P.S I am looking forward to being a true member of this great Empire of a site.
Logged

 have seen the end of every Zork ever made, I have played text based games from Atlantis to the depths of thee unimaginable, and I'm the only one who knows about it. Because I've done battle with the worst of creations.
Rattrapmax6
__/--\__
*****
Posts: 2577



WWW
« Reply #1 on: March 05, 2005, 09:45:03 PM »

:Huh: What particular part are you having problems with? Map making, barriers, moving, ASCII character placement? um all the above??  Smiley
Logged

Kevin (x.t.r.GRAPHICS)

Liquid Snake
Wandering Guru
***
Posts: 354



WWW
« Reply #2 on: March 05, 2005, 09:54:29 PM »

The easiest way I find is to make a do/loop with if statements leading to gosubs for example:


Code:

cls
choice=0
do
if choice=0 then gosub main
if choice=1 then gosub room1
loop until choice=2
end

main:
print
print"1.next room"
print"2.quit"
input "Where to? (Numbers only)";x
if x=1 then choice =1
if x=2 then choice=2
return

room1:
print
print"1.back"
print"2.quit"
input "Where to? (Numbers only)";x
if x=1 then choice =0
if x=2 then choice=2
return
Logged

Not yet Snake! It's not over yet!
na_th_an
*/-\*
*****
Posts: 8244



WWW
« Reply #3 on: March 05, 2005, 10:14:14 PM »

That's the wrong way to do it. You get sucky, limited games. Zork, etc. are Interactive Fiction, something way more advanced that a simple bunch of IFs.

Head to my tuts at Pete's QB Express mag:

http://www.petesqbsite.com/sections/express/issue6/#IFgames
http://www.petesqbsite.com/sections/express/issue7/#IFgames

In the next chapter (which will be released in this month's Issue #8 ) I'll give some code.

In the meantime, play our IF game: http://www.apeshell.com . Download "The Quest for Opa Opa". (It's in the downloads section http://www.apeshell.net/downloads/)
Logged

SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Liquid Snake
Wandering Guru
***
Posts: 354



WWW
« Reply #4 on: March 05, 2005, 11:16:23 PM »

I'm just saying that's probably the easiest way if you want to make a game that goes from room to room or scene to scene, you know...  I've never played Zork or whatever so I can't really say what those are like.  I'm just teaching him the way I learned it.  
besides, you can make the if statements into:
Code:

if (x="up") or (x="u") then...
elseif (x="east") or (x="e") then...
end if


You can get as complicated as you want.

What's the better way then? Cause I don't know how you can get easier than that.[
Logged

Not yet Snake! It's not over yet!
na_th_an
*/-\*
*****
Posts: 8244



WWW
« Reply #5 on: March 06, 2005, 12:37:32 AM »

That way you are limiting the player input. Plus you are givin hints on what the player should do.

In Zork and other IF games you have almost free will. You can do a lot of things with the objects, for example. Using your technique, you would need 1000 IFs per room to make a complex game.

Quote
You are sitting in your desk listening to a boring maths class. Everyone is soothing. You can see a pencil and a case. Obvious exits: none.

What now?

> get case and get pencil

You get the case
You get the pencil

> put pencil into case

The case is closed.

> open case

Opened.

> put pencil into case

The pencil is now in the case.

> close it

Closed.


That's how it works. It's not easier. In fact, it is like 1000 times harder. But once you have your engine running, you can use it to make all the games you want just changing the descriptions, the objects and the "exceptions". Read my tuts to find out how Wink
Logged

SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Liquid Snake
Wandering Guru
***
Posts: 354



WWW
« Reply #6 on: March 06, 2005, 12:43:07 AM »

I see.  How would you do that without as many if's?
Logged

Not yet Snake! It's not over yet!
na_th_an
*/-\*
*****
Posts: 8244



WWW
« Reply #7 on: March 06, 2005, 12:44:44 AM »

for the third time:

READ MY TUTS Wink

(note: you DO use IFs, I was just telling that "INPUT A$" and a bunch of IFs to check what the player wrote in each room is not the way to go)
Logged

SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Liquid Snake
Wandering Guru
***
Posts: 354



WWW
« Reply #8 on: March 06, 2005, 01:04:35 AM »

Sorry, it's just a bit confusing for me. You don't need to explain it for me.  I had a half year course of QBasic, so I wasn't able to learn everything, just the basics...Like the stuff I've been posting.
Logged

Not yet Snake! It's not over yet!
Storymaster
New Member

Posts: 7


« Reply #9 on: March 06, 2005, 12:01:13 PM »

Well since it is my first time creating this world of mine it's basically all of the above.
Logged

 have seen the end of every Zork ever made, I have played text based games from Atlantis to the depths of thee unimaginable, and I'm the only one who knows about it. Because I've done battle with the worst of creations.
Rattrapmax6
__/--\__
*****
Posts: 2577



WWW
« Reply #10 on: March 06, 2005, 08:23:00 PM »

Quote from: "Storymaster"
Well since it is my first time creating this world of mine it's basically all of the above.


Hmm, that was the one I least hoped you'd pick, heh heh,.. Maybe I could write a source of a bare'bones one heavly commented..  :wink: .. to look over or something.. hmm...
Logged

Kevin (x.t.r.GRAPHICS)

na_th_an
*/-\*
*****
Posts: 8244



WWW
« Reply #11 on: March 07, 2005, 06:07:25 AM »

Next issue of QB Express will feature the last chapter of my tuts. I'll be coding the whole thing step to step. Meanwhile, read the two first chapters to know how everything works.
Logged

SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Mitth'raw'nuruodo
Ancient Guru
****
Posts: 515



WWW
« Reply #12 on: March 07, 2005, 06:11:53 PM »

Quote from: "na_th_an"
That's the wrong way to do it. You get sucky, limited games. Zork, etc. are Interactive Fiction, something way more advanced that a simple bunch of IFs.


Hmmm...I am thinking I like you na_th_an... Cheesy

Ya, GOSUBs are the definent WRONG way, they are ok, but still really crappy like GOTO. If I want to do a SUB I just do a SUB the normal way.

And yes I only had a half a year course too (not even two years ago, and before that I had no knowlege of QB), but you can learn so much on your own (I am already doing my first good game in pure QB, and another in 3D!) or with help here like you are doing now (making mistakes), but mistakes are how you learn so, keep up the good work Liquid Snake. :wink:
Logged

i]"But...it was so beautifully done"[/i]
Rattrapmax6
__/--\__
*****
Posts: 2577



WWW
« Reply #13 on: March 07, 2005, 10:00:08 PM »

Smiley Okay, a example to look over and learn from... Heh, its my very first time I wrote one, yea! Sorry if it looks like half a raycaster, it works partly like one, just w/o the ray casting...  Cheesy

[syntax="qbasic"]SCREEN 13
CLS 'Clear the screen
DIM map(10, 10) 'Create Map Array

' Load Map DATA into array..
' When over given points like map(1, 1) = 4, and map(2, 2) = 3.. esc
FOR y = 1 TO 10
  FOR x = 1 TO 10
    READ z
    IF z = -1 THEN x1 = x: y1 = y: z = 0 ' Find players position.
    map(x, y) = z 'Pack all our Map info into array.
  NEXT
NEXT

DO ' Start main LOOP
press$ = INKEY$ ' Promt keys
' Display Map on screen..
FOR y = 1 TO 10
  FOR x = 1 TO 10
    ' Diff numers equal diff tiles, and there location is strored in
    ' Map(x, y).. Just remember LOCATE is backward Y, X..
    ' We assign color acording to how we want it displayed
    ' CHR$(219) equals a "".. You can just hold Alt and type in 219
    ' When you there-after release Alt it gives you that character
    IF map(x, y) = 0 THEN COLOR 6: LOCATE y, x: PRINT CHR$(219) 'Dirt
    IF map(x, y) = 2 THEN COLOR 2: LOCATE y, x: PRINT CHR$(219) 'Grass
    IF map(x, y) = 3 THEN COLOR 9: LOCATE y, x: PRINT CHR$(219) 'Water
    IF map(x, y) = 4 THEN COLOR 7: LOCATE y, x: PRINT CHR$(219) 'Wall
  NEXT
NEXT

IF press$ = CHR$(0) + "H" THEN ' On Keypress Up Arrow...
  y1 = y1 - 1 ' Move player Up screen..
 
  ' Check for walls or water, both are 3 or greater..
  IF map(x1, y1) >= 3 THEN y1 = y1 + 1
ELSEIF press$ = CHR$(0) + "P" THEN
  ' Move player down, also check, we have a door at the bottom
  ' We need to stall player sence there is no map info
  ' You can use this to call a new Map
  y1 = y1 + 1: IF y1 > 10 THEN y1 = 10: LOCATE 12, 1: PRINT "Can't Pass! No Map down there!"
 
  ' Check for walls or water, both are 3 or greater..
  IF map(x1, y1) >= 3 THEN y1 = y1 - 1
ELSEIF press$ = CHR$(0) + "M" THEN
  ' Move player right, also check, we have a door at the right
  ' We need to stall player sence there is no map info
  ' You can use this to call a new Map
   x1 = x1 + 1: IF x1 > 10 THEN x1 = 10: LOCATE 12, 1: PRINT "Can't Pass! No Map over there!"
 
  ' Check for walls or water, both are 3 or greater..
  IF map(x1, y1) >= 3 THEN x1 = x1 - 1
ELSEIF press$ = CHR$(0) + "K" THEN
  x1 = x1 - 1 ' Move player left
 
  ' Check for walls or water, both are 3 or greater..
  IF map(x1, y1) >= 3 THEN x1 = x1 + 1
END IF

' Display player on screen. Make sure you do this after you've
' checked for movement and barriers.. Like above ^^ ^^
LOCATE y1, x1: PRINT CHR$(1)

' Video Buffer
WAIT &H3DA, 8
' Helps Video Buffer
FOR I = 1 TO 1000: NEXT

LOOP UNTIL press$ = CHR$(27)' Loop until KeyPress = Esc

'------------Map!-------------
'[[ Notes ]]
'Notice I put the unpassible DATA ander numbers all higher than 2
'This way I can check for barriers in one line of code for each
'way your alowed to move.. Up, Down, Left, & Right.. so four times.. Cheesy
'Compare to about 8 times if they were random... Look up there where
'I checked for barriers to see what I'm on..

' This can be any number, if you have 8 passible objects, then make every
' thing higher than 8 the unpassible ones.. See where I'm at..

' IF map(x, y) >= 9 THEN ... block player for that direction..

'[[ Map ]]
'[[ Key ]]
'-1 = Player's position
'0 = Dirt
'2 = Grass
'3 = Water
'4 = Wall

DATA 4,4,4,4,4,4,4,4,4,4
DATA 4,3,3,3,3,3,2,4,0,4
DATA 4,2,3,3,3,2,2,4,0,4
DATA 4,2,2,2,2,2,2,4,0,4
DATA 4,0,2,2,2,2,0,4,0,0
DATA 4,0,0,0,0,0,0,0,0,0
DATA 4,0,0,0,-1,0,0,4,0,4
DATA 4,0,4,4,4,4,4,4,0,4
DATA 4,0,0,0,0,0,0,4,0,4
DATA 4,4,4,4,4,0,0,4,4,4[/syntax]

Enjoy!!!  :wink:
Logged

Kevin (x.t.r.GRAPHICS)

Mitth'raw'nuruodo
Ancient Guru
****
Posts: 515



WWW
« Reply #14 on: March 08, 2005, 01:06:34 AM »

Nice however I don't like that Can't pass thing, because it doesn't clear when I don't try to do it again, so it PRINTs it once then it will show forever.
Logged

i]"But...it was so beautifully done"[/i]
Pages: [1] 2 3 4
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!