elikkäs tässä koodi
Code: Select all
Type BULLETS
Field obj
End Type
FrameLimit 40
ClearText
CloseInput
ClearObjects
ruoho = MakeObjectFloor ()
nurmikko = LoadImage ("Media\ruoho.bmp")
PaintObject ruoho, nurmikko
map= LoadMap("media/cdm2.til","media/tiles.png")
PlayObject map,0,0,0.5
guy= LoadObject("Media\ukko.bmp",72)
vihu= LoadObject("media\vihu.bmp",72)
SetupCollision guy,map,2,4,2
SetupCollision vihu,map,2,4,2
hp = LoadObject("media/hp house.bmp")
nuoli=LoadObject ("media/nuoli.bmp",360)
auto = LoadObject ("Media\auto.bmp",72)
PositionObject guy,-300,180
PositionObject hp,-300,100
PositionObject auto,-100,550
SetupCollision auto,map,2,4,2
SetupCollision auto,hp,2,4,2
bullet=LoadObject("Media\bullet.bmp")
ShowObject bullet,OFF
Repeat
CloneObjectPosition nuoli,guy
PointObject nuoli,vihu
MoveObject vihu,1
PointObject vihu,guy
DrawGame
Text 0,0,"elämä :" + elama
If ObjectsOverlap(vihu,guy,2) Then
elama -1
EndIf
If ObjectsOverlap(guy,hp,2)And autossa = 0 Then
goto hp
EndIf
If elama = -2 Then Goto loppu
Color cbwhite
Text 10,50,FPS()
If autossa=1 Then
CloneObjectPosition guy,auto
ShowObject guy,OFF
MoveObject auto,(UpKey()-DownKey())*4
TurnObject auto,(LeftKey()-RightKey())* (UpKey() -DownKey())*3
If KeyHit(cbkeyreturn) Then autossa=0
Else
ShowObject guy,ON
If LeftKey() Then TurnObject guy,5
If RightKey() Then TurnObject guy,-5
If UpKey() Then MoveObject guy,5
If DownKey() Then MoveObject guy,-5
If Distance2(guy,auto)<70 And KeyHit(cbkeyreturn) Then autossa=1
EndIf
If KeyDown(cbkeyspace) And reload=0
newBullet.BULLETS= New(BULLETS)
newBullet\obj=CloneObject(bullet)
CloneObjectPosition newBullet\obj,guy
CloneObjectOrientation newBullet\obj,guy
MoveObject newBullet\obj,24
reload=4
EndIf
i=0
For iBullet.BULLETS= Each BULLETS
MoveObject iBullet\obj,6
If Distance2(iBullet\obj,guy)>200 Then
DeleteObject iBullet\obj
Delete iBullet
EndIf
i=i+1
Next iBullet
If reload>0 Then reload=reload-1
Return
CloneCameraPosition guy
DrawScreen
Until EscapeKey()