So I made a thing!
A while back I made a color cube. It involved a push block that changed color... It was complete crap. So I remade it completely.
This new version has done away with the push block altogether. Now the FFC will set solidarity, animations on its own and supports actual dice that changes sides when rolled. The FFC acts like a push(wait) block and will take care of collisions on its own.
The code: I don't recommend taking this code as it still has 1 or 2 bugs that need to be ironed out. I will release a Data Base version once it's completely working.
Spoiler
//=========================================Color Cube========================================== //Place FFC at cube location. Cube always starts with Red on Z and Yellow on Y. //D0: Pos of Trigger. //D1: Color for Trigger. //Colors const int RED = 0; const int BLUE = 1; const int YELLOW = 2; //Solids const int SOLIDFULL = 28551; //Cube Sides as stored in array. const int COLORX = 0; const int COLORY = 1; const int COLORZ = 2; //Cubes cube tiles: //Static Tiles const int REDBLUE = 27620; //Red up, blue front. const int REDYELLOW = 27640; //Red up, yellow front. const int BLUERED = 27700; //Blue up, red front. const int BLUEYELLOW = 27720; //Blue up, yellow front. const int YELLOWRED = 27680; //Yellow up, red front. const int YELLOWBLUE = 27660; //Yellow up, blue front. //Red Active const int H_REDBLUE = 28553; //rolling red to blue, left/right. const int V_REDBLUE = 28552; //rolling red to blue, up/down. const int H_REDYELLOW = 28554; //rolling red to yellow, left/right. const int V_REDYELLOW = 28555; //rolling red to yellow, up/down. //Blue Active const int H_BLUERED = 28561; //rolling blue to red, left/right. const int V_BLUERED = 28560; //rolling blue to red, up/down. const int H_BLUEYELLOW = 28562; //rolling blue to yellow, left/right. const int V_BLUEYELLOW = 28563; //rolling blue to yellow, up/down. //Yellow Active const int H_YELLOWRED = 28556; //rolling yellow to red, left/right. const int V_YELLOWRED = 28557; //rolling yellow to red, up/down. const int H_YELLOWBLUE = 28559; //rolling yellow to blue, left/right. const int V_YELLOWBLUE = 28558; //rolling yellow to blue, up/down. ffc script ColorCube { void run(int trigger, int triggerColor) { int colors[3] = {BLUE, YELLOW, RED}; int currenttile = REDYELLOW; int nexttile = REDYELLOW; int direction = -1; int movingcombo = -1; int pos; int wait; //Place solid at ffc location. pos = ComboAt(this->X, this->Y); Screen->ComboD[pos] = SOLIDFULL; //move to trigger and loop if secrets triggered. if(Screen->State[ST_SECRET]) { Screen->ComboD[pos] = 0; //Clear solid. //Set and Move cube. currenttile = Screen->D[2]; this->X = ComboX(trigger); this->Y = ComboY(trigger); pos = ComboAt(this->X, this->Y); Screen->ComboD[pos] = SOLIDFULL; //Set new Solid. while(true) { Screen->DrawTile(0, this->X, this->Y, currenttile, 1, 1, 0, -1, -1, 0, 0, 0, 0, true, OP_OPAQUE); Waitframe(); } } //Start Loop while(true) { direction = CubePush(this, currenttile); if(direction > -1) //Is being pushed. { movingcombo = CubeAnimation(direction, currenttile); nexttile = CubeSet(colors, direction, movingcombo); Game->PlaySound(102); for(wait = 0; wait < 16; wait++) //Loop for duration of movement. { Screen->DrawCombo(0, this->X, this->Y, movingcombo, 1, 1, 0, -1, -1, 0, 0, 0, 1, 0, true, OP_OPAQUE); if(direction == DIR_UP) this->Y -= 1; else if(direction == DIR_DOWN) this->Y += 1; else if(direction == DIR_LEFT) this->X -= 1; else this->X += 1; Waitframe(); } Screen->ComboD[pos] = 0; pos = ComboAt(this->X, this->Y); Screen->ComboD[pos] = SOLIDFULL; currenttile = nexttile; direction = -1; movingcombo = -1; if(ComboAt(this->X, this->Y) == trigger && colors[COLORZ] == triggerColor) { Screen->TriggerSecrets(); Screen->State[ST_SECRET] = true; Screen->D[2] = currenttile; Waitframe(); Game->PlaySound(SFX_SECRET); while(true) { Screen->DrawTile(0, this->X, this->Y, currenttile, 1, 1, 0, -1, -1, 0, 0, 0, 0, true, OP_OPAQUE); Waitframe(); } } } Screen->DrawTile(0, this->X, this->Y, currenttile, 1, 1, 0, -1, -1, 0, 0, 0, 0, true, OP_OPAQUE); Waitframe(); } } } int CubeSet(int colors, int direction, int movingcombo) { int store = colors[COLORZ]; int nexttile; //Change array to match new orientation. if(direction == DIR_UP || direction == DIR_DOWN) { colors[COLORZ] = colors[COLORY]; colors[COLORY] = store; } else { colors[COLORZ] = colors[COLORX]; colors[COLORX] = store; } //Find new static tile. //Red UP. if(movingcombo == V_REDBLUE) nexttile = BLUERED; else if(movingcombo == H_REDBLUE) nexttile = YELLOWBLUE; else if(movingcombo == V_REDYELLOW) nexttile = YELLOWRED; else if(movingcombo == H_REDYELLOW) nexttile = BLUEYELLOW; //Blue UP. else if(movingcombo == V_BLUERED) nexttile = REDBLUE; else if(movingcombo == H_BLUERED) nexttile = YELLOWRED; else if(movingcombo == V_BLUEYELLOW) nexttile = YELLOWBLUE; else if(movingcombo == H_BLUEYELLOW) nexttile = REDYELLOW; //Yellow UP. else if(movingcombo == V_YELLOWRED) nexttile = REDYELLOW; else if(movingcombo == H_YELLOWRED) nexttile = BLUERED; else if(movingcombo == V_YELLOWBLUE) nexttile = BLUEYELLOW; else nexttile = REDBLUE; return nexttile; } int CubeAnimation(int direction, int currenttile) { int movingcombo; //return the combo to be played for pushing. if(currenttile == REDBLUE) { if(direction == DIR_UP || direction == DIR_DOWN) movingcombo = V_REDBLUE; else movingcombo = H_REDBLUE; } else if(currenttile == REDYELLOW) { if(direction == DIR_UP || direction == DIR_DOWN) movingcombo = V_REDYELLOW; else movingcombo = H_REDYELLOW; } else if(currenttile == BLUERED) { if(direction == DIR_UP || direction == DIR_DOWN) movingcombo = V_BLUERED; else movingcombo = H_BLUERED; } else if(currenttile == BLUEYELLOW) { if(direction == DIR_UP || direction == DIR_DOWN) movingcombo = V_BLUEYELLOW; else movingcombo = H_BLUEYELLOW; } else if(currenttile == YELLOWRED) { if(direction == DIR_UP || direction == DIR_DOWN) movingcombo = V_YELLOWRED; else movingcombo = H_YELLOWRED; } else { if(direction == DIR_UP || direction == DIR_DOWN) movingcombo = V_YELLOWBLUE; else movingcombo = H_YELLOWBLUE; } return movingcombo; } int CubePush(ffc this, int currenttile) { int side = -1; int wait; //Check for direction and if Link is facing the cube and if he is currently walking. if(LinkCollision(this)) { side = AngleDir8(Angle(this->X+8, this->Y+8, Link->X+8, Link->Y+8)); if(side == DIR_LEFT && Link->InputRight && CubeSolid(this, DIR_RIGHT)) //Link is walking to the right. { for(wait = 0; wait < 10; wait++) { Screen->DrawTile(0, this->X, this->Y, currenttile, 1, 1, 0, -1, -1, 0, 0, 0, 0, true, OP_OPAQUE); Waitframe(); } if(side == DIR_LEFT && Link->InputRight && CubeSolid(this, DIR_RIGHT)) side = DIR_RIGHT; else side = -1; } else if(side == DIR_RIGHT && Link->InputLeft && CubeSolid(this, DIR_LEFT)) //Link is walking to the left. { for(wait = 0; wait < 10; wait++) { Screen->DrawTile(0, this->X, this->Y, currenttile, 1, 1, 0, -1, -1, 0, 0, 0, 0, true, OP_OPAQUE); Waitframe(); } if(side == DIR_RIGHT && Link->InputLeft && CubeSolid(this, DIR_LEFT)) side = DIR_LEFT; else side = -1; } else if(side == DIR_UP && Link->InputDown && CubeSolid(this, DIR_DOWN)) //Link is walking down. { for(wait = 0; wait < 10; wait++) { Screen->DrawTile(0, this->X, this->Y, currenttile, 1, 1, 0, -1, -1, 0, 0, 0, 0, true, OP_OPAQUE); Waitframe(); } if(side == DIR_UP && Link->InputDown && CubeSolid(this, DIR_DOWN)) side = DIR_DOWN; else side = -1; } else if(side == DIR_DOWN && Link->InputUp && CubeSolid(this, DIR_UP)) //Link is walking up. { for(wait = 0; wait < 10; wait++) { Screen->DrawTile(0, this->X, this->Y, currenttile, 1, 1, 0, -1, -1, 0, 0, 0, 0, true, OP_OPAQUE); Waitframe(); } if(side == DIR_DOWN && Link->InputUp && CubeSolid(this, DIR_UP)) side = DIR_UP; else side = -1; } else side = -1; } return side; } bool CubeSolid(ffc this, int direction) { int x = this->X; int y = this->Y; if(direction == DIR_UP) y -= 16; else if(direction == DIR_DOWN) y += 16; else if(direction == DIR_LEFT) x -= 16; else x += 16; if(ComboFI(x, y, CF_NOBLOCKS) || IsWater(ComboAt(x, y)) || GetLayerComboS(0, ComboAt(x, y)) > 0 || GetLayerComboS(1, ComboAt(x, y)) > 0) return false; else return true; }