Silent-Death
Unregistered
How do i use the enter because i want to use it in my game (Line Run V2). Any help will appricated (i hope that's how that spelled).
Posts: 2,765
Threads: 138
Joined: Nov 2002
CHR$(13) i believe
Code: DO
IF INKEY$ = CHR$(13) THEN EXIT DO
LOOP
edit: there may be something else missing though O.o
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Posts: 3,616
Threads: 287
Joined: Jan 2003
Nope, you're completely right. There's nothing missing - ASCII code 13 is the code for the enter key.
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Silent-Death
Unregistered
Ok thx , now i can complete the menu for Line Run V2
Posts: 3,616
Threads: 287
Joined: Jan 2003
(Btw veeeeeery nice menu job you did on that LineRun game)
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Silent-Death
Unregistered
Thanks... if you want i can post the code i have so far...
Posts: 3,616
Threads: 287
Joined: Jan 2003
That would be cool. I could learn from it, maybe, and get ideas for the Operation Pong menu system.
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Silent-Death
Unregistered
ok... here it is...
Code: DECLARE SUB IntroMenu ()
DECLARE SUB Intro ()
SCREEN 13 'Sets up the screen mode (duh!)
Intro
IntroMenu
SUB Intro
X = 208
Y = 98 'Varibles for Line Function 1
X2 = 212
Y2 = 102
X3 = 208
Y3 = 98 'Varibles for Line Function 2
X4 = 212
Y4 = 102
Pause = TIMER
DO 'Makes it pause while Screen 13 Sets Up
LOOP UNTIL Pause + .5 < TIMER
'----------------------------------
FOR LinesGoOut = 1 TO 25
Pause = TIMER
DO 'Makes it Pause
LOOP UNTIL Pause + .1 < TIMER
LINE (X, Y)-(X2, Y2), 7, BF 'Line Box 1
LINE (X3, Y3)-(X4, Y4), 7, BF 'Line Box 2
Press$ = INKEY$ 'Makes Press$ equal the key you press
X = X - 3
X2 = X2 - 3 'Makes Line Box 1 go left
X3 = X3 + 3
X4 = X4 + 3 'Makes Line Box 2 go right
IF Press$ <> "" THEN GOTO SkiptheIntro:
NEXT LinesGoOut
'-------------------------
FOR LinesGoUpDown = 1 TO 20
Pause = TIMER
DO
LOOP UNTIL Pause + .1 < TIMER
LINE (X, Y)-(X4, Y2), 7, BF
LINE (X, Y3)-(X4, Y4), 7, BF 'Makes New Lines
LINE (X + 4, Y + 4)-(X4 - 4, Y2 + 4), 0, BF
LINE (X + 4, Y3 - 4)-(X4 - 4, Y4 - 4), 0, BF 'Erases Old Lines
Press$ = INKEY$ 'Makes Press$ equal the key you press
Y = Y - 3
Y2 = Y2 - 3 'Makes Line Box 1 go up
Y3 = Y3 + 3
Y4 = Y4 + 3 'Makes Line Box 2 go down
IF Press$ <> "" THEN GOTO SkiptheIntro:
NEXT LinesGoUpDown
COLOR 1
FOR X = 2 TO 25
Press$ = INKEY$ 'Makes Press$ equal the key you press
Pause = TIMER
DO 'Makes the prog. pause
LOOP UNTIL Pause + .01 < TIMER
LOCATE 2, X: PRINT "2" 'Displays the charcter
LOCATE 2, X - 1: PRINT " " 'Eraeses the old one
IF Press$ <> "" THEN GOTO SkiptheIntro:
NEXT X
FOR X = 2 TO 24
Press$ = INKEY$ 'Makes Press$ equal the key you press
Pause = TIMER
DO 'Makes the prog. pause
LOOP UNTIL Pause + .01 < TIMER
LOCATE 2, X: PRINT "V" 'Displays the charcter
LOCATE 2, X - 1: PRINT " " 'Eraeses the old one
IF Press$ <> "" THEN GOTO SkiptheIntro:
NEXT X
FOR X = 2 TO 22
Press$ = INKEY$ 'Makes Press$ equal the key you press
Pause = TIMER
DO 'Makes the prog. pause
LOOP UNTIL Pause + .01 < TIMER
LOCATE 2, X: PRINT "N" 'Displays the charcter
LOCATE 2, X - 1: PRINT " " 'Eraeses the old one
IF Press$ <> "" THEN GOTO SkiptheIntro:
NEXT X
FOR X = 2 TO 21
Press$ = INKEY$ 'Makes Press$ equal the key you press
Pause = TIMER
DO 'Makes the prog. pause
LOOP UNTIL Pause + .01 < TIMER
LOCATE 2, X: PRINT "U" 'Displays the charcter
LOCATE 2, X - 1: PRINT " " 'Eraeses the old one
IF Press$ <> "" THEN GOTO SkiptheIntro:
NEXT X
FOR X = 2 TO 20
Press$ = INKEY$ 'Makes Press$ equal the key you press
Pause = TIMER
DO 'Makes the prog. pause
LOOP UNTIL Pause + .01 < TIMER
LOCATE 2, X: PRINT "R" 'Displays the charcter
LOCATE 2, X - 1: PRINT " " 'Eraeses the old one
IF Press$ <> "" THEN GOTO SkiptheIntro:
NEXT X
FOR X = 2 TO 18
Press$ = INKEY$ 'Makes Press$ equal the key you press
Pause = TIMER
DO 'Makes the prog. pause
LOOP UNTIL Pause + .01 < TIMER
LOCATE 2, X: PRINT "E" 'Displays the charcter
LOCATE 2, X - 1: PRINT " " 'Eraeses the old one
IF Press$ <> "" THEN GOTO SkiptheIntro:
NEXT X
FOR X = 2 TO 17
Press$ = INKEY$ 'Makes Press$ equal the key you press
Pause = TIMER
DO 'Makes the prog. pause
LOOP UNTIL Pause + .01 < TIMER
LOCATE 2, X: PRINT "N" 'Displays the charcter
LOCATE 2, X - 1: PRINT " " 'Eraeses the old one
IF Press$ <> "" THEN GOTO SkiptheIntro:
NEXT X
FOR X = 2 TO 16
Press$ = INKEY$ 'Makes Press$ equal the key you press
Pause = TIMER
DO 'Makes the prog. pause
LOOP UNTIL Pause + .01 < TIMER
LOCATE 2, X: PRINT "I" 'Displays the charcter
LOCATE 2, X - 1: PRINT " " 'Eraeses the old one
IF Press$ <> "" THEN GOTO SkiptheIntro:
NEXT X
FOR X = 2 TO 15
Press$ = INKEY$ 'Makes Press$ equal the key you press
Pause = TIMER
DO 'Makes the prog. pause
LOOP UNTIL Pause + .01 < TIMER
LOCATE 2, X: PRINT "L" 'Displays the charcter
LOCATE 2, X - 1: PRINT " " 'Eraeses the old one
IF Press$ <> "" THEN GOTO SkiptheIntro:
NEXT X
SkiptheIntro:
END SUB
SUB IntroMenu
LINE (1, 1)-(400, 400), 0, BF 'Erases the Screen
X = 208
Y = 98 'Varibles for Line Function 1
X2 = 212
Y2 = 102
X3 = 208
Y3 = 98 'Varibles for Line Function 2
X4 = 212
Y4 = 102
FOR LinesGoOut = 1 TO 25
LINE (X, Y)-(X2, Y2), 7, BF 'Line Box 1
LINE (X3, Y3)-(X4, Y4), 7, BF 'Line Box 2
X = X - 3
X2 = X2 - 3 'Makes Line Box 1 go left
X3 = X3 + 3
X4 = X4 + 3 'Makes Line Box 2 go right
NEXT LinesGoOut
FOR LinesGoUpDown = 1 TO 20
LINE (X, Y)-(X4, Y2), 7, BF
LINE (X, Y3)-(X4, Y4), 7, BF 'Makes New Lines
LINE (X + 4, Y + 4)-(X4 - 4, Y2 + 4), 0, BF
LINE (X + 4, Y3 - 4)-(X4 - 4, Y4 - 4), 0, BF 'Erases Old Lines
Y = Y - 3
Y2 = Y2 - 3 'Makes Line Box 1 go up
Y3 = Y3 + 3
Y4 = Y4 + 3 'Makes Line Box 2 go down
NEXT LinesGoUpDown
'------------------------------------------------------------------------
COLOR 1
LOCATE 2, 15: PRINT "LINE RUN V2"
COLOR 1
LOCATE 9, 6: PRINT "Menu"
LOCATE 11, 6: PRINT "Play"
LOCATE 12, 6: PRINT "Help"
LOCATE 13, 5: PRINT "Credits"
LOCATE 14, 6: PRINT "Quit"
LINE (39, 72)-(71, 72), 1
FOR SoundLoop = 1 TO 30
RANDOMIZE TIMER
S = INT(RND * 3000) + 37
SOUND S, .1
MenuButton = 1
NEXT SoundLoop
X = 208
Y = 98 'Sets up varibles for the line
X2 = 212
Y2 = 102
LINE (X, Y)-(X2, Y2), 6, BF
DO
FOR Counter = 1 TO 12
Press$ = INKEY$
Pause = TIMER
DO
LOOP UNTIL Pause + .1 < TIMER
Y = Y - 4
Y2 = Y2 - 4
LINE (X, Y)-(X2, Y2), 6, BF
GOSUB Menuchange:
NEXT Counter
'--------------------------------
FOR Counter = 1 TO 12
Press$ = INKEY$
Pause = TIMER
DO
LOOP UNTIL Pause + .1 < TIMER
X = X - 4
X2 = X2 - 4
LINE (X, Y)-(X2, Y2), 6, BF
GOSUB Menuchange:
NEXT Counter
'----------------------------
FOR Counter = 1 TO 10
Press$ = INKEY$
Pause = TIMER
DO
LOOP UNTIL Pause + .1 < TIMER
Y = Y + 4
Y2 = Y2 + 4
LINE (X, Y)-(X2, Y2), 6, BF
GOSUB Menuchange:
NEXT Counter
'------------------------------
FOR Counter = 1 TO 6
Press$ = INKEY$
Pause = TIMER
DO
LOOP UNTIL Pause + .1 < TIMER
X = X + 4
X2 = X2 + 4
LINE (X, Y)-(X2, Y2), 6, BF
GOSUB Menuchange:
NEXT Counter
'------------------------------
FOR Counter = 1 TO 11
Press$ = INKEY$
Pause = TIMER
DO
LOOP UNTIL Pause + .1 < TIMER
Y = Y + 4
Y2 = Y2 + 4
LINE (X, Y)-(X2, Y2), 6, BF
GOSUB Menuchange:
NEXT Counter
'------------------------------
FOR Counter = 1 TO 15
Press$ = INKEY$
Pause = TIMER
DO
LOOP UNTIL Pause + .1 < TIMER
X = X + 4
X2 = X2 + 4
LINE (X, Y)-(X2, Y2), 6, BF
GOSUB Menuchange:
NEXT Counter
'------------------------------
FOR Counter = 1 TO 9
Press$ = INKEY$
Pause = TIMER
DO
LOOP UNTIL Pause + .1 < TIMER
Y = Y - 4
Y2 = Y2 - 4
LINE (X, Y)-(X2, Y2), 6, BF
GOSUB Menuchange:
NEXT Counter
'------------------------------
FOR Counter = 1 TO 2
Press$ = INKEY$
Pause = TIMER
DO
LOOP UNTIL Pause + .1 < TIMER
X = X + 4
X2 = X2 + 4
LINE (X, Y)-(X2, Y2), 6, BF
GOSUB Menuchange:
NEXT Counter
'------------------------------
FOR Counter = 1 TO 10
Press$ = INKEY$
Pause = TIMER
DO
LOOP UNTIL Pause + .1 < TIMER
Y = Y + 4
Y2 = Y2 + 4
LINE (X, Y)-(X2, Y2), 6, BF
GOSUB Menuchange:
NEXT Counter
'------------------------------
FOR Counter = 1 TO 20
Press$ = INKEY$
Pause = TIMER
DO
LOOP UNTIL Pause + .1 < TIMER
X = X - 4
X2 = X2 - 4
LINE (X, Y)-(X2, Y2), 6, BF
GOSUB Menuchange:
NEXT Counter
'-----------------------------
FOR Counter = 1 TO 9
Press$ = INKEY$
Pause = TIMER
DO
LOOP UNTIL Pause + .1 < TIMER
Y = Y - 4
Y2 = Y2 - 4
LINE (X, Y)-(X2, Y2), 6, BF
GOSUB Menuchange:
NEXT Counter
'-----------------------------
FOR Counter = 1 TO 3
Press$ = INKEY$
Pause = TIMER
DO
LOOP UNTIL Pause + .1 < TIMER
X = X - 4
X2 = X2 - 4
LINE (X, Y)-(X2, Y2), 6, BF
GOSUB Menuchange:
NEXT Counter
'-----------------------------
FOR Counter = 1 TO 10
Press$ = INKEY$
Pause = TIMER
DO
LOOP UNTIL Pause + .1 < TIMER
Y = Y + 4
Y2 = Y2 + 4
LINE (X, Y)-(X2, Y2), 6, BF
GOSUB Menuchange:
NEXT Counter
'-----------------------------
FOR Counter = 1 TO 2
Press$ = INKEY$
Pause = TIMER
DO
LOOP UNTIL Pause + .1 < TIMER
X = X - 4
X2 = X2 - 4
LINE (X, Y)-(X2, Y2), 6, BF
GOSUB Menuchange:
NEXT Counter
'-----------------------------
FOR Counter = 1 TO 24
Press$ = INKEY$
Pause = TIMER
DO
LOOP UNTIL Pause + .1 < TIMER
Y = Y - 4
Y2 = Y2 - 4
LINE (X, Y)-(X2, Y2), 6, BF
GOSUB Menuchange:
NEXT Counter
'-----------------------------
FOR Counter = 1 TO 15
Press$ = INKEY$
Pause = TIMER
DO
LOOP UNTIL Pause + .1 < TIMER
X = X + 4
X2 = X2 + 4
LINE (X, Y)-(X2, Y2), 6, BF
GOSUB Menuchange:
NEXT Counter
'-----------------------------
FOR Counter = 1 TO 19
Press$ = INKEY$
Pause = TIMER
DO
LOOP UNTIL Pause + .1 < TIMER
Y = Y + 4
Y2 = Y2 + 4
LINE (X, Y)-(X2, Y2), 6, BF
GOSUB Menuchange:
NEXT Counter
'-----------------------------
FOR Counter = 1 TO 4
Press$ = INKEY$
Pause = TIMER
DO
LOOP UNTIL Pause + .1 < TIMER
X = X - 4
X2 = X2 - 4
LINE (X, Y)-(X2, Y2), 6, BF
GOSUB Menuchange:
NEXT Counter
'-----------------------------
FOR Counter = 1 TO 9
Press$ = INKEY$
Pause = TIMER
DO
LOOP UNTIL Pause + .1 < TIMER
Y = Y - 4
Y2 = Y2 - 4
LINE (X, Y)-(X2, Y2), 6, BF
GOSUB Menuchange:
NEXT Counter
'-----------------------------
FOR Counter = 1 TO 5
Press$ = INKEY$
Pause = TIMER
DO
LOOP UNTIL Pause + .1 < TIMER
X = X - 4
X2 = X2 - 4
LINE (X, Y)-(X2, Y2), 6, BF
GOSUB Menuchange:
NEXT Counter
'-----------------------------
FOR Counter = 1 TO 8
Press$ = INKEY$
Pause = TIMER
DO
LOOP UNTIL Pause + .1 < TIMER
Y = Y - 4
Y2 = Y2 - 4
LINE (X, Y)-(X2, Y2), 6, BF
GOSUB Menuchange:
NEXT Counter
'-----------------------------
FOR Counter = 1 TO 8
Press$ = INKEY$
Pause = TIMER
DO
LOOP UNTIL Pause + .1 < TIMER
X = X + 4
X2 = X2 + 4
LINE (X, Y)-(X2, Y2), 6, BF
GOSUB Menuchange:
NEXT Counter
'-----------------------------
X = 208
Y = 98 'Sets up varibles for the line
X2 = 212
Y2 = 102
LINE (140, 45)-(260, 150), 0, BF
LOOP
'------------------------------
Menuchange:
IF Press$ = CHR$(0) + CHR$(72) THEN
MenuButton = MenuButton - 1
IF MenuButton < 1 THEN
MenuButton = 4
END IF
END IF
IF Press$ = CHR$(0) + CHR$(80) THEN
MenuButton = MenuButton + 1
IF MenuButton > 4 THEN
MenuButton = 1
END IF
END IF
IF MenuButton = 1 THEN
COLOR 15
LOCATE 11, 6: PRINT "Play"
COLOR 1
LOCATE 12, 6: PRINT "Help"
LOCATE 13, 5: PRINT "Credits"
LOCATE 14, 6: PRINT "Quit"
END IF
IF MenuButton = 2 THEN
COLOR 15
LOCATE 12, 6: PRINT "Help"
COLOR 1
LOCATE 11, 6: PRINT "Play"
LOCATE 13, 5: PRINT "Credits"
LOCATE 14, 6: PRINT "Quit"
END IF
IF MenuButton = 3 THEN
COLOR 15
LOCATE 13, 5: PRINT "Credits"
COLOR 1
LOCATE 12, 6: PRINT "Help"
LOCATE 11, 6: PRINT "Play"
LOCATE 14, 6: PRINT "Quit"
END IF
IF MenuButton = 4 THEN
COLOR 15
LOCATE 14, 6: PRINT "Quit"
COLOR 1
LOCATE 12, 6: PRINT "Help"
LOCATE 13, 5: PRINT "Credits"
LOCATE 11, 6: PRINT "Play"
END IF
RETURN
'------------------------------
END SUB
Posts: 2,765
Threads: 138
Joined: Nov 2002
cool. lot of code though. (edit: but of course the moving snake thinky) i have some menu code too. *looks throough floppies* ah here it is... crud it not in text... grr
yay
Code: DECLARE SUB menu (data$, numofitems, mode, detail$, sw, sh)
CALL menu("Menu1Menu2... Close", 4, 1, "My menu", 80, 24)
SUB menu (data$, numofitems, mode, detail$, sw, sh)
CLS
ub = numofitems
lb = 1
selected = 1
COLOR 15
LOCATE sh / 2 - ub / 2 - lb + 1 - 1, (sw / 2) - (LEN(detail$) / 2)
PRINT detail$
DO
FOR i = lb TO ub
word$ = CHR$(219) + LTRIM$(STR$(i)) + ") " + MID$(data$, (i - 1) * (LEN(data$) / ub) + 1, LEN(data$) / ub) + " " + CHR$(219)
LOCATE sh / 2 - INT(ub / 2 + .5) + i, (sw / 2) - (LEN(word$) / 2)
'Change the select color here
IF selected = i THEN COLOR 4 ELSE COLOR 15
PRINT word$
NEXT
press$ = INKEY$
SELECT CASE press$
CASE CHR$(0) + CHR$(72): selected = selected - 1
CASE CHR$(0) + CHR$(80): selected = selected + 1
CASE CHR$(13)
'\/\/\/\/Multiple modes for multiple menus
SELECT CASE mode
CASE 1:
'\/\/\/\/Here you change what each links do (like call a sub)
SELECT CASE selected
CASE 1: COLOR 15:
CASE 2: COLOR 15:
CASE 3: COLOR 15:
CASE 4: COLOR 15: END
END SELECT
'
END SELECT
END SELECT
IF selected < lb THEN selected = ub
IF selected > ub THEN selected = lb
LOOP
END SUB
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Posts: 3,616
Threads: 287
Joined: Jan 2003
Wow, nice code SD, and you too Whitetiger.
Have to study that a bit. So far I only have a simple menu, but I'll make it more complex.
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
|