Btw, tässä minun pikku peli:
Code: Select all
Const Gravity = 0.225
Dim x#, y#, prevx#, prevy#
SCREEN 800, 600
fontbig = LoadFont("Arial", 22, True)
fontsmall = LoadFont("Arial", 15, True)
Gosub sub_start
SetFont fontsmall
tryagain$ = "Press mouse left button to try again."
tx = - TextWidth(tryagain)
Repeat
If GameOver = False Then
dx# = (x# - MouseX())
dy# = (y# - MouseY())
d# = Sqrt(dx#^2 + dy^2)
multiplier# = (d# - 120) / d#
x# = x# - dx# * 0.5 * multiplier#
y# = y# - dy# * 0.5 * multiplier#
Line MouseX(), MouseY(), x#, y#
If x# < 0 Or x# > ScreenWidth() Then GameOver = True : Reason = 1 : EndingTime = Timer() - startTime
tmpx# = x#
x# = 2 * x# - prevx#
prevx# = tmpx
tmpy# = y#
y# = 2 * y# - prevy# + Gravity
prevy# = tmpy
Text 0, 0, "Don't let stick fall!"
Text 0, 15, Replace("Try_to hold whole stick inside the_screen", "_", " ")
Text 0, 30, "Time survived: "+(Timer() - startTime)
If y# > (MouseY() + 119) Then
GameOver = True
EndingTime = Timer() - startTime
EndIf
Else
SetFont fontbig
CenterText 400, 300, "Game over!", 2
SetFont fontsmall
CenterText 400, 320, "You survived: "+EndingTime/1000+" seconds"
If Reason Then
CenterText 400, 335, Replace("Part of stick went outside of the_screen area!", "_", " ")
EndIf
tx = tx + plusx
If tx > 400 Then
plusx = 0
If MouseHit(1) Then Gosub sub_start : GameOver = False
Else
plusx = 5
EndIf
CenterText tx, 350, tryagain
EndIf
DrawScreen
Forever
sub_start:
PositionMouse 400, 300
startTime= Timer()
x# = MouseX() + Rnd(-0.1, 0.1)
y# = MouseY() - 120
prevx# = MouseX() + Rnd(-0.5, 0.5)
prevy# = MouseY() - 120
Return