Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Adam Atomic

Pages: 1 ... 39 40 [41] 42 43
801
Not currently, but I'm sure you could adapt the hitfloor/hitwall type calls to take a block pointer or something?  I can see how that could be useful...could get tricky sicne you can collide with more than one block at once though?

802
You should be able to simply remove it from your blocks array using the FlxArray.remove or FlxArray.removeAt functions without making it disappear visually.

You could also do something like add this line at the top of the FlxBlock.collide function:

Code: [Select]
if(dead) return;
And then you could freely toggle any of the blocks by flipping their "dead" variable.  There's actually a good chance that I will add that myself to the next public!

803
help / Re: How to remove the Flixel splash screen.
« on: Mon, Jun 8, 2009 »
weird...ah well just go with whatever works :)

804
help / Re: How to remove the Flixel splash screen.
« on: Mon, Jun 8, 2009 »
The easiest way to cut the 'f' logo splash:

Code: [Select]
if(true)//root.loaderInfo.url.indexOf("localhost") >= 0)
{
_logoComplete = true;
switchState(_iState);
}
else
{

805
releases / Re: Music
« on: Mon, Jun 8, 2009 »
Yeah FlxG is all static, you should just be able to call out to it from any state or sprite or anything

806
releases / Re: Speed Whore
« on: Mon, Jun 8, 2009 »
Yeah this has already been posted a few times :)

807
help / Re: How is the Mode map created?
« on: Mon, Jun 8, 2009 »
It's generated procedurally in PlayState

808
releases / Re: Some code for collision detection
« on: Sun, Jun 7, 2009 »
Ok I made a really stupid mistake - go ahead and replace your FlxBlock code with this:

