Jump to content

Photo

Moving Blocks


  • Please log in to reply
9 replies to this topic

#1 ElLibertador

ElLibertador

    Love and Peace

  • Members

Posted 07 April 2008 - 02:24 PM

I would like my blocks to move left and right. Right now just 2 tiles long, although I would like that to be editable. Up and down would be nice too. Please and Thanks.

Oh yeah. The tiles can only have to be one 16 by 16 tile, but if you could make it so that I could make it bigger, that would be great.

Edited by LinkMystro, 07 April 2008 - 02:26 PM.


#2 Joe123

Joe123

    Retired

  • Members

Posted 07 April 2008 - 03:23 PM

Can you elaborate a little?
Your blocks?

#3 ElLibertador

ElLibertador

    Love and Peace

  • Members

Posted 07 April 2008 - 03:33 PM

Oh sorry. I would like a combo that moves left and right. The combo would be 16 by 16. Like a moving platform.

#4 Joe123

Joe123

    Retired

  • Members

Posted 07 April 2008 - 04:01 PM

Can't you use combo cycling?
It'd be much easier than scripting.

Although it would be smoother to script I suppose.

#5 ElLibertador

ElLibertador

    Love and Peace

  • Members

Posted 07 April 2008 - 04:14 PM

Yeah I did Combo Cycling but it looks so meh and takes up so many tiles. Please :3

#6 Sephiroth

Sephiroth

    The Legendary Sephiroth

  • Members
  • Location:Somewhere... Lemme know if you find me :)

Posted 07 April 2008 - 04:22 PM

How about trying to use a FFC and a few FFC changers, as well as a script that emulates unwalkability on said FFC.

#7 Joe123

Joe123

    Retired

  • Members

Posted 07 April 2008 - 04:37 PM

Ah alright LM.

And yeah, that was how I was planning scripting it Sephiroth.


Will it be bad if it's not solid from the sides and bottom LM?

#8 ElLibertador

ElLibertador

    Love and Peace

  • Members

Posted 07 April 2008 - 09:05 PM

Umm yeah a little. It bother me too much though, since the point is too just try to land on it. No, it isn't then.

#9 Joe123

Joe123

    Retired

  • Members

Posted 11 April 2008 - 11:02 AM

CODE

ffc script solidblock{
    void run(){
    int dchk; int offset;
    if(this->TileWidth == 1) dchk = 8;
    else if(this->TileWidth == 2){dchk = 16; offset = 16;}
    else dchk = 8;
        while(true){
            if((Link->Y == this->Y || Link->Y == this->Y+1) && Abs(Link->X - this->X+offset) < dchk)){
                if(Link->Jump < 0) Link->Jump = 0;
                if(Link->InputDown){Link->Dir = 1; Link->InputDown = false;}
            }
        Waitframe();
        }
    }
}


Right.

So what this should do is:
  • Make the top of the ffc solid, so Link won't fall through
  • If you set the ffc's tilewidth to 2 instead of 1, it should still work

Once again, I haven't tried it, so you'll have to let me know what happens.
If it doesn't work, I'll open it up in ZC and have a look (well, if it's just a compile error let me know and I'll fix it).

So what you'll have to do is make the ffc move around with changers, and stick that script on it.

I've just realised though; what won't happen is that Link won't move along with the ffc, so you'll have to walk along with the platform at the moment.

If you want me to make it so that Link does move along with the platform, that probably won't be too hard.



#10 Joe123

Joe123

    Retired

  • Members

Posted 12 April 2008 - 07:14 AM

CODE
import "std.zh"

const int jumpheight = 32; //Height, in pixels, of Link's Jump.
const int jumppeak = 8;       //Time, in frames, Link will linger at the peak of his jump for.
const int jumpspeed = 2;   //Speed, in pixels per frame, of Link's Jump.

int jy;
bool jump; bool top;

