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.