dark        
angusm blog header photo
angusm's c-blog
Posts 0Blogs 39Following 0Followers 17


 
 

LONG BLOG

Dtoid Game: First Coded Class

   0
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;

}

}
}
Login to vote this up!


 
 

  0 COMMENTS

Please login (or) make a quick account (free)
to view and post comments.



 Login with Twitter

 Login with Dtoid

Three day old threads are only visible to verified humans - this helps our small community management team stay on top of spam

Sorry for the extra step!

 

About angusmone of us since 10:27 PM on 10.03.2007

Bullet Points 'Bout Me:
-Computer Science student
-Love games
-Play them
-Wanna make them
-Own Wii
-Own PC
-Own DS
-Mostly play PC
-Am a Nerd
-Am a Jock
-Like Cross Country
-Like Rugby
-Like Wrestling
-Canadian
-Likes brevity
-Likes bullet points


If'n you wanna talk, [email protected], let's talk