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

Pages: 1 [2] 3 4 5
21
That doesn't make too much sense. Yes it's still in memory when it's dead, but it was in memory when it was alive, so it shouldn't perform worse just because it's dead and not solid. Also, he does a super.kill after it fades out (but it doesn't appear like that ever happens, or something).

However, this was bothering me, so I looked deeper into it. It has nothing to do with your zombies. For example, aim at an area with no zombies and fire for 20 seconds straight. Every time you shoot you are creating a bullet, so over time the number of bullets builds up creating the slow down. The reason it seemed to happen when killing zombies is because you shoot to kill them.

You need to make sure you kill bullets that go off screen, and make sure all bullets that are killed are truly cleaned up (or reused). There's lots of optimization to be had, but that seems to be the one that is killing you. Collision and overlaps are expensive, so having lots of bullets makes those calls take a ton of time.

I did optimize my bullet code a little bit. I made it so it doesn't create a new sprite for every iteration and instead just moves one sprite down the line. That should have boosted performance the most but it made only a small fps difference of 4 or 5. Bullets don't go out of the camera's X/Y and are killed at the end of the iterations. I think >.>

I'm going to try to rewrite my bullet code, anyways. Any suggestions on how I could do it better? I really want to do a raycast but I'm not sure how to check collision of drawn line against an FlxSprite :S

