Jump to content

Photo

Sail Boat Script


  • Please log in to reply
84 replies to this topic

#61 Zephlon

Zephlon

    Experienced Forumer

  • Members

Posted 10 February 2008 - 11:42 AM

QUOTE
And it was you that broke the barrel code, not me.

What!?

Edit: Idea: We should double the rate of fire when you hold down the button. Just have it use two ffcs, (leave the speed alone.)

Edited by Mega Link, 10 February 2008 - 12:29 PM.


#62 Joe123

Joe123

    Retired

  • Members

Posted 10 February 2008 - 04:38 PM

In post #53.

So you have it working now then?

And I don't think we should, due to that being a lot more effort to code.
Perhaps as an extra once the cannon is working properly.
I assume you want it to smash the barrels?

#63 Zephlon

Zephlon

    Experienced Forumer

  • Members

Posted 10 February 2008 - 08:27 PM

I am using the barrel and jump ing code from post #50.

QUOTE
I assume you want it to smash the barrels?

Kinda. I want the cannon ball ffc to change to "explode". And the barrel to disappear, wait a few moments, then come back across the screen. Do ffc's combos cycle?

Just write the part that detects if the barrel is hit. I'll try writing the effects.

#64 Joe123

Joe123

    Retired

  • Members

Posted 10 February 2008 - 08:30 PM

So then it's not broken...

Yes, FFCs do cycle.

Do you have the cannon working or not?

You still haven't said...

#65 Zephlon

Zephlon

    Experienced Forumer

  • Members

Posted 10 February 2008 - 08:35 PM

Yes it works!

I am using the barrel and jumping code from post #50. So those work too.

#66 Joe123

Joe123

    Retired

  • Members

Posted 10 February 2008 - 08:39 PM

Oh, ok.
Well that's nice.

Wait.
You're using the jumping code from #50 and the most recent cannon code? icon_eyebrow.gif

It's an update to the same code, how are you doing that?

#67 Zephlon

Zephlon

    Experienced Forumer

  • Members

Posted 10 February 2008 - 08:45 PM

Just simple copy and replace. icon_eyebrow.gif

#68 Joe123

Joe123

    Retired

  • Members

Posted 10 February 2008 - 08:51 PM

You mean you just copied in the cannonball part into the script in #50?

#69 Zephlon

Zephlon

    Experienced Forumer

  • Members

Posted 10 February 2008 - 09:10 PM

No. I copied the barrel and jumping code from post #50.

#70 Joe123

Joe123

    Retired

  • Members

Posted 11 February 2008 - 04:47 AM

Well yes, but there is no cannon routine in the code in #50.

You aren't used two of the boat scripts simultaneously are you?

#71 Zephlon

Zephlon

    Experienced Forumer

  • Members

Posted 11 February 2008 - 07:36 PM

This is what it looks like:

CODE
ffc script boat{
    void run(){    // void run(){ goes on the SECOND line. NOT the first.
    ffc link2 = Screen->LoadFFC(2);
    ffc cball = Screen->LoadFFC(3);
    ffc cball2 = Screen->LoadFFC(8);
    ffc water = Screen->LoadFFC(32);// number, so this will draw your cannonball above your barrels instead of below.

    bool upcheck; bool cannon; bool cannon2;
    int yorig;
    int orig = this->Data;
    int worig = water->Data;
    int corig = cball->Data;

    int gravity = 0.1; // Acceleration due to gravity
    int jumpspd = 3;   // Starting speed of jump
    int cbspeed = 2;   // Speed of cannonball. No need to make it D0 really.
    Link->HP = 64;
    cball->Data = blank;

        while(true){
            upcheck = false;
            link2->Y = this->Y+28;

            if(!boatjump) water->Y = this->Y+32;

            if(Link->InputUp && !boatjump){
                this->Vy = -1;
                upcheck = true;
            }else this->Vy = 0;

            if(Link->InputDown && !boatjump) this->Vy = 1;
            else{
                if(!upcheck) this->Vy = 0;
            }    

            if(Link->InputB && !boatjump && !cannon){
                Game->PlaySound(3);
                cball->Y = water->Y; cball->X = 64;
                cball->Vx = cbspeed;
                cball->Data = corig;
                cannon = true;
                Link->InputB = false;
            }

            if(Link->InputB && !boatjump && !cannon2 && cannon){
                Game->PlaySound(3);
                cball2->Y = water->Y; cball2->X = 64;
                cball2->Vx = cbspeed;
                cball2->Data = corig;
                cannon2 = true;
                Link->InputB = false;
            }

            if(Link->InputA){
                Game->PlaySound(45);
                boatjump = true;
                this->Data = jumptil;
                water->Data = shadowtil;
                water->X += 24;
                yorig = this->Y;
                this->Vy = -jumpspd;
                this->Ay = gravity;
                Link->InputA = false;
            Waitframe();
            }

            while(boatjump){
                link2->Y = this->Y+28;
                if(this->Y == yorig){
                    this->Vy = 0;
                    this->Ay = 0;
                    this->Data = orig; water->Data = worig;
                    water->X -= 24;
                    boatjump = false;
                }
            Waitframe();
            }

            if(cannon){
                if(cball->X >= 256){
                    cball->Vx = 0;
                    cball->Data = blank;
                    cannon = false;
                }
            }

            if(cannon2){
                if(cball2->X >= 256){
                    cball2->Vx = 0;
                    cball2->Data = blank;
                    cannon2 = false;
                }
            }

            if(boatjump){
                if(this->Y == yorig){
                    this->Vy = 0;
                    this->Ay = 0;
                    this->Data = orig; water->Data = worig;
                    water->X -= 24;
                    boatjump = false;
                }
            }

            if(this->Y+28 > 136 && this->Vy > 0 && !boatjump) this->Vy = 0;
            if(this->Y+28 < 44 && this->Vy < 0 && !boatjump) this->Vy = 0;

        Waitframe();
        }
    }
}

