Thinking of a ASCII text Adventure? Look here first!

Discuss whatever you want here--both QB and non-QB related. Anything from the DEF INT command to the meaning of life!

Moderators: Pete, Mods

Rattrapmax6
Veteran
Posts: 1055
Joined: Sun Jan 02, 2005 2:11 pm
Location: At my computer
Contact:

Thinking of a ASCII text Adventure? Look here first!

Post by Rattrapmax6 »

:D Hay! You thinking of making a ASCII text adventure in QB? Then you should like these SUB routines that modify the PRINT statment. After loading these SUBs into your QBIDE the new PRINT statments are

Code: Select all

TYPTEXT y, x, "text here"
ALNTYPE "left, center, or right", y, "text here"
ALNTEXT "left, center, or right", y, "text here"
REVTEXT y, x, "text here"
NUMTEXT y, x, "text here"
ALN sentax can be any case "LEFT", "LeFt", or "left"

Sentaxt error would be spacing around ALN command, " left ", this is not handled and will cause your text not to PRINT.

This will only work in SCREEN 0, 2, 3, 4, 8, 9, or 10...
I'll be working on one for the others screens when ever I get round to it, but this will do for all you ASCII text adventure scripters!

Statments effects are discused with REMlines in the code, also a .BAS form will be placed on my site for those who don't know how to get this into QB..

POWERCALL.BAS (PWRCALL.BAS)

Code: Select all

'
'     Hello, and welcome to my SCREEN 0, 2, 3, 4, 8, 9, & 10
' SUB routines for modified print staments. Great routines for
' ASCII text adventure to add ease and eye-catching efects.
' Take a look at the examples below, they'll show you how
' to work them....

DECLARE SUB ALNTYPE (aln$, y!, text$)
DECLARE SUB NUMTEXT (y!, x!, text$)
DECLARE SUB REVTEXT (y!, x!, text$)
DECLARE SUB ALNTEXT (aln$, y!, text$)
DECLARE SUB TYPTEXT (y!, x!, text$)

CLS
' ########### EXAMPLES ################
'Read over what each statment does, how it works. Then press <F5>
'to see then in action!!

'TYPTEXT types text as if it were bieng entered from a keyboard!
' You must note Y & X locations as with LOCATE...

TYPTEXT 1, 1, "You can have your text type like a LOCATE/PRINT statment!"

'ALNTYPE types text like above statment, but from either
' CENTER, LEFT, or RIGHT (Any Case), Y location must be noted

ALNTYPE "right", 2, "Or type to the right of the screen!"
ALNTYPE "center", 3, "Type into the center of the screen!"
ALNTYPE "left", 4, "Or just type from the left!!"

'ALNTEXT, if you want to PRINT to the LEFT, CENTER, or RIGHT (Any Case)
' Y Location must be noted (Are you tiered of me saying that yet?)

ALNTEXT "right", 5, "PRINT to the right!"
ALNTEXT "center", 6, "PRINT into the center!"
ALNTEXT "left", 7, "Or PRINT from the left!"

'REVTEXT is just for fun, reverses the intered text
' Y & X locations must be noted

REVTEXT 9, 1, "Looking funny yet?"

'NUMTEXT, returns the ASCII values in numbers
' Y & X locations must be noted

NUMTEXT 11, 1, "NUMBERS!"

'Enjoy these SUB routine statments, easy to map into any program!

SUB ALNTEXT (aln$, y, text$)
a = LEN(text$)
IF UCASE$(aln$) = "LEFT" THEN
   x = 1
   LOCATE y, x: PRINT text$
END IF
IF UCASE$(aln$) = "CENTER" THEN
   c = a \ 2
   x = 40 - c
   LOCATE y, x: PRINT text$
END IF
IF UCASE$(aln$) = "RIGHT" THEN
   x = 80 - a
   LOCATE y, x: PRINT text$
END IF
END SUB

SUB ALNTYPE (aln$, y, text$)
a = LEN(text$)
IF UCASE$(aln$) = "LEFT" THEN
   x = 1
   IF y > 23 THEN y = 23
   cont = 0
   DO
      cont = cont + 1
      phr$ = phr$ + MID$(text$, cont, 1)
      LOCATE y, x: PRINT phr$
      IF cont = LEN(text$) THEN GOTO endsub
      FOR i = 1 TO 40000: NEXT
   LOOP UNTIL INKEY$ = CHR$(27)
