Re: Tyhmät kysymykset (I/2010)
Posted: Thu Jan 06, 2011 10:47 pm
siinä koodisi korjattuna ja objektilla tehty
Code: Select all
FrameLimit 40 'rajoita nopeutta
SCREEN 800,600
Include "sdk/include/cbMap.cb"
MapLoad("Media\cdm2.til","Media\tileset.bmp")
PlayObject gCurrentMap,0,0,1
ukko = LoadObject ("Media\guy.bmp",72)
ukko2=CloneObject(ukko)
haamu=MakeObject()
SetupCollision ukko,gCurrentMap,2,4,2
SetupCollision ukko2,gCurrentMap,2,4,2
PositionObject ukko2,0,200
done=1
Repeat
'Ukon ohjaus
If LeftKey() Then TurnObject ukko,5
If RightKey() Then TurnObject ukko,-5
If UpKey() Then MoveObject ukko,3
If DownKey() Then MoveObject ukko,-3
If ObjectSight (ukko,ukko2) And done=1 Then
lastseenx=(ObjectX(ukko))
lastseeny=(ObjectY(ukko))
PointObject ukko2,ukko
Else
PositionObject haamu,lastseenx,lastseeny
PointObject ukko2,haamu
If ObjectsOverlap(ukko2,haamu) Then
done=1
Else
done=0
EndIf
EndIf
MoveObject ukko2,2
DrawGame
Text 0,0, Int(GetAngle2(ukko,ukko2))
Text 0,20, Int(ObjectAngle(ukko2))
CloneCameraPosition ukko
DrawScreen
Forever