
|
|
|
|
For you coders out there, actionscript class of the triangles that the player will be able to build on.
If you DON'T GIVE A FUCK, check out the Concept Sketches and Ideas instead. package{ class GridTriangle{ var accelX:int; //How much creeps are accelerated along the x axis when they stand on the triangle. var accelY:int; //Same as above but for y axis. var buildCost:Number //How much the cost of a tower is multiplied by when it is built on this triangle. var threePoints:Array; //Keeps track of the location of each point of the triangle. var color:Color; //Keeps track of the color that the triangle will be drawn. var buildable:Boolean; //Keeps track of whether or not you can build on this triangle. var tower:Tower; //Keeps track of the tower built on this triangle. function gridTriangle(x1:int, y1:int, x2:int, y2:int, x3:int, y3:int){ threePoints[1] = new Point(x1,y1); //Creates the three points with info from the constructor threePoints[2] = new Point(x2,y2); threePoints[3] = new Point(x3,y3); accelX = 0; //Accelerations are 0 by default accelY = 0; buildCost = 1; //Buildcost is 1 by default, implying 0 percent change in the cost to build on the triangle color = new Color(0,0,0,1,0,0,0,0); //Color should be black by default4 buildable = true; //Can build on the triangle by default } function gridTriangle(x1:int, y1:int, x2:int, y2:int, x3:int, y3:int, aX:int, aY:int){ threePoints[1] = new Point(x1,y1); //Creates a triangle with acceleration from the constructor threePoints[2] = new Point(x2,y2); threePoints[3] = new Point(x3,y3); accelX = aX; accelY = aY; buildCost = 1; color = new Color(0,0,0,1,0,0,0,0); buildable = true; } function gridTriangle(x1:int, y1:int, x2:int, y2:int, x3:int, y3:int, aX:int, aY:int, bCost:Number){ threePoints[1] = new Point(x1,y1); //Creates a triangle with acceleration and build cost from the constructor threePoints[2] = new Point(x2,y2); threePoints[3] = new Point(x3,y3); accelX = aX; accelY = aY; buildCost = bCost; color = new Color(0,0,0,1,0,0,0,0); if(bCost != 1){ //Changes the color of the lines to reflect the build cost. if(bCost > 1){ //If the build cost will increase the lines get a red tint. if(bCost <= 3){ //Build cost should never be more than 3 times the original color.redOffset = bCost * 85; //The red value = the build cost modifier multiplied by 85. }else{ //In the rare event that the build cost modifier is greater color.redOffset = 255; //than three, the red value is set to 255. } }else{ //If the cost is going to be cheaper than normal the color if(bCost >= 0){ //gains a green tint. color.greenOffset = (1 - bCost) * 255; //The cost should never be less than 0, implying 0% of the }else{ //original cost. Color changing technique is similar to red color.greenOffset = 255; //and should be self explanitory. } } } buildable = true; } function gridTriangle(x1:int, y1:int, x2:int, y2:int, x3:int, y3:int, aX:int, aY:int, bCost:Number, canBuild:Boolean ){ threePoints[1] = new Point(x1,y1); threePoints[2] = new Point(x2,y2); threePoints[3] = new Point(x3,y3); accelX = aX; accelY = aY; buildCost = bCost; color = new Color(0,0,0,1,0,0,0,0); if(canBuild){ //Same as above, but buildability is taken from if(bCost != 1){ //the constructor. The line color will be set to if(bCost > 1){ //gray if the player will be unable to build on the if(bCost <= 3){ //tile. color.redOffset = bCost * 85; }else{ color.redOffset = 255; } }else{ if(bCost >= 0){ color.greenOffset = (1 - bCost) * 255; }else{ color.greenOffset = 255; } } } }else{ color.greenOffset = 140; color.redOffset = 140; color.blueOffset = 140; } buildable = canBuild; } function gridTriangle(x1:int, y1:int, x2:int, y2:int, x3:int, y3:int, aX:int, aY:int, canBuild:Boolean ){ threePoints[1] = new Point(x1,y1); //Creates triangle with acceleration and buildability from constructor. threePoints[2] = new Point(x2,y2); threePoints[3] = new Point(x3,y3); accelX = aX; accelY = aY; buildCost = bCost; color = new Color(0,0,0,1,0,0,0,0); if(bCost != 1){ if(bCost > 1){ if(bCost <= 3){ color.redOffset = bCost * 85; }else{ color.redOffset = 255; } }else{ if(bCost >= 0){ color.greenOffset = (1 - bCost) * 255; }else{ color.greenOffset = 255; } } } buildable = canBuild; } function gridTriangle(x1:int, y1:int, x2:int, y2:int, x3:int, y3:int, canBuild:Boolean ){ threePoints[1] = new Point(x1,y1); //Creates a constructor with buildability from the constructor. threePoints[2] = new Point(x2,y2); threePoints[3] = new Point(x3,y3); accelX = 0; accelY = 0; buildCost = bCost; color = new Color(0,0,0,1,0,0,0,0); if(bCost != 1){ if(bCost > 1){ if(bCost <= 3){ color.redOffset = bCost * 85; }else{ color.redOffset = 255; } }else{ if(bCost >= 0){ color.greenOffset = (1 - bCost) * 255; }else{ color.greenOffset = 255; } } } buildable = canBuild; } function gridTriangle(x1:int, y1:int, x2:int, y2:int, x3:int, y3:int, bCost:Number){ threePoints[1] = new Point(x1,y1); //Creates a triangle with cost modifier from the constructor. threePoints[2] = new Point(x2,y2); threePoints[3] = new Point(x3,y3); accelX = 0; accelY = 0; buildCost = bCost; color = new Color(0,0,0,1,0,0,0,0); if(canBuild){ if(bCost != 1){ if(bCost > 1){ if(bCost <= 3){ color.redOffset = bCost * 85; }else{ color.redOffset = 255; } }else{ if(bCost >= 0){ color.greenOffset = (1 - bCost) * 255; }else{ color.greenOffset = 255; } } } }else{ color.greenOffset = 140; color.redOffset = 140; color.blueOffset = 140; } buildable = true; } function gridTriangle(x1:int, y1:int, x2:int, y2:int, x3:int, y3:int, bCost:Number, canBuild:Boolean ){ threePoints[1] = new Point(x1,y1); //Creates a triangle with cost modifier and buildability from the constructor. threePoints[2] = new Point(x2,y2); threePoints[3] = new Point(x3,y3); accelX = 0; accelY = 0; buildCost = bCost; color = new Color(0,0,0,1,0,0,0,0); if(canBuild){ if(bCost != 1){ if(bCost > 1){ if(bCost <= 3){ color.redOffset = bCost * 85; }else{ color.redOffset = 255; } }else{ if(bCost >= 0){ color.greenOffset = (1 - bCost) * 255; }else{ color.greenOffset = 255; } } } }else{ color.greenOffset = 140; color.redOffset = 140; color.blueOffset = 140; } buildable = canBuild; } } }
|
|
|
|
Post a comment! You can also post a photo below:
|
Comment with FacebookClick connect and comment instantly! |
Comment with Dtoid
New? SIGN UP - it takes 5 seconds |
Comments policy
Destructoid is an open discussion community. You don't need to "audition" to post a comment - just speak your mind. We respect differing opinions on the site, so have at it. Be smart, funny, insightful, clueless, or cute -- but back it up with substance. Keep your cool, keep it fun. We only ask that you act respectfully and above all: don't be a troll and ruin it for everyone else. Don't bring down gamers or we'll, you know, gently shoot you in the face and stuff you into a flaming mailbox. Each comment is your opportuntity to make this community awesomer. Is that even a word?
Avoiding the banhammer only requires common sense: spamming, trolling, racism, NSFW stuff, and other forms of sucking will not be tolerated. If anyone is griefing please report abuse. Be good. Don't suck!

