Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Text rpg question
#1
Im very new to qbasic and have just learned a few simple bits here and there.
To help myself get better im currently trying to make a mini TEXT only rpg type thing, basically a small shopping mall type simulation, where i can walk around and look in shops (kinda sad but i need to learn this) :bounce:
I have managed to programme all the 'rooms' of my mall but making commands specific to a certain room is causing quite a few problems for me. In general, north east south west for each room was easy i used the if and then commands.
I want to set specific key promts in rooms like shops though:
eg: buy 'item' in a shop, which i want only to be applicable in that particular room and nowhere else. (if this makes sense)

can anyone help me?
im very new to all this... :-? so im a bit slow at the minute hehe
-p
Reply
#2
Hmmm, just use IFs in combination with what is called "flag variables". These kinds of variables store numeric values that have an useful meaning. For example, you can have a flag to store which kind of room you are, for example, let's say

Code:
' the RoomType% variable will equal...
'  1   If you are in a corridor
'  2   If you are in the greengrocer's
'  3   If you are in the toy shop
'  4   If you are in the boutique
' (err... to name a few)

RoomType%=4

You only have to set it correctly for each room, and just make an IF. I don't know what kind of data structure you are using to store the room data, or maybe if you are hard-coding them with PRINTs and GOTOs (I would not do that!)...

In Sum, I don't know if I am helping you, mostly because I don't know how you are implementing your game Big Grin
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#3
ok i kinda understand now but im still too crap to put that into use, iv been programming about 3 days hehe and it aint goin all to well never done it before do i set these room types as an array, and is there a way i can customise each room type somehow after the array setting:-s sorry if i make no sense
-p
Reply
#4
The best thing is to have everything inside a data structure. Check for TYPE commands. You can look:

1. In QB help.
2. In tutorials (found in this site)
3. Do a SEARCH in this forum for "TYPE" and you'll find tons of info in past posts.
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#5
hey there

Umm, let's see.

Let's see if I got this right: So are you using a command menu such as


Where would you like to go?
1-> Shoe Store
2-> Software Etc
(and so on)
_ <-- the input


?

Oh i think I get it... so you can type in southeast and it would take you southeast, right? Well, if you are in a certain shop you can use the INKEY$ variable to program keys that would only work for a certain area

what you should do is create a DO LOOP UNTIL loop where the user can input a key. You could have the movement instead of typing southeast northwest and so forth just be a diagonal pad something along the lines of

q w e w is up, q is upleft (northwest) e is upright (northeast)
a s d and soforth...
z x c

so your program could look something like this

Code:
DO
PUSH$ = INKEY$
'use the above line because it is more responsive than just inkey$
'alone.  For some reason there is a delay when you use an if inkey$
'statement, but if you use a push$ (when push$ = inkey$) it will
'work.
IF PUSH$ = "w" THEN WAY$ = "north"  'WAY$ is the clarifying var.
IF PUSH$ = "s" THEN WAY$ = "south"
IF PUSH$ = "a" THEN WAY$ = "east"
IF PUSH$ = "d" THEN WAY$ = "west"
IF PUSH$ = "q" THEN WAY$ = "northwest"
IF PUSH$ = "e" THEN WAY$ = "northeast"
IF PUSH$ = "z" THEN WAY$ = "southwest"
IF PUSH$ = "c" THEN WAY$ = "southeast"
'to create other commans for a certain shop you should use
'something like a variable called place$ that would tell what shop
'you are in...
IF PLACE$ = "shoes" AND PUSH$ = "b" THEN GOTO BUYINGSHOES
'and create a label called buyingshoes: that would have the buying
'process in it.
LOOP UNITL PUSH$ <> ""
'loops until a button is pushed....... you may want to change this to
'be until push$ = "a" or push$ = "c" and go through all the choices
'this is a little painstaking but it would help safeguard your
'program from glitches.
I got to go, email me @
NOVA@EDGEEMU.COM
if you need more help than that, but I think that is fairly seflexplanetory. (did I spell that right?! Big Grin )

-NOVA
ovaProgramming.

One night I had a dream where I was breaking balls. The next morning, BALLSBREAKER was born.

Quote: Excellent. Now you can have things without paying for them.

BALLSBREAKER 2
~-_-Status Report-_-~
Engine: 94%
Graphics: 95%
Sound: 100%
A Severe Error has crippled BB2 for the time being... I have to figure it out, but until then you won't see much of it Sad.
-----------------------------
Reply
#6
Don't use "IF" in such cases. Better take "Select Case". Here ya go:
Code:
Key$=IINKEY$
SELECT CASE Key$
CASE "W": Way$ = "North"
CASE "S": Way$ = "South"
CASE "A": Way$ = "West"
CASE "D": Way$ = "East"
END SELECT
"Select case" is times faster than "if" if you want to compare a variable not only one time with some values.
B 4 EVER
Reply
#7
Thanks, I didn't think of that one. :lol:
ovaProgramming.

One night I had a dream where I was breaking balls. The next morning, BALLSBREAKER was born.

Quote: Excellent. Now you can have things without paying for them.

BALLSBREAKER 2
~-_-Status Report-_-~
Engine: 94%
Graphics: 95%
Sound: 100%
A Severe Error has crippled BB2 for the time being... I have to figure it out, but until then you won't see much of it Sad.
-----------------------------
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)