Taas on tekoälyn kanssa ongelmia. Siis:
Code: Select all
'============================'
'========BulletStorm========='
'============================'
Valikko:
SCREEN 800,600
SetWindow "BulletStorm"
tausta = LoadObject ("gfx\tausta.png")
aloitus_nappula = LoadObject ("gfx\aloita.png")
lopetus_nappula = LoadObject ("gfx\poistu.png")
aloitus_pohj = LoadObject ("gfx\aloita2.png")
ShowObject aloitus_pohj, OFF
lopetus_pohj = LoadObject ("gfx\poistu2.png")
ShowObject lopetus_pohj, OFF
hiiri = LoadObject("gfx\aim.png")
click = LoadSound ("sfx\click.wav")
PositionObject aloitus_nappula, -345, 0
PositionObject lopetus_nappula, -345,-50
PositionObject aloitus_pohj, -345, 0
PositionObject lopetus_pohj, -345, -50
Repeat
ShowMouse OFF
PositionObject hiiri,MouseWX(),MouseWY()
If ObjectsOverlap (aloitus_nappula,hiiri) And MouseHit(1) Then
PlaySound click
Goto peli
ElseIf ObjectsOverlap (lopetus_nappula,hiiri) And MouseHit(1) Then
PlaySound click
Wait 800
End
ElseIf ObjectsOverlap (aloitus_nappula, hiiri) Then
ShowObject aloitus_nappula, OFF
ShowObject aloitus_pohj, ON
ElseIf ObjectsOverlap (lopetus_nappula, hiiri) Then
ShowObject lopetus_nappula, OFF
ShowObject lopetus_pohj, ON
ElseIf ObjectsOverlap (aloitus_nappula, hiiri) = False Then
ShowObject aloitus_nappula, ON
ShowObject aloitus_pohj, OFF
EndIf
If ObjectsOverlap (lopetus_nappula, hiiri) = False Then
ShowObject lopetus_nappula, ON
ShowObject lopetus_pohj, OFF
EndIf
DrawScreen
Until EscapeKey()
Peli:
Type LUODIT
Field obj
EndType
Type VIHUT
Field vihu1
Field vihu2
Field pati
Field enut
EndType
'============================
FrameLimit 40
SCREEN 800, 600
SetWindow "BulletStorm"
//Muuttujat:
health# = 100
ammukset = 30
//Health Bar:
healthbar = LoadImage ("gfx\healthbar.png")
//Lataa pelaaja:
pelaaja = LoadObject ("gfx\soldier.png", 72)
//Lataa vihut:
vihu = LoadObject ("gfx\sissi.png", 72)
ShowObject vihu, OFF
//Lataa luoti ja tee siitä näkymätön:
luoti = LoadObject ("gfx\luoti.png")
ShowObject luoti, OFF
//Lataa kaikki äänet:
lataus = LoadSound ("sfx\reload.wav")
sig = LoadSound ("sfx\sig.wav")
ak47 = LoadSound ("sfx\ak47.wav")
//Lataa hiiren kuvake/tähtäin:
tähtäin = LoadImage ("gfx\aim.png")
//Lataa mappi ja sen textuuri:
maailma = LoadMap ("world\woods.til","world\tilesetwoods.png")
PlayObject maailma, 0, 0, 0, 5
MaskObject maailma, 255, 0, 252
PositionObject vihu, 300, 0
SetupCollision pelaaja,maailma,2,4,2
SetupCollision vihu,maailma,2,4,2
SetupCollision pelaaja,vihu,2,2,2
SetupCollision vihu,pelaaja,2,2,2
CameraFollow pelaaja, 1, 70
Repeat
ObjectOrder maailma, -1
RotateObject pelaaja, GetAngle(ObjectX(pelaaja),-ObjectY(pelaaja),MouseWX(),-MouseWY())//Pelaaja osoittaa tähtäintä
ShowMouse tähtäin//Näyttää hiiren, tässä tapauksessa tähtäimen
//Liikkuminen
If UpKey() Then MoveObject pelaaja, 5
If DownKey() Then MoveObject pelaaja, -3
//Ampuminen
If MouseDown(1) And reload=0
newLuoti.LUODIT = New(LUODIT)
newLuoti\obj = CloneObject(luoti)
RotateObject newLuoti\obj, ObjectAngle (pelaaja)
CloneObjectPosition newLuoti\obj, pelaaja
CloneObjectOrientation newLuoti\obj, pelaaja
MoveObject newLuoti\obj, 24
PlaySound sig
ammukset -1
//Ammutaan 30 luotia, odotetaan ja ammutaan uudestaan
If ammuttu >= 30 Then ammuttu = 0
ammuttu + 1
If ammuttu >= 30 Then reload = 100 Else reload=6.5 'aseen lataus
If ammuttu >= 30 Then PlaySound lataus
If ammuttu >= 30 Then ammukset + 30
EndIf
i = 0
For iLuoti.LUODIT = Each LUODIT
MoveObject iLuoti\obj, 10//vauhti = 6
//poistaa luodin jos se menee
//liian kauas
If Distance2(iLuoti\obj,pelaaja)>400 Then
DeleteObject iLuoti\obj
Delete iLuoti
ElseIf GetMap (2, ObjectX(iLuoti\obj), objectY(iLuoti\obj)) Then
DeleteObject iLuoti\obj
Delete iLuoti
ElseIf ObjectsOverlap (iLuoti\obj, vihu, 3) Then
DeleteObject iLuoti\obj
Delete iLuoti
EndIf
i=i+1
Next iLuoti
If reload >0 Then reload=reload -1
If ObjectVision (vihu,pelaaja, 75, 500) Then
PointObject vihu, pelaaja
MoveObject vihu, 2
ShowObject vihu, ON
ElseIf ObjectVision (pelaaja,vihu, 75, 500) Then
ShowObject vihu, ON
ElseIf Distance2 (vihu, pelaaja) =<150 Then
MoveObject vihu, 2
PointObject vihu, pelaaja
EndIf
If SoundPlaying (sig) And Distance2 (pelaaja, vihu) <350 Then
PointObject vihu, pelaaja
MoveObject vihu, 2
EndIf
DrawGame
//Tehdään Health Bar
Color 0, 163, 255
Box 630,540,health,14.5
DrawImage healthbar, 625, 482
Text 675, 510, "" + ammukset
UpdateGame
DrawScreen
Forever
Function ObjectVision( _obj, _obj2, _fov = 90, _dist = 1000 )
If Distance2( _obj, _obj2 ) < _dist And ObjectSight( _obj, _obj2 ) Then
_angle = WrapAngle( ( GetAngle2( _obj, _obj2 ) - ObjectAngle( _obj ) ) )
_sight = _fov / 2
If _angle < _sight Or _angle > 360 - _sight Then
Return True
EndIf
EndIf
End Function