|
Post by nishlaverz on Oct 19, 2021 10:29:24 GMT
I'm looking to create a text adventure for my Daughter and her friend who are into tabletop gaming/ fantasy RPG's. would love some insight in to what you guys think would be the best way to code one as I'm a little rusty. Will need to move variables from on array to another and create and populate rooms/dungeons.
|
|
|
Post by tsh73 on Oct 19, 2021 12:12:00 GMT
|
|
|
Post by nishlaverz on Oct 19, 2021 20:06:42 GMT
i have a copy of that first book somewhere in my collection. I used and still use zx basic a lot more than JB so just need to get back into it and see what i can come up with. i have an idea for the story which i'm putting into code at the minute but i'm very rusty. I have seen some code that seems to work well so will see what i can do. ps thanks for the archive link as i've not come across that one before. It will be a great help for me and others looking for help.
|
|
|
Post by nishlaverz on Oct 20, 2021 11:06:52 GMT
got a little bit done. Will work on one class at a time this will mean i duplicate code at times but will then try to refine it later.
[menu] 'display menu options
cls
print "** Dragon Dungeon **"
print ""
print ""
print ""
print "what do you wish to do?"
print ""
print " 1) Start New Game"
print " 2) Instructions"
print " 3) Quit"
print
print "Choose an option from 1 to 3."
input ">"; option
if option < 1 or option > 3 then gosub [badOption]
if option = 1 then gosub [game]
if option = 2 then gosub [instructions]
if option = 3 then [quit]
goto [menu]
[badOption] 'display a notice that a bad selection was made
print
beep
print "Option "; option; " is unsupported."
print "Press any key."
dummyVar$ = input$(1)
return
[game]
cls
Print "** Dragon Dungeon **"
print ""
print ""
print ""
print "Choose Your Character"
print ""
print "1) Barbarian"
print "2) Monk"
print "3) Ranger"
print "4) Sorcerer"
print "5) Thief"
Print "6) Wizard"
print ""
print "For Info on all Character Classes Press 0"
input ">"; class
if class = 1 then gosub [Barbarian]
if class = 0 then gosub [ClassInfo]
[ClassInfo]
cls
print "** Dragon Dungeon **"
print ""
print "Character Class Information"
print ""
print ""
print "Barbarian"
print ""
print "Primitive Warrior who is fierce in Battle"
[Barbarian]
let cc$ = "Barbarian"
let hp = 12
let ap = 10
let wp = 10
let at = 5
let df = 1
cls
print cc$
print "You are a Primitive Warrior who is fierce in Battle"
print "You have", hp, "HP"
print "You have", ap, "Ability Points to spend"
print "you have", wp, "Weapon Points to spend"
Print ""
print "Weapons Available"
print ""
print "Weapon", "", "Cost"
print "1) Great Axe", "", "6"
print "2) Great Sword", "8"
Print "What is your Weapon of Choice?"
input ">"; weapon
if weapon = 1 then let wp = wp-6: let at = at+6
if weapon = 2 then let wp = wp-8: let at = at+8
print "Weapon points remaning", wp
print "You have", at, "Attack Points"
print ""
print "Secondary Weapons"
print ""
print "Weapon", "", "cost"
print "1) Wooden Daggers", "2"
print "2) Iron Daggers", "4"
print "3) Wooden Shield", "4"
input ">"; sweapon
if sweapon = 1 then let wp = wp-2: let at = at+2
if sweapon = 2 and wp = 4 then let wp = wp-4: let at = at+4
if sweapon = 2 and wp = 2 then print "you cannot afford that"
if sweapon = 3 and wp = 4 then let wp = wp-4: let df = df+4
if sweapon = 3 and wp = 2 then print "you cannot afford that"
print "You have", at, "Attack Points"
print "You have", df, "Defence Points"
goto [MainGame]
[MainGame]
cls
print cc$
print "you have", hp, "HP"
print "you have", at, "Attack Points"
print "You have", df, "Defence Points"
|
|
|
Post by tsh73 on Oct 20, 2021 14:41:01 GMT
you can save a fiew keystrokes by omitting LET keyword. JB just works without it ;)
Also, is asking (me ;) ) to be translated to arrays, something like
weap=2 weapName$(weap)= "Iron Daggers" weapCost(weap)=4
Then you'll be able to do stuff like
if weapCost(sweapon) > wp then print "you cannot afford ";weapName$(sweapon) else wp = wp-weapCost(sweapon) df = df+weapCost(sweapon) end if see? no separate cases for different weapons
EDIT my bad. Did not paid attention to "at" - attack points and "df" - defence points, but I hope you get the idea
|
|
|
Post by nishlaverz on Oct 20, 2021 15:30:04 GMT
That's what I'm looking at as I build up the game. Just need to build the actual game. I have some code that I'm working on integrating.
|
|
|
Post by nishlaverz on Oct 20, 2021 18:43:48 GMT
Looking to use something like to code below. Just need to see if I can make it work and work on code for the inventory and fights.
True = 1
False = 0
[WindowSetup]
WindowWidth = 511 : WindowHeight = 358
UpperLeftX = INT((DisplayWidth-WindowWidth)/2)
UpperLeftY = INT((DisplayHeight-WindowHeight)/2)
[ControlSetup]
statictext #main.s1, "Type here. Hit 'ENTER.'", 10, 260, 169, 25
statictext #main.s2, "Dragon Dungeon.", 10, 10, 169, 25
button #main.default, "Okay",[processinput],UL, 380, 290, 105, 25
button #main.quit, "Quit",[quit],UL, 380, 255, 105, 25
textbox #main.type, 10, 290, 355, 24
texteditor #main.display, 10, 40, 490, 210
Open "Dragon Dungeon" for Dialog as #main
#main "trapclose [quit]"
#main "font ms_sans_serif 10"
gosub [data]
[awaitinput]
#main.type ""
#main.type "!setfocus"
wait
[quit]
close #main : END
[processinput]
#main.type "!contents? txt$"
select case upper$(left$(txt$,1))
case "N"
if moven$<>"" then
move$ = "You walk North"
loc$ = moven$
move = True
else
move$ = "You cannot go North"
move = False
end if
case "S"
if moves$<>"" then
move$ = "You walk South"
loc$ = moves$
move = True
else
move$ = "You can't go South"
move = False
end if
case "E"
if movee$<>"" then
move$ = "You walk East"
loc$ = movee$
move = True
else
move$ = "You are not able to go East"
move = False
end if
case "W"
if movew$<>"" then
move$ = "You walk West"
loc$ = movew$
move = True
else
move$ = "You can't go West"
move = False
end if
case "T"
if o$<>"" then
#main.display "You pick up the "+o$
else
#main.display "There is nothing to pick up."
end if
goto [awaitinput]
' add code to remove the item from location$() and add it to inventory$
case "A"
if mons$<>"" then
#main.display "You swing your weapon at the enemy"
else
#main.display "There is nothing to attack"
end if
goto [awaitinput]
case "L"
#main.display, "I didn't bring my glasses so can't see anything."
goto [awaitinput]
case else
#main.display "I don't yet understand that word."
#main.display "I do understand North South East West Look Take"
goto [awaitinput]
end select
[displaylocation]
#main.display "!cls"
#main.display move$
desc$ = ""
n$ = ""
moven$ = ""
s$ = ""
moves$ = ""
e$ = ""
movee$ = ""
w$ = ""
movew$ = ""
o$ = ""
mons$ = ""
for n = 1 to 100
if left$(location$(n),7) = loc$+"DESC" then desc$ = right$(location$(n),len(location$(n))-7)
if left$(location$(n),4) = loc$+"N" then n$ = right$(location$(n),len(location$(n))-7) : moven$ = mid$(location$(n),5,3)
if left$(location$(n),4) = loc$+"S" then s$ = right$(location$(n),len(location$(n))-7) : moves$ = mid$(location$(n),5,3)
if left$(location$(n),4) = loc$+"E" then e$ = right$(location$(n),len(location$(n))-7) : movee$ = mid$(location$(n),5,3)
if left$(location$(n),4) = loc$+"W" then w$ = right$(location$(n),len(location$(n))-7) : movew$ = mid$(location$(n),5,3)
if left$(location$(n),4) = loc$+"O" then o$ = right$(location$(n),len(location$(n))-7)
if left$(location$(n),7) = loc$+"MONS" then mons$ = right$(location$(n),len(location$(n))-7)
next n
#main.display desc$
if n$<>"" then #main.display "To the north ";n$
if s$<>"" then #main.display "To the south ";s$
if e$<>"" then #main.display "To the east ";e$
if w$<>"" then #main.display "To the west ";w$
if o$<>"" then #main.display "At your feet there is a ";o$
if mons$<>"" then #main.display mons$
#main.display "What do you want to do?"
goto [awaitinput]
[data]
dim location$(100)
restore
read d$
n = 1
while d$<>"EndofData"
location$(n) = d$
n = n+1
read d$
wend
loc$ = "001"
goto [displaylocation]
data, "001DESCYou are standing in a clearing where you have set up camp."
data, "001N002you see a forest."
data, "001OBJEtar torch and a stone flint."
data, "002DESCYou are at the edge of a forest."
data, "002N005the light fades quickly in the thickness of the trees."
data, "002S001is the clearing."
data, "002E003you see the entrance to a guard hut."
data, "002W004there is what looks like a storage room."
data, "002OBJEsword"
data, "003DESCThe hut door is ajar."
data, "003W002edge of the forest."
data, "003E006inside the Hut"
data, "004DESCThe door has been forced and the storage room is empty."
data, "004E005is the tunnel."
data, "005DESCIt is to dark to go any further in."
data, "005S002is the edge of the forest."
data, "006DESCYou are inside the Hut"
data, "006MONSSomething comes at you"
data, "EndofData"
|
|