END IF
IF UCASE$(aln$) = "CENTER" THEN
   x = 40 - (a \ 2)
   IF y > 23 THEN y = 23
   cont = 0
   DO
      cont = cont + 1
      phr$ = phr$ + MID$(text$, cont, 1)
      LOCATE y, x: PRINT phr$
      IF cont = LEN(text$) THEN GOTO endsub
      FOR i = 1 TO 40000: NEXT
   LOOP UNTIL INKEY$ = CHR$(27)
END IF
IF UCASE$(aln$) = "RIGHT" THEN
   x = 80 - a
   IF y > 23 THEN y = 23
   cont = 0
   DO
      cont = cont + 1
      phr$ = phr$ + MID$(text$, cont, 1)
      LOCATE y, x: PRINT phr$
      IF cont = LEN(text$) THEN GOTO endsub
      FOR i = 1 TO 40000: NEXT
   LOOP UNTIL INKEY$ = CHR$(27)
END IF

endsub:
END SUB

SUB NUMTEXT (y, x, text$)
cont = 0
DO
cont = cont + 1
lttr$ = MID$(text$, cont, 1)
num = ASC(lttr$)
lnum$ = STR$(num)
pnum$ = pnum$ + lnum$
IF cont = LEN(text$) THEN EXIT DO
LOOP
LOCATE y, x: PRINT pnum$
END SUB

SUB REVTEXT (y, x, text$)
cont = LEN(text$)
DO
phr$ = phr$ + MID$(text$, cont, 1)
cont = cont - 1
IF cont = 0 THEN EXIT DO
LOOP
LOCATE y, x: PRINT phr$
END SUB

SUB TYPTEXT (y!, x!, text$)
IF y > 23 THEN y = 23
cont = 0
DO
cont = cont + 1
phr$ = phr$ + MID$(text$, cont, 1)
LOCATE y, x: PRINT phr$
IF cont = LEN(text$) THEN EXIT DO
FOR i = 1 TO 40000: NEXT
LOOP UNTIL INKEY$ = CHR$(27)
END SUB
-Kevin (aka:Rattra)
(x.t.r.GRAPHICS)
User avatar
Mitth'raw'nuruodo
Veteran
Posts: 839
Joined: Sat Jan 22, 2005 11:04 am
Location: Eastern Coast of US
Contact:

Post by Mitth'raw'nuruodo »

Looks nice but I write my own code when I can...or understand what I'm doing and I can't learn it. :D

I believe that using other peoples code is bad for you as a programmer too.
"But...It was so beutifully done"
Rattrapmax6
Veteran
Posts: 1055
Joined: Sun Jan 02, 2005 2:11 pm
Location: At my computer
Contact:

Post by Rattrapmax6 »

:) Umm, dude, there new PRINT statments that I've built... All the code is locked in SUBs and wouln't be seen while your coding, something like a Lib file inside the program itself... its just the same as using LOCATE/PRINT,.. see..

Code: Select all

TYPTEXT 1, 1, "Hello,  world!"
the output is: "Hello, world", as if were bing type by a keyboard. Its just modified stuff using logic and some math that most would pass over or not even know how to build in such a neat fasion, unless they were right advance... :wink:

PS: there are more Modified PRINT commands in this pwrcall.bas too than to one I just discribed. :D

Edit: Say, its like that SuperPut routine you got, :wink: , :D
-Kevin (aka:Rattra)
(x.t.r.GRAPHICS)
Z!re
Veteran
Posts: 887
Joined: Wed Aug 04, 2004 11:15 am

Post by Z!re »

Code: Select all

FOR i = 1 TO 40000: NEXT 
Blasphemer! A FOR/NEXT delay!

May the sword of functional code smite thee a thousand times!
I have left this dump.
Rattrapmax6
Veteran
Posts: 1055
Joined: Sun Jan 02, 2005 2:11 pm
Location: At my computer
Contact:

Post by Rattrapmax6 »

Hay, nice new Avatar.. :wink: Do any of 'em not '$include: 'blood'??

