Skip to content

Commit

Permalink
v2.35 - bounding boxes and a few other things
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamAtomic committed Apr 19, 2010
1 parent 681a7a0 commit c5c8369
Show file tree
Hide file tree
Showing 13 changed files with 372 additions and 46 deletions.
6 changes: 4 additions & 2 deletions flx.py
Expand Up @@ -108,8 +108,12 @@
lines.append('\t\toverride public function update():void\r\n')
lines.append('\t\t{\r\n')
lines.append('\t\t\tsuper.update();\r\n')
lines.append('\r\n')
lines.append('\t\t\tif(FlxG.mouse.justPressed())\r\n')
lines.append('\t\t\t{\r\n')
lines.append('\t\t\t\tFlxG.mouse.hide();\r\n')
lines.append('\t\t\t\tFlxG.state = new PlayState();\r\n')
lines.append('\t\t\t}\r\n')
lines.append('\t\t}\r\n')
lines.append('\t}\r\n')
lines.append('}\r\n')
Expand All @@ -132,8 +136,6 @@
lines.append('\t{\r\n')
lines.append('\t\toverride public function create():void\r\n')
lines.append('\t\t{\r\n')
lines.append('\t\t\tFlxG.mouse.hide();\r\n')
lines.append('\t\t\t\r\n')
lines.append('\t\t\tadd(new FlxText(0,0,100,"INSERT GAME HERE"));\r\n')
lines.append('\t\t}\r\n')
lines.append('\t}\r\n')
Expand Down
9 changes: 8 additions & 1 deletion org/flixel/FlxEmitter.as
Expand Up @@ -96,7 +96,7 @@ package org.flixel
maxRotation = 360;
gravity = 400;
particleDrag = new FlxPoint();
delay = 0.1;
delay = 0;
quantity = 0;
_counter = 0;
_explode = true;
Expand Down Expand Up @@ -309,6 +309,13 @@ package org.flixel
delay = Delay;
if(delay < 0)
delay = -delay;
if(delay == 0)
{
if(Explode)
delay = 3; //default value for particle explosions
else
delay = 0.1;//default value for particle streams
}
}

/**
Expand Down
30 changes: 28 additions & 2 deletions org/flixel/FlxG.as
Expand Up @@ -27,7 +27,7 @@ package org.flixel
* Assign a minor version to your library.
* Appears after the decimal in the console.
*/
static public var LIBRARY_MINOR_VERSION:uint = 34;
static public var LIBRARY_MINOR_VERSION:uint = 35;

/**
* Internal tracker for game object (so we can pause & unpause)
Expand All @@ -42,6 +42,10 @@ package org.flixel
* Set automatically by <code>FlxFactory</code> during startup.
*/
static public var debug:Boolean;
/**
* Internal tracker for bounding box visibility.
*/
static protected var _showBounds:Boolean;

/**
* Represents the amount of time in seconds that passed since last frame.
Expand Down Expand Up @@ -206,6 +210,25 @@ package org.flixel
}
}

/**
* Set <code>showBounds</code> to true to display the bounding boxes of the in-game objects.
*/
static public function get showBounds():Boolean
{
return _showBounds;
}

/**
* @private
*/
static public function set showBounds(ShowBounds:Boolean):void
{
var osb:Boolean = _showBounds;
_showBounds = ShowBounds;
if(_showBounds != osb)
FlxObject._refreshBounds = true;
}

/**
* The game and SWF framerate; default is 60.
*/
Expand Down Expand Up @@ -654,13 +677,16 @@ package org.flixel
framerate = 60;
frameratePaused = 10;
maxElapsed = 0.0333333;
FlxG.elapsed = 0;
_showBounds = false;
FlxObject._refreshBounds = false;

panel = new FlxPanel();
quake = new FlxQuake(Zoom);
flash = new FlxFlash();
fade = new FlxFade();

FlxU.setWorldBounds();
FlxU.setWorldBounds(0,0,FlxG.width,FlxG.height);
}

/**
Expand Down
1 change: 1 addition & 0 deletions org/flixel/FlxGame.as
Expand Up @@ -321,6 +321,7 @@ package org.flixel
_console.update();

//State updating
FlxObject._refreshBounds = false;
FlxG.updateInput();
FlxG.updateSounds();
if(_paused)
Expand Down
70 changes: 61 additions & 9 deletions org/flixel/FlxObject.as
Expand Up @@ -22,14 +22,13 @@ package org.flixel
*/
public var visible:Boolean;
/**
* If an object is dead, the functions that automate collisions will skip it (see <code>FlxG.overlapArrays()</code> and <code>FlxG.collideArrays()</code>).
* Internal tracker for whether or not the object collides (see <code>solid</code>).
*/
public var solid:Boolean;
protected var _solid:Boolean;
/**
* If an object is 'fixed' in space, it will not budge when it collides with a not-fixed object.
* Fixed objects also shortcut out of updateMotion by default.
* Internal tracker for whether an object will move/alter position after a collision (see <code>fixed</code>).
*/
public var fixed:Boolean;
protected var _fixed:Boolean;

/**
* The basic speed of this object.
Expand Down Expand Up @@ -175,6 +174,10 @@ package org.flixel
* Flag for direction collision resolution.
*/
public var collideBottom:Boolean;
/**
* Flag for whether the bounding box visuals need to be refreshed.
*/
static internal var _refreshBounds:Boolean;

/**
* Creates a new <code>FlxObject</code>.
Expand All @@ -191,8 +194,8 @@ package org.flixel
exists = true;
active = true;
visible = true;
solid = true;
fixed = false;
_solid = true;
_fixed = false;
moves = true;

collideLeft = true;
Expand Down Expand Up @@ -239,6 +242,39 @@ package org.flixel
//Nothing to destroy yet
}

/**
* Set <code>solid</code> to true if you want to collide this object.
*/
public function get solid():Boolean
{
return _solid;
}

/**
* @private
*/
public function set solid(Solid:Boolean):void
{
_solid = Solid;
}

/**
* Set <code>fixed</code> to true if you want the object to stay in place during collisions.
* Useful for levels and other environmental objects.
*/
public function get fixed():Boolean
{
return _fixed;
}

/**
* @private
*/
public function set fixed(Fixed:Boolean):void
{
_fixed = Fixed;
}

/**
* Called by <code>FlxObject.updateMotion()</code> and some constructors to
* rebuild the basic collision data for this object.
Expand All @@ -264,7 +300,7 @@ package org.flixel
if(!moves)
return;

if(solid)
if(_solid)
refreshHulls();
onFloor = false;
var vc:Number;
Expand Down Expand Up @@ -303,7 +339,7 @@ package org.flixel
y += yd;

//Update collision data with new movement results
if(!solid)
if(!_solid)
return;
colVector.x = xd;
colVector.y = yd;
Expand Down Expand Up @@ -560,5 +596,21 @@ package org.flixel
exists = true;
dead = false;
}

/**
* Returns the appropriate color for the bounding box depending on object state.
*/
public function getBoundingColor():uint
{
if(solid)
{
if(fixed)
return 0x7f00f225;
else
return 0x7fff0012;
}
else
return 0x7f0090e9;
}
}
}

0 comments on commit c5c8369

Please sign in to comment.