02-01-2004, 01:38 AM
Hey guys. i'm working on a game with a circle running back and forth over a bridge. eventually, it will be a scrolling game, but for now, you just run back and forth.
i started with a circle going back and forth over a bridge, gaining points each time they got to the other side. now, i'm trying to make it so that my circle jumps when you press "8" on the keyboard, but it's not working.
can someone help me out? i know my code is probably horrible, especially the jumping code. thanks.
i don't know if it's obvious from the jump sub, but i'm trying to have it so once they jump, they go up for a bit and then down.
i started with a circle going back and forth over a bridge, gaining points each time they got to the other side. now, i'm trying to make it so that my circle jumps when you press "8" on the keyboard, but it's not working.
can someone help me out? i know my code is probably horrible, especially the jumping code. thanks.
i don't know if it's obvious from the jump sub, but i'm trying to have it so once they jump, they go up for a bit and then down.
Code:
'sub declarations
DECLARE SUB intro ()
DECLARE SUB startgame ()
DECLARE SUB drawcirc ()
DECLARE SUB erasecirc ()
DECLARE SUB score ()
DECLARE SUB jump ()
'so all of the subs can access them
COMMON SHARED xpos
COMMON SHARED ypos
COMMON SHARED pts
COMMON SHARED real
COMMON SHARED jumper
COMMON SHARED jcount
SCREEN 13
CLS
CALL intro 'calls the intro SUB, which displays the title screen
CALL startgame ' starts the game
END
SUB drawcirc
CIRCLE (xpos, ypos), 7, 2
CIRCLE (xpos, ypos), 6, 5
CIRCLE (xpos, ypos), 5, 2
CIRCLE (xpos, ypos), 4, 5
CIRCLE (xpos, ypos), 3, 4
CIRCLE (xpos, ypos), 2, 7
CIRCLE (xpos, ypos), 1, 3
END SUB
SUB erasecirc
LINE (0, 20)-(320, 150), 0, BF
END SUB
SUB intro
COLOR 7
PRINT "Bridge Walker!"
PRINT "--------------"
PRINT
PRINT "AKA the best game ever. is there a game better? NO!"
PRINT
PRINT
PRINT "Controls:"
PRINT
PRINT "Move Left '4'"
PRINT "Move Right- '6'"
PRINT "Jump- '8'"
PRINT "Quit- Q"
PRINT
PRINT
PRINT "Press any key to continue"
WHILE INKEY$ = ""
WEND
CLS
END SUB
SUB jump
SELECT CASE jcount
CASE 1 TO 4
ypos = ypos - 4
CASE 5 TO 8
ypos = ypos + 4
CASE 9
jumper = 0
jcount = -1
END SELECT
jcount = jcount + 1
END SUB
SUB save
LOCATE 5, 1
INPUT "Pick a slot:", snum
OPEN "s1.txt" FOR INPUT AS #1
OPEN "s2.txt" FOR INPUT AS #2
OPEN "s3.txt" FOR INPUT AS #3
PRINT "Slot 1:"
PRINT "Slot 2"
PRINT "Slot 3"
END SUB
SUB score
SELECT CASE real
'gives you points if you cross the bridge
CASE 0
GOTO done
CASE 1
IF xpos > 250 THEN pts = pts + 1
CASE 2
IF xpos < 51 THEN pts = pts + 1
END SELECT
done:
'switches real if you reach a side of the bridge
IF xpos < 51 THEN real = 1
IF xpos > 250 THEN real = 2
LOCATE 1, 1
PRINT "Score:"; pts
END SUB
SUB startgame
'Draw the bridge and such
LINE (0, 150)-(50, 200), 6, BF
LINE (51, 150)-(250, 170), 8, BF
LINE (251, 150)-(500, 500), 6, BF
'starting position for the bridgecrosser
xpos = 10
ypos = 142
'starting points
pts = 0
real = 0
jumper = 0
jcount = 0
DO
drawcirc 'draws the circle
DO
ink$ = INKEY$
INKY$ = LCASE$(ink$)
LOOP UNTIL INKY$ = "4" OR INKY$ = "q" OR INKY$ = "6" OR INKY$ = "8"
IF INKY$ = "8" THEN
IF jumper = 0 THEN jumper = 1 AND jcount = 1
IF jumper = 1 THEN CALL jump
END IF
IF INKY$ = "4" THEN xpos = xpos - 4
IF INKY$ = "6" THEN xpos = xpos + 4
CALL erasecirc
CALL score
LOOP UNTIL INKY$ = "q"
END SUB