Ok i have read alot about timers and functions, and i kinda got my head round it, but i'm having problems with certain part, i have 3 cook buttons (this is a cafe game), i also have 3 functions for cooking, which numerous checks are used to make sure that the variables are all ok or else it gives you a message, so i am trying to cook 3 things at once, i thought i got it all covered, but it doesn't work correcty, 1st off the once cooking 1 item, if you try to cook another it gives the message which you have no food prepared, which is correct if there was not food prepared but there is, then when the 1st item has finished the nex item strts to cook on a minus timer...
REM Globals
sync on
sync rate 30
Backdrop off
global Level = 1
global Cash = 250
global CurExp# = 0.0
global NextExp# = 10.0
global Name$ = ""
global hitClose = 0
global currentCookPage = 1
global currentStockPage = 1
global expProgress# = 492.0
REM Timers
REM global Seconds = 30
global Time1 = Timer()
global Time2 = Timer()
global Time3 = Timer()
REM Food Amounts
global Pizzas = 0
global foodcount = 0
REM Game-start and Code
sync
titlescreen()
do
sync
printScreen()
loadImages()
processButton(3,2,1,5,2,50,120) REM Cookbook
processButton(5,4,2,175,2,50,120) REM Stockbook
processButton(993,994,4,545,500,83,83) REM Cook Button 1
processButton(1000,1001,6,627,500,83,83) REM Cook Button 2
processButton(1002,1003,7,710,500,83,83) REM Cook Button 3
expBar()
if inkey$() = "s" then savegame()
if inkey$() = "l" then loadgame()
REM show sprite 1005
REM show sprite 1006
loop
REM Functions
function savegame()
if File Exist("savegame.dat") = 1 then delete file "savegame.dat"
open to write 1, "savegame.dat"
write long 1, Level
write long 1, Cash
write long 1, CurExp#
write long 1, expProgress#
write long 1, Pizzas
write long 1, foodcount
write long 1, NextExp#
close file 1
wait 1000
if file exist("savegame.dat") = 1
center text 400, 200, "Save Game Completed, Press Any Key To Continue.."
sync
wait key
else
center text 400, 200, "Save Game Failed, Press Any Key To Continue.."
sync
wait key
endif
endfunction
function loadgame()
if File Exist("savegame.dat") = 1
open to read 1, "savegame.dat"
read long 1, Level
read long 1, Cash
read long 1, CurExp#
read long 1, expProgress#
read long 1, Pizzas
read long 1, foodcount
read long 1, NextExp#
close file 1
wait 1000
center text 400, 200, "Load Game Completed, Press Any Key To Continue.."
sync
wait key
else
center text 400, 200, "Save Game Doesn't Exist, Press Any Key To Continue.."
sync
wait key
endif
endfunction
function titlescreen()
LOAD MUSIC "breakfast.mid", 20
loop music 20
load Bitmap "backgroundname.bmp" ,0
SET CURSOR 280, 155
input Name$
endfunction
function expBar()
box 492, 5, 642, 20, rgb(0,0,0), rgb(0,0,0), rgb(0,0,0), rgb(0,0,0)
box 492, 5, expProgress#, 20, rgb(0,255,0), rgb(0,255,0), rgb(0,255,0), rgb(0,255,0)
endfunction
function buyFood(Nbr)
if Nbr = 1
printScreen()
Pizzas = Pizzas + 10
Cash = Cash - 25
center text 653, 330, "You bought 10 Pizza's"
sync
sleep 1500
printScreen()
endif
endfunction
function cookFood(Nbr)
if Nbr = 1
if Pizzas >= 1
cookPizza()
if Nbr = 2
if Pizzas >= 1
cookPizza2()
if Nbr = 3
if Pizzas >= 1
cookPizza3()
endif
endif
endif
endif
endif
endif
endfunction
function cookPizza()
sync
if foodcount = 0
printScreen()
center text 653, 330, "you have no Food Prepared"
sync
sleep 3000
printScreen()
exitfunction
else
Pizzas = Pizzas - 1
foodcount = foodcount -1
Seconds=30
T=Timer()
Repeat
Elapsed=(Timer()-T)/1000
TimeLeft=Seconds-Elapsed
printScreen()
processButton(3,2,1,5,2,50,120) REM Cookbook
processButton(5,4,2,175,2,50,120) REM Stockbook
processButton(993,994,4,545,500,83,83) REM Cook Button
processButton(1000,1001,4,627,500,83,83) REM Cook Button
processButton(1002,1003,4,710,500,83,83) REM Cook Button
center text 653, 330, "Cooking Pizza Please Wait.."
center text 783, 330,Str$(TimeLeft)+" "
sync
Until TimeLeft=0
printScreen()
processButton(3,2,1,5,2,50,120) REM Cookbook
processButton(5,4,2,175,2,50,120) REM Stockbook
processButton(993,994,4,545,500,83,83) REM Cook Button
processButton(1000,1001,4,627,500,83,83) REM Cook Button
processButton(1002,1003,4,710,500,83,83) REM Cook Button
center text 653, 330, "You Cooked a Pizza"
sync
addExp(5.0)
Cash = Cash + 5
printScreen()
exitfunction
endif
endfunction
function cookPizza2()
sync
if foodcount = 0
printScreen()
center text 653, 330, "you have no Food Prepared"
sync
sleep 3000
printScreen()
exitfunction
else
Pizzas = Pizzas - 1
foodcount = foodcount -1
Seconds=30
T1=Timer()
Repeat
Elapsed=(Timer()-T1)/1000
TimeLeft=Seconds-Elapsed
printScreen()
processButton(3,2,1,5,2,50,120) REM Cookbook
processButton(5,4,2,175,2,50,120) REM Stockbook
processButton(993,994,4,545,500,83,83) REM Cook Button
processButton(1000,1001,4,627,500,83,83) REM Cook Button
processButton(1002,1003,4,710,500,83,83) REM Cook Button
center text 653, 340, "Cooking Pizza Please Wait.."
center text 783, 340,Str$(TimeLeft)+" "
sync
Until TimeLeft=0
printScreen()
processButton(3,2,1,5,2,50,120) REM Cookbook
processButton(5,4,2,175,2,50,120) REM Stockbook
processButton(993,994,4,545,500,83,83) REM Cook Button
processButton(1000,1001,4,627,500,83,83) REM Cook Button
processButton(1002,1003,4,710,500,83,83) REM Cook Button
center text 653, 340, "You Cooked a Pizza"
sync
addExp(5.0)
Cash = Cash + 5
printScreen()
exitfunction
endif
endfunction
function cookPizza3()
sync
if foodcount = 0
printScreen()
center text 653, 330, "you have no Food Prepared"
sync
sleep 3000
printScreen()
exitfunction
else
Pizzas = Pizzas - 1
foodcount = foodcount -1
Seconds=30
T2=Timer()
Repeat
Elapsed=(Timer()-T2)/1000
TimeLeft=Seconds-Elapsed
printScreen()
processButton(3,2,1,5,2,50,120) REM Cookbook
processButton(5,4,2,175,2,50,120) REM Stockbook
processButton(993,994,4,545,500,83,83) REM Cook Button
processButton(1000,1001,4,627,500,83,83) REM Cook Button
processButton(1002,1003,4,710,500,83,83) REM Cook Button
center text 653, 350, "Cooking Pizza Please Wait.."
center text 783, 350,Str$(TimeLeft)+" "
sync
Until TimeLeft=0
printScreen()
processButton(3,2,1,5,2,50,120) REM Cookbook
processButton(5,4,2,175,2,50,120) REM Stockbook
processButton(993,994,4,545,500,83,83) REM Cook Button
processButton(1000,1001,4,627,500,83,83) REM Cook Button
processButton(1002,1003,4,710,500,83,83) REM Cook Button
center text 653, 350, "You Cooked a Pizza"
sync
addExp(5.0)
Cash = Cash + 5
printScreen()
exitfunction
endif
endfunction
function addExp(ExpAdd#)
CurExp# = CurExp# + ExpAdd# REM Exp + ExpAdd
expProgress# = expProgress# + (150 / NextExp#) * ExpAdd#
if CurExp# >= NextExp# REM If current exp is higher than Exp for next level
CurExp# = 0.0 REM Fix up over-mating the Next-Exp before change
NextExp# = NextExp# * 2.0 REM Next Level Exp Doubles
Level = Level + 1
CashGain = CurExp# / 3
print "Lvl up! $"; CashGain; " Gained!"
Cash = Cash + CashGain
expProgress# = 492.0
endif
print "You gained "; ExpAdd#; " Exp!"
sleep 2500
printScreen()
endfunction
function displayCookBook()
do
printScreen()
paste sprite 6,100,100 REM Inside the Cookbook
paste sprite 10,545,110 REM Close Button
if currentCookPage = 1
paste sprite 7,150,150 REM Pizza Interface
paste sprite 995,205,210 REM Prepare Pizza Button
processButton(996,995,5,205,210,15,40) REM Prepare Pizza
center text 227, 188, STR$(Pizzas)
endif
processButton(11,10,999,545,110,25,25) REM Close Book
if hitClose = 1
hitClose = 0
exitfunction
endif
sync
loop
endfunction
function displayStockbook()
do
printScreen()
paste sprite 8,100,100 REM Inside the Stockbook
paste sprite 10,545,110 REM Close Button
if currentStockPage = 1
paste sprite 9,150,150 REM Pizza Interface
paste sprite 997,205,210 REM Buy Pizza
processButton(998,997,3,205,210,15,40) REM Buy Pizza Button
endif
processButton(11,10,999,545,110,25,25) REM Close Book
if hitClose = 1
hitClose = 0
exitfunction
endif
sync
loop
endfunction
function checkStock(Nmb)
if Nmb = 1
if Cash >= 20
buyFood(1)
exitfunction
endif
endif
printScreen()
endfunction
function checkFood(Nmb)
if Nmb = 1
if Pizzas >= 1
cookFood(1)
if Nmb = 2
if Pizzas >= 1
cookFood(2)
if Nmb = 3
if Pizzas >= 1
cookFood(3)
endif
endif
endif
endif
endif
endif
printScreen()
endfunction
function processButton(spr, sprX, Int2, btnX, btnY, btnH, btnW)
if mousex() > btnX and mousex() < btnX + btnW
if mousey() > btnY and mousey() < btnY + btnH
show sprite spr
hide sprite sprX
if MOUSECLICK() = 1
findFunction(Int2)
if spr = 996
hitClose = 1
else
if spr = 998
hitClose = 1
endif
endif
exitfunction
endif
else
show sprite sprX
hide sprite spr
endif
else
show sprite sprX
hide sprite spr
endif
endfunction
function FoodPrepared()
if Pizzas >= 1
print "Preparing Pizza"
Sleep 1000
foodcount = foodcount +1
endif
endfunction
function findFunction(Int5)
if Int5 = 1 REM Cookbook
displayCookBook()
else
if Int5 = 2 REM Stockbook
displayStockbook()
endif
endif
if Int5 = 3 REM Buy Pizza
checkStock(1)
else
if Int5 = 999 REM Close
hitClose = 1
endif
endif
if Int5 = 4 REM Cook Pizza
checkFood(1)
endif
if Int5 = 5 REM Prepare Food
FoodPrepared()
endif
if Int5 = 6 REM Cook Pizza
checkFood(2)
endif
if Int5 = 7 REM Cook Pizza
checkFood(3)
endif
exitfunction
endfunction
function loadImages()
load image "Cookbook\cookbook.png",2
load image "Cookbook\cookbook_hover.png",3
load image "Stockbook\stockbook.png",4
load image "Stockbook\stockbook_hover.png",5
load image "Cookbook\cookbook inside.png",6
load image "Cookbook\pizza-cookbook.png",7
load image "Stockbook\stockbook inside.png",8
load image "Stockbook\pizza-stockbook.png",9
load image "Close Btn.png",10
load image "Close Btn_down.png",11
load image "cook.png",995
load image "cook_hover.png",996
load image "buy.png",997
load image "buy_hover.png",998
load image "cook1.png", 993
load image "cook1Over.png", 994
load image "cook1.png", 1000
load image "cook1Over.png", 1001
load image "cook1.png", 1002
load image "cook1Over.png", 1003
load image "cafeimage2.png", 1005
load image "kitchen2.png", 1006
sprite 2,5,2,2
sprite 3,5,2,3
sprite 4,175,2,4
sprite 5,175,2,5
sprite 6,100,100,6
sprite 7,150,150,7
sprite 8,100,100,8
sprite 9,150,150,9
sprite 10,545,110,10
sprite 11,545,110,11
sprite 993,545,500,993 REM Cook Button
sprite 994,545,500,994 REM Cook Button Over
sprite 995,205,210,995 REM Pizza Cook
sprite 996,205,210,996 REM Pizza Cook
sprite 997,205,210,997 REM Pizza Buy
sprite 998,205,210,998 REM Pizza Buy
sprite 1000,627,500,1000 REM Cook Button
sprite 1001,627,500,1001 REM Cook Button Over
sprite 1002,710,500,1002 REM Cook Button
sprite 1003,710,500,1003 REM Cook Button Over
REM sprite 1005,541,78,1005 REM Cafe Image 1
REM sprite 1006,561,330,1006 REM Cafe Image 1
hide all sprites
endfunction
function printScreen()
hide all sprites
cls
load bitmap "BG 2.bmp"
center text 450, 35, STR$(Level)
center text 375, 35, STR$(CurExp#) + "/" + STR$(NextExp#)
center text 400, 5, Name$ + "'s Cafe"
center text 725, 5, "Cash: $" + STR$(Cash)
text 635,63,get time$()
center text 90, 500, "Food Prepared = " + STR$(foodcount)
REM STR$(*) Converts a Integer into a String
endfunction
FPS Creator Updated 116,Vista 32Bit UpTo Date, nVidea 8500 1Gig Graphics Card, 4 Gig DDR2 Ram, Intel Duel Core 3GHZ CPU