Jump to content

Photo

Sail Boat Script


  • Please log in to reply
84 replies to this topic

#16 Joe123

Joe123

    Retired

  • Members

Posted 29 January 2008 - 11:22 AM

How does triggering global variables give Link items? icon_eyebrow.gif

Edited by Joe123, 29 January 2008 - 11:22 AM.


#17 Zephlon

Zephlon

    Experienced Forumer

  • Members

Posted 29 January 2008 - 12:04 PM

They don't. The script itself does not give you any items.

#18 Joe123

Joe123

    Retired

  • Members

Posted 29 January 2008 - 12:32 PM

I can see that.

Why not?

#19 Zephlon

Zephlon

    Experienced Forumer

  • Members

Posted 29 January 2008 - 02:32 PM

Because Link eventually finds the item.

Back on topic:

I don't get it. Why won't the boat move!?

#20 Joe123

Joe123

    Retired

  • Members

Posted 29 January 2008 - 02:41 PM

CODE

ffc script boat{
    void run(){
    ffc link2 = Screen->LoadFFC(2);
    ffc water = Screen->LoadFFC(3);
        while(true){
            //Link->Action = LA_FROZEN;

            if(Link->InputUp){
                this->Vy = 1;
                link2->Vy = 1;
                water->Vy = 1;
            }
            if(Link->InputDown){
                this->Vy = -1;
                link2->Vy = -1;
                water->Vy = -1;
            }
            if(link2->Y > 152){this->Vy = 0; link2->Vy = 0; water->Vy = 0;}
            if(link2->Y < 16){this->Vy = 0; link2->Vy = 0; water->Vy = 0;}

        Waitframe();
        }
    }
}

Try that.

I haven't but I did change some rather unusual parts of the script.

Set on FFC 1:
The combo you want the boat to have
This script

#21 Zephlon

Zephlon

    Experienced Forumer

  • Members

Posted 29 January 2008 - 03:04 PM

icon_lol.gif How weird. All this time I thought it was the script. When I edited FFC #1, the script wasn't there.

Updated Script:
CODE
ffc script boat{
    void run(){
    ffc link2 = Screen->LoadFFC(2);
    ffc water = Screen->LoadFFC(3);
        while(true){
            //Link->Action = LA_FROZEN;
            if(link2->Y > 136){this->Vy = 0; link2->Vy = 0; water->Vy = 0;}
            if(link2->Y < 32){this->Vy = 0; link2->Vy = 0; water->Vy = 0;}
            if(Link->InputUp){
                this->Vy = -1;
                link2->Vy = -1;
                water->Vy = -1;
            }
            if(Link->InputDown){
                this->Vy = 1;
                link2->Vy = 1;
                water->Vy = 1;
            }
            if(Link->InputLeft || Link->InputRight){
                this->Vy = 0;
                link2->Vy = 0;
                water->Vy = 0;
            }
        Waitframe();
        }
    }
}


Now the boat will move up and down. Press left or right to make it stop moving.
There was a bug that wouldn't let you move the boat after it touched the top or bottom of the screen. But I fixed it.
Just a simple mater of moving
CODE
            if(link2->Y > 136){this->Vy = 0; link2->Vy = 0; water->Vy = 0;}
            if(link2->Y < 32){this->Vy = 0; link2->Vy = 0; water->Vy = 0;}

higher.


Edit: Now to make it jump. Any ideas?

Edited by Mega Link, 29 January 2008 - 03:32 PM.


#22 Joe123

Joe123

    Retired

  • Members

Posted 29 January 2008 - 03:44 PM

CODE
ffc script boat{
    void run(){
    ffc link2 = Screen->LoadFFC(2);
    ffc water = Screen->LoadFFC(3);
    bool upcheck;
        while(true){
            //Link->Action = LA_FROZEN;
            upcheck = false;

            if(Link->InputUp){
                this->Vy = -1;
                link2->Vy = -1;
                water->Vy = -1;
                upcheck = true;
            }else{
                this->Vy = 0;
                link2->Vy = 0;
                water->Vy = 0;
            }
            if(Link->InputDown && !upcheck){
                this->Vy = 1;
                link2->Vy = 1;
                water->Vy = 1;
            }else{
                this->Vy = 0;
                link2->Vy = 0;
                water->Vy = 0;
            }
            if(link2->Y > 136 && this->Vy > 0){this->Vy = 0; link2->Vy = 0; water->Vy = 0;}
            if(link2->Y < 32 && this->Vy < 0){this->Vy = 0; link2->Vy = 0; water->Vy = 0;}
        Waitframe();
        }
    }
}

