' Empty GUI script created on 09-18-2013/09-26-2013 13:00:25 by largo_winch/maurice_fischer(thinAir)
' version 1kk
Uses "UI" ', "console"
#MINVERSION 1.8.8.0
Begin ControlID
%MY_TIMER = 500
%pause
%start
%continue
%myCanvas
%btnClose
%score
%energy=150
%ctimer
End ControlID
Global hDlg As Long, continue As Long
Function TBMain () As Long
Dialog New Pixels, 0, "Image+Synchronize_Animation 1k",-1,-1, 460,400, %WS_OVERLAPPEDWINDOW To hDlg
Control Add Button, hDlg, %pause, "pause", 110,10,70,24
Control Add Button, hDlg, %start, "step", 280,10,70,24
Control Add Textbox, hDlg, %energy, "energy_55%", 350,10,90,24, %WS_BORDER Or %WS_TABSTOP
Control Set Color, hDlg,%energy,Rgb(0,0,0),Rgb(250,0,0)
Control Add Button, hDlg, %continue, "continue", 190,10,70,24
Control Add Canvas, hDlg, %myCanvas, "", 10,40,440,350, %WS_BORDER
Control Add Button, hDlg, %btnClose, "Click to close", 20,10,80,24 Call btnCloseProc
Canvas_Attach hDlg, %myCanvas,%TRUE
Dialog Show Modal hDlg, Call DlgProc
End Function
CallBack Function DlgProc() As Long
Static myTimer As cTimer
myTimer = New cTimer()
myTimer.Start
Select Case CBMSG
Case %WM_INITDIALOG
Dialog Set Timer CBHNDL, %MY_TIMER, %pause : continue = 1
Case %WM_COMMAND
Select Case CBCTL
Case %pause : continue = 0
Case %continue : continue = 1
Case %start : moveBoxImage()
End Select
Case %WM_TIMER
If continue Then MoveBoxImage
Dialog Set Text hDlg, "Image+Synchronize 1k " + Time$
Case %WM_DESTROY
Dialog Kill Timer CBHNDL, %MY_TIMER
End Select
End Function
Sub MoveBoxImage()
Local x,y,gameover As Long 'level,
Static level As Long
Static score As Long
Static energy As Long
Static vx As Double
Static vy As Double
Static yPush As Double
Local sImageSmall As String = APP_SourcePath+ "woman1a.bmp"
Local sImageBackground As String = APP_SourcePath+"woman1.bmp"
Local nWidth, nHeight As Long
'Local myTimer As cTimer
Static myTimer As cTimer
myTimer = New cTimer()
myTimer.Start
level = 1
'GetAsyncKeyState(-1)
Canvas_BitmapGetFileInfo(sImageBackground, nWidth, nHeight)
Canvas_Clear
vx=Rnd(10,150)
If vx=>68 And vx<=72 Then
energy+=5 'energy=energy-15
'score+=10
Score =score+10*level
level = Int(score/10+1)
Control Set Text, hDlg, %energy,"energy_lost: "+Format$(energy)
MsgBox 0,"x: near target "+Str$(vx)
Sleep 150
End If
If energy >= 55 And vx => 68 Then
Control Set Text, hDlg, %energy,"%energy_lost: "+Format$(energy)
Dialog Kill Timer hDlg, %MY_TIMER
MsgBox 0, "energy lost, game_over"
Dialog End hDlg
End If
vy=Rnd(10,150)
If vy=>18 And vy <=22 Then
score+=10
energy+=5
level = Int(score/10+1)
Control Set Text, hDlg, %energy,"energy_lost: "+Format$(energy)
Sleep 150
MsgBox 0,"y: near target "+Str$(vy)
End If
If energy >= 55 And vy => 18 Then
Control Set Text, hDlg, %energy,"energy_lost: "+Format$(energy)
Dialog Kill Timer hDlg, %MY_TIMER
MsgBox 0, "energy lost, game_over"
Dialog End hDlg
End If
'--------------- target ------------------
If vx=70 And vy=19 Then
MsgBox 0, "you've won!"
score += 100 : Beep
energy+= 100 : Beep
End If
'--------------- target ------------------
If myTimer.Elapsed(%CTIMER_SECONDS) >= 0.880 Then
MsgBox 0, "times-Up, you have Level " & level & " Score of " & score
End If
If GetAsyncKeyState(%VK_ESCAPE) Then
Dialog End hDlg
End If
Canvas_BitmapRender(sImageBackground)
Canvas_SetPos(vx,vy)
Canvas_Font "Comic Sans MS", 12, 0
Canvas_SetPos(vx,vy)
Canvas_Scale Pixels
Canvas_Print ""+Str$(vx)+","+Str$(vy)
Canvas_BitmapRender(sImageSmall)
Canvas_Color(Rgb(255,10,100))
Canvas_SetPos(20,320)
Canvas_Color %YELLOW, %BLACK
Canvas_SetPos(60, 320)
Canvas_Print(" Level " & level & " Score " & Format$(score) & " Time " & myTimer.ElapsedToString(%CTIMER_SECONDS, "#0.0000")) '"0"
Canvas_Redraw
End Sub
CallBack Function btnCloseProc()
If CBMSG = %WM_COMMAND Then
If CBCTLMSG = %BN_CLICKED Then
Dialog End CBHNDL
End If
End If
End Function
bye, largo
Bookmarks