Code: Select all
FrameLimit 60
SCREEN 400,400
SetWindow "Pikkuräiskintä",0,"Haluatko varmasti lopettaa?"
SAFEEXIT OFF
Dim weap (1) As String
weap (0) = "konekivääri"
weap (1) = "haulikko"
Type enemies
Field x As Float
Field y As Float
Field a As Float
Field hp
Field r
Field t
End Type
Type bullets
Field x As Float
Field y As Float
Field a As Float
Field l
End Type
Type blood
Field obj
Field age
End Type
veri = MakeImage (1,1)
DrawToImage veri
Color cbred
Dot 0,0
DrawToScreen
Valikko:
DrawToWorld OFF
Repeat
Color cbgreen
For i = 1 To 400 Step 3
For j = 1 To 400 Step 3
Dot i,j
Next j
Next i
Color cbblack
Box 50,50,155,50
Color 0,255,0
Box 50,50,155,50,0
Text 70,60,"Pikkuräiskintä"
Text 70,80, "Tehnyt Mickey"
For i = 0 To 400 Step 20
Color cbblack
Box 370,i,15,15
Color 0,255,0
Box 370,i,15,15,0
Next i
If MouseY () < 201 Then
For i = -10 To 400 Step 20
Color cbblack
Box i,180,15,15
Color 0,255,0
Box i,180,15,15,0
Next i
Box 370,180,15,15
Color 0,255,0
Box 50,180,155,15
Color cbblack
CenterText 52,186,"Aloita peli",1
Box 50,200,155,15
Color 0,255,0
Box 50,200,155,15,0
CenterText 52,206,"Lopeta",1
If MouseHit (1) Then Exit
EndIf
If MouseY () > 200 Then
For i = -10 To 400 Step 20
Color cbblack
Box i,200,15,15
Color 0,255,0
Box i,200,15,15,0
Next i
Color cbblack
Box 50,180,155,15
Color 0,255,0
Box 50,180,155,15,0
CenterText 52,186,"Aloita peli",1
Color 0,255,0
Box 370,200,15,15
Color 0,255,0
Box 50,200,155,15
Color cbblack
CenterText 52,206,"Lopeta",1
If MouseHit (1) Then End
EndIf
DrawScreen
Forever
DrawToWorld ON
Const r = 5
hp = 100
ajas = Timer () - 3000
w = 0
x = 0
y = 0
k = 0
Repeat
Color 0,255,0
Text 0,0,"Elämä: "+hp
Text 0,10,"Ase: "+weap (w)
Text 0,20,"Tapot: "+k
Color cbred
reload - 1
If Timer () > ajas + 5000 Then
ajas = Timer ()
vihu.enemies = New (enemies)
vihu\a = GetAngle (vihu\x,vihu\y,x,y)
vihu\hp = 10
vihu\r = 25
vihu\t = Rand (1)
s = Rand (1,4)
Select s
Case 1
vihu\x = -200
vihu\y = 0
Case 2
vihu\x = 200
vihu\y = 0
Case 3
vihu\x = 0
vihu\y = -200
Case 4
vihu\x = 0
vihu\y = 200
End Select
EndIf
x = x + (RightKey () - LeftKey ())
x = Min (x,200)
x = Max (x,-200)
y = y + (UpKey () - DownKey ())
y = Min (y,200)
y = Max (y,-200)
If MouseHit (2) Then w = Not w
Select w
Case 0
If reload < 0 And MouseDown (1) Then
reload = 5
pauk.bullets = New (bullets)
pauk\x = x
pauk\y = y
pauk\a = GetAngle (x,y,MouseWX (),MouseWY ())
pauk\l = 1
EndIf
Case 1
If reload < 0 And MouseHit (1) Then
reload = 55
For i = -5 To 5
pauk.bullets = New (bullets)
pauk\x = x
pauk\y = y
pauk\a = (GetAngle (x,y,MouseWX (),MouseWY ()))+i
pauk\l = 1
Next i
EndIf
End Select
For vihu.enemies = Each enemies
vihu\r - 1
vihu\a = CurveAngle (GetAngle (vihu\x,vihu\y,x,y),vihu\a,10)
vihu\x = vihu\x + Cos (vihu\a)*0.5
vihu\y = vihu\y - Sin (vihu\a)*0.5
Circle2 (vihu\x,vihu\y,r,1)
If vihu\r < 0 Then
Select vihu\t
Case 0
vihu\r = 5
pauk.bullets = New (bullets)
pauk\x = vihu\x
pauk\y = vihu\y
pauk\a = GetAngle (vihu\x,vihu\y,x,y)
pauk\l = 0
Case 1
vihu\r = 55
For i = -5 To 5
pauk.bullets = New (bullets)
pauk\x = vihu\x
pauk\y = vihu\y
pauk\a = (GetAngle (vihu\x,vihu\y,x,y))+i
pauk\l = 0
Next i
End Select
EndIf
If vihu\hp < 0 Then
k + 1
emit.blood = New (blood)
emit\obj = MakeEmitter (veri,10)
ParticleEmission emit\obj,0,20,180
ParticleMovement emit\obj,2,0
PositionObject emit\obj,vihu\x,vihu\y
Delete vihu
EndIf
Next vihu
Color cbwhite
Circle2 (x,y,r,1)
For pauk.bullets = Each bullets
pauk\x = pauk\x +Cos (pauk\a)*3
pauk\y = pauk\y -Sin (pauk\a)*3
Select pauk\l
Case 1
Color cbwhite
Dot pauk\x,pauk\y
For vihu.enemies = Each enemies
If Distance (pauk\x,pauk\y,vihu\x,vihu\y) < r + 1 Then
Delete pauk
vihu\hp-1
EndIf
Next vihu
Case 0
Color cbred
Dot pauk\x,pauk\y
If Distance (pauk\x,pauk\y,x,y) < r + 1 Then
Delete pauk
hp-1
EndIf
End Select
Next pauk
For pauk.bullets = Each bullets
If OutScreen (pauk\x,pauk\y) Then Delete pauk
Next pauk
For emit.blood = Each blood
emit\age + 1
If emit\age > 10 Then DeleteObject emit\obj : Delete emit
Next emit
DrawScreen
If EscapeKey () Then Goto valikko
If hp <1 Then Goto loppu
Forever
loppu:
For vihu.enemies = Each enemies
Delete vihu
Next vihu
For pauk.bullets = Each bullets
Delete pauk
Next pauk
For emit.blood = Each blood
Delete emit
Next emit
DrawToScreen
Color cbgreen
For i = -200 To 200 Step 3
For j = -200 To 200 Step 3
Dot i,j
Next j
Next i
Color cbblack
Box -120,25,240,50
Color 0,255,0
Box -120,25,240,50,0
CenterText 200,185,"Sait "+k+" tappoa"
CenterText 200,205,"Paina mitä tahansa näppäintä"
DrawScreen
WaitKey
Goto valikko
Function Circle2(x#, y#, r#, fill=0)
Circle x - r, y + r, r * 2, fill
EndFunction
Function OutScreen (x,y)
If x < -(ScreenWidth ()/2) Or x > (ScreenWidth ()/2) Or y < -(ScreenHeight ()/2) Or y > (ScreenHeight ()/2) Then Return 1
Return 0
End Function
Pikku vinkki: vaikka aseet ovat käytännössä yhtä tehokkaat, suosittelen käyttämään haulikkovihuja vastaan konekivääriä ja toisinpäin. Oma ennätykseni on yli 100 tappoa.