In the following code :
function createMenu(menu as integer)
ptr as dword
filename as string
sectionName as string
menuSize as integer
text$ as string
l as integer
spr as integer
text 0,90,"Hello":sync:wait key
for l=TITLE_SPRITE to MENU5_SPRITE
if sprite exist (l)0
delete sprite l
endif
next l
for l=TITLE_BITMAP to MENU5_BITMAP
if image exist (l)0
delete image l
endif
next l
filename=INI_PATH+"MENUS.INI"
sectionName="MENUS"
ptr=make memory (1024)
rem Get the number of menus
menuSize=call dll (DLL_INIFILE,"readDataAsInt",fileName,sectionName,"MENU"+str$(menu)+"SIZE",0)
if menuSize0
rem Get the title
call dll DLL_INIFILE,"readDataAsStringDB",fileName,sectionName,"MENU"+str$(menu)+"TITLE",ptr,""
text$=call dll (DLL_POINTER,"__peekString",ptr,4)
rem Create the title
putCharIntoBitmap(1,TITLE_BITMAP,32,_
text$,_
GAME_FONT)
sprite TITLE_SPRITE,_
10,_
(screen height()-16-((menuSize+1)*32))-20,_
TITLE_BITMAP
set sprite TITLE_SPRITE,0,1
rem Now do each of the options
for l=1 to menuSize
call dll DLL_INIFILE,"readDataAsStringDB",filename,sectionName,"MENU"+str$(menu)+"PART"+str$(l),ptr,""
text$=call dll (DLL_POINTER,"__peekString",ptr,4)
putCharIntoBitmap(1,MENU1_BITMAP+(l-1),32,_
text$,_
GAME_FONT)
spr=(l-1)+MENU1_SPRITE
sprite spr,_
(screen width()-(len(text$)*32))>>1,_
(screen height()-16-(menuSize*32))+((l-1)*32),_
MENU1_BITMAP+(l-1)
set sprite spr,0,1
next l
hide all sprites
endif
delete memory (ptr)
endfunction menuSize
function displayMenu(menuSize as integer,menu as integer)
l as integer
lx as integer
Rem Show the TITLE sprite
text 0,50,str$(menuSize)+" "+str$(menu)
show sprite (TITLE_SPRITE)
rem text 0,50,str$(menuSize):sync:wait key
for l=1 to menuSize
show sprite ((l-1)+MENU1_SPRITE)
next l
show sprite (POINTER_SPRITE)
lx=(screen height()-16-((menuSize+1)*32))
repeat
cls 0
ink rgb(255,255,0),rgb(0,0,0)
line 0,_
lx,_
screen width(),_
lx
line 0,lx,0,screen height()-5
line 0,screen height()-5,screen width(),screen height()-5
line screen width()-1,screen height()-5,screen width()-1,lx
movePointer()
TEXT 0,0,str$(sprite collision(POINTER_SPRITE,0))
text 0,100,str$(mousey())
sync
until mouseclick()=1
select menu
case 1 : REM Main Menu
select sprite collision(POINTER_SPRITE,0)
case 2 : REM One Player Game
endcase
case 3 : REM Two Player Game
endcase
case 4 : REM Options
displayMenu(createMenu(4),4)
endcase
case 5 : REM Instructions
endcase
case 6 : REM Quit Program
endcase
endselect
endcase
endselect
endfunction
I'm using recursion to re-draw the menu. However, without the text command in createMenu routine, the program crashes...
Has anyone else had this problem ?
Yes, I really am THAT good...