Hmm, you got a betta one? I'm all ears. :)
-Kevin (aka:Rattra)
(x.t.r.GRAPHICS)
User avatar
{Nathan}
Veteran
Posts: 1169
Joined: Thu Aug 19, 2004 6:08 pm
Location: The wetlands of central Ohio, USA
Contact:

Post by {Nathan} »

I was watching a show about the history of Lucas Arts and relized something QB has never had! Lets say I have this string:

The world may never know another Bob...

And I wanted to CENTER it at 20, 20. Make a routine to do that! Also, try making these routines new-font compatible and P*P lineup compatible... new lib, anyone?!

:lol:
Image
User avatar
Mitth'raw'nuruodo
Veteran
Posts: 839
Joined: Sat Jan 22, 2005 11:04 am
Location: Eastern Coast of US
Contact:

Post by Mitth'raw'nuruodo »

Ya I knew that, BTW they're called internal Libs.....
Oh, yeah I knew how to do those already anyways but its nice that you made some Subs for them...

LOL Z!re....he he.....Lets see, 40000, hmmm that will take a NANOSECOND to go though on my 3.0Ghz, or more like a Hundreth of a second, but close enough....

Code: Select all

CALL Change_To_Better_Code Rattrapmax6, For/Next, Time

SUB Change_To_Better_Code(Programmer, BadCode, ReplaceCode)
'Statements
END SUB
BTW, how do you do the TIME statement?

Code: Select all

CALL Change_To_Better_Code Mitth'raw'nurudo, For/Next, Time

SUB Change_To_Better_Code(Programmer, BadCode, ReplaceCode)
'Statements
END SUB
LOL :lol: !

Hey Nate....what do you mean by new-font P*P lineup compatible?
And where did Lucas Arts come from? :D
"But...It was so beutifully done"
Z!re
Veteran
Posts: 887
Joined: Wed Aug 04, 2004 11:15 am

Post by Z!re »

Mitth, using a FOR/NEXT delay properly is incredibly difficult.

It needs to be dynamic, and constantly update/change. Not something everyone knows how to do...

The smallest functional FOR/NEXT delay with 0.001 second accuracy I've made was around 50 lines of code.



Using a static FOR/NEXT like Rattr is doing is bad, you never know how long it'll take to go through.

Today it may take 0.001sec, tomorrow when you're running winamp in the background it might take 0.05, thats 50 times slower. *sarcasm* But who cares, it's so fast anyways... :roll:

Also, Rattrs program uses SINGLE for all numerical variables, meaning it's even slower.


And I know, you got a 3.0ghz, you don't care.. well, keep talking/thinking like that and you'll end up coding in C, thinking you're 1337 when you make your first string handler program.


Optimize people.. O P T I M I Z E !
I have left this dump.
User avatar
Mitth'raw'nuruodo
Veteran
Posts: 839
Joined: Sat Jan 22, 2005 11:04 am
Location: Eastern Coast of US
Contact:

Post by Mitth'raw'nuruodo »

Z!re I don't think that you got my meaning in my last post....FOR/LOOP delays are BAD and they're not good coding pratices!

Much like others I know about he he.... :)

I haven't learned how to use the TIME statement in order to do it better so I don't.

Yes I know to optimize and I DO!!! Believe me most of my programs would be a thousand times slower and longer but quicker to code which this is not...

However I do code in C as well.... :wink:
"But...It was so beutifully done"
Rattrapmax6
Veteran
Posts: 1055
Joined: Sun Jan 02, 2005 2:11 pm
Location: At my computer
Contact:

Post by Rattrapmax6 »

:) I already knew this problem, on my spare comp it runs slow, types one letter every 1/2 sec,. on my mian comp, the one I'm on now, it types every 1/4 sec... I could have used "WAIT &H3DA, 8" That really slows stuff down, or it slows down equilly where I've tested it.. :)

If you got a better way, lets here it,. FOR..NEXT or not...

Nathan, if you want to center text on SCREEN 13 then..

Code: Select all

DECLARE SUB CNTTEXT (y!, text$)

SCREEN 13
CLS

CNTTEXT 4, "Center in SCEEN 13!"

