Skip to content

Commit

Permalink
Migrate render code to appropriate classes,cleanup.
Browse files Browse the repository at this point in the history
IT NO WERK
  • Loading branch information
pablo-meier committed Sep 22, 2011
1 parent 8409990 commit 95acfbc
Show file tree
Hide file tree
Showing 5 changed files with 173 additions and 193 deletions.
22 changes: 12 additions & 10 deletions tacobell/src/com/morepaul/tacobell/display/TacoCurtain.as
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
package com.morepaul.tacobell.display
{

import flash.display.Shape;
import flash.display.Sprite;

/**
Expand All @@ -34,25 +35,26 @@ package com.morepaul.tacobell.display
*/
public class TacoCurtain extends Sprite
{

private var m_background : Shape;

public function TacoCurtain():void
{
super();
}

/**
* Lowers the curtain -- covers the animation. }
*/
public function lower():void
{

var m_background : Shape = new Shape();
addChild(m_background);
}

/**
* Raise the curtian -- shows the animation.
* Lowers the curtain -- covers the animation. }
*/
public function raise():void
public function display():void
{

m_background.graphics.lineStyle();
m_background.graphics.beginFill(0x000000);
m_background.graphics.drawRect(0,0, this.width, this.height);
m_background.graphics.endFill();
}
}
}
20 changes: 15 additions & 5 deletions tacobell/src/com/morepaul/tacobell/display/TacoMatchPlacard.as
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,17 @@

package com.morepaul.tacobell.display
{

import flash.display.Sprite;
import flash.display.Bitmap;
import flash.display.Graphics;
import flash.display.Shape;
import flash.display.Sprite
import flash.text.AntiAliasType;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.text.TextFormatAlign;

import com.morepaul.tacobell.data.TacoMatch;


/**
* The MatchPlacard lies at the bottom of the render area, and displays
* information about the match that is not specific to any player. In this
Expand All @@ -36,9 +41,14 @@ package com.morepaul.tacobell.display
*/
public class TacoMatchPlacard extends Sprite
{
private var m_media : TacoMediaManager;

public function TacoMatchPlacard():void
{ super(); }
public function TacoMatchPlacard( media : TacoMediaManager ):void
{
super();

m_media = media;
}

/**
* The primary functionality -- we render the MatchPlacard to render
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ package com.morepaul.tacobell.display
return icon;
}

public function league( name:String, rank:String ):Bitmap
public function league( name:String, rankInt:uint ):Bitmap
{
var league : TacoLeague;
var icon : Bitmap;
Expand All @@ -107,8 +107,6 @@ package com.morepaul.tacobell.display
case "GRANDMASTER" : league = this.grandmaster; break;
}

var rankInt : uint = Number(rank);

if (rankInt > 50) { icon = league.standard }
else if (rankInt > 25) { icon = league.top50 }
else if (rankInt > 8) { icon = league.top25 }
Expand Down
124 changes: 121 additions & 3 deletions tacobell/src/com/morepaul/tacobell/display/TacoPlayerTable.as
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,43 @@
package com.morepaul.tacobell.display
{

import flash.display.Bitmap;
import flash.display.Graphics;
import flash.display.Shape;
import flash.display.Sprite
import flash.text.AntiAliasType;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.text.TextFormatAlign;

import com.morepaul.tacobell.data.TacoMatch;
import com.morepaul.tacobell.data.TacoPlayer;

public class TacoPlayerTable extends Sprite
{

public function TacoPlayerTable():void
{ super(); }
private static const Y_INCREMENT : uint = 60;
private static const Y_START : uint = 60;

private var m_media : TacoMediaManager;
private var m_prettyFormat : TextFormat;
private var m_background : Shape;

public function TacoPlayerTable( media : TacoMediaManager ):void
{
super();

m_media = media;

var m_background : Shape = new Shape();
addChild(m_background);

m_prettyFormat = new TextFormat();
m_prettyFormat.align = TextFormatAlign.CENTER;
m_prettyFormat.bold = true;
m_prettyFormat.color = 0x6BF8FF;
m_prettyFormat.font = "Arial";
m_prettyFormat.size = 16;
}


/**
Expand All @@ -39,7 +69,95 @@ package com.morepaul.tacobell.display
*/
public function display( players : Array ):void
{
drawBackground();

var numCols : uint = players.length;

var colWidth : uint = (this.width / numCols);

var rightColBoundary : uint = colWidth;
var leftColBoundary : uint = 0;

for (var i:int = 0; i < players.length; ++i)
{
var yValue : uint = Y_START;

var thisPlayer : TacoPlayer = players[i];

// Define the boundaries of the column...
var colIncrement : uint = (rightColBoundary - leftColBoundary) / 4;
var xCol1 : uint = leftColBoundary + colIncrement;
var xCol2 : uint = leftColBoundary + (2 * colIncrement);
var xCol3 : uint = leftColBoundary + (3 * colIncrement);

var nameStr : String = thisPlayer.name;
var leagueStr : String = thisPlayer.league;
var raceStr : String = thisPlayer.race;
var rank : uint = thisPlayer.rank;

var raceImg : Bitmap = m_media.race(raceStr);
var nameTF : TextField = createPrettyTextField(nameStr);
var leagueImg : Bitmap = m_media.league(leagueStr, rank);

raceImg.width = 50;
raceImg.height = 50;

leagueImg.width = 50;
leagueImg.height = 50;

// place the name row...
raceImg.x = xCol1 - (raceImg.width / 2);
nameTF.x = xCol2 - (nameTF.width / 2);
leagueImg.x = xCol3 - (raceImg.width / 2 );

raceImg.y = yValue;
nameTF.y = yValue;
leagueImg.y = yValue;

addChild(raceImg);
addChild(nameTF);
addChild(leagueImg);

yValue += Y_INCREMENT;

// Place the APM --
var apmStr : String = thisPlayer.apm.toString();

var apmTF : TextField = createPrettyTextField(apmStr);

apmTF.x = xCol2 - (apmTF.width / 2);
apmTF.y = yValue;

addChild(apmTF);

leftColBoundary += colWidth;
rightColBoundary += colWidth;
}
}


private function drawBackground():void
{
// m_background.graphics.lineStyle();
// m_background.graphics.beginFill(0x4036FF);
// m_background.graphics.drawRect(0,0, this.width, this.height);
// m_background.graphics.endFill();
}


/**
* Makes a new TextField the way we want it! Initializes styles, sets contents, etc.
*/
private function createPrettyTextField( contents : String ):TextField
{
var tf : TextField = new TextField();

tf.text = contents;
tf.setTextFormat(m_prettyFormat);

tf.antiAliasType = AntiAliasType.ADVANCED;

return tf;
}
}
}
Loading

0 comments on commit 95acfbc

Please sign in to comment.