22
I can have dozens (I've even tried hundreds) of zombies on-screen and they render and perform just fine. When I kill a few, however, the FPS drops drastically. I had 100+ on screen once and the FPS was ~50. I killed 3, fps dropped to ~10. I have no clue what could be causing this, as I've tried commenting out a lot of code that I thought could be the culprit (namely the random number generations and z-index sorting while the zombie is dead). It did help the FPS, but only by like 5 or 6 FPS. I've also commented out some of the shooting code, basically trimming the code to bear-bones point, click, and shoot and the zombie simply dying via kill(). It didn't help :/.

Here is my repo:
https://github.com/NateTheGreatt/Coffee-Beans

I don't have my flixel framework in the repo, I plan on putting it in soon.

Anyways, could anyone provide any insight on what's making the FPS drop so drastically? I'm using Flixel 2.5 if that's any help

23
help / Re: Jump from wall
« on: Fri, May 27, 2011 »
uhm this might be just me.. (maybe 'cause I'm noob)

but he doesn't know onWall? but he does know onFloor? why is that? :P

Sorry, I didn't mean that onWall was an already defined variable xD. I meant to define it as a public variable in the player's class. I didn't know abot isTouching, that's very useful! Do that.

24
help / Re: Jump from wall
« on: Fri, May 27, 2011 »
I have yet to attempt coding wall-jumping. If I were to do it, I would check if the player collides with a wall and, if he does, then lock his velocity.x to 0 and manipulate his velocity.y according to how fast you want him to slide down the wall.

Something like this in the playstate:
Code: [Select]
if(FlxG.collide(player, wallTileMap) && player.jumping == true) {
     player.onWall = true;
}

and then inside the player class's update function:
Code: [Select]
if(onWall) {
     velocity.x = 0;
     acceleration.y = -10;
}

Does that help? If there are any confusions let me know.

25
help / Tile edge / border walls
« on: Fri, May 27, 2011 »
Hey Flixel,

I'm trying to set up walls in my game to be the edge / border of the respective tiles. I have a tile for each type of wall. Left, right, top, bottom, and corners.

http://www.swfcabin.com/open/1306508334

I have collisions for the outside of the walls working with the setTileProperties() function allowing certain collisions. I'm kind of stumped on what to do for checking collision with the interior of the walls, when the player is overlapping the tile.

Is there a way I can get the tile's index that the player is overlapping?

26
help / Re: Character with multiple animation images
« on: Tue, Mar 8, 2011 »
Thanks. It looks like I also need to update positions.

One question:
Does it matter whether the super() call is first or last in the function? If so, what is flixel's convention?

In my experience it can matter for some classes, but it usually doesn't. Then again it all depends on what variables you're defining I suppose. Check out the code of the class you're extending. If you see some variable definitions that you're redefining, you should probably call super() first, yeah?

I'm fairly sure it calls it automatically, though. Probably first.

27
help / Re: Character with multiple animation images
« on: Tue, Mar 8, 2011 »
This was on the first page, dude.

http://flixel.org/forums/index.php?topic=3271.0

28
Set your maxVelocity.y to _gravity_y instead of _jumpspeed. I think that will fix your problem.

29
help / Re: DAME - a new map editor made using flixel!
« on: Sat, Mar 5, 2011 »
I unchecked the groups, but they were still exported... D:

Can you confirm that you unchecked the correct box? I just looked at the code and tried it to be sure and the export does indeed ignore any groups if they are unchecked for export.

You need to uncheck the tick for Export (which is in the Group properties underneath the layers tab). I'm guessing that you might have actually just ticked the box next to the group itself, which controls group visibility.

Oh, I'm an idiot.

Thank you.

30
help / Re: DAME - a new map editor made using flixel!
« on: Thu, Mar 3, 2011 »
Groups can have "Export" set on them directly - just tick the box (or not!). I don't recall if setting the group itself to not export excludes its contents however. Should be quick enough for you to experiment and find out :)

I unchecked the groups, but they were still exported... D:

31
help / Re: DAME - a new map editor made using flixel!
« on: Thu, Mar 3, 2011 »
Sure, the lua scripts are really easy to use.

I've written my own exporter but only one with very simple modifications to the default one. I'll take up the challenge, though.

Is there a way to detect in the exporter LUA if a group is visible or not? That way the un-checked (not visible) groups will not be exported.

32
help / Re: DAME - a new map editor made using flixel!
« on: Thu, Mar 3, 2011 »
Quick question: For different levels of my game, do I have to make a new .dam file? Or am I missing something that lets me make different levels in one DAME file, perhaps?

The game I'm working on at the moment has 60 levels all in one DAME file. I just use a new Map each time in dame, so my left-hand panel has lots of maps in. Actually they are grouped, 10 levels per group, but same end result :)

I tried doing that, but I realized that it exports information for every group in the level class. Doesn't that make your level class very cluttered? Or is that only preventable by doing what Titch said, and having the custom exporter take care of that?

I don't feel I'm experienced enough to have it do that xD

33
help / Re: DAME - a new map editor made using flixel!
« on: Wed, Mar 2, 2011 »
Quick question: For different levels of my game, do I have to make a new .dam file? Or am I missing something that lets me make different levels in one DAME file, perhaps?

34
Thank you for that suggestion, it helped me realize that it's overlapping with and passing the sprite contained inside of the EnemyEntity class. I'm dumb :-[

Thanks

35
I'm trying to use the FlxU.overlap() function to check collision between my melee sprite and a group containing my enemies.

My enemies are made of classes called EnemyEntity which extends FlxGroup and has a sprite inside for the graphic. I put all of these in another group called enemies in the playstate.

When I go to check for overlap via FlxU.overlap(melee, enemies, enemyHit), the game freezes up when it uses the callback function shown here:

Code: [Select]
public function enemyHit(_melee:FlxObject, enemy:EnemyEntity):void {}
I've identified the reason being that I'm using the EnemyEntity class (which extends FlxGroup) as a parameter, for if I change the parameter to enemy:FlxObject it works fine.

The problem is, I need the object passed in to be an EnemyEntity so I can access some public variables and functions necessary to have the enemy be hit and damaged.

Is it not possible to use custom classes as parameters in overlap() callback functions? If so, any suggestions on what I'm doing wrong?

36
help / Re: Child class's public variable access problem
« on: Wed, Feb 16, 2011 »
I've refactored five times already T.T

I'm trying to make a side-scroller engine with entities that can be added via DAME. I want the entities to be FlxGroups though, so I can add HP bars and damage counters to the entities. I made a custom exporter in DAME to add FlxGroups fluidly.

Perhaps there is a better way to make entities like this?

37
help / Child class's public variable access problem
« on: Wed, Feb 16, 2011 »
I'm in a bit of a rut with this one. I'm really bad at explaining things so I'll just throw the code down and tell the problem, and hope someone's willing to help lol.
Code: [Select]
package  
{
import org.flixel.*;

public class Entity extends FlxGroup
{

[Embed(source = 'data/images/items/coin.png')] private var imgSprite:Class;

public var sprite:FlxSprite;

//properties
public var maxHP:Number;
public var power:Number;
public var coinValue:int;

//physics
public var gravity:int = 800;
public var gravityOn:Boolean;

//gui
public var guiDisplay:int;
public var stickyGUI:Boolean;
private var gui:EntityGUI;

public function Entity(X:Number, Y:Number)
{
//property declarations
maxHP = 1;
health = maxHP;

//sprite = new FlxSprite(X, Y);
//loadSprite(imgSprite);

gui = new EntityGUI(this.x, this.y);
add(gui);

gui.hpBar.scale.x = maxHP;

guiDisplay = 0;

gravityOn = true;

}

/*public function loadSprite(imgSprite:Class, width:Number = 24, height:Number = 24):FlxSprite
{
sprite.loadGraphic(imgSprite, true, true, width, height);
add(sprite);
return sprite;
}*/

override public function update():void
{
super.update();

if (gravityOn) {
sprite.acceleration.y = gravity;
}

if (FlxG.keys.justPressed("E")) hit(.1);

displayGUI();

if (stickyGUI) guiDisplay = 1;

}

private function displayGUI():void
{
if (guiDisplay > 0)
{
gui.visible = true;
if (gui.bg.x != sprite.x) gui.bg.x = sprite.x;
if (gui.bg.y != sprite.y) gui.bg.y = sprite.y - 10;
if (gui.hpBar.x != gui.bg.x) gui.hpBar.x = gui.bg.x + 1;
if (gui.hpBar.y != gui.bg.y) gui.hpBar.y = gui.bg.y + 1;
guiDisplay -= 1;
} else {
gui.visible = false;
}
recalculateHP();
}

public function recalculateHP():void
{
if (gui.hpBar.scale.x > .1) gui.hpBar.scale.x = health / maxHP * maxHP;
else kill();
}

public function hit(dmg:Number):void
{
flicker(.3);
guiDisplay = 100;
health -= dmg;
}

}
}
Code: [Select]
package  
{
import org.flixel.*;
public class PlayerEntity extends Entity
{

public function PlayerEntity(X:Number, Y:Number)
{
super(X, Y);

sprite = new Player(X, Y);
add(sprite);

stickyGUI = true;


}

override public function update():void
{
super.update();
}

}

}

So I define the sprite as an FlxSprite. When I reassign it in the PlayerEntity child class, I reassign it as a Player class which extends FlxSprite.

The problem is that when I try to access the sprite's public variables inside of the PlayerEntity class (the Player class's public variables), it can not find them. I tried removing the sprite assignment in the Entity class and moving it to the PlayerEntity class like so:
public var sprite:Player;

and that enabled me to access the public variables. But the Entity class needs a sprite variable to do it's magic.

Any suggestions/ideas?

38
help / Re: DAME - a new map editor made using flixel!
« on: Sun, Feb 13, 2011 »
I have a question:

I'm making the entities of my game FlxGroups, so that I can tie multiple sprites to one entity. I would love to use DAME to add these entities to my world but from what I've learned you can only add sprites.

Is it possible to add FlxGroups as a sprite or do I have to do some code rewriting or a custom exporter?

39
help / Re: Preventing player from running off the level
« on: Fri, Nov 19, 2010 »
If I don't use tiles to prevent this, I just stick this code in my Player class:

Code: [Select]
if (x < PlayState.level.boundsMinX) x = PlayState.level.boundsMinX; //prevent player from walking off left of screen
if (x + width > PlayState.level.boundsMaxX) x = PlayState.level.boundsMaxX - width; //prevent player from walking off right of screen

Where boundsMaxX is the FlxTilemap.width and boundsMinX is (usually) zero. I use DAME with a custom exporter for my levels.

In this case, level.boundsMaxX can be replaced with level.width (or wherever you don't want the player to pass on the right side of the screen). level.boundsMinX can be replaced with 0 (or wherever you don't want the player to pass on the left side of the screen).

40
chat / Pokemon - Standing the Test of Time
« on: Thu, Nov 18, 2010 »
So I'm sitting here in my C++ class waiting for my professor to arrive, and the kid next to me turns to me and says "How would you rate Pokemon games at this day in age, against today's games?"

I thought about it, and I realized that I would probably still rate the game pretty high. Pokemon is still a very unique game, it's practically a sub-genre of its own.

Then I tried to abstract why. What makes Pokemon so unique? It has the basic elements of an RPG: open adventure, exploration, unique interactions throughout, and a strive for character improvement. Instead of strengthening the character you control specifically, you collect these unique entities with special and respectively categorized powers.

I was just wondering how you guys think Pokemon is seeming to stand the test of time? I'm trying to abstract it design-wise as much as I can.

Pages: 1 [2] 3 4 5