SUB CNTTEXT (y!, text$)
a = LEN(text$)
c = a \ 2
x = 20 - c
LOCATE y, x: PRINT text$
END SUB
I just typed that, so if nothing works, I'll fix it, but your text will center on 20.. :wink:
-Kevin (aka:Rattra)
(x.t.r.GRAPHICS)
User avatar
{Nathan}
Veteran
Posts: 1169
Joined: Thu Aug 19, 2004 6:08 pm
Location: The wetlands of central Ohio, USA
Contact:

Post by {Nathan} »

I was watching a show about Lucas Arts then typed my post... but I mean like do this

Center "This is centered text!", 30, 30

would center the string at 30, 30. If you are up to the challenge make it p*p cornation, but otherwise just use LOCATE! :lol:
Image
Rattrapmax6
Veteran
Posts: 1055
Joined: Sun Jan 02, 2005 2:11 pm
Location: At my computer
Contact:

Post by Rattrapmax6 »

:shock: Oh, challenge??? that would be easy, error handling and all, all it is, is a lil math! :wink: , I'll be back... :D
-Kevin (aka:Rattra)
(x.t.r.GRAPHICS)
Rattrapmax6
Veteran
Posts: 1055
Joined: Sun Jan 02, 2005 2:11 pm
Location: At my computer
Contact:

Post by Rattrapmax6 »

Nathan, check the post times, heh heh, then ask whats a challenge...

Code: Select all

DECLARE SUB CNTCORD (y!, x!, text$)

CLS
CNTCORD 12, 40, "Power Centering!"

SUB CNTCORD (y!, x!, text$)
'Error handle
a = LEN(text$)
cntr = a \ 2
IF a > 80 THEN PRINT "String Overflow!": END
IF y < 1 THEN y = 1
IF y > 23 THEN y = 23
IF x + cntr > 80 THEN PRINT "Over Set!": END
IF x - cntr < 1 THEN PRINT "Under Set!": END
'Center and PRINT
x = x - cntr
LOCATE y, x: PRINT text$
END SUB
And there is your center around text CALL, :D ,.. works too!!
-Kevin (aka:Rattra)
(x.t.r.GRAPHICS)
User avatar
Mitth'raw'nuruodo
Veteran
Posts: 839
Joined: Sat Jan 22, 2005 11:04 am
Location: Eastern Coast of US
Contact:

Post by Mitth'raw'nuruodo »

Burn
Rattrapmax6
Veteran
Posts: 1055
Joined: Sun Jan 02, 2005 2:11 pm
Location: At my computer
Contact:

Post by Rattrapmax6 »

Burn what Mitth?? :D

My 40min code?? My first code?? what??
-Kevin (aka:Rattra)
(x.t.r.GRAPHICS)
User avatar
{Nathan}
Veteran
Posts: 1169
Joined: Thu Aug 19, 2004 6:08 pm
Location: The wetlands of central Ohio, USA
Contact:

Post by {Nathan} »

wow :shock: :!: you guys never noticed how lazy i am :wink: notice how i always post psudo code never use punctiation and dont use shift or caps :?:
Image
Rattrapmax6
Veteran
Posts: 1055
Joined: Sun Jan 02, 2005 2:11 pm
Location: At my computer
Contact:

Post by Rattrapmax6 »

Nathan? What? Look at your above posts,.. they got tons off caps in stuff,... oh well...
-Kevin (aka:Rattra)
(x.t.r.GRAPHICS)
User avatar
Mitth'raw'nuruodo
Veteran
Posts: 839
Joined: Sat Jan 22, 2005 11:04 am
Location: Eastern Coast of US
Contact:

Post by Mitth'raw'nuruodo »

The burn that you gave Nate....

You know dis, ouch, burn, eh?
"But...It was so beutifully done"
Rattrapmax6
Veteran
Posts: 1055
Joined: Sun Jan 02, 2005 2:11 pm
Location: At my computer
Contact:

Post by Rattrapmax6 »

:) Oh so you mine my speed coding just burned Nate.. he really wanted a P*P what ever the heck that means... but I made a center that you can locate.. in 40mins too,. heh heh.. :wink:
-Kevin (aka:Rattra)
(x.t.r.GRAPHICS)
SBM Productions
Coder
Posts: 11
Joined: Sat Jan 08, 2005 8:56 am
Location: Australia
Contact:

Post by SBM Productions »

P*P = Pixel by Pixel
Post Reply