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.


Topics - !8bit!man

Pages: [1] 2 3 4
1
help / rotate boundbox?
« on: Wed, Sep 4, 2013 »
there's a way to rotate a sprite's boundbox?

thanks

2
help / drawing lines from point to point?
« on: Mon, Sep 2, 2013 »
hi guys, today i've tried to draw a line in my game (i need some lazors :D) but  the built in drawLine() function draws a line on the sprite i've selected...

there's some other way to achieve some good results? i also want to check if my player overlaps that line too..

thanks for your help

3
help / what to do after profiling?
« on: Thu, Dec 20, 2012 »
hi guys,

i've used flashdevelop built-in profiler and i found my game's bitmapdata occupy a lot of memory: what can i do to improve this situation?

thanks

4
help / edit how you see objects on screen?
« on: Tue, Dec 11, 2012 »
Hi guys, how can i "deform" displayed objects? I mean something like moving their pixels in a certain way or move them in another location

5
hi guys, i'm here to share with you a method i use to generate random levels in my game MadAubergine.

one day, while i was searching for a cool method for generating random levels, i've found this tut http://noelberry.ca/2011/04/procedural-generation-the-caves/ and i've decided to follow it.

this is the result:

FlxDigger.as
Code: [Select]
package 
{
import org.flixel.*
/**
* ...
* @author Grey
*/
public class FlxDigger extends FlxSprite
{

public var Diggers:FlxGroup;
public var mat:Array;
public var cols:int = 0;
public var rows:int = 0;
public var cntdig:int = 0;
public var stuck:Number = 0;
public var oldx:int = 0;
public var oldy:int = 0;
private var szX:int;
private var szY:int;

public function FlxDigger(matrix:Array,Digga:FlxGroup,MapWidth:int,MapHeight:int,X:int,Y:int,sizeX:int=16,sizeY:int=16)
{
super();
makeGraphic(sizeX, sizeY, 0xff000000);
Diggers = Digga;
mat = matrix;
cols = MapWidth/sizeX;
rows = MapWidth/sizeY;
x = X;
y = Y;
szX = sizeX;
szY = sizeY;
}

override public function update():void
{
super.update();
if (stuck == 0)
{
oldx = x;
oldy = y;
}
cntdig = Registry.totdiggers - Registry.ddig;
stuck += FlxG.elapsed;
if (x-(szX*2) <= 0)
    kill();
if (x+(szX*2)>= cols * szX - szX)
    kill();
if (y-(szY*2) <= 0)
    kill();
if (y+(szY*2)>= rows * szY-szY)
    kill();
if (mat[y/szY][x/szX]==1)
mat[y / szY][x / szX] = 0;
chooseDir();
var f:Number = Math.random();
if (f > 0.91)
{
var d:FlxDigger = new FlxDigger(mat, Diggers, 640, 640, x, y, szX, szY);
Diggers.add(d);
Registry.totdiggers++;
}
if (Registry.totdiggers >= 340)
    kill();
if (stuck >= 1)
{
if (oldx == x || oldy == y)
{
Registry.ddig++;
    kill();
}
else
    stuck = 0;
}
}
private function chooseDir():void
{
var f:Number = 0;
//check if there are non-empty blocks
if (mat[y/szY][(x - szX)/szX] == 0)
{
if (mat[y/szY][(x + szX)/szX] == 0)
{
if (mat[(y - szY)/szY][x/szX] == 0)
{
if (mat[(y + szY) / szY][x / szX] == 0)
{
if(cntdig>1)
kill();
}
else
    y += szY;
}
else
{
if (mat[(y + szY)/szY][x/szX] == 0)
    y -= szY;
else
{
f = Math.floor(Math.random()*2)
if (f == 0)
   y -= szY;
else
   y += szY;
}
}
}
else
{
if (mat[(y - szY)/szY][x/szX] == 0)
{
if (mat[(y + szY)/szY][x/szX] == 0)
    x += szX;
else
{
f = Math.floor(Math.random()*2);
if (f == 0)
   x += szX;
else
   y += szY;
}
}
else
{
if (mat[(y + szY)/szY][x/szX] == 0)
{
f = Math.floor(Math.random()*2);
if (f == 0)
   x += szX;
else
   y -= szY;
}
else
{
f = Math.floor(Math.random() * 3);
if (f == 0)
    x += szX;
if (f == 1)
    y -= szY;
if (f == 2)
    y += szY;
}
}
}
}
else
{
if (mat[y / szY][(x + szX) / szX]==0)
{
if (mat[(y - szY) / szY][x / szX] == 0)
{
if (mat[(y + szY) / szY][x / szX] == 0)
   x -= szX;
else
{
f = Math.floor(Math.random() * 2);
if (f == 0)
    x -= szX;
    else
    y += szY;
}
}
else
{
if (mat[(y + szY) / szY][x / szX] == 0)
{
f = Math.floor(Math.random() * 2);
if (f == 0)
    x += szX;
    else
    y -= szY;
}
else
{
f = Math.floor(Math.random() * 3);
if (f == 0)
    x -= szX;
if (f == 1)
    y -= szY;
if (f == 2)
    y += szY;
}
}
}
else
{
if (mat[(y - szY) / szY][x / szX] == 0)
{
if (mat[(y + szY) / szY][x / szX] == 0)
{
f = Math.floor(Math.random() * 2);
if (f == 0)
    x -= szX;
    else
    x += szX;
}
else
{
f = Math.floor(Math.random() * 3);
if (f == 0)
    x -= szX;
if (f == 1)
    x += szX;
if (f == 2)
    y += szY;
}
}
else
{
f = Math.floor(Math.random() * 4);
if (f == 0)
    x += szX;
if (f == 1)
    y -= szY;
if (f == 2)
    x -= szX;
if (f == 3)
    y += szY;
}
}
}
}
override public function kill():void
{
if(!alive) return;
    velocity.x = 0;
    velocity.y = 0;
    alive = false;
    exists = false;
cntdig--;
}
}

}