Follow
RSS
Contact
Got a wiki?
I swear it's all tabbed with nice whitespacing in the actual file, but, when I pasted it into a blog post it got all fucked up :S.
Thanks for pointing out my horrible habits of forgetting that shit. Will fix.
@Reverend Anthony
It's ActionScript, Flash's programming language. It's very similar to Java, which I hear, is uh, similar to C...
AHAAHHAHAHHAHAHAH.
No.
@Blehman
It basically says bewbtastic, or possibly bewbtacular.
Keep up the good work.
Still, good to see that you've actually started work on it.
Some quick comments that you may take or leave :
1. The important thing is to be writing code (so don't worry too much about what I'm going to tell you)
2. I'm not sure if you can overload constructors in actionscript, but if so you should make one giant constructor that all your other constructors feed into. This is more of a maintenance issue (if you add or remove a single attribute you'll end up changing a ton of code)
3. variable names : you have a variable called "buildcostnumber" but the description is of a multiplier for build cost. I'd suggest renaming it to avoid confusion.
bcost loop seems weird.
4. You don't set any color if the bcost value is 1. Then you set different color schemes for 1. Bcost 2 or 3, 2. Bcost >= 3, 3. bcost 0, 4. bcost < 0. Did you mean to miss bcost 1? And the code is a little weird too, it took me a few minutes to figure out what was going on (again, a maintenance issue for you if you come back to the code and need to figure out what it was doing).
5. again, don't get too hung up on what I'm telling you -- the most important thing is to keep writing
i sure hope you can finish this one and have it be good before the deadline. good luck!