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 - MattB

Pages: [1]
help / Seperation Code Explained
« on: Mon, Apr 30, 2012 »
I'm trying to implement the code flixel uses to seperate Rectangles in another project and I was wondering if anyone could explain these lines of code in the SeparateX function (it also appears in the SeparateY):

Code: [Select]
var obj1rect:FlxRect = new FlxRect(Object1.x-((obj1delta > 0)?obj1delta:0),Object1.last.y,Object1.width+((obj1delta > 0)?obj1delta:-obj1delta),Object1.height);

var obj2rect:FlxRect = new FlxRect(Object2.x-((obj2delta > 0)?obj2delta:0),Object2.last.y,Object2.width+((obj2delta > 0)?obj2delta:-obj2delta),Object2.height);

It uses these rectangles to determine if it should check for overlap, and I'm not sure why the X is defineds as:
Object1.x-((obj1delta > 0)?obj1delta:0

Why do I only was to add the change in X to the check rectangle if the object was moving right? I'm also a little hazy as to why we add absolute value of the X delta to the width, though it makes since if the implication is it's checking overlap for the objects soon-to-be position.

It would be super helpful if some one could explain these rectangles to me.

help / Mouse Movement
« on: Fri, Dec 16, 2011 »
Has anyone on here made a game with flixel that features move-to-mouse-click style game play like Diablo or newer Kings Quest games. I'm trying to make a quick adventure game for my dads birthday and need help getting started quickly without testing a bunch of different methods to find what works best.

help / Ledge Grabbing?
« on: Tue, Oct 25, 2011 »
I only found one other thread on this with no real answers.

I'm working on a side-scroller and I want to do this:  (Yeah, I'll probably message the guy who made this and ask too)

I'm using an old version of Flixel that still includes the hitWall function, and my initial idea is to override that, setting a flag like canGrab, when the player is above the ledge, and then when the player collides with his top below the edge, put him in a grab state if the canGrab flag is true. But I imagine the player would then be able to grab every flxBlock, even blocks with blocks on top of them that weren't really blocks. Then there's the matter of the "pulling up".

Has anyone done this?

games / My Robot is Fight
« on: Fri, Apr 15, 2011 »
Hey all. Just wanted to post a link to the alpha test of a game I've been developing using Flixel [modified from version 1.4]. It's called My Robot is Fight and it's a Side-Scroller Rogue-like where you take the role of a determined robot trying to save its home planet from horrible flesh-beast.

Tell me what you think and let me know if you find any bugs.

(A few of the graphics and sounds are still placeholders.)

[I did all of the music, art and sound.]

help / HALP! Brawler / Beat Em Up Attack Code
« on: Mon, Nov 16, 2009 »
Okay, so I'm currently modifying the Ninja Game Tutorial to include different modes a play, and I've reached some significant hurtles in finding a good approach to a beat 'em up / brawler mode. The first method I've tried is this code, placed at the beginning of the EnemyHit function called when the Player collides with an Enemy in

Code: [Select]
if (P.pClass == "Brawler" && P._attack_counter > 0)
if ((P.facingMod == 1 && E.x > P.x) || (P.facingMod == -1 && E.x < P.x))
E.velocity.x = -400 * P.facingMod;
} else

and this code in

Code: [Select]
if(FlxG.justPressed(FlxG.B) && _attack_counter <= 0)
if(pClass == "Blaster"){
//after attacking, player can't attack for 1 second
_attack_counter = 0.5;
//plays attack animation
//executes the throwStar function
} else if (pClass == "Brawler") {
_attack_counter = 0.5;
if (velocity.x != 0)
{velocity.x = 0;}
} else
//do nothing

To explain, P.pClass is a string set in the menuState to select a mode of play and P.facingMod is an int set by the player's facing I've been using to adjust the velocity of things that collide with the player. When _attack_counter is greater than 0, hitting the player from the side should deal them 10 damage.

This code works creates some unfavorable issues.
1. It always kills the enemy. Even though I send 10 to the Enemy's hurt function (they have 30 health), it always kills them. I presume this is because it's dealing 10 damage to them several time each FlxG.elapsed.
2. It allows you to kill the enemy even when they're jumping on you. This isn't terrible, but just plays weird.
3. The enemies simply blink out existence when they're killed. I can't seem to make them bounce back or become stunned. They just hit the player and poof. This relates to number 1, but again, it just feels and plays really strange.
4. If I had a player with a spear or any kind of reach weapon I have no real idea of how to temporarily extend their bounding box during the attack and set it back after wards to make the attack reach out.

So alternatively I tried this:

in, (my version of Bullet, or Star)
Code: [Select]
override public function update():void
_hasTraveled = Math.abs(x - _originX);
if (_hasTraveled > _range) {
_hasTraveled = 0;

and also a bunch of other code where I've expanded my Projectile class to let you choose different projectiles with different ranges. One of these is punch:

Code: [Select]
if (ProjName == "Punch")
_range = 32;
_bHeight = 32;
_bWidth = 32;
_offsetY = -16;
_projImg = ImgNull;

Currently punch is big red 32x32 pixels block so I can see where it goes, but when it works it'll just be a transparent *.png.

Here's my reset function, just for reference:

Code: [Select]
public function reset(facingMod:int, :Number,Y:Number,XVelocity:Number,YVelocity:Number):void
            x = X + _xSpawnAdj * facingMod;
            y = Y + _ySpawnAdj;
   _originX = x;
   FlxG.log("Bullet Starts at: " + String(_originX));

            dead = false;
            exists = true;
            visible = true;
            velocity.x = XVelocity; //Set the left and right speed
            play("normal"); //Play the animation

Here's the problems with this code:
1.The projectile starts further on the left of the sprite than it does on the right. I have no clue why.
2.While running right, the punch won't actually extend past the player sprite. In either direction, it's severally shortened. I've tried adding the players (velocity.x * FlxG.elapsed) to both the projectiles starting x and its starting velocity. It helps barely, but not enough.
3.Still plays weird, and is difficult to hit enemies with.

Any help improving either of these methods or creating a better method to perform an punch attack would be helpful. Until then, I guess here's some iffy code to do it with.

help / Sending data from one state to another
« on: Wed, Nov 11, 2009 »
Hi everyone. I'm new to flixel and I just completed SeiferTims Basic Game Tutorial.

Since then, I've implemented an alternate mode of play where you stomp on enemies to destroy them rather than shoot at them. This mode can be toggled with a string sent to the player class.

Now what I'd like to do is allow players to choose between these modes of play from the menu screen, but I need to know how to send a string from MenuState to PlayState.

This is probably a simple task, but prior to this I've had very little programming experience.


Pages: [1]