home *** CD-ROM | disk | FTP | other *** search
- property obj, spriteNum, startpoint, endpoint, currentvector, ph, pv, vectorlist, vectorpos, displacement
-
- on beginSprite me
- obj = sprite(spriteNum)
- vectorlist = [[-110, 0], [0, -210], [110, 0], [0, 210]]
- vectorpos = 1
- startpoint = [obj.locH.float, obj.locV.float]
- endpoint = [startpoint[1] + vectorlist[vectorpos][1], startpoint[2] + vectorlist[vectorpos][2]]
- displacement = [endpoint[1] - startpoint[1], endpoint[2] - startpoint[2]]
- end
-
- on enterFrame me
- if vectorpos = 1 then
- ph = -1
- pv = 0
- else
- if vectorpos = 2 then
- ph = 0
- pv = -1
- else
- if vectorpos = 3 then
- ph = 1
- pv = 0
- else
- if vectorpos = 4 then
- ph = 0
- pv = 1
- end if
- end if
- end if
- end if
- obj.locH = obj.locH + ph
- obj.locV = obj.locV + pv
- startpoint = [obj.locH.float, obj.locV.float]
- displacement = [endpoint[1] - startpoint[1], endpoint[2] - startpoint[2]]
- thelength = sqrt((displacement[1] * displacement[1]) + (displacement[2] * displacement[2]))
- if thelength < 0.5 then
- vectorpos = vectorpos + 1
- if vectorpos > 4 then
- vectorpos = 1
- end if
- if vectorpos = 1 then
- obj.rotation = 0
- else
- if vectorpos = 2 then
- obj.rotation = 90
- else
- if vectorpos = 3 then
- obj.rotation = 180
- else
- if vectorpos = 4 then
- obj.rotation = -90
- end if
- end if
- end if
- end if
- startpoint = [obj.locH.float, obj.locV.float]
- endpoint = [startpoint[1] + vectorlist[vectorpos][1], startpoint[2] + vectorlist[vectorpos][2]]
- displacement = [endpoint[1] - startpoint[1], endpoint[2] - startpoint[2]]
- end if
- end
-