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.