Main Menu shows hiscore and player name input
function MenuMain()
HiScoreShow(Game.Level)
//---------------------------------------------
iTextIndex=CreateText("Level " + right("0"+str(Game.Level),2))
h=11
SetTextSize(iTextIndex,h)
SetTextAlignment( iTextIndex, 1 )
SetTextPosition( iTextIndex, x#,y#-h/2 )
FixTextToScreen( iTextIndex, 1 )
SetTextDepth( iTextIndex, 0 )
SetTextColor(iTextIndex,255,255,255,255)
//--------------------------------------------- Player Name
iName=CreateText("Player :")
h=8
SetTextSize(iName,h)
SetTextAlignment( iName, 0 )
SetTextPosition( iName, 10,10 )
FixTextToScreen( iName, 1 )
SetTextDepth( iName, 0 )
SetTextColor(iName,255,255,255,255)
iNameEdit=createeditbox()
FixEditBoxToScreen(iNameEdit,1)
SetEditBoxBorderColor(iNameEdit,128,128,128,128)
SetEditBoxDepth(iNameEdit,0)
SetEditBoxPosition(iNameEdit,4.5*10,10-1)
SetEditBoxSize(iNameEdit,6*12,10)
SetEditBoxFontImage(iNameEdit,imgFont)
SetEditBoxExtendedFontImage(iNameEdit,imgFont)
SetEditBoxBorderSize(iNameEdit,1)
SetEditBoxCursorBlinkTime(iNameEdit,1)
SetEditBoxBackgroundColor(iNameEdit,255,255,255,128)
SetEditBoxTextColor(iNameEdit,255,255,255)
SetEditBoxTextSize(iNameEdit, h )
SetEditBoxMaxChars(iNameEdit,12)
SetEditBoxText(iNameEdit,Player.Name$)
SetEditBoxCursorColor(iNameEdit,255,255,255)
SetEditBoxCursorWidth(iNameEdit,2)
SetEditBoxBackgroundImage(iNameEdit,imgWater10)
do
...
Sync()
loop
Player.Name$=getEditBoxText(iNameEdit)
if len(Player.Name$)=0 then Player.Name$="?"
deletetext(iName)
deleteeditbox(iNameEdit)
HiScoreHide()
endfunction ret
HiScore Modul
type THiScore
Name$
Score
endtype
global hiangle#
function HiScoreShow(LevelNr)
h=8
x=getvirtualwidth()/4-20 //- Manual/2
y=getvirtualheight()/2-5*h
For i=0 To 10
if i=>1
a$=str(i) + " " + right("000000" + str(HiScore[LevelNr,i].Score),6) + " " + HiScore[LevelNr,i].Name$
endif
if i=0 then a$="High Score Level "+str(LevelNr)
createtext(i,a$)
FixTextToScreen(i,1)
setTextSize(i,h)
if i=0
w#=GetTextTotalWidth(i)
x=x-w#/2.0
endif
SetTextExtendedFontImage(i,imgFont)
SetTextFontImage(i,imgFont)
SetTextDepth( i, 1 )
SetTextPosition(i,x -(i=10)*5.4 ,y+i*h-h)
next
endfunction
function HiScoreAngle() //unbenutzt
hiangle#=hiangle#+45.0/60.0
if hiangle#>360.0 then hiangle#=hiangle#-360.0
for i=1 to 10
charangle#=sin(hiangle#+i*45.0)*10.0
for c=0 to GetTextLength(i)-1
setTextCharAngle(i,c,charangle#)
next
next
endfunction
function HiScoreHide()
For i=0 To 10
deletetext(i)
next
endfunction
function HiScoreDraw(LevelNr)
For i=1 To 10
a$=right("000000" + str(HiScore[LevelNr,i].Score),6) + " " + HiScore[LevelNr,i].Name$
print(a$)
next
endfunction
Function HiScorePlayer(LevelNr)
If Player.Score=0 Then exitfunction
For i=1 To 10
If Player.score => HiScore[LevelNr,i].score
If i<10
For i1=10-1 To i Step -1
HiScore[LevelNr,i1+1].Name$ = HiScore[LevelNr,i1].Name$
HiScore[LevelNr,i1+1].Score = HiScore[LevelNr,i1].Score
Next
EndIf
HiScore[LevelNr,i].Name$=Player.Name$
HiScore[LevelNr,i].Score=Player.Score
Exit
EndIf
Next
EndFunction
Function HiScoreSave()
f=OpenToWrite("HiScore.TXT",0)
WriteString(f,"... HiScore List !")
For l=1 To 99
For i=1 To 10
WriteString(f,HiScore[l,i].Name$)
WriteInteger(f,HiScore[l,i].Score)
Next
next
CloseFile(f)
EndFunction
Function HiScoreLoad()
If GetFileExists("HiScore.TXT")=0
For l=1 To 99
For i=1 To 10
HiScore[l,i].Name$="--------"
HiScore[l,i].Score=0
Next
Next
else
f=OpenToRead("HiScore.TXT")
a$=ReadString(f)
For l=1 To 99
For i=1 To 10
HiScore[l,i].Name$=ReadString(f)
HiScore[l,i].Score=ReadInteger(f)
Next
next
CloseFile(f)
EndIf
EndFunction
type TGame
Level as integer
endtype
global Game as TGame
type TPlayer
Name$
Health as integer
Lives as integer
Score as integer
...
endtype
Config
function ConfigSave()
File$="Config.txt"
f=OpenTowrite(File$,0)
if f
WriteString ( f, Player.Name$ )
Writeinteger( f, Game.Level)
closefile(f)
endif
endfunction
function ConfigLoad()
File$="Config.txt"
if GetFileExists( File$ ) =0 then exitfunction
f=OpenToRead(File$)
if f
Player.Name$ = readString (f)
Game.Level = readinteger(f)
closefile(f)
endif
endfunction
AGK (Steam) V2017.08.16 : Windows 10 Pro 64 Bit : AMD (17.7.2) Radeon R7 265 : Mac mini OS Sierra (10.12.2)