Author Topic: v1.3 Planning Thread  (Read 27094 times)

deff

  • Member
  • **
  • Posts: 13
  • Karma: +0/-0
    • View Profile
Re: v1.3 Planning Thread
« Reply #40 on: Fri, Aug 7, 2009 »
I don't know if it is possible to use more than the 6 keyboard buttons (arrow keys + x and c) or if it is possible to customize them but if it is not then it would be a nice feature to add. I want to make a two player game.  :)

Tutorial of Adding multiple, configurable keys
http://flixel.org/forums/index.php?topic=93

vonWolfehaus

  • Active Member
  • ***
  • Posts: 247
  • Karma: +0/-0
    • View Profile
    • Cold Constructs
Re: v1.3 Planning Thread
« Reply #41 on: Mon, Aug 10, 2009 »
I don't know if it is possible to use more than the 6 keyboard buttons (arrow keys + x and c) or if it is possible to customize them but if it is not then it would be a nice feature to add. I want to make a two player game.  :)

Tutorial of Adding multiple, configurable keys
http://flixel.org/forums/index.php?topic=93

Yeah but that didn't work for me at all, plus it runs a for loop every single time a key is pressed which is hugely inefficient. I wrote my own version that uses an Object to store keys so it's like a Dictionary or Hash Table, but faster. Input is extremely important so I took care to make it nice. I also added support for shift and control keys.

It's not done yet (still going to add timer-based mouse clicking stuff) and I haven't fully tested it, but when I do I'll be sure to post about it here and elsewhere.
Meet Obama every day at #flixel on irc.freenode.net.
Use your favorite IRC client or  http://webchat.freenode.net/

nitram_cero (2bam)

  • Contributor
  • ****
  • Posts: 484
  • Karma: +0/-0
    • View Profile
    • 2BAM
Re: v1.3 Planning Thread
« Reply #42 on: Tue, Aug 11, 2009 »
If you're worried about performance you could always use up a little more space for it.
Having an array that maps keycodes to "actions" will avoid you the for loop and string comparison.
You'll also need an action array, and action integer consts

Example:
Code: [Select]
const A_LEFT:uint = 0;
const A_RIGHT:uint = 1;
const A_JUMP:uint = 2;
const A_COUNT:uint = 3;

keycodeToAction = Array(128)       all default to -1
actions = Array(A_COUNT);    all default to false
lastActions = Array(A_COUNT);    all default to false

---keyboard mapping (using random keycodes but serves the idea) ---
keycodeToAction[47] = A_LEFT;
keycodeToAction[49] = A_RIGHT;
keycodeToAction[32] = A_JUMP;

on key press:
if (keycode < 128 && keycodeToAction[keycode]!=-1)
actions[keycodeToAction[keycode]] = true
on key release:
if(keycode < 128  && keycodeToAction[keycode]!=-1)
actions[keycodeToAction[keycode]] = false
on game frame update:
copy actions to lastActions.

func justPressed(action:uint) = actions[action] && !lastActions[action]
func justReleased(action:uint) = !actions[action] && lastActions[action]
« Last Edit: Tue, Aug 11, 2009 by nitram_cero »

vonWolfehaus

  • Active Member
  • ***
  • Posts: 247
  • Karma: +0/-0
    • View Profile
    • Cold Constructs
Re: v1.3 Planning Thread
« Reply #43 on: Wed, Aug 12, 2009 »
If you're worried about performance you could always use up a little more space for it.
Having an array that maps keycodes to "actions" will avoid you the for loop and string comparison.
You'll also need an action array, and action integer consts
...

I already rewrote Flixel's stuff with my own. My requirements were pretty tight--no loops when checking for presses and configurable for any key, including shift and control, plus a mouse down timer. Also as little code as possible. My solution hit all those points so I'm set.

Also, looks like constants are slow too.
« Last Edit: Sat, Aug 15, 2009 by vonWolfehaus »
Meet Obama every day at #flixel on irc.freenode.net.
Use your favorite IRC client or  http://webchat.freenode.net/

nitram_cero (2bam)

  • Contributor
  • ****
  • Posts: 484
  • Karma: +0/-0
    • View Profile
    • 2BAM
