A VERY VERY QUICK question!
A VERY VERY QUICK question!
How do you make a timer in your program that you can see but doesnt affect your whole program?
Can you clarify? Do you mean like show the current time at the top of your screen? Or just display a countdown from any particular starting time while other stuff happens? What do you mean by doesnt affect your whole program?
Pseudo-code for possibly doing what you're asking:
Pseudo-code for possibly doing what you're asking:
Code: Select all
Determine countdown time length (like 10 seconds or whatever)
Check current time and determine what time countdown will end
Store countdown ending time
DO
Check current time and see if current time is later than countdown ending time
IF YES, run a sub that does whatever you want when countdown ends
IF NO, display countdown ending time - current time
continue the rest of the main program
LOOP
actually a count up timer but when i use the FOR..NEXT with sleep in the middle it stops my program till it gets to lets say...3000 or something. And where can i find the forumla to draw the "sprite" (intropage thing")
my code
my code
Code: Select all
CLS
DIM field$(15)
field$(0) = " "
field$(1) = " __________________________________________________"
field$(2) = "| | "
field$(3) = "| | "
field$(4) = "| | "
field$(5) = "| | "
field$(6) = "| | "
field$(7) = "| | "
field$(8) = "| | "
field$(9) = "| | "
field$(10) = "| | "
field$(11) = "| | "
field$(12) = "| | "
field$(13) = "| | "
field$(14) = "| | "
field$(15) = "|__________________________________________________| "
DIM intropage$(100)
DATA 15,00,00,00,15,00,15,15,15,00,15,00,00,00,00,15,15,00,00,15,15,00,00,00,15,00,15,00,00,15,15,15,00,00,00
DATA 15,00,00,00,15,00,15,00,00,00,15,00,00,00,15,00,00,00,15,00,00,15,00,15,00,15,00,15,00,15,00,00,00,00,00
DATA 15,00,15,00,15,00,15,15,00,00,15,00,00,00,15,00,00,00,15,00,00,15,00,15,00,15,00,15,00,15,15,00,00,00,00
DATA 15,00,15,00,15,00,15,00,00,00,15,00,00,00,15,00,00,00,15,00,00,15,00,15,00,15,00,15,00,15,00,00,00,00,00
DATA 00,15,00,15,00,00,15,15,15,00,15,15,15,00,00,15,15,00,00,15,15,00,00,15,00,00,00,15,00,15,15,15,00,00,00
DATA 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
DATA 00,00,00,00,00,00,00,00,00,00,15,15,15,00,15,15,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
DATA 00,00,00,00,00,00,00,00,00,00,00,15,00,15,00,00,15,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
DATA 00,00,00,00,00,00,00,00,00,00,00,15,00,15,00,00,15,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
DATA 00,00,00,00,00,00,00,00,00,00,00,15,00,15,00,00,15,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
DATA 00,00,00,00,00,00,00,00,00,00,00,15,00,00,15,15,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
DATA 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
DATA 00,00,00,15,15,00,00,15,00,00,15,00,15,00,00,15,00,00,15,00,00,15,00,00,00,15,00,00,15,00,00,15,00,15,00
DATA 00,00,00,15,00,15,00,15,00,00,15,00,15,15,00,15,00,15,00,15,00,15,00,00,00,15,00,15,00,15,00,15,00,15,00
DATA 00,00,00,15,00,15,00,15,00,00,15,00,15,15,15,15,00,15,15,15,00,15,00,15,00,15,00,15,15,15,00,00,15,00,00
DATA 00,00,00,15,15,00,00,15,00,00,15,00,15,00,15,15,00,15,00,15,00,15,00,15,00,15,00,15,00,15,00,00,15,00,00
DATA 00,00,00,15,00,15,00,15,00,00,15,00,15,00,00,15,00,15,00,15,00,15,00,15,00,15,00,15,00,15,00,00,15,00,00
DATA 00,00,00,15,00,15,00,00,15,15,00,00,15,00,00,15,00,15,00,15,00,00,15,00,15,00,00,15,00,15,00,00,15,00,00
data1 = 18
data2 = 35
hx = 25
hy = 16
kp$ = INKEY$
intro:
SCREEN 13
CLS
DO
FOR y = 0 TO 18
FOR x = 0 TO 35
READ intropage$
PSET (X,y), intropage$
NEXT X
NEXT y
hl% = 20
kp$ = INKEY$
COLOR INT(RND * 15) + 2
LOCATE 8, 10
PRINT "Welcome to RUN AWAY!"
LOCATE 14, 10
COLOR 15
PRINT "1 Play"
LOCATE 16, 10
COLOR 6
PRINT "2 Instructions"
LOCATE 18, 10
COLOR 3
PRINT "3 Quit"
IF kp$ = "1" THEN GOTO game
IF kp$ = "2" THEN GOTO instruc
IF kp$ = "3" THEN END
LOOP
instruc:
CLS
COLOR 15
FOR d = 1 TO 5
PRINT
NEXT d
PRINT "Oneday the guards of a town caught a man trying to a steal an apple, so then he had to RUN AWAY! (This is where YOU come in =>)"
PRINT
PRINT
COLOR 17
PRINT "CONTROLS"
COLOR 15
PRINT "w = up"
PRINT "s = down"
PRINT "a = left"
PRINT "d = right"
PRINT
PRINT "q = quit"
FOR f = 1 TO 10
PRINT
NEXT f
PRINT "Press Q to go back <--"
DO
kp$ = INKEY$
COLOR 2
LOCATE 10, 25
PRINT ".8. = YOU"
LOCATE 12, 25
COLOR 4
PRINT "|8. = ENEMY!"
IF kp$ = "q" THEN GOTO intro
LOOP
game:
timex = 54
timey = 2
TIME = 0
lvlx = 54
lvly = 5
lvl = 1
x = 48
y = 7
enemyx = 5
enemyy = 7
enemyx2 = 10
enemyy2 = 5
health = 20
CLS
DO
LOCATE 1, 1
FOR mz = 1 TO 15
COLOR 7
PRINT field$(mz)
NEXT mz
LOCATE lvly, lvlx
COLOR 15
PRINT "lvl :"; lvl
LOCATE hy, hx
COLOR 10
PRINT health; "/"; hl%
LOCATE y, x
COLOR 15
PRINT ".8."
LOCATE enemyy, enemyx
COLOR 12
PRINT "|8."
IF ((x = enemyx) AND (y = enemyy)) THEN
health = health - 1
END IF
IF TIME = 120 THEN
LOCATE enemyy2, enemyx2
COLOR 12
PRINT "|8."
ELSE
GOTO pause
END IF
IF ((x = enemyx2) AND (y = enemyy2)) THEN
health = health - 1
END IF
IF TIME = 120 THEN
lvl = lvl + 1
PRINT lvl
ELSE
GOTO pause
END IF
oldx = x
oldy = y
pause:
'pause
DO
kp$ = INKEY$
LOOP UNTIL kp$ <LOCATE> 1 THEN y = y - 1
IF kp$ = "s" THEN y = y + 1
IF kp$ = "a" THEN x = x - 1
IF kp$ = "d" AND x + 3 < 52 THEN x = x + 1
IF MID$(field$(y), x, 1) = "|" THEN
LOCATE y, x
PRINT "|"
x = oldx
y = oldy
END IF
IF MID$(field$(y), x, 1) = "_" THEN
LOCATE y, x
PRINT "___"
x = oldx
y = oldy
END IF
IF health = 0 THEN
GOTO deathmessage
ELSE
GOTO gai
END IF
deathmessage:
DO
kp$ = INKEY$
LOCATE 8, 10
COLOR 12
PRINT ",`YOU'RE DEAD!'."
LOCATE 9, 10
COLOR 4
PRINT "`, ',"
LOCATE 12, 10
COLOR 15
PRINT "Press space to try again"
LOCATE 13, 10
PRINT "Or press Q to quit"
IF kp$ = " " THEN GOTO game
IF kp$ = CHR$(113) THEN GOTO intro
LOOP
gai:
' ghost AI
oldy = enemyy
oldx = enemyx
IF RND < .3 THEN
SELECT CASE enemyx
CASE IS <x> x
enemyx = enemyx - 1
END SELECT
SELECT CASE enemyy
CASE IS <y> y
enemyy = enemyy - 1
END SELECT
IF MID$(field$(enemyy), enemyx, 1) = "_" THEN
enemyx = oldx
enemyy = oldy
LOCATE enemyy, enemyx
PRINT "_"
END IF
END IF
gai2:
'ghost2 AI
oldy = enemyy2
oldx = enemyx2
SELECT CASE enemyx2
CASE IS <x> x
enemyx2 = enemyx2 - 1
END SELECT
SELECT CASE enemyy2
CASE IS <y> y
enemyy2 = enemyy2 - 1
END SELECT
IF MID$(field$(enemyy2), enemyx2, 1) = "_" THEN
enemyx2 = oldx
enemyy2 = oldy
LOCATE enemyy2, enemyx2
PRINT "_"
END IF
LOOP
Do you mean an elapsed game timer?
This code shows how to do a timer on the screen showing hours, minutes and seconds that the timer has been running. If used within a game it can be used to show the elapsed time of any selected event or the entire length of time that the game has been running.
[/code]
Code: Select all
CLS
ON TIMER(1) GOSUB timetick
timecount = 0
PRINT
PRINT
PRINT
PRINT "This program will update a time counter at the top of the screen once"
PRINT "every "; s; " seconds."
PRINT "Press any key when ready to begin"
getkey$ = ""
WHILE getkey$ = "": GOSUB getky: WEND
PRINT "Timer started -- press any key to quit"
getkey$ = ""
TIMER ON
WHILE getkey$ = "": GOSUB getky: WEND
TIMER OFF
PRINT "Demo ended"
SYSTEM
timetick:
timecount = timecount + 1
LOCATE 1, 1
t = timecount
h = INT(t / 60 / 60)
t = t - h * 60 * 60
m = INT(t / 60)
t = t - m * 60
h$ = STR$(h)
m$ = STR$(m)
s$ = STR$(t)
h$ = RIGHT$(h$, LEN(h$) - 1): IF LEN(h$) < 2 THEN h$ = "0" + h$
m$ = RIGHT$(m$, LEN(m$) - 1): IF LEN(m$) < 2 THEN m$ = "0" + m$
s$ = RIGHT$(s$, LEN(s$) - 1): IF LEN(s$) < 2 THEN s$ = "0" + s$
PRINT h$; ":"; m$; ":"; s$
RETURN
getky:
getkey$ = INKEY$
RETURN
Roger Greenlaw