how can you use it? do something like this:


DigState.as
Code: [Select]
package 
{
import org.flixel.*;
/**
* ...
* @author Grey
*/
public class DigState extends FlxState
{
[Embed(source = "media/wt.png")]public var wT:Class;
[Embed(source = "media/cursor.png")] private var ImgCursor:Class;

public var diggroup:FlxGroup;
public var splscrn:FlxSprite;
public var matrix:Array;
public var month:Number = 0;
public var mindiggrs:int = 300;

override public function create():void
{
super.create();
diggroup = new FlxGroup();
Registry.mapray = new Array();
Registry.totdiggers = 1;
Registry.ddig = 0;
Registry.mapray = genInitMatrix(640/8, 640/8);
splscrn = new FlxSprite(0, 0, wT);
var d:FlxDigger = new FlxDigger(Registry.mapray, diggroup, 640, 640, 5 * 16, 7 * 16, 8, 8);
diggroup.add(d);
add(diggroup);
add(splscrn);
FlxG.mouse.show(ImgCursor);
}

override public function update():void
{
super.update();
if (Registry.totdiggers >= mindiggrs)
{
    FlxG.fade(0xff000000, 1, go);
}
if (Registry.totdiggers < mindiggrs-50 && diggroup.countLiving() == 0)
    FlxG.switchState(new DigState);
}
private function go():void
{
FlxG.switchState(new PlayState);
}

public function genInitMatrix( rows:uint, cols:uint ,negative:Boolean=false):Array
{
// Build array of 1s
var mat:Array = new Array();
for ( var y:uint = 0; y < rows; ++y )
{
mat.push( new Array );
for ( var x:uint = 0; x < cols; ++x )
{
if (!negative)
    mat[y].push(1);
else
    mat[y].push(0);
}
}

return mat;
}
}
}

6
help / get the displayed text width
« on: Mon, Oct 8, 2012 »
how can i do that?

7
help / one color glowing in the dark?
« on: Mon, Sep 10, 2012 »
well, i've made some graphics for making a "darkness" effect and i need that, when it's activated, a color will start to glow.....
i need something like filters for this? how can i do this?
thx

8
help / jumping enemy?
« on: Wed, Sep 5, 2012 »
how can i make an enemy play a certain animation, then jump and then do it all again?
thx

9
help / Animation doesn't restart
« on: Thu, Aug 30, 2012 »
Title says all, after my object dies (through kill() function), when i reset it, its animation doesn't restart.... how can i fix this?

10
help / FlxCamera problem
« on: Tue, Aug 21, 2012 »
well, my problem is that when i set my game's zoom to 2 in my Main class, this happens:


11
help / FlxCaveGenerator improvement?
« on: Mon, Jul 23, 2012 »
Hi guys, i'm making a platformer with a random generated map and i found FlxCaveGenerator pretty useful for this.

The problem is that it generates sometimes a map with too much open spaces (so the player once he get at the bottom of the map he can't go back at ttghe start): http://roguebasin.roguelikedevelopment.org/index.php/Cellular_Automata_Method_for_Generating_Random_Cave-Like_Levels as you can see there there's a way to improve the level generation, so, as i haven't understood very well that part, can someone tell me how to do that in as3 or tell me another way to obtain cool results?

Thanks

12
help / Know FlxGroup members' position?
« on: Mon, Jul 16, 2012 »
How can i get the x and y position of each members of a FlxGroup?

thx

13
help / HELP! Can't get mouse's world x and y values
« on: Tue, Jul 10, 2012 »
Hi guys, i need your help to find out why i can't get the world position of my mouse.
In practice those values are equal to the mouse's screen position.... it's possible that it's caused by my camera?
Please i can't really understand why it do this....
Thx

14
help / How to site lock?
« on: Tue, Jul 3, 2012 »
How can i lock my swf on my site?

thx

15
help / aiming?
« on: Fri, Jun 29, 2012 »
Which is the best way for aiming the mouse?

Thx

16
help / strange aiming
« on: Sun, Jun 24, 2012 »
Goodmorning guys, i have little problem with mouse aiming. I don't know why if i use a little map  the weapon aims really well the mouse, but if i play in a big random generated map if i go with my player at the bottom of the map or to the right, my weapon starts to behave badly and it aims the wrong point. What can i do to fix it?

Thx

17
help / Numbers
« on: Sun, May 13, 2012 »
How can i display a number with only three digits after the decimal point? For now i can only display one that have a lot of number after the decimal point....

18
help / slowmotion?
« on: Tue, Apr 24, 2012 »
How can i add a slowmotion effect to my game?

19
help / screen.destroy() = null?
« on: Sun, Mar 25, 2012 »
Hi to all guys..... well, in my game, when i switch state and my FlxCamera runs the destroy function, the debugger shows me that screen, in the code screen.destroy(), seems to be null: how can i fix it?

20
help / choose randomly an enemy to spawn?
« on: Fri, Mar 9, 2012 »
Well, i have some different kinds of enemies and i want to know how to spawn one of them randomly, how can i do that?

Pages: [1] 2 3 4