Code: [Select]
package com.adamatomic.flixel
{
import com.adamatomic.flixel.data.FlxCore;
import flash.display.BitmapData;
import flash.geom.Point;
import flash.geom.Rectangle;

//@desc This is the basic "environment object" class, used to create walls and floors
public class FlxBlock extends FlxCore
{
private var _pixels:BitmapData;
private var _rects:FlxArray;
private var _tileSize:uint;
private var _p:Point;

//@desc Constructor
//@param X The X position of the block
//@param Y The Y position of the block
//@param Width The width of the block
//@param Height The height of the block
//@param TileGraphic The graphic class that contains the tiles that should fill this block
//@param Empties The number of "empty" tiles to add to the auto-fill algorithm (e.g. 8 tiles + 4 empties = 1/3 of block will be open holes)
public function FlxBlock(X:int,Y:int,Width:uint,Height:uint,TileGraphic:Class,Empties:uint=0)
{
super();
x = X;
y = Y;
width = Width;
height = Height;
if(TileGraphic == null)
return;

_pixels = FlxG.addBitmap(TileGraphic);
_rects = new FlxArray();
_p = new Point();
_tileSize = _pixels.height;
var widthInTiles:uint = Math.ceil(width/_tileSize);
var heightInTiles:uint = Math.ceil(height/_tileSize);
width = widthInTiles*_tileSize;
height = heightInTiles*_tileSize;
var numTiles:uint = widthInTiles*heightInTiles;
var numGraphics:uint = _pixels.width/_tileSize;
for(var i:uint = 0; i < numTiles; i++)
{
if(Math.random()*(numGraphics+Empties) > Empties)
_rects.push(new Rectangle(_tileSize*Math.floor(Math.random()*numGraphics),0,_tileSize,_tileSize));
else
_rects.push(null);
}
}

//@desc Draws this block
override public function render():void
{
if(!visible)
return;
getScreenXY(_p);
var opx:int = _p.x;
for(var i:uint = 0; i < _rects.length; i++)
{
if(_rects[i] != null) FlxG.buffer.copyPixels(_pixels,_rects[i],_p,null,null,true);
_p.x += _tileSize;
if(_p.x >= opx + width)
{
_p.x = opx;
_p.y += _tileSize;
}
}
}

//@desc Collides a FlxSprite against this block
//@param Spr The FlxSprite you want to check
public function collide(Spr:FlxSprite):void
{
if((Math.abs(Spr.x + (Spr.width>>1) - x - (width>>1)) > (width>>1) + (Spr.width>>1)) && (Math.abs(Spr.y + (Spr.height>>1) - y - (height>>1)) > (height>>1) + (Spr.height>>1)))
return;

var yFirst:Boolean = true;
if((Math.abs(Spr.velocity.x) > Math.abs(Spr.velocity.y)))
yFirst = false;

var checkForMoreX:Boolean = false;
var checkForMoreY:Boolean = false;
if(yFirst)
{
if(Spr.velocity.y > 0)
{
if(overlapsPoint(Spr.x + (Spr.width>>1),Spr.y + Spr.height))
{
if(Spr.hitFloor())
Spr.y = y - Spr.height;
}
else
checkForMoreY = true;
}
else if(Spr.velocity.y < 0)
{
if(overlapsPoint(Spr.x + (Spr.width>>1),Spr.y))
{
if(Spr.hitCeiling())
Spr.y = y + height;
}
else
checkForMoreY = true;
}

if(Spr.velocity.x < 0)
{
if(overlapsPoint(Spr.x,Spr.y + (Spr.height>>1)))
{
if(Spr.hitWall())
Spr.x = x + width;
}
else
checkForMoreX = true;
}
else if(Spr.velocity.x > 0)
{
if(overlapsPoint(Spr.x + Spr.width,Spr.y + (Spr.height>>1)))
{
if(Spr.hitWall())
Spr.x = x - Spr.width;
}
else
checkForMoreX = true;
}
}
else
{
if(Spr.velocity.x < 0)
{
if(overlapsPoint(Spr.x,Spr.y + (Spr.height>>1)))
{
if(Spr.hitWall())
Spr.x = x + width;
}
else
checkForMoreX = true;
}
else if(Spr.velocity.x > 0)
{
if(overlapsPoint(Spr.x + Spr.width,Spr.y + (Spr.height>>1)))
{
if(Spr.hitWall())
Spr.x = x - Spr.width;
}
else
checkForMoreX = true;
}

if(Spr.velocity.y > 0)
{
if(overlapsPoint(Spr.x + (Spr.width>>1),Spr.y + Spr.height))
{
if(Spr.hitFloor())
Spr.y = y - Spr.height;
}
else
checkForMoreY = true;
}
else if(Spr.velocity.y < 0)
{
if(overlapsPoint(Spr.x + (Spr.width>>1),Spr.y))
{
if(Spr.hitCeiling())
Spr.y = y + height;
}
else
checkForMoreY = true;
}
}

if(!checkForMoreY && !checkForMoreX)
return;
var bias:int = Spr.width>>3;
if(bias < 1)
bias = 1;
if(checkForMoreY && checkForMoreX)
{
if(yFirst)
{
if(checkForMoreY)
{
if((Spr.x + Spr.width - bias > x) && (Spr.x + bias < x + width))
{
if((Spr.velocity.y > 0) && (Spr.y + Spr.height > y) && (Spr.y + Spr.height < y + height) && Spr.hitFloor())
Spr.y = y - Spr.height;
else if((Spr.velocity.y < 0) && (Spr.y > y) && (Spr.y < y + height) && Spr.hitCeiling())
Spr.y = y + height;
}
}
if(checkForMoreX)
{
if((Spr.y + Spr.height - bias > y) && (Spr.y + bias < y + height))
{
if((Spr.velocity.x > 0) && (Spr.x + Spr.width > x) && (Spr.x + Spr.width < x + width) && Spr.hitWall())
Spr.x = x - Spr.width;
else if((Spr.velocity.x < 0) && (Spr.x > x) && (Spr.x < x + width) && Spr.hitWall())
Spr.x = x + width;
}
}
}
else
{
if(checkForMoreX)
{
if((Spr.y + Spr.height - bias > y) && (Spr.y + bias < y + height))
{
if((Spr.velocity.x > 0) && (Spr.x + Spr.width > x) && (Spr.x + Spr.width < x + width) && Spr.hitWall())
Spr.x = x - Spr.width;
else if((Spr.velocity.x < 0) && (Spr.x > x) && (Spr.x < x + width) && Spr.hitWall())
Spr.x = x + width;
}
}
if(checkForMoreY)
{
if((Spr.x + Spr.width - bias > x) && (Spr.x + bias < x + width))
{
if((Spr.velocity.y > 0) && (Spr.y + Spr.height > y) && (Spr.y + Spr.height < y + height) && Spr.hitFloor())
Spr.y = y - Spr.height;
else if((Spr.velocity.y < 0) && (Spr.y > y) && (Spr.y < y + height) && Spr.hitCeiling())
Spr.y = y + height;
}
}
}
}
else if(checkForMoreY)
{
if((Spr.x + Spr.width - bias > x) && (Spr.x + bias < x + width))
{
if((Spr.velocity.y > 0) && (Spr.y + Spr.height > y) && (Spr.y + Spr.height < y + height) && Spr.hitFloor())
Spr.y = y - Spr.height;
else if((Spr.velocity.y < 0) && (Spr.y > y) && (Spr.y < y + height) && Spr.hitCeiling())
Spr.y = y + height;
}
}
else if(checkForMoreX)
{
if((Spr.y + Spr.height - bias > y) && (Spr.y + bias < y + height))
{
if((Spr.velocity.x > 0) && (Spr.x + Spr.width > x) && (Spr.x + Spr.width < x + width) && Spr.hitWall())
Spr.x = x - Spr.width;
else if((Spr.velocity.x < 0) && (Spr.x > x) && (Spr.x < x + width) && Spr.hitWall())
Spr.x = x + width;
}
}
}

//@desc Collides a FlxSprite against an array of FlxBlock objects
//@param Blocks A FlxArray of FlxBlock objects
//@param Sprite The FlxSprite object you want to check
static public function collideArray(Blocks:FlxArray,Sprite:FlxSprite):void
{
if(!Sprite.exists || Sprite.dead) return;
for(var i:uint = 0; i < Blocks.length; i++)
Blocks[i].collide(Sprite);
}

//@desc Collides an array of FlxSprites against an array of FlxBlock objects
//@param Blocks A FlxArray of FlxBlock objects
//@param Sprites A FlxArray of FlxSprite objects
static public function collideArrays(Blocks:FlxArray,Sprites:FlxArray):void
{
for(var i:uint = 0; i < Blocks.length; i++)
for(var j:uint = 0; j < Sprites.length; j++)
{
if(!Sprites[j].exists || Sprites[j].dead) continue;
Blocks[i].collide(Sprites[j]);
}
}
}
}