global script slot2{
    void run(){
    int i; int jtmr; int ttmr;

    if(jumpspeed != 0) int jmax = jumpheight/jumpspeed;
        while(true){
            if(Screen->ComboF[ComboAt(Link->X+8, Link->Y+16)] == 98 || Screen->ComboI[ComboAt(Link->X+8, Link->Y+16)] == 98){
                if(Link->Jump < 0) Link->Jump = 0;
                if(Link->InputDown){Link->Dir = 1; Link->InputDown = false;}
            }
            if(Screen->ComboF[ComboAt(Link->X+16, Link->Y+8)] == 98 || Screen->ComboI[ComboAt(Link->X+16, Link->Y+8)] == 98){
                if(Link->InputRight){Link->Dir = 3; Link->InputRight = false;}
            }
            if(Screen->ComboF[ComboAt(Link->X, Link->Y+8)] == 98 || Screen->ComboI[ComboAt(Link->X, Link->Y+8)] == 98){
                if(Link->InputLeft){Link->Dir = 2; Link->InputLeft = false;}
            }
            
            if(Link->InputL && !jump && !top){
                Link->InputL = false;
                if(isSolid(Link->X+8, Link->Y+18) || Screen->ComboF[ComboAt(Link->X+8, Link->Y+18)] == 98 || Screen->ComboI[ComboAt(Link->X+8, Link->Y+18)] == 98){jump = true; jy = Link->Y;}
            }
            if(jump){
                jtmr++;
                Link->Jump = jumpspeed;
                Link->InputA = false; Link->InputB = false; Link->InputL = false;
                if(jtmr >= jmax){
                    jtmr = 0;
                    jump = false;
                    top = true;
                }
                for(i=0; i<16; i++){
                    if(isSolid(Link->X+i, Link->Y-2) || Screen->ComboF[ComboAt(Link->X+i, Link->Y-2)] == 98 || Screen->ComboI[ComboAt(Link->X+i, Link->Y-2)] == 98){jtmr = 0; jump = false; top = true;}
                }
            }
            if(top){
                ttmr++;
                Link->InputA = false; Link->InputB = false; Link->InputL = false;
                Link->Jump = 0;
                if(ttmr == jumppeak){
                    ttmr = 0;
                    top = false;
                }
            }
        Waitframe();
        }
    }

    bool isSolid(int x, int y) {
        if(x<0 || x>255 || y<0 || y>175)
                return false;
        int mask=1111b;
        if(x%16<8)
            mask&=0011b;
        else
            mask&=1100b;
        if(y%16<8)
            mask&=0101b;
        else
            mask&=1010b;
        return (!(Screen->ComboS[ComboAt(x, y)]&mask)==0);
    }
}

ffc script solidblock{
    void run(){
    int dx;
    int dchk; int offset;
    if(this->TileWidth == 1) dchk = 12;
    else if(this->TileWidth == 2){dchk = 22; offset = 8;}
    else dchk = 8;
        while(true){
            if((Link->Y+16 == this->Y || Link->Y+17 == this->Y) && Abs(Link->X - this->X-offset) < dchk){
                if(Link->InputL && !jump && !top){
                    Link->InputL = false;
                    jump = true; jy = Link->Y;
                }
                if(Link->Jump < 0) Link->Jump = 0;
                if(Link->InputDown){Link->Dir = 1; Link->InputDown = false;}
            }
        Waitframe();=
        }
    }
}


OK, I checked it and it didn't work.
Now it does.
But the block still won't move Link along with it, because I had a little trouble adding that right now (although it's still perfectly possible), and my sister wants to use the computer.

You will have to insert the new global script, because I had to edit it slightly to allow Link to be able to jump while standing on the block.

If you just set the ffc to use a tilewidth of 2 instead of 1, it'll work fine though, without inputting any more data.
So that's a bonus.

Edited by Joe123, 12 April 2008 - 07:14 AM.



0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users