Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Warp Aperature Animation FFC
- //for ywkls, by ZoriaRPG
- //14th May, 201
- //v0.2
- const int SCREEN_CENTRE_X = 128;
- const int SCREEN_CENTRE_Y = 88;
- const int CUBE_TEXT_TIMER_DUR = 200;
- //General Warp Aperature Settings
- const int APERATURE_LAYER = 1;
- const int APERATURE_TILE_WIDTH = 6;
- const int APERATURE_TILE_HEIGHT = 7;
- const float APERATURE_DEFAULT_OPEN_RATE = 0.3;
- //Left Warp Aperature
- const int APERATURE_LEFT_X = 0;
- const int APERATURE_LEFT_Y = 0;
- const int APERATURE_LEFT_BASE_TILE = 15860;
- const int APERATURE_LEFT_CSET = 0;
- const int APERATURE_LEFT_XSCALE = -1;
- const int APERATURE_LEFT_YSCALE = -1;
- const int APERATURE_LEFT_RX = 0;
- const int APERATURE_LEFT_RY = 0;
- const int APERATURE_LEFT_RANGLE = 0;
- const int APERATURE_LEFT_FLIP = 0;
- const int APERATURE_LEFT_OPACITY = 64;
- //Right Warp Aperature
- const int APERATURE_RIGHT_X = 96;
- const int APERATURE_RIGHT_Y = 96;
- const int APERATURE_RIGHT_BASE_TILE = 15866;
- const int APERATURE_RIGHT_CSET = 0;
- const int APERATURE_RIGHT_XSCALE = -1;
- const int APERATURE_RIGHT_YSCALE = -1;
- const int APERATURE_RIGHT_RX = 0;
- const int APERATURE_RIGHT_RY = 0;
- const int APERATURE_RIGHT_RANGLE = 0;
- const int APERATURE_RIGHT_FLIP = 0;
- const int APERATURE_RIGHT_OPACITY = 128;
- //Cube animation 2x2 tile textures (tile page 61)
- const int CUBE_TEX_1 = 16020;
- const int CUBE_TEX_2 = 16022;
- const int CUBE_TEX_3 = 16024;
- const int CUBE_TEX_4 = 16026;
- const int CUBE_TEX_5 = 16028;
- ffc script portal{
- void run(int bitty, int cubetimer, int modulus, int textime, int open_rate){
- //Warp Gate Aperature Values Array
- int aperature_pos[18]; //0,1: left x, y;
- //2,3: right x,y,
- //4,5: left xscale, yscale;
- //6,7: right xscale, yscale
- //8,9, left rx, ry
- //10, 11: right rx, ry
- //12, 13: left rangle, flip
- //14, 15: right rangle, flip
- if ( open_rate <= 0 ) { open_rate = APERATURE_DEFAULT_OPEN_RATE; }
- int cube[12]={SCREEN_CENTRE_X+30,SCREEN_CENTRE_Y+30, 1,
- SCREEN_CENTRE_X+30,SCREEN_CENTRE_Y-30, 1,
- SCREEN_CENTRE_X-30,SCREEN_CENTRE_Y-30, 1,
- SCREEN_CENTRE_X-30,SCREEN_CENTRE_Y+30, 1};
- int cube_uv[8]={0,0, 31,0, 31, 31, 31, 0}; //Texture coordinates.
- //How mdo these work?
- //!
- int cube_csets[4]={0,0,0,0}; //Csets
- int textures[10]={CUBE_TEX_1,CUBE_TEX_2,CUBE_TEX_3,CUBE_TEX_4,CUBE_TEX_5,CUBE_TEX_1,CUBE_TEX_2,CUBE_TEX_3,CUBE_TEX_4,CUBE_TEX_5}; //Holds textures.
- int tex_state; //Which texture to use this frame.
- int cube_tex[2]={2,2}; //Texture size.
- //Draw each half of the aperature, using DrawTile, and slowly move them to open.
- int aperature_left_x; int aperature_right_x;
- int aperature_timer;
- int cube_rot_timer;
- if ( modulus <= 0 ) modulus = 30;
- if ( cubetimer <= 0 ) cubetimer = 60000;
- cube_rot_timer = cubetimer;
- if ( textime <= 0 ) textime = CUBE_TEXT_TIMER_DUR;
- //Start the aperature opening animation.
- while(aperature_timer--){
- //Draw the aperature...
- //Left side...updating the positions every frame. Floored as we increment in decimals.
- //Truncation here, is to avoid any glitch potential.
- //DrawTile(left side)
- //Move it left to open it
- Screen->DrawTile(APERATURE_LAYER, ((APERATURE_RIGHT_X+aperature_pos[2])<<0), ((APERATURE_RIGHT_Y+aperature_pos[3])<<0),
- APERATURE_RIGHT_BASE_TILE, APERATURE_TILE_WIDTH, APERATURE_TILE_HEIGHT,
- APERATURE_RIGHT_CSET, ((APERATURE_RIGHT_XSCALE+aperature_pos[6])<<0), ((APERATURE_RIGHT_YSCALE+aperature_pos[7])<<0),
- ((APERATURE_RIGHT_RX+aperature_pos[10])), ((APERATURE_RIGHT_RY+aperature_pos[11])), ((APERATURE_RIGHT_RANGLE+aperature_pos[14])),
- ((APERATURE_RIGHT_FLIP+aperature_pos[15])<<0),
- true, ((APERATURE_RIGHT_OPACITY+aperature_pos[17])<<));
- //DrawTile(right side)
- //move it right to open it
- Screen->DrawTile(APERATURE_LAYER, ((APERATURE_LEFT_X+aperature_pos[0])<<0), ((APERATURE_LEFT_Y+aperature_pos[1])<<0),
- APERATURE_LEFT_BASE_TILE, APERATURE_TILE_WIDTH, APERATURE_TILE_HEIGHT,
- APERATURE_LEFT_CSET, ((APERATURE_LEFT_XSCALE+aperature_pos[4])<<0), ((APERATURE_LEFT_YSCALE+aperature_pos[5])<<0),
- ((APERATURE_LEFT_RX+aperature_pos[8])), ((APERATURE_LEFT_RY+aperature_pos[9])), ((APERATURE_LEFT_RANGLE+aperature_pos[12])),
- ((APERATURE_LEFT_FLIP+aperature_pos[13])<<0),
- true, APERATURE_LEFT_OPACITY+aperature_pos[16]);
- //Every frame, increase the aperature opening. This is a decimal increase, trhat is truncated, so that it opens in whole pixels.
- //The decimal + truncation approach allows more freedom in timing.
- openWarpAperature(aperature_pos, open_rate); //array, and opening rate in pixels per frame. Default is '0.3'.
- Waitframe();
- }
- //The aperature animation cycle is over, draw the cube...
- while(aperature_timer <= 0 ){
- if ( cube_rot_timer <= 0 ) {
- //Reset the timer for cube rotation base don if D1 was set.
- if ( cubetimer ) cube_rot_timer= 60000;
- else cube_rot_timer = cubetimer;
- }
- cube_timer--; //A monulus of this determines if we rotate the cube this frame.
- //the aperature has opened.
- //Draw both halves of the aperature in an open state.
- //Left Side.
- Screen->DrawTile(APERATURE_LAYER, APERATURE_RIGHT_X+aperature_pos[2], APERATURE_RIGHT_Y+aperature_pos[3],
- APERATURE_RIGHT_BASE_TILE, APERATURE_TILE_WIDTH, APERATURE_TILE_HEIGHT,
- APERATURE_RIGHT_CSET, APERATURE_RIGHT_XSCALE+aperature_pos[6], APERATURE_RIGHT_YSCALE+aperature_pos[7],
- APERATURE_RIGHT_RX+aperature_pos[10], APERATURE_RIGHT_RY+aperature_pos[11], APERATURE_RIGHT_RANGLE+aperature_pos[14],
- APERATURE_RIGHT_FLIP+aperature_pos[15],
- true, APERATURE_RIGHT_OPACITY+aperature_pos[17]);
- //Right Side.
- Screen->DrawTile(APERATURE_LAYER, APERATURE_LEFT_X+aperature_pos[0], APERATURE_LEFT_Y+aperature_pos[1],
- APERATURE_LEFT_BASE_TILE, APERATURE_TILE_WIDTH, APERATURE_TILE_HEIGHT,
- APERATURE_LEFT_CSET, APERATURE_LEFT_XSCALE+aperature_pos[4], APERATURE_LEFT_YSCALE+aperature_pos[5],
- APERATURE_LEFT_RX+aperature_pos[8], APERATURE_LEFT_RY+aperature_pos[9], APERATURE_LEFT_RANGLE+aperature_pos[12],
- APERATURE_LEFT_FLIP+aperature_pos[13],
- true, APERATURE_LEFT_OPACITY+aperature_pos[16]);
- //Handle texture change timer.
- if ( textime > 0 ) { textime--; } //Tick off the texture timer.
- else { //The timer has elapsed.
- if ( this->InitD[3] <= 0 ) textime = CUBE_TEXT_TIMER_DUR;
- else textime = this->InitD[3];
- //Advance the array texture.
- if ( tex_state < 10 ) { tex_state++; }
- else tex_state = 0; //Wrap to index 0.
- }
- //Decide if we rotate the cube:
- if ( cube_rot_timer != cubetimer && cube_rot_timer % modulus == 0 ) {
- //if this is not the initial frame, check if the rotation
- //timer modulus. Defualt move every 30 frames.
- //Do rotational effect to cube[]
- }
- //Draw the cube.
- Screen->Quad3D(3,cube,cube_uv, cube_csets,cube_tex, 0, textures[tex_state], 0);
- //! Do we do anything fancy for warping on collision with the cube??
- //! If som i=t goes here.
- Waitframe();
- }
- }
- void __RotateQuad3D_X(int angle, int pos} {
- //int cx, int cy, int cz){
- for(int i=0; i<3; i++){
- int y = pos[(i*3)+1];
- int z = pos[(i*3)+2];
- pos[(i*3)+1] = y * Cos(angle) - z * Sin(angle);
- pos[(i*3)+2] = z * Cos(angle) + y * Sin(angle);
- }
- }
- //'amount' should be positive to open, negative to close.
- void openWarpAperature(int aperature_pos, int amount){
- aperature_pos[0]-=amount;
- aperature_pos[2]+= amount;
- }
- }
- /*
- //Find a free bitmap to use
- //We want a circle of shimmering blue and white
- //We want some tiles copies to it
- //We need to make the area around it translucent.
- //Triangle 3D might do better?
- //Or a cube?
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement