(include "sci.sh")
(use "Main")
(use "eureka")
(use "Cycle")
(use "Sounds")
(use "View")
(use "Obj")
(script 222)


(local
    local0
    local1
    local2

)
(procedure (localproc_003c)
    (var temp0)
    = temp0 1
    (while (< temp0 40)
        (send ((star:new())):init())
        ++temp0
    )
    (star:init())
)


(instance public rm222 of Rm
    (properties
        picture 55
        style rm222
    )

    (method (init)
        (send gRoom:setRegions(210))
        (send gSQ5:handsOff())
        localproc_013c()
        (self:setScript(sGoliathApproach))
        (super:init())
    )

)
(instance sEurekaRuns of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (= seconds 2  )
            )
            (case 1
                ((eurekaShip:setCycle(End self))  )
            )
            (case 2
                ((eurekaShip:setMotion(MoveTo 185 72 self))  )
            )
            (case 3
                (= gEurekaCurLocation 15 (eureka:
                    curLocation(15)
                    state(3)
                )
 (send gRoom:newRoom(201)) (self:dispose()) )
            )
        )
    )

)
(instance sGoliathApproach of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                ((leadStar:init())  )
            )
            (case 1
                (
                (if (proc0_1(42))
                    (send gRoom:newRoom(201))
                )(else
                    = next sEurekaRuns
                )
 (self:dispose()) )
            )
        )
    )

)
(instance star of Actor
    (properties
        view 217
        priority 4
        signal 24576
        moveSpeed 0
    )

    (method (init param1)
        (var temp0, temp1, temp2, temp3)
        = temp0 Random(50 160)
        = temp2 (+ 155 CosMult((= temp1 Random(0 359)) temp0))
        (self:
            illegalBits(0)
            posn(temp2 = temp3 (+ 78 SinMult(temp1 temp0)))
            setLoop(Random(0 2))
            setCel(Random(0 3))
            heading(135)
            setCycle(0)
            setPri(4)
        )
        (super:init(rest param1))
    )


    (method (doit param1)
        (if (local1)
            (self:
                x(+ x 
                    (if ((< cel 2) and (== loop 2))
                        4
                    )(else
                        2
                    )
)
                y(+ y 
                    (if ((< cel 2) and (== loop 2))
                        4
                    )(else
                        2
                    )
)
            )
            (if ((> x 320) or (> y 200))
                (self:
                    x(- x 320)
                    y(- y 200)
                )
            )
        )(else
            (if (local2)
                (self:
                    x(+ x 
                        (if ((< cel 2) and (== loop 2))
                            4
                        )(else
                            2
                        )
)
                    y(+ y 
                        (if ((< cel 2) and (== loop 2))
                            2
                        )(else
                            1
                        )
)
                )
                (if ((> x 320) or (> y 200))
                    (self:
                        x(- x 320)
                        y(- y 200)
                    )
                )
            )(else
                (if (local0)
                    (self:x((+ x 
                        (if ((< cel 2) and (== loop 2))
                            4
                        )(else
                            2
                        )
)))
                    (if (> x 319)
                        (self:x((- x 319)))
                    )
                )
            )
        )
        (super:doit(rest param1))
    )

)
(instance leadStar of Actor
    (properties
        view 217
        priority 4
        signal 24576
        moveSpeed 0
    )

    (method (init param1)
        (super:init(rest param1))
        = local1 1
    )


    (method (doit param1)
        (if (local1)
            (self:
                x(+ x 6)
                y(+ y 6)
            )
            (if ((> x 320) and (> y 200))
                = local1 0
                = local2 1
                (self:
                    x(0)
                    y(0)
                )
            )
        )(else
            (if (local2)
                (self:
                    x(+ x 6)
                    y(+ y 3)
                )
                (if (> x 319)
                    = local2 0
                    = local0 1
                    (self:
                        x(0)
                        y(0)
                    )
                )
            )(else
                (if (local0)
                    (eurekaShip:init())
                    (asteroids:init())
                    (self:dispose())
                )
            )
        )
        (super:doit(rest param1))
    )

)
(instance eurekaShip of Actor
    (properties
        x 65533
        y 72
        view 2242
        loop 1
        priority 5
        signal 24576
        cycleSpeed 2
    )

    (method (doit param1)
        (if (local0)
            (if (< x 236)
                (self:x((+ x 3)))
            )(else
                = local0 0
                (sGoliathApproach:cue())
            )
        )
        (super:doit(rest param1))
    )

)
(instance asteroids of Actor
    (properties
        x 65366
        y 62
        view 2242
        priority 5
        signal 24576
    )

    (method (doit param1)
        (if (local0)
            (self:x((- (eurekaShip:x) 167)))
        )
        (super:doit(rest param1))
    )

)