Re: v1.3 Planning Thread
« Reply #44 on: Sat, Aug 15, 2009 »
I think that article is a bit biased. Everyone uses consts, perhaps it's a tiny bit slower... but negligible if you're human (Why would you need so much precision in response? Your eye-hand reflexes aren't that fast) :)



Adam, I think that the render/update functionality from FlxLayer would be better at FlxArray.
Or otherwise having the FlxLayer's children exposed.

E.g. I maintain a vector of bullets (different classes)... and clean it up from time to time to remove the dead bullets (and improve collision checks, since you don't have check&discard thousands of dead sprites).
Because of this, I can't use FlxLayer (no raw access to children)... so I need to do the render/update loop (and exists&&visible/active comparison) myself.

Not a big deal, but it would be nicer to have it in the FlxArray class

Regards :)
-Martín

nitram_cero (2bam)

  • Contributor
  • ****
  • Posts: 484
  • Karma: +0/-0
    • View Profile
    • 2BAM
Re: v1.3 Planning Thread
« Reply #45 on: Wed, Aug 19, 2009 »
Code: [Select]
if((myURL != null) && (myURL.length > 0) && (root.loaderInfo.url.indexOf(myURL) < 0) && (root.loaderInfo.url.indexOf("localhost") < 0) && (root.loaderInfo.url.substr(0, 7)!="file://"))

I changed the check to this this in FlxFactory to be able to test local swf files, specially with FlashDevelop (with the standalone Flash Debug Player "Projector")

This fix should be safe for anyone else.

Regards
-Martín

ETG

  • Active Member
  • ***
  • Posts: 115
  • Karma: +0/-0
    • View Profile
Re: v1.3 Planning Thread
« Reply #46 on: Wed, Aug 19, 2009 »
I was watching a video from google on developing games on the android platform.
http://www.youtube.com/watch?v=U4Bk5rmIpic

Around the 30 min. mark, he mentions that java will allocate memory for, basically anything that's supposed to be immutable. So if Flash is doing something like that, it might explain why const might be slower.

Titch

  • Contributor
  • ****
  • Posts: 270
  • Karma: +0/-0
  • Thing with the guy in the place.
    • View Profile
Re: v1.3 Planning Thread
« Reply #47 on: Sun, Aug 23, 2009 »
I generated an interesting overflow bug the other day by altering the value of 'facing' on a FlxSprite inside the animationCallback function. I've not looked at the source (in the end I simply wrote in a workaround that changes the direction in the next frame) but it would be nice if there was a solution for 1.3.
Free cake whippings every day at #flixel on irc.freenode.net.

SeiferTim

  • Contributor
  • ****
  • Posts: 253
  • Karma: +0/-0
    • View Profile
    • Tim's World
Re: v1.3 Planning Thread
« Reply #48 on: Mon, Aug 24, 2009 »
Here's a suggestion:
We have a great class now with FlxTilemap, but it would be nice to be able to have something just like it, only pass it an array of FlxSprites...
For instance, we want to make a FlxLayer that has all the enemies on it, we could make a FlxArray of enemies and the FlxSpritemap (or whatever) would place nothing where there are 0s in the map, FlxArray[1] where there are 1s, etc..

nitram_cero (2bam)

  • Contributor
  • ****
  • Posts: 484
  • Karma: +0/-0
    • View Profile
    • 2BAM
Re: v1.3 Planning Thread
« Reply #49 on: Mon, Aug 24, 2009 »
"Overlap" functions for Tilemaps would be nice (for special tiles like water, lava, slime, "regen", you get the idea)

the callback could be something like

fuction overlapCoreTile(core:FlxCore, tilemap:FlxTilemap, tileType:uint, tileX:uint, tileY:uint)

Regards
-Martín

sztk

  • Guest
Re: v1.3 Planning Thread
« Reply #50 on: Mon, Aug 24, 2009 »
"Overlap" functions for Tilemaps would be nice (for special tiles like water, lava, slime, "regen", you get the idea)

the callback could be something like

fuction overlapCoreTile(core:FlxCore, tilemap:FlxTilemap, tileType:uint, tileX:uint, tileY:uint)

Regards
-Martín

I agree! overlap for tilemaps would be very useful. maybe my most wanted feature.

Adam Atomic

  • Founder
  • Key Contributor
  • *****
  • Posts: 852
  • Karma: +0/-0
  • new dad
    • View Profile
    • Adam Atomic
Re: v1.3 Planning Thread
« Reply #51 on: Tue, Aug 25, 2009 »
Yes that is a cool idea...noted!

nitram_cero (2bam)

  • Contributor
  • ****
  • Posts: 484
  • Karma: +0/-0
    • View Profile
    • 2BAM
Re: v1.3 Planning Thread
« Reply #52 on: Mon, Aug 31, 2009 »
I suggest this patch: Dynamically chaning a FlxTilemap

Regards
-Martín

PizzaBoy

  • Guest
Re: v1.3 Planning Thread
« Reply #53 on: Fri, Sep 4, 2009 »
What about extending FlxArray into FlxKeyMap or Flx2DGrid?

Rolpege

  • Guest
Re: v1.3 Planning Thread
« Reply #54 on: Mon, Sep 7, 2009 »
Saving/Loading by Flash Shared Objects would be great!

And how about a simple method for adding more keys?

nitram_cero (2bam)

  • Contributor
  • ****
  • Posts: 484
  • Karma: +0/-0
    • View Profile
    • 2BAM
Re: v1.3 Planning Thread
« Reply #55 on: Thu, Sep 10, 2009 »
I think it would be really cool that each core had a reference to it's containing layer.

on "FlxLayer.add(core)" sets "core.ownerLayer = this".

It could be named parent, owner, ownerLayer, etc. But parent has other meaning in Flex, so I wouldn't go for it.

This is most useful to check some states that depends on ancestors.
For example like:
Code: [Select]
function isReallyShown():Boolean = {
   ancestor = this;
   do {  
       if(!ancestor.visible)
           return false;
       ancestor = ancestor.ownerLayer;
   } while(ancestor != null);
   return true;
}

You could use this yourself for the "popup blocker workaround": adding a weakptr MouseDown event listener on each FlxButton and check if the button is visible/active this way, and trigger acordingly.

EDIT: I made an implementation for a workaround on the popup-blocker issue. Be sure to check it out when you have some time.

Best Regards
-Martín
« Last Edit: Thu, Sep 10, 2009 by nitram_cero »

borlak

  • Guest
Re: v1.3 Planning Thread
« Reply #56 on: Thu, Sep 10, 2009 »
just a quick note: I think defaulting 'p' for pause would be a good idea.  I noticed in some kongregate comments on flixel games people were complaining about no pause.  yeah, you can pause, but you have to know how ^_^

nitram_cero (2bam)

  • Contributor
  • ****
  • Posts: 484
  • Karma: +0/-0
    • View Profile
    • 2BAM
Re: v1.3 Planning Thread
« Reply #57 on: Fri, Sep 11, 2009 »
just a quick note: I think defaulting 'p' for pause would be a good idea.  I noticed in some kongregate comments on flixel games people were complaining about no pause.  yeah, you can pause, but you have to know how ^_^
I agree with this. Perhaps also using the Pause key in addition to P, if flash allows that.

One more thing: a sort of flag to enable/disable the experimental fullscreen? I diked it out because when I pressed Esc it never allowed me to go back to windowed mode. Also Escape is sort of a "abort/red button" thing, fullscreen toggling doesn't seem right binded to that key.

Good luck!
-Martín

Adam Atomic

  • Founder
  • Key Contributor
  • *****
  • Posts: 852
  • Karma: +0/-0
  • new dad
    • View Profile
    • Adam Atomic
Re: v1.3 Planning Thread
« Reply #58 on: Sat, Sep 12, 2009 »
yea the fullscreen stuff seems to be more trouble than it's worth, stripping it out of the next public really couldn't hurt

noonat

  • Guest
Re: v1.3 Planning Thread
« Reply #59 on: Fri, Sep 18, 2009 »
Finally I am still kinda torn between having an SVN repo on google code or having an account on github - git is absolutely superior in every regard, but SVN seems to be more widely used...so not sure what to do about that yet :-/  In the meantime, it may not be totally ideal, but I'd recommend subclassing Flixel when you want to make big changes - so make NitramBlock extend FlxBlock and then do your mods.  It should make it much easier to update regardless of the source control service!

I would vote git for this. With git people could clone and use a local repo to make changes. They could still pull in new changes from you even if they couldn't push up. Github is also very helpful for pushing patches to you, if people have forked. Anyone who doesn't use git isn't any worse off than they are now.

I'm dying without this right now. :(

I would love to just subclass, but Flixel has a lot of private stuff. Many of my changes are just going and making things protected so I can subclass it to do what I need to.