03-19-2005, 10:40 AM
if i wanted to have a box with a message displayed over my map(rpg map) have the game pause then dissapear when the user types so how could i do that
pausing game so a message can come up
|
03-19-2005, 10:40 AM
if i wanted to have a box with a message displayed over my map(rpg map) have the game pause then dissapear when the user types so how could i do that
03-19-2005, 02:05 PM
put something like this in the main that disides contols etc loop
Code: key$ = INKEY$
url=http://www.sloganizer.net/en/][/url]
03-19-2005, 06:15 PM
Here is a full working sample code...
[syntax="QBasic"]SCREEN 13 CLS DIM Map(10, 10) FOR y = 1 TO 10 FOR x = 1 TO 10 READ z IF z = -1 THEN x1 = x: y1 = y: z = 0 Map(x, y) = z NEXT NEXT DO press$ = INKEY$ FOR y = 1 TO 10 FOR x = 1 TO 10 IF Map(x, y) = 0 THEN COLOR 6: LOCATE y, x: PRINT CHR$(219) 'Dirt IF Map(x, y) = 2 THEN COLOR 2: LOCATE y, x: PRINT CHR$(219) 'Grass IF Map(x, y) = 3 THEN COLOR 9: LOCATE y, x: PRINT CHR$(219) 'Water IF Map(x, y) = 4 THEN COLOR 7: LOCATE y, x: PRINT CHR$(219) 'Wall NEXT NEXT IF press$ = CHR$(0) + "H" THEN ' On Keypress Up Arrow... y1 = y1 - 1 IF Map(x1, y1) >= 3 THEN y1 = y1 + 1 LOCATE 12, 1: PRINT " " ELSEIF press$ = CHR$(0) + "P" THEN y1 = y1 + 1: IF y1 > 10 THEN y1 = 10: LOCATE 12, 1: PRINT "Can't Pass! No Map down there!" IF Map(x1, y1) >= 3 THEN y1 = y1 - 1 ELSEIF press$ = CHR$(0) + "M" THEN x1 = x1 + 1: IF x1 > 10 THEN x1 = 10: LOCATE 12, 1: PRINT "Can't Pass! No Map over there!" IF Map(x1, y1) >= 3 THEN x1 = x1 - 1 ELSEIF press$ = CHR$(0) + "K" THEN x1 = x1 - 1 ' Move player left IF Map(x1, y1) >= 3 THEN x1 = x1 + 1 LOCATE 12, 1: PRINT " " ' This is the event box control your asking about, Forget the other code.. ' On keypress L any case, triggers event.. ELSEIF UCASE$(press$) = "L" THEN CLS ' Clear map.. DO ' Start LOOP press$ = INKEY$ 'Make a INKEY$ promt in this LOOP to,.. ' Just a simple code for a example event, work of the Map system.. IF Map(x1, y1) = 0 THEN LOCATE 1, 1: PRINT "Looks down at the Dirt... Nothing." IF Map(x1, y1) = 2 THEN LOCATE 1, 1: PRINT "Looks down at the Grass.. Nothing." LOOP UNTIL press$ <> "" 'LOOP Message until keypress.. CLS ' Clear massage.. Once that is over, Map will return, if ' you are using a simular tile engine,.. END IF LOCATE y1, x1: PRINT CHR$(1) WAIT &H3DA, 8 FOR I = 1 TO 1000: NEXT LOOP UNTIL press$ = CHR$(27)' Loop until KeyPress = Esc '[[ Map ]] '[[ Key ]] '-1 = Player's position '0 = Dirt '2 = Grass '3 = Water '4 = Wall DATA 4,4,4,4,4,4,4,4,4,4 DATA 4,3,3,3,3,3,2,4,0,4 DATA 4,2,3,3,3,2,2,4,0,4 DATA 4,2,2,2,2,2,2,4,0,4 DATA 4,0,2,2,2,2,0,4,0,0 DATA 4,0,0,0,0,0,0,0,0,0 DATA 4,0,0,0,-1,0,0,4,0,4 DATA 4,0,4,4,4,4,4,4,0,4 DATA 4,0,0,0,0,0,0,4,0,4 DATA 4,4,4,4,4,0,0,4,4,4[/syntax] Copy that to QBasic, and look for the REMs that separate the Message control from the rest of the code... Hmm, here is the message controll in that.. want work alone, best to run and look at it in the full one above.. [syntax="QBasic"]' This is the event box control your asking about, Forget the other code.. ' On keypress L any case, triggers event.. ELSEIF UCASE$(press$) = "L" THEN CLS ' Clear map.. DO ' Start LOOP press$ = INKEY$ 'Make a refresh promt in this LOOP to,.. ' Just a simple code for a example event, work of the Map system.. IF Map(x1, y1) = 0 THEN LOCATE 1, 1: PRINT "Looks down at the Dirt... Nothing." IF Map(x1, y1) = 2 THEN LOCATE 1, 1: PRINT "Looks down at the Grass.. Nothing." LOOP UNTIL press$ <> "" 'LOOP Message until keypress.. CLS ' Clear massage.. Once that is over, Map will return, if ' you are using a simular tile engine,..[/syntax] Hope this helps! :wink: |
« Next Oldest | Next Newest »
|