Quote: "It wont work with the LOOP command"
Timers do work with do/loops... you just mean you don't have do/loops in your code, right?
Timers can work anywhere in any kind of loop and/or function.
This also has two commands you may have not seen before "remstart" and "remend" for those times you want a huge amount of "rem"s without typing "rem" each line (also good for reming off sections of code when your trying to track down hard to find nesting errors).
remstart
Project: square linx copy
Created: 1/15/2007 9:13:57 PM
***** Main Source File *****
Project: Square Linx
Created: 1/4/2007 9:52:07 PM
***** Main Source File *****
---------------------------------------------------
Project: Square Linx
Created: 12/25/2006 6:44:17 PM
***** Main Source File *****
Author : JSG
Edited by indi : 28/12/2006
NOTES: indi cleaned up and remarked the code
the old structure was a complete mess and would create headaches
using functions allows for better control of code
remend
REM ---------------------------------------------------
REM INIT GAME
REM ---------------------------------------------------
sync on : sync rate 60
set text size 12 : set text font "arial" : ink rgb(255,255,255),1
set window title "Square Linx"
set display mode 800,600,32
backdrop off
REM ---------------------------------------------------
REM INIT VARIABLES
REM ---------------------------------------------------
GLOBAL SCRW = screen width
GLOBAL SCRH = screen height
REM ---------------------------------------------------
REM PLAYER VARIABLES
REM ---------------------------------------------------
REM STARTING MONEY
GLOBAL PLR_MONEY : PLR_MONEY = 20000
REM GENDER
GLOBAL PLR_GENDER$ : PLR_GENDER$ = "Unknown"
REM PLAYER NAME DATA
GLOBAL PLR_NAME$ : PLR_NAME$ = "Unknown"
GLOBAL PLR_SURNAME$ : PLR_NAME$ = "Unknown"
REM ---------------------------------------------------
REM STARTING MENU
REM ---------------------------------------------------
disable escapekey : while escapekey()=0
text 0,15,"Hello Welcome To Square Linx"
text 0,30,"Press 1 to create a cube family"
text 0,45,"Press 2 to load a cube family"
text 0,60,"Press 3 to see an example"
if inkey$()="1"
MAKE_FAMILY()
endif
if inkey$()="2"
LOAD_FAMILY()
endif
if inkey$()="3"
STARTGAME()
endif
REM END PROGRAM IF ESCAPE IS PRESSED
if escapekey() = 1
ENDGAME()
endif
sync : endwhile
FUNCTION STARTGAME()
REM ---------------------------------------------------
REM NEEDS VARIABLES
REM ---------------------------------------------------
hunger#=100
sleep#=100
`Timer#=Timer() I remed this off because setting a timer too
` far away from where it's actually used adds more time so your
` first minute wouldn't really be a minute... even though nobody
` would notice such a small difference. :-)
REM ---------------------------------------------------
REM LOAD WORLD
REM ---------------------------------------------------
rem load a temp object instead of yours
make object plain 1,600,800
load image "fridge.tga",1
load image "bed.tga",3
REM ---------------------------------------------------
REM PRE MAIN LOOP
REM -------------------------------------------
backdrop on : color backdrop rgb(0,0,0)
load image "texture.tga",2
REM ---------------------------------------------------
REM MAIN GAME LOOP
REM ---------------------------------------------------
` Set the timer
tim=timer()
while escapekey()=0
text SCRW/2,12,"First Name :" +PLR_NAME$
text SCRW/2,30,"Surname : "+PLR_SURNAME$
text SCRW/2,50,"Money : "+STR$(PLR_MONEY)
text scrw/2,70,"Hunger : "+str$(hunger#)
text scrw/2,90,"Energy : "+str$(sleep#)
texture object 1,2
paste image 1,260,110,1
paste image 3,480,110,1
` Check if 1 minute has past
if timer()>tim+60000
dec hunger#,5
dec sleep#,6
` Reset timer
tim=timer()
endif
if mouseclick()=1 and mousex()>260 and mousey()>110 and mousex()<260+324 and mousey()<110+169
cls
input "Vegetables, Fruit, or Junk?",whattoeat$
if whattoeat$="junk" then fatness=fatness+10 : nutrition=nutrition-5 : hunger#=hunger#-1 : ate=no
if whattoeat$="vegetables" then nutrition=nutrition+5 : fatness=fatness-2 : hunger#=hunger#+5 : ate=yes
if whattoeat$="fruit" then nutrition=nutrition+2 : hunger#=hunger#+2 : ate=yes
endif
sync : endwhile
ENDGAME()
ENDFUNCTION
FUNCTION MAKE_FAMILY()
cls
text 1,1,"MAKE CUBE FAMILY : Enter Some Information"
set cursor 1,15
input "First Name : ",PLR_NAME$
set cursor 1,30
input "Last Name : ",PLR_SURNAME$
REM CHEAT CODE
if lower$(PLR_NAME$)="bill" and lower$(PLR_SURNAME$)="gates"
PLR_MONEY = ( PLR_MONEY + 200000 )
endif
input "Gender : ",PLR_GENDER$
cls
STARTGAME()
ENDFUNCTION
FUNCTION LOAD_FAMILY()
cls
text 1,15,"Under Construction : press a key to end program"
sync : suspend for key
ENDGAME()
ENDFUNCTION
FUNCTION ENDGAME()
FOR I = 1 to 100
IF object exist(I) = 1
Delete object I
ENDIF
NEXT I
END
ENDFUNCTION