Skip to content

Commit

Permalink
cleaning up
Browse files Browse the repository at this point in the history
  • Loading branch information
James Paterson committed Jul 28, 2011
1 parent ee37224 commit a0ca87c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 43 deletions.
4 changes: 2 additions & 2 deletions src/com/presstube/chunkulus/ChunkulusApp.as
Expand Up @@ -16,7 +16,7 @@ package com.presstube.chunkulus {
private var bgCircle:Sprite;
private var activeStage:ActiveStage;
private var parallaxScroller:ParallaxScroller;
private var flyingChunk:Chunkulus;
private var flyingChunk:ChunkulusHimself;
private var boundingCircle:Sprite;
private var radius:int;
private var spawning:Boolean;
Expand Down Expand Up @@ -82,7 +82,7 @@ package com.presstube.chunkulus {
scaleStage.addChild(bgCircle = makeBoundingCircle());
scaleStage.addChild(activeStage = new ActiveStage);
scaleStage.addChildAt(parallaxScroller = new ParallaxScroller(scaleStage, activeStage, radius), 1);
activeStage.addChild(flyingChunk = new Chunkulus(activeStage, radius));
activeStage.addChild(flyingChunk = new ChunkulusHimself(activeStage, radius));

scaleStage.addChildAt(boundingCircle = makeBoundingCircle(), 0);
scaleStage.mask = boundingCircle;
Expand Down
Expand Up @@ -8,7 +8,7 @@ package com.presstube.chunkulus {
import flash.geom.Point;
import flash.utils.getDefinitionByName;

public class Chunkulus extends Sprite {
public class ChunkulusHimself extends Sprite {

private static const OPEN:String = "OPEN";
private static const CLOSE:String = "CLOSE";
Expand All @@ -33,7 +33,7 @@ package com.presstube.chunkulus {
private var head:MovieClip;
private var direction:String;

public function Chunkulus(activeStage:ActiveStage, radius:Number) {
public function ChunkulusHimself(activeStage:ActiveStage, radius:Number) {
this.activeStage = activeStage;
this.radius = radius;
bodyAnimIndex = 2;
Expand Down Expand Up @@ -159,7 +159,7 @@ package com.presstube.chunkulus {
public function spawnChunklet():void {
var spread:Number = 10;
var spitRotation:Number = rotation + (Math.random() * spread - Math.random() * spread);
var chunklet:Chunklet = new Chunklet(activeStage, radius, (Math.random() * 10) + 50, spitRotation, velocity);
var chunklet:ConfettiChunklet = new ConfettiChunklet(activeStage, radius, (Math.random() * 10) + 50, spitRotation, velocity);
chunklet.x = x;
chunklet.y = y;
if (Math.random() < .5) {
Expand Down
@@ -1,17 +1,13 @@
package com.presstube.chunkulus {
import com.presstube.utils.PTmove;

import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.MovieClip;
import flash.display.PixelSnapping;
import flash.display.Sprite;
import flash.events.Event;
import flash.geom.ColorTransform;
import flash.geom.Point;
import flash.utils.getDefinitionByName;

public class Chunklet extends Sprite {
public class ConfettiChunklet extends Sprite {

private var activeStage:ActiveStage;
private var radius:Number;
Expand All @@ -21,44 +17,24 @@ package com.presstube.chunkulus {
private var directionInDegrees:Number = 0;
private var amountToRotate:Number;

// private var colors:Array = [0xf800ff, 0xe6e6e6, 0xbcf200, 0x00ffda, 0x0afb00, 0x0304c4, 0xf20086, 0x7c0005, 0x9099ff, 0x614730, 0x20150d, 0xf800ff, 0x301d0d, 0xfffc80, 0x07302f, 0x04fb79, 0x996208, 0xfff809, 0x82ff00, 0xf70609, 0x4c4a3e, 0x271f2f, 0x20150d, 0x603f80];

public function Chunklet(activeStage:ActiveStage, radius:Number, force:Number=10, direction:Number=0, initVelocity:Point=null) {
public function ConfettiChunklet(activeStage:ActiveStage, radius:Number, force:Number=10, direction:Number=0, initVelocity:Point=null) {
this.activeStage = activeStage;
this.radius = radius;
this.amountToRotate = ((direction - 45) * force) / 5;
if (initVelocity)
velocity = initVelocity;

// trace("VELOCITY: " + velocity);
rotation = direction;
var forceToAdd:Point = Point.polar(force, PTmove.degreesToRadsAdjusted(rotation));
velocity.x = forceToAdd.x;
velocity.y = forceToAdd.y;
// makeGraphics();
var chunkyAsset:MovieClip = makeChunky();
scaleX = scaleY = 0;

// TweenLite.to(chunkyAsset, 1, {scaleX:.5, scaleY:.5, ease:Expo.easeOut});
addChild(chunkyAsset);

// var ct:ColorTransform = new ColorTransform;
// var colorIndex:int = Math.floor(Math.random() * colors.length);
// ct.color = colors[colorIndex];
// this.transform.colorTransform = ct;

addEventListener(Event.ENTER_FRAME, onEnterFrame);
}

private function makeGraphics():void {
graphics.beginFill(0x222222);
graphics.lineTo(5, 0);
graphics.lineTo(0, -10);
graphics.lineTo(-5, 0);
graphics.lineTo(0, 0);
graphics.endFill();
}

private function onEnterFrame(e:Event):void {
scaleX += (.5 - scaleX) / 2;
scaleY += (.5 - scaleY) / 2;
Expand Down Expand Up @@ -87,18 +63,6 @@ package com.presstube.chunkulus {
}
}

private function makeChunkletItem():Sprite {
var item:Sprite = new Sprite;
var ran:int = Math.floor(Math.random() * 5) + 1;
var nothingClass:Class = getDefinitionByName("Chunky_" + ran) as Class;
var nothingBMD:BitmapData = new nothingClass() as BitmapData;
var nothingBitmap:Bitmap = new Bitmap(nothingBMD, PixelSnapping.NEVER, true);
item.addChild(nothingBitmap);
nothingBitmap.x = -(nothingBitmap.width / 2);
nothingBitmap.y = -(nothingBitmap.height / 2);
return item;
}

private function makeChunky():MovieClip {
var ran:int = Math.floor(Math.random() * 48) + 1;
var nothingClass:Class = getDefinitionByName("Chunky_" + ran) as Class;
Expand Down

0 comments on commit a0ca87c

Please sign in to comment.