//Pentavalence_v1; Pant_Zipper !lk38OS7kEE aka ineptia !FQ4R9ypnJQ/!!BCfeOlVwRRQ; /f/, January 31st, 2025 //what's in the package; //IMPORTS import openfl.display.Sprite; import openfl.display.Shape; import openfl.events.Event; import openfl.geom.Matrix; import openfl.events.KeyboardEvent; import openfl.ui.Keyboard; import openfl.events.MouseEvent; import openfl.Assets; import openfl.events.Event; import openfl.media.Sound; import openfl.media.SoundChannel; import openfl.media.SoundMixer; import openfl.text.TextField; import openfl.text.TextFieldAutoSize; import openfl.text.TextFormat; //import openfl.text.Font; //I can't get a .ttf to work, so relying on the a player's default font import openfl.utils.Assets; //first class Main extends Sprite { //PUBLIC VARIABLES PUBLIC VARIABLES PUBLIC VARIABLES PUBLIC VARIABLES PUBLIC VARIABLES //SOUND INITIALIZATION var soundWaves:SoundChannel; var proForma:Sound; //TEXT INITIALIZATION var writingPlane:TextField; var writingFormat:TextFormat; var controls:String = ""; var pentavalence:String = ""; //PUBLIC SPRITES & SHAPES var BGplane:Sprite = new Sprite(); var background:Shape = new Shape(); var pentagonPlane:Sprite = new Sprite(); //this will get its shapes later //FRAMES var frameNumber = 0; //increases every frame; reset @1000 var timeyWimey:Int = 1; //frame rate; changes between 1 & 5 //PENTAGON VARIABLES var sides:Int = 5; var angle:Float = (360/5)*(Math.PI/180); //radians var originalRadius:Int = 750; //width & height are both 500; change in .xml var radius:Float = 750; var frameHypotenuse:Float = 0; //on resize, this will become Flash window's hypotenuse; ensures the 45º-rotated "fields" go far enough var flatConstant:Float = 12; //when perspective=0, each new radius will be 12 less than the one nesting it var roundConstant:Float = 0; //Math.floor(165/s) //CONCENTRIC VARIABLES var ringNum:Int = 60; //# of concentric "rings" //upOrDown & leftOrRight allow the "camera" to get closer to a "wall", "ceiling" or "floor"; ARROW-KEYS/WASD or mouse changes them var upOrDown:Float = .5; var leftOrRight:Float = 0; //adjX & adjY are upOrDown & leftOrRight multiplied by each new pentagon-ring's decreasing radius; smaller pentagons move less var adjX:Float = 0; var adjY:Float = 0; //every frame, the mouse or autoPath will fill in the next 3 Floats, which will trickle thru their respective floatArrays var xNew:Float = 0; var offsetX:Array = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; var yNew:Float = 0; var offsetY:Array = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; var twist:Float = 0; var vortex:Array = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; //AUTOPATH //the autoPath moves via sin/cos functions; the autoMove variables tell the function how slowly/quickly to oscillate var autoMoveX:Float = .25; var autoMoveY:Float = .25; //the sin/cos functions output values -1 to 1; these values are mapped onto the autoRanges and are added to offSet[0] //all of these auotPath variables (except the triggers) get randomized; 200 frames for X & 250 frames for Y var autoRangeX_left:Float = 0; var autoRangeX_right:Float = 0; var autoRangeY_up:Float = 0; var autoRangeY_down:Float = 0; //if the translated offSet[0]s bump into the Flash's corners, their respective triggers are multiplied by -1 var triggerX:Int = 1; var triggerY:Int = 1; var turnOfTheScrew:Float = .1; //COLORS var black:Int = 0x000000; var white:Int = 0xFFFFFF; var gray:Int = 0x808080; var red:Int = 0xFF0000; var orange:Int = 0xFFA500; var yellow:Int = 0xFFFF00; var green:Int = 0x008000; var blue:Int = 0x0000FF; var purple:Int = 0x4B0082; var pink:Int = 0xEE82EE; //COLORS TO SIDES var field:Int = 6; var fieldColor0:Int = 0x008000; var fieldColor1:Int = 0x008000; var rock:Int = 2; var rockColor0:Int = 0x808080; var rockColor1:Int = 0x808080; var water:Int = 8; var waterColor0:Int = 0x0000FF; var backdrop:Int = 0; //set to black //KEYBOARD BOOLEANS var autoPathP:Bool = false; var perspectiveN:Bool = true; var mouseCreepM:Bool = false; var infoShowI:Bool = false; var pentShowO:Bool = false; var slowDownU:Bool = false; var randomColor:Bool = false; var firstPress:Bool = false; //KEYBOARD CYCLES (0 usually means OFF) var foundation:Int = 2; // 0=Cave, 1=roller coaster, 2=river, 3=trench var autoRotateC:Int = 0; //0 = no rotation; 1 = clockwise; 2 = no rotation; 3 = anti-clockwise var lineToggleY:Int = 1; //0 = no lineWeight; 1 = thicker lines "further away"; 2 = thicker lines "closer up" var whoaQ:Int = 0; public function new() { super(); //SNATCH & PLAY THE MUSIC proForma = Assets.getSound("assets/song1 small.mp3"); soundWaves = proForma.play(0, 666); //get the hypotenuse of the curren window (500x500) frameHypotenuser(); //fill the offsets with zeros (again, because why not?) for(i in 0...offsetX.length){ offsetX[i] = 0; offsetY[i] = 0; } //ADD THE BACKGROUND PLANE & DRAW THE BACKGROUND RECTANGLE addChild(BGplane); background.graphics.beginFill(chooseColor(backdrop)); background.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight); background.graphics.endFill(); BGplane.addChild(background); //ADD THE PENTAGON PLANE addChild(pentagonPlane); //SET UP THE TEXT BOX, TEXT FORMAT & ADD THE WRITING PLANE //set up the writing plane and make it very small & empty; it will get bigger and filled with controls/pentavalence when called writingPlane = new TextField(); controls = Assets.getText("assets/PentagonFlash_buttons.txt"); pentavalence = Assets.getText("assets/PentagonFlash_drivel.txt"); writingPlane.text = "PRESS [ i ] FOR EXTENSIVE CONTROLS"; //see? It's empty writingPlane.background = true; //make sure no background for the text writingPlane.backgroundColor = 0x000000;//0x023020; writingPlane.alpha = 1;//.75; writingPlane.width = stage.stageWidth; writingPlane.height = 35; //stage.stageHeight/8; writingPlane.wordWrap = true; // Enable word wrapping //set up the writing format writingFormat = new TextFormat(); writingFormat.size = 25; writingFormat.color = white; //writingFormat.font = Assets.getFont("assets/Times New Roman.ttf").fontName; writingFormat.align = "center"; writingPlane.defaultTextFormat = writingFormat; writingPlane.setTextFormat(writingFormat); writingPlane.x = 0; writingPlane.y = 0; addChild(writingPlane); //EVENT LISTENERS addEventListener(Event.ENTER_FRAME, drawPentagon); stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown); stage.addEventListener(Event.RESIZE, onResize); stage.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown); stage.addEventListener(openfl.events.MouseEvent.MOUSE_WHEEL, onMouseWheel); } function drawPentagon(event:Event):Void { //REMOVE LAST FRAME'S LINES while (pentagonPlane.numChildren > 0){ pentagonPlane.removeChildAt(0); } //RESET RADIUS radius = originalRadius; //CALCULATE NEW PENTAGON VALUES CALCULATE NEW PENTAGON VALUES CALCULATE NEW PENTAGON VALUES CALCULATE NEW PENTAGON VALUES //but only when the frame rate steps forward --> timeyWimey if(frameNumber%timeyWimey == 0){ //MAKE OFFSETS AND VORTEX VALUES FOR ALL PENTAGONS "TRICKLE" UP //Example --> offsetX[59] takes offsetX[58]'s value; //Example --> offsetY[58] takes offsetY[57]'s value; //Example --> vortex[1] takes vortex[0]'s value for(thisRing in 1...ringNum){ //as far as I know, for-loops can only count up, even though I want to count down right now... //so the above for-loop is combined with "ringNum-thisRing" to produce 59, 58, 57, etc. down to 1 // thisRing goes from 1 to 59; countDown goes from 59 to 1 var countDown:Int = ringNum - thisRing; offsetX[countDown] = offsetX[countDown-1]; offsetY[countDown] = offsetY[countDown-1]; vortex[countDown] = vortex[countDown-1]; } //at the end of this for-loop, vortex[1] and vortex[0] have the same values... //so afterward, for this frame, a new [0] will be made //CALCULATE NEW OFFSETX[0], OFFSETY[0] AND OPTIONALLY VORTEX[0] //MOUSE if(autoPathP == false){ if((mouseX > 0 && mouseY > 0) && (mouseX < stage.stageWidth && mouseY < stage.stageHeight)){ //here, the mouse draws the smallest pentagon //the mouseX & mouseY are mapped to -stage/2 & stage/2 because it's neater to draw things at (0, 0)... //and to translate all the lines at the end of the frame offsetX[0] = mapper(mouseX, 0, stage.stageWidth, -stage.stageWidth/2, stage.stageWidth/2); offsetY[0] = mapper(mouseY, 0, stage.stageHeight, -stage.stageHeight/2, stage.stageHeight/2); } } //AUTOPATH else{ //here, autoPath draws the smallest pentagon //autoX and autoY may need to be re-randomized depending on the frameNumber if(frameNumber%200==0){ autoX(); } if(frameNumber%250==0){ autoY(); } //the neatest part below is the "-offset[0]/50", which will always trend the offsets/autoPath back to the center offsetX[0] += triggerX * mapper(Math.sin(autoMoveX*(frameNumber)/Math.PI), -1, 1, autoRangeX_left, autoRangeX_right) -offsetX[0]/50; offsetY[0] += triggerY * mapper(Math.cos(autoMoveY*(frameNumber)/Math.PI), -1, 1, autoRangeY_up, autoRangeY_down) -offsetY[0]/50; //if the translated offSet[0]s bump into the Flash's corners, their respective triggers are multiplied by -1 if(offsetX[0] > stage.stageWidth/2 || offsetX[0] < -stage.stageWidth/2){ triggerX = -triggerX; } if(offsetY[0] > stage.stageHeight/2 || offsetY[0] < -stage.stageHeight/2){ triggerY = -triggerY; } } //AUTOROTATE INCREASE/DECREASE (OFF if autoRotateC == 0) if(autoRotateC == 1){ vortex[0] += turnOfTheScrew; } if(autoRotateC == 3){ vortex[0] -= turnOfTheScrew; } } //DRAW THE PENTAGON DRAW THE PENTAGON DRAW THE PENTAGON DRAW THE PENTAGON DRAW THE PENTAGON DRAW THE PENTAGON DRAW THE PENTAGON //this is done every frame because position-creep always needs to be smooth var pentaLines:Shape = new Shape(); for (thisRing in 1...(ringNum+1)) { //CALL OFFSETS & VORTEX //for each new pentagon being drawn, its center's respective offset[n[/vortex[n] values are called //in order to get the for-loop to count down, same drill as before (n = 59, 58, etc.), except this time n goes down to 0 //the pentagons are drawn from the biggest/"closest" to the smallest/"furthest away" //thisRing goes from 1 to 60; countDown goes from 59 to 0 //it helps to think of the concentric rings like this: the biggest pentagon is 1st biggest AND the 59th away from the center... //the center being [0], the thing being moved, so it makes sense to be counting down to it //also, counting down is necessary in order for the closest pentagon to always have the originalRadius value var countDown = ringNum - thisRing; xNew = offsetX[countDown]; yNew = offsetY[countDown]; twist = vortex[countDown]; //CHANGE POSITION (OPTIONAL) //if mouseCreep is true, new positions need to be mapped; will only assign new if mouse is on-screen if(mouseCreepM == true){ if((mouseX > 0 && mouseY > 0) && (mouseX < stage.stageWidth && mouseY < stage.stageHeight)){ leftOrRight = mapper(mouseX, 0, stage.stageWidth, -5*(stage.stageWidth/500), 5*(stage.stageWidth/500)); upOrDown = mapper(mouseY, 0, stage.stageHeight, -5*(stage.stageHeight/500), 5*(stage.stageHeight/500)); } } //CUSTOMIZE POSITION //whether mouseCreep just changed positions, or the keyboard changed them, or they're unchanged... //each new pentagon's center now gets moved by the creep-positions propotional to their size (radius) adjX = radius*(leftOrRight); adjY = radius*(upOrDown); //LINE WEIGHT //as the rings get smaller, do their line weights stay the same (lineToggleY==0), increase (==1), or decrease (==2)? var lineWeight:Float = 1; if(lineToggleY == 1){ lineWeight = thisRing/30; } if(lineToggleY == 2){ lineWeight = 1/(thisRing/30); } //DRAW PENTAGON SIDES ONE LINE AT A TIME for (j in 0...sides) { var i:Int = sides - j -1; //LINE COLOR //unique color depending on what # lines is being drawn //symmetry: 0 1 2 3 4 == A B C B A if(i%5 == 0){ pentaLines.graphics.lineStyle(lineWeight, fieldColor0); } if(i%5 == 1){ pentaLines.graphics.lineStyle(lineWeight, rockColor0); } if(i%5 == 2){ pentaLines.graphics.lineStyle(lineWeight, waterColor0); } if(i%5 == 3){ pentaLines.graphics.lineStyle(lineWeight, rockColor1); } if(i%5 == 4){ pentaLines.graphics.lineStyle(lineWeight, fieldColor1); } //DRAW A LINE INSIDE A FOUNDATION (cave 0, roller coaster 1, river 2, or trench 3) //establish wildCards var wildCard0:Float = 1; var wildCard1:Float = 1; var wildCard2:Float = 1; var wildCard3:Float = 1; var wildTwist0:Float = 1; var wildTwist1:Float = 1; var wildTwist2:Float = 1; var wildTwist3:Float = 1; //basically just putting gibberish into each whoaQ below if(whoaQ == 1){ wildCard0 = 1; wildCard1 = Math.sin(offsetX[i]/Math.PI/10); wildCard2 = 1; wildCard3 = -Math.cos(offsetY[i]/Math.PI/10); } if(whoaQ == 2){ wildCard0 = Math.sin(offsetX[thisRing]/Math.PI/10); wildCard1 = 1; wildCard2 = -Math.cos(offsetY[i]/Math.PI/10); wildCard3 = 1; } if(whoaQ == 3){ wildCard0 = Math.sin(offsetX[i]/Math.PI/10); wildCard1 = Math.sin(offsetX[i]/Math.PI/10); wildCard2 = -Math.cos(offsetY[i]/Math.PI/10); wildCard3 = -Math.cos(offsetY[i]/Math.PI/10); } if(whoaQ == 4){ wildCard0 = -Math.cos(thisRing/Math.PI/10); wildCard1 = -Math.cos(offsetX[i]/Math.PI/10); wildCard2 = Math.sin(i/Math.PI/10); wildCard3 = Math.sin(offsetY[i]/Math.PI/10); } if(whoaQ == 5){ wildCard0 = -Math.cos(countDown/Math.PI/10)/(i+1); wildCard1 = -Math.cos(offsetY[i]/Math.PI/10)/(i+2); wildCard2 = Math.sin(thisRing/Math.PI/10)/(i+2); wildCard3 = Math.sin(offsetX[i]/Math.PI/10)/(i+1); } if(whoaQ == 6){ wildTwist0 = thisRing/Math.PI; wildTwist1 = 1; wildTwist2 = 1; wildTwist3 = 1; } if(whoaQ == 7){ wildTwist0 = offsetX[thisRing]/Math.PI/10; wildTwist1 = 1; wildTwist2 = 1; wildTwist3 = 1; } if(whoaQ == 8){ wildTwist0 = (thisRing+i)/Math.PI/10; wildTwist1 = 1; wildTwist2 = 1; wildTwist3 = countDown/Math.PI/10; } if(whoaQ == 9){ wildTwist0 = countDown/Math.PI/10; wildTwist1 = thisRing/Math.PI/10; wildTwist2 = 1; wildTwist3 = 1; } if(whoaQ == 10){ wildTwist0 = thisRing/Math.PI/10; wildTwist1 = countDown/Math.PI/10; wildTwist2 = offsetY[i]/Math.PI/10; wildTwist3 = thisRing/Math.PI/10; } if(whoaQ == 11){ wildTwist0 = offsetX[thisRing]/Math.PI/10; wildTwist1 = 1; wildTwist2 = 1; wildTwist3 = 1; wildCard0 = 1; wildCard1 = Math.sin(offsetX[i]/Math.PI/10); wildCard2 = 1; wildCard3 = -Math.cos(offsetY[i]/Math.PI/10); } if(whoaQ == 12){ wildTwist0 = (countDown*i)/Math.PI/10; wildTwist1 = 1; wildTwist2 = 1; wildTwist3 = 1; wildCard0 = Math.sin(offsetX[i]/Math.PI/10); wildCard1 = 1; wildCard2 = -Math.cos(offsetY[i]/Math.PI/10); wildCard3 = 1; } if(whoaQ == 13){ wildTwist0 = (thisRing-offsetY[countDown])/Math.PI/10; wildTwist1 = 1; wildTwist2 = 1; wildTwist3 = countDown/Math.PI/10; wildCard0 = Math.sin(offsetX[i]/Math.PI/10); wildCard1 = Math.sin(offsetX[i]/Math.PI/10); wildCard2 = -Math.cos(offsetY[i]/Math.PI/10); wildCard3 = -Math.cos(offsetY[i]/Math.PI/10); } if(whoaQ == 14){ wildTwist0 = countDown/Math.PI/10; wildTwist1 = thisRing/Math.PI/10; wildTwist2 = (offsetY[thisRing]/offsetX[i])/Math.PI/10; wildTwist3 = 1; wildCard0 = -Math.cos(thisRing/Math.PI/10); wildCard1 = -Math.cos(offsetX[i]/Math.PI/10); wildCard2 = Math.sin(thisRing/Math.PI/10); wildCard3 = Math.sin(offsetY[i]/Math.PI/10); } if(whoaQ == 15){ wildTwist0 = (thisRing/(i+1))/Math.PI/10; wildTwist1 = countDown/Math.PI/10; wildTwist2 = (countDown-i)/Math.PI/10; wildTwist3 = thisRing/Math.PI/10; wildCard0 = -Math.cos(countDown/Math.PI/10)/(i+1); wildCard1 = -Math.cos(offsetY[i]/Math.PI/10)/(i+2); wildCard2 = Math.sin(thisRing/Math.PI/10)/(i+2); wildCard3 = Math.sin(offsetX[i]/Math.PI/10)/(i+1); } //CAVE if(foundation == 0){ pentaLines.graphics.moveTo(xNew + radius*wildCard0*Math.sin(angle*wildTwist0*(i+twist)) + adjX, yNew + -radius*wildCard1*Math.cos(angle*wildTwist1*(i+twist)) + adjY); pentaLines.graphics.lineTo(xNew + radius*wildCard2*Math.sin(angle*wildTwist2*((i+twist)+1)) + adjX, yNew + -radius*wildCard3*Math.cos(angle*wildTwist3*((i+twist)+1))+ adjY); } //ngl, the other foundations are VERY complicated //lines 0 & 4 have to trail off straight up, down, or horizontally, and this would normally be easy, //using the next point's, (i+1)'s, Y-coordinate and then just using stage.stageWidth or zero for the X, //but because the lines rotate these lines are no longer sraight up/down/sideways—they get their own trig. //all this bother could probably just be solved by just rotating the matrix, but it was rewarding for me... //to figure it all out like this, tacking points onto other points. //again, frameHypotenuse because what if the "horizon" is tilted 45º @ (0, 0)? it needs to reach //ROLLER COASTER if(foundation == 1){ if(i%5 == 0){ pentaLines.graphics.moveTo((xNew + radius*wildCard0*Math.sin(angle*wildTwist0*((i+twist)+1)) + adjX) + frameHypotenuse*Math.sin(angle*wildTwist0*((i+twist)+1 + 1.5)), (yNew + -radius*wildCard1*Math.cos(angle*wildTwist1*((i+twist)+1)) + adjY) + -frameHypotenuse*Math.cos(angle*wildTwist1*((i+twist)+1 + 1.5))); pentaLines.graphics.lineTo(xNew + radius*wildCard2*Math.sin(angle*wildTwist2*((i+twist)+1)) + adjX, yNew + -radius*wildCard3*Math.cos(angle*wildTwist3*((i+twist)+1)) + adjY); } if(i%5 == 1 || i%5 == 2 || i%5 == 3){ pentaLines.graphics.moveTo(xNew + radius*wildCard0*Math.sin(angle*wildTwist0*(i+twist)) + adjX, yNew + -radius*wildCard1*Math.cos(angle*wildTwist1*(i+twist)) + adjY); pentaLines.graphics.lineTo(xNew + radius*wildCard2*Math.sin(angle*wildTwist2*((i+twist)+1)) + adjX, yNew + -radius*wildCard3*Math.cos(angle*wildTwist3*((i+twist)+1)) + adjY); } if(i%5 == 4){ pentaLines.graphics.moveTo(xNew + radius*wildCard0*Math.sin(angle*(i+twist)) + adjX, yNew + -radius*wildCard1*Math.cos(angle*(i+twist)) + adjY); pentaLines.graphics.lineTo((xNew + radius*wildCard2*Math.sin(angle*wildTwist2*((i+twist))) + adjX) + frameHypotenuse*Math.sin(angle*wildTwist2*((i+twist) - 1.5)), (yNew + -radius*wildCard3*Math.cos(angle*wildTwist3*((i+twist))) + adjY) + -frameHypotenuse*Math.cos(angle*wildTwist3*((i+twist) - 1.5))); } } //RIVER if(foundation == 2){ if(i%5 == 0){ pentaLines.graphics.moveTo((xNew + radius*wildCard0*Math.sin(angle*wildTwist0*((i+twist)+1)) + adjX) + frameHypotenuse*Math.sin(angle*wildTwist0*((i+twist)+1 + .25)), (yNew + -radius*wildCard1*Math.cos(angle*wildTwist1*((i+twist)+1)) + adjY) + -frameHypotenuse*Math.cos(angle*wildTwist1*((i+twist)+1 + .25))); pentaLines.graphics.lineTo(xNew + radius*wildCard2*Math.sin(angle*wildTwist2*((i+twist)+1)) + adjX, yNew + -radius*wildCard3*Math.cos(angle*wildTwist3*((i+twist)+1)) + adjY); } if(i%5 == 1 || i%5 == 2 || i%5 == 3){ pentaLines.graphics.moveTo(xNew + radius*wildCard0*Math.sin(angle*wildTwist0*(i+twist)) + adjX, yNew + -radius*wildCard1*Math.cos(angle*wildTwist1*(i+twist)) + adjY); pentaLines.graphics.lineTo(xNew + radius*wildCard2*Math.sin(angle*wildTwist2*((i+twist)+1)) + adjX, yNew + -radius*wildCard3*Math.cos(angle*wildTwist3*((i+twist)+1)) + adjY); } if(i%5 == 4){ pentaLines.graphics.moveTo(xNew + radius*wildCard0*Math.sin(angle*wildTwist0*(i+twist)) + adjX, yNew + -radius*wildCard1*Math.cos(angle*wildTwist1*(i+twist)) + adjY); pentaLines.graphics.lineTo((xNew + radius*wildCard2*Math.sin(angle*wildTwist2*((i+twist))) + adjX) + frameHypotenuse*Math.sin(angle*wildTwist2*((i+twist) + -.25)), (yNew + -radius*wildCard3*Math.cos(angle*wildTwist3*((i+twist))) + adjY) + -frameHypotenuse*Math.cos(angle*wildTwist3*((i+twist)+ -.25))); } } //TRENCH if(foundation == 3){ if(i%5 == 0){ pentaLines.graphics.moveTo((xNew + radius*wildCard0*Math.sin(angle*wildTwist0*((i+twist)+1)) + adjX) + frameHypotenuse*Math.sin(angle*wildTwist0*((i+twist)+1 - 1)), (yNew + -radius*wildCard1*Math.cos(angle*wildTwist1*((i+twist)+1)) + adjY) + -frameHypotenuse*Math.cos(angle*wildTwist1*((i+twist)+1 - 1))); pentaLines.graphics.lineTo(xNew + radius*wildCard2*Math.sin(angle*wildTwist2*((i+twist)+1)) + adjX, yNew + -radius*wildCard3*Math.cos(angle*wildTwist3*((i+twist)+1)) + adjY); } if(i%5 == 1 || i%5 == 2 || i%5 == 3){ pentaLines.graphics.moveTo(xNew + radius*wildCard0*Math.sin(angle*wildTwist0*(i+twist)) + adjX, yNew + -radius*wildCard1*Math.cos(angle*wildTwist1*(i+twist)) + adjY); pentaLines.graphics.lineTo(xNew + radius*wildCard2*Math.sin(angle*wildTwist2*((i+twist)+1)) + adjX, yNew + -radius*wildCard3*Math.cos(angle*wildTwist3*((i+twist)+1)) + adjY); } if(i%5 == 4){ pentaLines.graphics.moveTo(xNew + radius*wildCard0*Math.sin(angle*wildTwist0*(i+twist)) + adjX, yNew + -radius*wildCard1*Math.cos(angle*wildTwist1*(i+twist)) + adjY); pentaLines.graphics.lineTo((xNew + radius*wildCard2*Math.sin(angle*wildTwist2*((i+twist))) + adjX) + frameHypotenuse*Math.sin(angle*wildTwist2*((i+twist) + 1)), (yNew + -radius*wildCard3*Math.cos(angle*wildTwist3*((i+twist))) + adjY) + -frameHypotenuse*Math.cos(angle*wildTwist3*((i+twist) + 1))); } } } //DECREASE RADIUS FOR NEXT RING //now that one pentagon has been drawn, get ready to draw a smaller one; this means decreasing the radius if(perspectiveN == true){ radius -= Math.floor(165/thisRing) + roundConstant; //subtract a lot at first (closer up), and less further one(far away) } else{ radius -= flatConstant; //flat perspective means same spacing } } //Now that all the lines of the Pentagon have been drawn, add them to the pentagonPlane pentagonPlane.addChild(pentaLines); //TRANSLATE LINES TO CENTER var centerStage:Matrix = new Matrix(); centerStage.translate(stage.stageWidth / 2, stage.stageHeight / 2); pentaLines.transform.matrix = centerStage; //FRAME NUMBER INCREASE frameNumber++; //a frame has been drawn, so increase the frame number; //reset @100000 //nah... //if(frameNumber >= 100000){ // frameNumber = 0; //} } //COLOR CHANGE FUNCTION function chooseColor(thingNumber:Int):Int{ var returnColor:Int = 0; if(thingNumber == 0){ returnColor = black; } if(thingNumber == 1){ returnColor = gray; } if(thingNumber == 2){ returnColor = white; } if(thingNumber == 3){ returnColor = red; } if(thingNumber == 4){ returnColor = orange; } if(thingNumber == 5){ returnColor = yellow; } if(thingNumber == 6){ returnColor = green; } if(thingNumber == 7){ returnColor = blue; } if(thingNumber == 8){ returnColor = purple; } if(thingNumber == 9){ returnColor = pink; } return returnColor; } //MAP VALUES FUNCTION function mapper(input:Float, inputLeftUp:Float, inputRightUp:Float, outputLeftUp:Float, outputRightDown:Float):Float{ return outputLeftUp + (input - inputLeftUp) * (outputRightDown - outputLeftUp) / (inputRightUp - inputLeftUp); } //CALCULATE HYPOTENUSE (called at beginning & on resize) function frameHypotenuser():Void{ frameHypotenuse = Math.sqrt(stage.stageWidth*stage.stageWidth + stage.stageHeight*stage.stageHeight); } //AUTOPATH //randomize autoX function autoX():Void{ autoMoveX = Math.random()/2; autoRangeX_left = -Math.random()*5; autoRangeX_right = Math.random()*5; } //randomize autoY function autoY():Void{ autoMoveY = Math.random()/2; autoRangeY_up = -Math.random()*5; autoRangeY_down = Math.random()*5; } //MOUSE CLICK = CHANGE PERSPECTIVE (press N also works) function onMouseDown(e:MouseEvent):Void{ perspectiveN =! perspectiveN; } //MOUSE WHEEL = ROTATE function onMouseWheel(event:openfl.events.MouseEvent):Void { if(event.delta > 0){ vortex[0] += .01 * event.delta; } if(event.delta < 0){ vortex[0] += .01 * event.delta; } } //RESIZE WINDOW function onResize(e:Event):Void { //get new hypotenuse frameHypotenuser(); //redraw the background rectangle to fit the new window's size BGplane.removeChildAt(0); background.graphics.beginFill(chooseColor(backdrop)); // black background.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight); background.graphics.endFill(); BGplane.addChild(background); } //KEYBOARD KEYS function onKeyDown(event:KeyboardEvent):Void { //get rid of the "PRESS [I} FOR EXTENSIVE CONTROLS" box & textFormat if(firstPress == false){ writingPlane.text = ""; //see? It's empty writingPlane.background = true; //make sure no background for the text writingPlane.backgroundColor = 0x000000;//0x023020; writingPlane.alpha = .75; writingPlane.width = 0; writingPlane.height = 0; //stage.stageHeight/8; writingPlane.wordWrap = true; // Enable word wrapping //set up the writing format writingFormat.size = 9; writingFormat.color = white; //writingFormat.font = Assets.getFont("assets/Times New Roman.ttf").fontName; writingFormat.align = "left"; writingPlane.defaultTextFormat = writingFormat; writingPlane.setTextFormat(writingFormat); writingPlane.x = 0; writingPlane.y = 0; firstPress = true; } //PRESETS PRESETS PRESETS PRESETS PRESETS PRESETS PRESETS PRESETS PRESETS PRESETS PRESETS PRESETS PRESETS PRESETS PRESETS PRESETS //1 --> (Gliding over all) if(event.keyCode == 49){ ringNum = 60; lineToggleY = 1; sides = 5; angle = (360/sides)*(Math.PI/180); flatConstant = 12; roundConstant = 0; perspectiveN = true; autoPathP = false; mouseCreepM = false; whoaQ = 0; upOrDown = .5; leftOrRight = 0; field = 6; fieldColor0 = green; fieldColor1 = green; rock = 1; rockColor0 = gray; rockColor1 = gray; water = 7; waterColor0 = blue; foundation = 2; vortex[0] = 0; autoRotateC = 0; turnOfTheScrew = .1; BGplane.removeChildAt(0); backdrop = 0; background.graphics.beginFill(chooseColor(backdrop)); // black background.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight); background.graphics.endFill(); BGplane.addChild(background); } //2 --> (Magma tunnel) if(event.keyCode == 50){ ringNum = 60; lineToggleY = 2; sides = 5; angle = (360/sides)*(Math.PI/180); flatConstant = 12; roundConstant = 0; perspectiveN = true; autoPathP = true; mouseCreepM = false; whoaQ = 0; upOrDown = 0; leftOrRight = 0; field = 1; fieldColor0 = white; fieldColor1 = white; rock = 1; rockColor0 = white; rockColor1 = white; water = 3; waterColor0 = red; foundation = 0; vortex[0] = 0; autoRotateC = 0; turnOfTheScrew = .1; BGplane.removeChildAt(0); backdrop = 0; background.graphics.beginFill(chooseColor(backdrop)); // black background.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight); background.graphics.endFill(); BGplane.addChild(background); } //3 --> (Undersea trench) if(event.keyCode == 51){ ringNum = 60; lineToggleY = 0; sides = 5; angle = (360/sides)*(Math.PI/180); flatConstant = 12; roundConstant = 0; perspectiveN = false; autoPathP = true; mouseCreepM = true; whoaQ = 0; upOrDown = 0; leftOrRight = 0; field = 5; fieldColor0 = orange; fieldColor1 = orange; rock = 1; rockColor0 = gray; rockColor1 = gray; water = 8; waterColor0 = purple; foundation = 3; vortex[0] = 0; autoRotateC = 0; turnOfTheScrew = .1; BGplane.removeChildAt(0); backdrop = 7; background.graphics.beginFill(chooseColor(backdrop)); // black background.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight); background.graphics.endFill(); BGplane.addChild(background); } //4 --> (Roller coaster) if(event.keyCode == 52){ ringNum = 60; lineToggleY = 0; sides = 5; angle = (360/sides)*(Math.PI/180); flatConstant = 12; roundConstant = 0; perspectiveN = true; autoPathP = false; mouseCreepM = true; whoaQ = 0; upOrDown = 2; leftOrRight = 2; field = 4; fieldColor0 = orange; fieldColor1 = orange; rock = 3; rockColor0 = red; rockColor1 = red; water = 1; waterColor0 = white; foundation = 1; vortex[0] = -.2; autoRotateC = 0; turnOfTheScrew = .1; BGplane.removeChildAt(0); backdrop = 6; background.graphics.beginFill(chooseColor(backdrop)); // black background.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight); background.graphics.endFill(); BGplane.addChild(background); } //5 --> (Twist) if(event.keyCode == 53){ ringNum = 60; lineToggleY = 0; sides = 15; angle = (360/sides)*(Math.PI/180); flatConstant = 15; roundConstant = 0; perspectiveN = false; autoPathP = false; mouseCreepM = false; whoaQ = 0; upOrDown = 1.25; leftOrRight = -.5; field = 6; fieldColor0 = blue; fieldColor1 = blue; rock = 9; rockColor0 = pink; rockColor1 = pink; water = 1; waterColor0 = white; foundation = 0; vortex[0] = 0; autoRotateC = 1; turnOfTheScrew = .1; BGplane.removeChildAt(0); backdrop = 0; background.graphics.beginFill(chooseColor(backdrop)); // black background.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight); background.graphics.endFill(); BGplane.addChild(background); } //0 --> (Panchira) if(event.keyCode == 48){ ringNum = 60; lineToggleY = 0; sides = 5; angle = (360/sides)*(Math.PI/180); flatConstant = 12; roundConstant = 0; perspectiveN = false; autoPathP = true; mouseCreepM = false; whoaQ = 0; upOrDown = 0; leftOrRight = 0; field = 6; fieldColor0 = blue; fieldColor1 = blue; rock = 9; rockColor0 = pink; rockColor1 = pink; water = 1; waterColor0 = white; foundation = 3; vortex[0] = 2.5; autoRotateC = 0; turnOfTheScrew = .1; BGplane.removeChildAt(0); backdrop = 0; background.graphics.beginFill(chooseColor(backdrop)); // black background.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight); background.graphics.endFill(); BGplane.addChild(background); } //VANTAGE POINT VANTAGE POINT VANTAGE POINT VANTAGE POINT VANTAGE POINT VANTAGE POINT VANTAGE POINT VANTAGE POINT VANTAGE POINT //N --> (change perspective) if (event.keyCode == 78) { perspectiveN =! perspectiveN; } //A & LEFT --> (creep position left) if (event.keyCode == 65 || event.keyCode == 37) { leftOrRight += .1; } //D & RIGHT -- (creep position right) if (event.keyCode == 68 || event.keyCode == 39) { leftOrRight -= .1; } //W & UP --> (creep position up) if (event.keyCode == 38 || event.keyCode == 87) { upOrDown += .1; } //S & DOWN --> (creep position down) if (event.keyCode == 40 || event.keyCode == 83) { upOrDown -= .1; } //M --> (mouseCreep ON/OFF) if (event.keyCode == 77) { mouseCreepM =! mouseCreepM; leftOrRight = 0; upOrDown = 0; } //COMMA , --> (decrease spacing) if(event.keyCode == 188){ if(perspectiveN == false){ flatConstant -= .1; } else{ roundConstant -= .1; } } //PERIOD . --> (increase spacing) if(event.keyCode == 190){ if(perspectiveN == false){ flatConstant += .1; } else{ roundConstant += .1; } } //SLASH / --> (reset spacing) if(event.keyCode == 191){ flatConstant = 12; roundConstant = 0; } //AUTO AUTO AUTO AUTO AUTO AUTO AUTO AUTO AUTO AUTO AUTO AUTO AUTO AUTO AUTO AUTO AUTO AUTO AUTO AUTO AUTO AUTO AUTO AUTO //P --> (autoPath ON/OFF) if (event.keyCode == 80) { autoPathP =! autoPathP; autoX(); autoY(); } //C --> (autoRotate cycle) if(event.keyCode == 67){ autoRotateC = (autoRotateC+1)%4; } //B --> (rotation reset; autoRotate OFF) if (event.keyCode == 66) { vortex[0] = 0; autoRotateC = 0; } //FOUNDATION FOUNDATION FOUNDATION FOUNDATION FOUNDATION FOUNDATION FOUNDATION FOUNDATION FOUNDATION FOUNDATION FOUNDATION //V --> (foundation cycle) if(event.keyCode == 86){ foundation = (foundation+1)%4; } //Z --> (sides minus one) if(event.keyCode == 90){ if(sides>2){ sides--; angle = (360/sides)*(Math.PI/180); } } //X --> (sides plus one) if(event.keyCode == 88){ sides++; angle = (360/sides)*(Math.PI/180); } //L --> (increase ringNum) if(event.keyCode == 76){ if(ringNum <120){ ringNum++; } } //K --> (decrease ringNum) if(event.keyCode == 75){ if(ringNum >0){ ringNum--; } } //SEMICOLON --> (reset ringNum to 60) if(event.keyCode == 186){ ringNum = 60; } //COSMETIC COSMETIC COSMETIC COSMETIC COSMETIC COSMETIC COSMETIC COSMETIC COSMETIC COSMETIC COSMETIC COSMETIC COSMETIC COSMETIC //Y --> (line weight cycle) if(event.keyCode == 89){ lineToggleY = (lineToggleY+1)%3; } //E --> (random color for each line) if(event.keyCode == 69){ fieldColor0 = Math.floor(Math.random()*0xFFFFFF); rockColor0 = Math.floor(Math.random()*0xFFFFFF); waterColor0 = Math.floor(Math.random()*0xFFFFFF); rockColor1 = Math.floor(Math.random()*0xFFFFFF); fieldColor1 = Math.floor(Math.random()*0xFFFFFF); } //F --> (top pair of pentagon sides) if(event.keyCode == 70){ field = (field+1)%10; fieldColor0 = chooseColor(field); fieldColor1 = chooseColor(field); } //G --> (bottom pair of pentagon sides) if(event.keyCode == 71){ rock = (rock+1)%10; rockColor0 = chooseColor(rock); rockColor1 = chooseColor(rock); } //H --> (floor of pentagon sides) if(event.keyCode == 72){ water = (water+1)%10; waterColor0 = chooseColor(water); } //J --> (background) if(event.keyCode == 74){ backdrop = (backdrop+1)%10; BGplane.removeChildAt(0); background.graphics.beginFill(chooseColor(backdrop)); // black background.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight); background.graphics.endFill(); BGplane.addChild(background); } //OTHER OTHER OTHER OTHER OTHER OTHER OTHER OTHER OTHER OTHER OTHER OTHER OTHER OTHER OTHER OTHER OTHER OTHER OTHER OTHER //I --> (info ON/OFF) if(event.keyCode == 73){ infoShowI = !infoShowI; if(infoShowI == true){ pentShowO = false; writingPlane.text = controls; writingPlane.width = stage.stageWidth/2; writingPlane.height = stage.stageHeight; } else{ pentShowO = false; writingPlane.text = ""; writingPlane.width = 0; writingPlane.height = 0; } } //O --> (pentavalence ON/OFF) if(event.keyCode == 79){ pentShowO = !pentShowO; if(pentShowO == true){ infoShowI = false; writingPlane.text = pentavalence; writingPlane.width = stage.stageWidth/2; writingPlane.height = stage.stageHeight; } else{ infoShowI = false; writingPlane.text = ""; writingPlane.width = 0; writingPlane.height = 0; } } //U --> ("slow time" w/o text) if(event.keyCode == 85){ slowDownU = !slowDownU; if(slowDownU == true){ timeyWimey = 5; } else{ timeyWimey = 1; } } //Q --> (wildcard) if(event.keyCode == 81){ whoaQ = (whoaQ+1)%16; } //R --> (RANDOM) if(event.keyCode == 82){ ringNum = Math.floor(Math.random()*120)+1; lineToggleY = Math.floor(Math.random()*2); sides = Math.floor(Math.random()*10)+2; angle = (360/sides)*(Math.PI/180); flatConstant = Math.floor(Math.random()*50); roundConstant = 0; perspectiveN = Math.random() < .5; autoPathP = Math.random() < .5; mouseCreepM = Math.random() < .5; whoaQ = 0; upOrDown = 1.5 - Math.random()*3; leftOrRight = 1.5 - Math.random()*3; field = 6; fieldColor0 = Math.floor(Math.random() * 0xFFFFFF); fieldColor1 = Math.floor(Math.random() * 0xFFFFFF); rock = 9; rockColor0 = Math.floor(Math.random() * 0xFFFFFF); rockColor1 = Math.floor(Math.random() * 0xFFFFFF); water = 1; waterColor0 = Math.floor(Math.random() * 0xFFFFFF); foundation = Math.floor(Math.random()*3); vortex[0] = Math.random()*5; autoRotateC = Math.floor(Math.random()*2) + 1; turnOfTheScrew = Math.random()*.1; BGplane.removeChildAt(0); backdrop = 0; background.graphics.beginFill(chooseColor(backdrop)); // black background.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight); background.graphics.endFill(); BGplane.addChild(background); } //T --> (RANDOM w/ WILDCARDS) if(event.keyCode == 84){ ringNum = Math.floor(Math.random()*120)+1; lineToggleY = Math.floor(Math.random()*2); sides = Math.floor(Math.random()*10)+2; angle = (360/sides)*(Math.PI/180); flatConstant = Math.floor(Math.random()*50); roundConstant = 0; perspectiveN = Math.random() < .5; autoPathP = Math.random() < .5; mouseCreepM = Math.random() < .5; whoaQ = Math.floor(Math.random()*15); upOrDown = 1.5 - Math.random()*3; leftOrRight = 1.5 - Math.random()*3; field = 6; fieldColor0 = Math.floor(Math.random() * 0xFFFFFF); fieldColor1 = Math.floor(Math.random() * 0xFFFFFF); rock = 9; rockColor0 = Math.floor(Math.random() * 0xFFFFFF); rockColor1 = Math.floor(Math.random() * 0xFFFFFF); water = 1; waterColor0 = Math.floor(Math.random() * 0xFFFFFF); foundation = Math.floor(Math.random()*3); vortex[0] = Math.random()*5; autoRotateC = Math.floor(Math.random()*2) + 1; turnOfTheScrew = Math.random()*.1; BGplane.removeChildAt(0); backdrop = 0; background.graphics.beginFill(chooseColor(backdrop)); // black background.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight); background.graphics.endFill(); BGplane.addChild(background); } } } //This Flash was created command-line using Haxe/openFL on a Mac in a folder called "SecondFlash" //everything above was in a file called "Main.hx" which I wrote using TextEdit; getting errors as I ran thru Terminal //remove the leading "//"s below for the "project.xml" and the "SecondFlash.hxproj" of course //BELOW IS THE project.xml BELOW IS THE project.xml BELOW IS THE project.xml BELOW IS THE project.xml BELOW IS THE project.xml // // // // // // // // // // // // // // // // // // //ABOVE IS THE project.xml ABOVE IS THE project.xml ABOVE IS THE project.xml ABOVE IS THE project.xml ABOVE IS THE project.xml //(the .xml overrides the wrong dimensions here below in the .hxproj; I leave them in to illustrate how the .xml can supercedes things) //BELOW IS THE SecondFlash.hxproj BELOW IS THE SecondFlash.hxproj BELOW IS THE SecondFlash.hxproj BELOW IS THE SecondFlash.hxproj // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // "$(CompilerPath)/haxelib" run lime build "$(OutputFile)" $(TargetBuild) -$(BuildConfig) -Dfdb // // // // // // // // //ABOVE IS THE SecondFlash.hxproj ABOVE IS THE SecondFlash.hxproj ABOVE IS THE SecondFlash.hxproj ABOVE IS THE SecondFlash.hxproj //ASSETS //there were three assets for this Flash: //"song1 small.mp3" --> a low quality .mp3 of a song made called 'Pro Forma Incantation' (written note-by-note in GarageBand 2-ish yrs ago) //"PentagonFlash_buttons.txt" --> controls //"PentagonFlash_drivel.txt" --> bloviation //began January 22, 2025; finished* January 31st //*that's what the "_v1" is for; definitely revisiting this //I apologize if my code/comments are laughable; this is the first time seriously trying to organize/explain my script