Now it stops moving when you stop pressing the button.
I thought you wanted it to continue.
It'll also not be able to leave the screen, but it won't stop moving ever once it hits the edges.

And making it jump probably wouldn't be impossible.

Hrm.

I think you need to sort out barrel collision first though.

Edited by Joe123, 29 January 2008 - 03:45 PM.


#23 Zephlon

Zephlon

    Experienced Forumer

  • Members

Posted 29 January 2008 - 04:21 PM

It won't let me move up.

#24 Joe123

Joe123

    Retired

  • Members

Posted 29 January 2008 - 04:26 PM

CODE
ffc script boat{
    void run(){
    ffc link2 = Screen->LoadFFC(2);
    ffc water = Screen->LoadFFC(3);
    bool upcheck;
        while(true){
            //Link->Action = LA_FROZEN;
            upcheck = false;

            if(Link->InputUp){
                this->Vy = -1;
                link2->Vy = -1;
                water->Vy = -1;
                upcheck = true;
            }else{
                this->Vy = 0;
                link2->Vy = 0;
                water->Vy = 0;
            }
            if(Link->InputDown){
                this->Vy = 1;
                link2->Vy = 1;
                water->Vy = 1;
            }else{
                if(!upcheck){
                    this->Vy = 0;
                    link2->Vy = 0;
                    water->Vy = 0;
                }
            }
            if(link2->Y > 136 && this->Vy > 0){this->Vy = 0; link2->Vy = 0; water->Vy = 0;}
            if(link2->Y < 32 && this->Vy < 0){this->Vy = 0; link2->Vy = 0; water->Vy = 0;}
        Waitframe();
        }
    }
}


Sorry, I noticed that, then made a half-assed attempt to fix it in an edit, but I obviously didn't think it through properly.

#25 Zephlon

Zephlon

    Experienced Forumer

  • Members

Posted 29 January 2008 - 05:24 PM

It works now!

I decided to do the obstacles in a different, fairly easier way.

Woah! I messed up!
CODE
//D0 = combo # for Zora rising
//D1 = combo # for Zora diving
//D2 = combo # for Zora hit
ffc script boat{
    void run(int rise, int dive, int hit){
    ffc link2 = Screen->LoadFFC(2);
    ffc water = Screen->LoadFFC(3);
    bool upcheck;
    int zorapos;
    ffc zora1 = Screen->LoadFFC(4);
    ffc zora2 = Screen->LoadFFC(5);
    ffc zora3 = Screen->LoadFFC(6);
    bool zora;
    while(true){
        //Link->Action = LA_FROZEN;
        upcheck = false;

        if(Link->InputUp){
            this->Vy = -1;
            link2->Vy = -1;
            water->Vy = -1;
            upcheck = true;
        }else{
            this->Vy = 0;
            link2->Vy = 0;
            water->Vy = 0;
            }
            if(Link->InputDown){
            this->Vy = 1;
            link2->Vy = 1;
            water->Vy = 1;
        }else{
            if(!upcheck){
                this->Vy = 0;
                link2->Vy = 0;
                water->Vy = 0;
                }
            }
        if(link2->Y > 136 && this->Vy > 0){this->Vy = 0; link2->Vy = 0; water->Vy = 0;}
        if(link2->Y < 32 && this->Vy < 0){this->Vy = 0; link2->Vy = 0; water->Vy = 0;}
        Waitframe();
        int zorapos = Rand(3);
        if(zorapos == 1) {
            zora1->Data = rise;
            zora = true;
            Waitframes(200);
            zora1->Data = dive;
            zora = false;
            }
        if(zorapos == 2) {
            zora2->Data = rise;
            zora = true;
            Waitframes(200);
            zora2->Data = dive;
            zora = false;
            }
        if(zorapos == 3) {
            zora3->Data = rise;
            zora = true;
            Waitframes(200);
            zora3->Data = dive;
            zora = false;
            }
        }
    }
}


#26 Joe123

Joe123

    Retired

  • Members

Posted 29 January 2008 - 05:41 PM

