Need help with this game I am making :( 
Author Message
 Need help with this game I am making :(

Hi-

I just can't seem to get the scrolling collision detection working
in the city. Need HELP! :(

http://www.*-*-*.com/ ~panks/progue.zip

Ok, below is the entire QBasic 1.1 code for progue.bas. The url above has
both the .bas file, the .txt file and all the .map files required by the
game.

The scrolling routine for the city is in lines 900-908 or there about. The
problem is that although the city scrolls, the player walks right through
impassable objects like walls and such.

Any suggestions on how to make it so that doesn't happen? The Y coordinate
is always stable at 13 or so, but the city scrolls up or down by c and d
variables in lines 60-99.

Need help! :( If you help to figure this problem out, you will receive
credit on my page for debugging and code help.

Regards,

Paul Allen Panks

!---Begin progue.bas---! (QBasic 1.1 code)
0 SCREEN 0: REM ON ERROR GOTO 6000
up$ = CHR$(0) + CHR$(72)
dn$ = CHR$(0) + CHR$(80)
rt$ = CHR$(0) + CHR$(77)
lt$ = CHR$(0) + CHR$(75)
1 CLS : COLOR 12: GOSUB title: COLOR 0, 0: COLOR 15: PRINT "Progue Beta
v0.20": PRINT : COLOR 14: PRINT "Press enter to start...": SLEEP
2 hp = 25: hm = 25: ac = 1: lv = 1: ex& = 0: em& = 5: KEY 15, CHR$(&H20) +
CHR$(59)
3 f$ = "world1.map": pl = 1: dm = 1: ac = 1: b$ = "C": DEF SEG = 0: kf =
PEEK(1047): POKE 1047, kf OR 32: IF (kf AND 32) = 0 THEN DEF SEG : DEF SEG
= 0
4 DIM m$(120), lo(126), ob$(126), mh(91): FOR g = 33 TO 126: READ lo(g):
NEXT: FOR g = 33 TO 126: READ ob$(g): NEXT: FOR g = 65 TO 90: READ mh(g):
NEXT
5 c = 1: d = 20: y = 11: x = 21: s$ = "You cannot move further."
6 CLS : OPEN "I$", 1, f$: FOR g = 1 TO 20: INPUT #1, m$(g): NEXT: CLOSE 1
barrier$ = "abcdefghkpr"
up% = INSTR(barrier$, MID$(m$(y), x, 1))
dn% = INSTR(barrier$, MID$(m$(y), x, 1))
rt% = INSTR(barrier$, MID$(m$(y), x, 1))
lt% = INSTR(barrier$, MID$(m$(y), x, 1))
wu% = INSTR(barrier$, MID$(m$(c - 1), x, 1))
wd% = INSTR(barrier$, MID$(m$(c + 1), x, 1))
7 x$ = CHR$(64): n = 2: si = 0: LOCATE 21, 1: PRINT "
": GOTO 60
10 LOCATE y, x: COLOR 15: PRINT x$: LOCATE 21, 1: COLOR 0: PRINT "
"
11 LOCATE 22, 1: COLOR 14: PRINT "C:"; c; " D:"; d; " Level:"; pl; "
Hits:"; hp; "("; hm; ") Gold:"; g%; " Armor:"; ac; " Exp:"; ex&; "/"; em&;
"         "
12 COLOR 15: IF lo(36) = 0 AND iz = 0 THEN iz = 1: g% = g% + 50
13 IF lo(36) <> 0 AND iz = 1 THEN iz = 0: g% = g% - 50
14 LOCATE 23, 1: PRINT "? for help
": il = 0: si = 1: n = 0: a$ = INKEY$: IF a$ = "" THEN GOTO 15
15 a$ = "": ix = 0: si = 0: n = 0: a$ = INKEY$: IF n! <> TIMER THEN GOSUB
800: n! = TIMER
IF a$ = "" THEN GOTO 15
16 GOSUB 899: IF a$ = up$ AND MID$(m$(y - 1), x, 1) = "4" OR a$ = up$ AND
MID$(m$(y - 1), x, 1) = "5" OR a$ = up$ AND MID$(m$(y - 1), x, 1) = "8"
THEN LOCATE 21, 1: COLOR 15: PRINT s$: GOTO 7:  ELSE IF a$ = up$ AND up%
<> INSTR(barrier$, MID$(m$(y - 1), x, 1)) AND f$ <> "world2.map" THEN
LOCATE 21, 1: PRINT s$: SLEEP 1: GOSUB 5500: GOTO 15
17 IF a$ = dn$ AND MID$(m$(y + 1), x, 1) = "4" OR a$ = dn$ AND MID$(m$(y +
1), x, 1) = "5" OR a$ = dn$ AND MID$(m$(y + 1), x, 1) = "8" THEN LOCATE
21, 1: COLOR 15: PRINT s$: GOTO 7:  ELSE IF a$ = dn$ AND dn% <>
INSTR(barrier$, MID$(m$(y + 1), x, 1)) AND y < 20 THEN LOCATE 21, 1: PRINT
s$: SLEEP 1: GOSUB 5500: GOTO 15
18 IF a$ = rt$ AND MID$(m$(y), x + 1, 1) = "4" OR a$ = rt$ AND MID$(m$(y),
x + 1, 1) = "5" OR a$ = rt$ AND MID$(m$(y), x + 1, 1) = "8" THEN LOCATE
21, 1: COLOR 15: PRINT s$: SLEEP 1: GOTO 7:  ELSE IF a$ = rt$ AND x = 64
AND f$ <> "city.map" THEN LOCATE 21, 1: PRINT s$: SLEEP 1: GOTO 7:  ELSE
IF a$ = rt$ AND rt% <> INSTR(barrier$, MID$(m$(y), x + 1, 1)) THEN LOCATE
21, 1: PRINT s$: SLEEP 1: GOSUB 5500: GOTO 15
19 IF a$ = lt$ AND x = 2 AND f$ <> "world3.map" THEN LOCATE 21, 1: PRINT
s$: SLEEP 1: GOTO 7:  ELSE IF a$ = lt$ AND MID$(m$(y), x - 1, 1) = "4" OR
a$ = lt$ AND MID$(m$(y), x - 1, 1) = "5" OR a$ = lt$ AND MID$(m$(y), x -
1, 1) = "8" THEN LOCATE 21, 1: COLOR 15: PRINT s$: SLEEP 1: GOTO 7:  ELSE
IF a$ = lt$ AND lt% <> INSTR(barrier$, MID$(m$(y), x - 1, 1)) THEN LOCATE
21, 1: PRINT s$: SLEEP 1: GOSUB 5500: GOTO 15
20 IF a$ = up$ AND si <> 3 AND y <> 1 THEN k = 8: y = y - 1: GOTO 60:
ELSE IF a$ = up$ AND y = 1 AND f$ = "world2.map" THEN y = 20: f$ =
"world1.map": GOTO 6
21 IF a$ = dn$ THEN k = 2: y = y + 1: GOTO 60:  ELSE IF a$ = dn$ THEN
LOCATE 21, 1: COLOR 15: PRINT s$: SLEEP 1: LOCATE 21, 1: PRINT "
": GOTO 7
22 IF a$ = rt$ THEN k = 6: x = x + 1: GOTO 60
23 IF a$ = lt$ AND x > 1 THEN k = 4: x = x - 1: GOTO 60
24 IF a$ = "x" THEN COLOR 15: LOCATE 21, 1: COLOR 15: INPUT "Are you sure?
<y/n>", a$: IF a$ = "y" THEN LOCATE 21, 1: PRINT "Quiting...
": SLEEP 1: SYSTEM
25 IF rs > 5 THEN rs = 0: hp = hp + 1: IF hp > hm THEN hp = hm
26 IF a$ = CHR$(27) THEN CLS : COLOR 7: SHELL: GOTO 7
SELECT CASE a$
CASE "i": CLS : GOTO 100
CASE "q": GOTO 103
CASE "a": GOTO 129
CASE "?": GOTO 400
CASE "E": GOTO 150
CASE "j": LOCATE 21, 1: COLOR 15: INPUT "Select coord Y:", y: LOCATE 21,
1: COLOR 15: INPUT "Select coord X:", x: LOCATE 21, 1: PRINT "
": GOTO 7
CASE "g":  GOTO 260
CASE "d": GOTO 265
CASE "b": GOTO 500
CASE "c": GOTO 510
CASE "e": GOTO 540
CASE "f": GOTO 170
CASE "w": GOTO 200
CASE "z": GOTO 300
CASE ".": rs = rs + 1: GOTO 10
CASE "h": GOTO 400
END SELECT

49 LOCATE 21, 1: COLOR 15: PRINT "Illegal command.
": SLEEP 1: LOCATE 21, 1: PRINT "                    ": GOTO 15
59 GOTO 15
60 LOCATE 1, 1: FOR b = c TO d: FOR g = 1 TO LEN(m$(b))
   SELECT CASE MID$(m$(b), g, 1)
   CASE "0": COLOR 0: PRINT CHR$(32);
   CASE "a": COLOR 7: PRINT "";
   CASE "b": COLOR 7: PRINT "";
   CASE "c": COLOR 7: PRINT "";
   CASE "d": COLOR 7: PRINT "?";
   CASE "e": COLOR 7: PRINT "?";
   CASE "f": COLOR 7: PRINT "o";
   CASE "g": COLOR 7: PRINT "";
   CASE "h": COLOR 7: PRINT "1";
   CASE "k": COLOR 7: PRINT "?";
   CASE "p": COLOR 7: PRINT "";
   CASE "r": COLOR 7: PRINT "?";
   CASE "2": COLOR 10: PRINT CHR$(34);
   CASE "3": COLOR 6: PRINT ".";
   CASE ".": COLOR 6: PRINT ".";
   CASE "4": COLOR 9: PRINT "";
   CASE "5": COLOR 2: PRINT "*";
   CASE "6": COLOR 14: PRINT "%";
   CASE "7": COLOR 11: PRINT "-";
   CASE "8": COLOR 8: PRINT "^";
   CASE "9": COLOR 5: PRINT "|";
   CASE "q": PRINT CHR$(13);
   CASE "&": IF lo(38) = lv THEN COLOR 14: PRINT "&";
   CASE "\": IF lo(92) = lv THEN COLOR 13: PRINT "\";
   CASE "/": IF lo(47) = lv THEN COLOR 3: PRINT "/";
   CASE "(": IF lo(40) = lv THEN COLOR 15: PRINT "(";
   CASE "{": IF lo(123) = lv THEN COLOR 5: PRINT "{";
   CASE "v": IF lo(118) = lv THEN COLOR 6: PRINT "v";
   CASE ")": IF lo(41) = lv THEN COLOR 9: PRINT ")";
   CASE "o": IF lo(111) = lv THEN COLOR 14: PRINT "o";
   CASE "i": IF lo(105) = lv THEN COLOR 15: PRINT "i";
   CASE "m": IF lo(109) = lv THEN COLOR 6: PRINT "m";
   CASE "+": IF lo(43) = lv THEN COLOR 3: PRINT "+";
   CASE "$": IF lo(36) = lv THEN COLOR 13: PRINT "$";
   CASE "[": COLOR 15: PRINT "[";
   CASE "]": COLOR 15: PRINT "]";
   CASE "t": IF lo(116) = lv THEN COLOR 14: PRINT "t";
   CASE "T": IF lo(84) = lv THEN COLOR 15: PRINT "T";
   CASE "s": IF lo(115) = lv THEN COLOR 7: PRINT "s";
   CASE "w": IF lo(119) = lv THEN COLOR 14: PRINT "w";
   CASE "x": IF lo(120) = lv THEN COLOR 13: PRINT "x";
   CASE "!": IF lo(33) = lv THEN COLOR 4: PRINT "!";
   CASE "`": IF lo(96) = lv THEN COLOR 14: PRINT "`";
   CASE "<": COLOR 15: PRINT "<";
   CASE ">": COLOR 15: PRINT ">";
   CASE ";": IF lo(59) = lv THEN COLOR 12: PRINT ";";
   CASE "?": IF lo(63) = lv THEN COLOR 13: PRINT "?";
   CASE ",": IF lo(44) = lv THEN COLOR 11: PRINT ",";
   CASE "A": IF lo(65) = lv THEN COLOR 15: PRINT "A";
   CASE "B": IF lo(66) = lv THEN COLOR 8: PRINT "B";
   CASE "C": IF lo(67) = lv THEN COLOR 15: PRINT "C";
   CASE "D": IF lo(68) = lv THEN COLOR 10: PRINT "D";
   CASE "E": IF lo(69) = lv THEN COLOR 2: PRINT "E";
   CASE "F": IF lo(70) = lv THEN COLOR 3: PRINT "F";
   CASE "G": IF lo(71) = lv THEN COLOR 3: PRINT "G";
   CASE "H": IF lo(72) = lv THEN COLOR 13: PRINT "H";
   CASE "I": IF lo(73) = lv THEN COLOR 0: PRINT "I";
   CASE "J": IF lo(74) = lv THEN COLOR 13: PRINT "J";
   CASE "K": IF lo(75) = lv THEN COLOR 15: PRINT "K";
   CASE "L": IF lo(76) = lv THEN COLOR 12: PRINT "L";
   CASE "M": IF lo(77) = lv THEN COLOR 2: PRINT "M";
   CASE "N": IF lo(78) = lv THEN COLOR 5: PRINT "N";
   CASE "O": IF lo(79) = lv THEN COLOR 7: PRINT "O";
   CASE "P": IF lo(80) = lv THEN COLOR 15: PRINT "P";
   CASE "Q": IF lo(81) = lv THEN COLOR 13: PRINT "Q";
   CASE "R": IF lo(82) = lv THEN COLOR 9: PRINT "R";
   CASE "S": IF lo(83) = lv THEN COLOR 4: PRINT "S";
   CASE "T": IF lo(84) = lv THEN COLOR 15: PRINT "T";
   CASE "U": IF lo(85) = lv THEN COLOR 4: PRINT "U";
   CASE "V": IF lo(86) = lv THEN COLOR 3: PRINT "V";
   CASE "W": IF lo(87) = lv THEN COLOR 7: PRINT "W";
   CASE "X": IF lo(88) = lv THEN COLOR 12: PRINT "X";
   CASE "Y": IF lo(89) = lv THEN COLOR 14: PRINT "Y";
   CASE "Z": IF lo(90) = lv THEN COLOR 13: PRINT "Z";
END SELECT
99 NEXT: NEXT: GOTO 390
100 COLOR 15: FOR g = 33 TO 126: IF lo(g) = 0 THEN PRINT ob$(g): il = 1:
ELSE IF lo(g) = 105 THEN PRINT ob$(g); " (wielded)": il = 1:  ELSE IF
lo(g) = 205 THEN PRINT ob$(g); " (worn)": il = 1
101 NEXT: IF il = 0 THEN SLEEP 1: PRINT "You are empty handed."
102 GOSUB 5000: GOTO 7
103 LOCATE 21, 1: PRINT "Quaff what? (* for list):"; : a$ = INKEY$: IF a$
= "" THEN GOTO 103:  ELSE IF a$ = CHR$(27) THEN GOSUB 5500: GOTO 15
104 PRINT a$: SLEEP 1: IF a$ = "*" THEN GOTO 120
105 IF a$ = "p" OR a$ = "1" AND lo(26) = 0 THEN lo(33) = -1: ic = ic - 1:
hp = hm: LOCATE 21, 1: PRINT "You drink the potion and feel strong!":
SLEEP 1: LOCATE 21, 1: PRINT "                                     ": GOTO
7
106 LOCATE 21, 1: COLOR 15: PRINT "Nothing to Quaff!
": SLEEP 1: LOCATE 21, 1: PRINT "                  ": GOTO 7
120 CLS : COLOR 15: IF lo(33) = 0 THEN PRINT "1) Potion (red)": il = 1
121 IF il = 0 THEN PRINT "Alas, you don't have anything to Quaff...":
GOSUB 5000: GOTO 7
122 GOSUB 5000: CLS : GOTO 103
129 IF y = 4 AND x = 59 AND lv = 1 AND MID$(m$(y), x, 1) = "5" THEN ...

read more »



Mon, 16 Oct 2000 03:00:00 GMT  
 Need help with this game I am making :(

<snipped some irrelevant newsgroups>

Quote:
> Ok, below is the entire QBasic 1.1 code for progue.bas. The url above has
> both the .bas file, the .txt file and all the .map files required by the
> game.

Hey, wait! Some people have to *pay* for this stuff, y'know! Including
thousands of lines of QBasic program is *not* a good idea. Besides
which, the people here are under no obligation to help you, and most of
us don't have time to look through lots of code, let alone icky BASIC.
If you really must post code (and btw this is not a development n.g),
try cutting it down to a *few* lines and *then* post to a more
appropriate n.g. then rec.games.roguelike.rogue! Make it easy for people
to help you.

Oh - writing a roguelike in QBasic might not be a good idea. QBasic,
while good for simple programs, is probably not up to writing major
programs like an rl. It can be done, it's just not at all easy. Have you
looked into C, C++ (for example)? They may be harder to learn, but
they'll be a *lot* more powerful.

And looking at your code, you want to simplify things a bit. Find out
which direction to want to go in, look up the tile at that position,
define a function that returns whether a tile is valid or not etc. Try
to write general, multi-purpose code rather than code that is specific
to one situation.

Quote:
> 13 AND MID$(m$(y + 1), x, 1) <> "a" OR a$ = dn$ AND f$ = "city.map" AND y
> > 13 AND MID$(m$(y + 1), x, 1) <> "p" OR a$ = dn$ AND f$ = "city.map" AND
> y > 13 AND MID$(m$(y + 1), x, 1) <> "f" OR a$ = dn$ AND f$ = "city.map"

^^ You're doing the same test over and over again, and that MID$ only
needs to be done once - just extract the character you want and test
that. And I've a feeling you'll come back to that in a few weeks and you
won't have the faintest idea how it works :)

Mark, feeling grumpy ;)



Tue, 17 Oct 2000 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. I am making a VB game, that is like Final Fantasy, and need some advise

2. Help with game I am making

3. Need help on making a game

4. VB newbie needs HELP making RPG game

5. Can someone HELP! Need help with game

6. Making a game in .Net

7. need help with game

8. I need help with my game

9. QUICKBASIC game, need help.

10. Making a Duke Nukem type game

11. Help with a game needed!

12. Need Help Programming a Game

 

 
Powered by phpBB® Forum Software