ffc script barrel{
    void run(int speed){
    ffc link2 = Screen->LoadFFC(2);
    bool go; bool active;
    int ran;
    int orig = this->Data;

    this->Data = blank;
    ran = Rand(120);
    Waitframes(ran);
    this->Data = orig;

    while(true){
        ran = Rand(104) + 42;
        this->Y = ran;
        this->X = 256;
            
        this->Vx = -speed;
        go = true;
        active = true;

        while(go){
            if(this->X < -16) go = false;
            if((this->X < 65 && this->X > 47) && Abs(this->Y - link2->Y) < 16 && !boatjump && active){
                Link->HP -= 16;
                active = false;
                Game->PlaySound(19);
            }
            Waitframe();
            }
        Waitframes(10);
        }
    }
}


Edit: Notice I tried to make it fire at a faster rate, but it ignores that extra code.

Edited by Mega Link, 11 February 2008 - 07:39 PM.


#72 Joe123

Joe123

    Retired

  • Members

Posted 11 February 2008 - 07:39 PM

*sigh*

You can't just whack those cannonball things in with the boatjump while.
While the boatjump part is tripped, it will only run that part of the script.
I made it into an if for a reason, not just because I felt like it.
I'll fix it tomorow.

And you can't just make two cannonballs like that, it'll shoot them one frame after the other.

#73 Zephlon

Zephlon

    Experienced Forumer

  • Members

Posted 13 February 2008 - 07:22 PM

Did you fix it yet?

#74 Russ

Russ

    Caelan, the Encouraging

  • Administrators
  • Location:Washington

Posted 13 February 2008 - 08:19 PM

Can somebody post a demo quest of exactly what this script can currently do? I tried following along with this discussion, but ended up just getting confused.

#75 Joe123

Joe123

    Retired

  • Members

Posted 15 February 2008 - 06:55 AM

CODE
ffc script boat{
    void run(){    // Thanks for sorting out your scope, it is much appreciated =)
    ffc link2 = Screen->LoadFFC(2);
    ffc cball = Screen->LoadFFC(3);
    ffc water = Screen->LoadFFC(32);

    bool upcheck; bool cannon;
    int yorig;
    int orig = this->Data;
    int worig = water->Data;
    int corig = cball->Data;

    int gravity = 0.1; // Acceleration due to gravity
    int jumpspd = 3;   // Starting speed of jump
    int cbspeed = 2;   // Speed of cannonball
    Link->HP = 64;
    cball->Data = blank;

        while(true){
            upcheck = false;

            //Tieing on graphics
            link2->Y = this->Y+28;
            if(!boatjump) water->Y = this->Y+32;

            //Up-Down movement
            if(Link->InputUp && !boatjump){
                this->Vy = -1;
                upcheck = true;
            }else this->Vy = 0;

            if(Link->InputDown && !boatjump) this->Vy = 1;
            else{
                if(!upcheck) this->Vy = 0;
            }            

            //Cannon start check
            if(Link->InputB && !boatjump && !cannon){
                Game->PlaySound(3);
                cball->Y = water->Y; cball->X = 64;
                cball->Vx = cbspeed;
                cball->Data = corig;
                cannon = true;
                Link->InputB = false;
            }

            //Jump start check
            if(Link->InputA){
                Game->PlaySound(45);
                boatjump = true;
                this->Data = jumptil;
                water->Data = shadowtil;
                water->X += 24;
                yorig = this->Y;
                this->Vy = -jumpspd;
                this->Ay = gravity;
                Link->InputA = false;
            Waitframe();
            }

            //Cannon check
            if(cannon){
                if(cball->X >= 256){
                    cball->Vx = 0;
                    cball->Data = blank;
                    cannon = false;
                }
            }

            //Cannon check
            if(boatjump){
                Waitframe();
                if(this->Y <= yorig){
                    this->Vy = 0;
                    this->Ay = 0;
                    this->Data = orig; water->Data = worig;
                    water->X -= 24;
                    boatjump = false;
                }
            }

            //Edgeguard
            if(this->Y+28 > 136 && this->Vy > 0 && !boatjump) this->Vy = 0;
            if(this->Y+28 < 44 && this->Vy < 0 && !boatjump) this->Vy = 0;

        Waitframe();
        }
    }
}


Give that one a try.
EDIT: Oh yeah, copy it over your script, don't just move in the parts that you think look better.

What it does Russ is:
Place a boat ffc at x == 64.
When you press up, it moves up, and when you press down, it moves down.
So it's locked at x == 64 for the entirety of the screen.
When you press A, it jumps
When you press B, it (should) shoot a cannonball.
There are barrels that move from the right hand side of the screen across to hit the boat, and it has 3 lives.

When we've actually got it working, it'll be a nice little mini-game.

Edited by Joe123, 15 February 2008 - 06:56 AM.



0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users