You can't just wait for 200 frames in the middle of a script that's trying to do other things!

*sigh*

CODE
ffc script boat{
    void run(){
    ffc link2 = Screen->LoadFFC(2);
    ffc water = Screen->LoadFFC(3);
    bool upcheck;
        while(true){
            //Link->Action = LA_FROZEN;
            upcheck = false;

            if(Link->InputUp){
                this->Vy = -1;
                link2->Vy = -1;
                water->Vy = -1;
                upcheck = true;
            }else{
                this->Vy = 0;
                link2->Vy = 0;
                water->Vy = 0;
            }
            if(Link->InputDown){
                this->Vy = 1;
                link2->Vy = 1;
                water->Vy = 1;
            }else{
                if(!upcheck){
                    this->Vy = 0;
                    link2->Vy = 0;
                    water->Vy = 0;
                }
            }
            if(link2->Y > 136 && this->Vy > 0){this->Vy = 0; link2->Vy = 0; water->Vy = 0;}
            if(link2->Y < 32 && this->Vy < 0){this->Vy = 0; link2->Vy = 0; water->Vy = 0;}
        Waitframe();
        }
    }
}

ffc script barrel{
    void run(){
    bool go; int ran;
        while(true){
            ran = Rand(104) + 32;
            this->Y = ran;
            this->X = 256;
            this->Vx = -1;
            go = true;
            while(go){
                if(this->X < 8) go = false;
            Waitframe();
            }
        Waitframe();
        }
    }
}

Two scripts.
First one is the same as before, second one takes the ffc it's attacked to, sets it at a random Y position and at the far right of the screen, then makes it more to the left at 1 pixel per frame, then puts it back at the right when it gets to the left of the screen, and it goes round again.

If you want two barrels, just make two ffcs with the same script.
Just give it the correct graphic, and leave it in the top left of the screen, and check the 'Run Script on Screen Init.' FFC flag.

Try that out, and tell me if it works.

Is like where the boat is, or just in the corner of the screen at the moment?

Cause I'll need to know that to add the damage detection function.
At the moment, they won't do any damage, I just need to know if they work.


#27 Zephlon

Zephlon

    Experienced Forumer

  • Members

Posted 29 January 2008 - 05:52 PM

It works, but it is'nt very random. And the barrel moves a little too fast. (Just half its speed.)

And when there are multiple barrels, they move next to each other. Sometimes on each other.

Edited by Mega Link, 29 January 2008 - 05:54 PM.


#28 Joe123

Joe123

    Retired

  • Members

Posted 29 January 2008 - 06:03 PM

CODE


ffc script barrel{
    void run(){
    bool go; int ran;
        while(true){
            ran = Rand(180); //space out the barrels
            Waitframes(ran);
            
            ran = Rand(104) + 32; //put the barrel at a random Y coordinate
            this->Y = ran;
            this->X = 256;
            
            ran = (Rand(5)/10) + 0.25; // random speeds
            this->Vx = ran;
            go = true;

            while(go){
                if(this->X < 8) go = false;
            Waitframe();
            }

        }
    }
}

It's more random now.

Where are you putting Link on the screen?

Cause I need to know how to do the damage function

#29 Zephlon

Zephlon

    Experienced Forumer

  • Members

Posted 29 January 2008 - 07:29 PM

The barrels don't appear at all now. icon_frown.gif

Link is at (16,0).

#30 Joe123

Joe123

    Retired

  • Members

Posted 30 January 2008 - 03:18 AM

CODE
ffc script barrel{
    void run(){
    bool go; int ran; int orig = this->Data;

    this->Data = blanknonzerocombo;
    ran = Rand(120); //space out the barrels
    Waitframes(ran);
    this->Data = orig;
        while(true){
            ran = Rand(104) + 32; //put the barrel at a random Y coordinate
            this->Y = ran;
            this->X = 256;
            
            ran = (Rand(5)/10) + 0.25; // random speeds
            this->Vx = -ran;
            go = true;

            while(go){
                if(this->X < -16) go = false;
            Waitframe();
            }
        Waitframes(10);
        }
    }
}


That's the one.

The barrels might go on top of each other, if they do, tough luck.

EDIT: Oh, I haven't added collision detection yet, but I need to go to school now, I'll do it when I get home.

Edited by Joe123, 30 January 2008 - 03:19 AM.



0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users