I left out like two stupid 'else' cases :P   sorry about that!

809
releases / Re: Some code for collision detection
« on: Sun, Jun 7, 2009 »
yea my friend ivan is seeing this too, not sure why that case isn't being caught...it will DEFINITELY be fixed in the next public!

810
releases / Re: Music
« on: Sun, Jun 7, 2009 »
Not sure exactly what's going on there, I do a stopMusic() call in 'mode' and it seems to work fine, will let you know if i think of anything!

811
help / Re: TUTORIAL: mode Jetpack Mod
« on: Sun, Jun 7, 2009 »
mad props adamrobo :D  added it to the official help resources thread

812
games / Re: Gravity Hook
« on: Sun, Jun 7, 2009 »
Gravity Hook was the third game I made using Flixel, believe it or not!  Someday I will link the first two, they are pretty stripped down (i.e. completely unfinished) though.

813
help / Re: TUTORIAL: mode Jetpack Mod
« on: Sun, Jun 7, 2009 »
Awesome!!  Can you link to a playable version of this on the web somewhere?  Or did I just miss the link

814
games / Re: Gravity Hook
« on: Sun, Jun 7, 2009 »
MUCH earlier version :)

815
help / Re: Hello world in Flixel?
« on: Sun, Jun 7, 2009 »
Remember the Flash color format is AARRGGBB

816
help / Re: FlxSprite physics and zoom
« on: Sun, Jun 7, 2009 »
smoothing is part Of the vector renderer so you,d have to use the bitmap class from the normal flash libraries if you want AA

817
releases / Re: About FlxEmitter
« on: Sun, Jun 7, 2009 »
Yeah it could stand some improvement, mainly I think lifespan and the ability for continuous emitters to fire more than one particle per frame, so expect some improvements there in the next public!

818
help / Re: FlxSprite physics and zoom
« on: Sun, Jun 7, 2009 »
MAke sure you are setting velocity to zero if no directionals are pressed :)

819
help / Re: FlxBlock initialization question
« on: Sun, Jun 7, 2009 »
You can rewrite the flxblock unit code, but using an embedded image was much easier to both implement and use during the last couple games

820
releases / Re: Music playing twice on focus
« on: Sun, Jun 7, 2009 »
Hey good find, I'll make sure that's fixed up in the next public!

Pages: 1 ... 39 40 [41] 42 43