05-24-2005, 08:15 AM
I'm new, and this is probably a stupid question I could fix myself, but I'm making a small RPG-like game called Battle Thing (v1.0 can be found here), and I figured out how to easily add more characters/weapons to the game without using random numbers and going IF num% = soandso Or num% = soandso THEN: pname$ = "Dude Guy": etc.
Here's the code (char select):
The last three lines are the variables I want to transfer to the main program. Problem is this: I want to put this code in a sub so I can call it when I need to. However, when I put in this code in a SUB or FUNCTION, QBASIC yells at me saying I used an illegal function or a DEF FN (something along those lines), and it highlights the DATA statements. How do I fix this? Or should just make it all one big program and forget the SUBS? Because I was planning on doing something like this for the weapons and the opposition selection.
Also, when you get into the battle, when it's the opponent's turn, his actions are based on random numbers, but I think I did it poorly. Sometimes he attacks with his weapon twice in a row, which I don't want, and sometimes if he attacks twice with his weapons, it hits twice, causing too much damage to the player. So far I haven't had the latter, though. I, however, have had it happen on the player's side.
Also, the damages are randomized, but I plan to fix that.
Here's the code that executes when it's the opposition's turn:
Lastly, how would I make a buy system? Some people suggested I use text files to store the data and then have the program get the data from there, but that still doesn't solve the problem on how to list the weapons one currently has and how to let the player use a weapon from that list.
I'm not good at explaining things, but any help would be appreciated. Thanx.
EDIT: Oh, one thing I forgot to mention. It seems that the only way to win the game is to hit the opponent with your weapon at least once. Is there a way I can fix that? The player attack code basically runs on the same principles, except with the badguyturn% procedure.
Here's the code (char select):
Code:
TYPE playerchar
charname AS STRING * 100
charpic AS INTEGER
charcolor AS INTEGER
END TYPE
DIM playerchar(5) AS playerchar
FOR num = 1 TO 5
READ name$, picnum%, colornum%
playerchar(num).charname = name$
playerchar(num).charpic = picnum%
playerchar(num).charcolor = colornum%
NEXT num
DATA "Tom The Trucker", 38, 14
DATA "Zamzix From Planet Googlyeyes", 37, 10
DATA "Ivan The Gullible", 2, 5
DATA "Spagetti Man", 36, 6
DATA "Guy with a Fork Lad", 2, 9
CLS
COLOR 15
PRINT STRING$(80, CHR$(196))
PRINT "Character Select"
PRINT STRING$(80, CHR$(196))
FOR listguys = 1 TO 5
PRINT "[" + LTRIM$(STR$(listguys)) + ".] " + RTRIM$(LTRIM$(playerchar(listguys).charname)); " [";
COLOR playerchar(listguys).charcolor
PRINT "" + CHR$(playerchar(listguys).charpic) + "";
COLOR 15
PRINT "]"
NEXT listguys
PRINT STRING$(80, CHR$(196))
INPUT "Select: ", choice%
charname$ = playerchar(choice%).charname
pcolor% = playerchar(choice%).charcolor
ppic% = playerchar(choice%).charpic
The last three lines are the variables I want to transfer to the main program. Problem is this: I want to put this code in a sub so I can call it when I need to. However, when I put in this code in a SUB or FUNCTION, QBASIC yells at me saying I used an illegal function or a DEF FN (something along those lines), and it highlights the DATA statements. How do I fix this? Or should just make it all one big program and forget the SUBS? Because I was planning on doing something like this for the weapons and the opposition selection.
Also, when you get into the battle, when it's the opponent's turn, his actions are based on random numbers, but I think I did it poorly. Sometimes he attacks with his weapon twice in a row, which I don't want, and sometimes if he attacks twice with his weapons, it hits twice, causing too much damage to the player. So far I haven't had the latter, though. I, however, have had it happen on the player's side.
Also, the damages are randomized, but I plan to fix that.
Here's the code that executes when it's the opposition's turn:
Code:
badguyturn:
badguyturn% = RND * 9
bghitprcnt% = RND * 6
ernddmg% = INT(RND * 5) + 1
ebigdmg% = INT(RND * 30) + 10
COLOR bgcolor%
IF badguyturn% = 1 OR badguyturn% = 3 OR badguyturn% = 5 OR badguyturn% = 7 THEN
narccount% = 0
LOCATE 23, 2
PRINT bgname$ + " punches you! *POW!*"
php% = php% - ernddmg%
ELSEIF badguyturn% = 2 OR badguyturn% = 4 OR badguyturn% = 6 THEN
narccount% = 0
LOCATE 23, 2
PRINT bgname$ + " kicks you! *WHACK!*"
php% = php% - ernddmg%
ELSEIF badguyturn% = 8 THEN
narccount% = 0
LOCATE 23, 2
PRINT bgname$ + " swings their " + bgweapname$ + ", and";
IF bghitprcnt% = 3 AND hitcount% = 0 THEN
PRINT " hits!"
php% = php% - ebigdmg%
hitcount% = 1
ELSE
PRINT " misses!"
hitcount% = 0
END IF
ELSEIF badguyturn% > 8 AND narccount% = 0 THEN
LOCATE 23, 2
PRINT bgname$ + " had a bout of narcolepsy and skipped their turn!"
narccount% = 1
ELSE
GOTO badguyturn
END IF
Lastly, how would I make a buy system? Some people suggested I use text files to store the data and then have the program get the data from there, but that still doesn't solve the problem on how to list the weapons one currently has and how to let the player use a weapon from that list.
I'm not good at explaining things, but any help would be appreciated. Thanx.
EDIT: Oh, one thing I forgot to mention. It seems that the only way to win the game is to hit the opponent with your weapon at least once. Is there a way I can fix that? The player attack code basically runs on the same principles, except with the badguyturn% procedure.
url=http://www.freewebs.com/boxtopstuff/]Planet Boxtop[/url] (Look out for the redesign!)
The only member of QBNF with severe "tomorrow syndrome."
The only member of QBNF with severe "tomorrow syndrome."