So yeah, beta testing time draws near! page 4

119 posts

Flag Post
private function DoGameObjectMovement():Void
{
	var i:Number;
	for (i = 0; i < aPlayerBulletObject.length; i += 1)
	{
		aPlayerBulletObject[i].DoMovement();
		if (aPlayerBulletObject[i].bTerminate)
		{
			//trace("Destroying object: " + aPlayerBulletObject[i]._name);
			aPlayerBulletObject[i].Destroy();
			aPlayerBulletObject[i] = aPlayerBulletObject[aPlayerBulletObject-1];
			aPlayerBulletObject.length--;
			i--;
		}
	}
	// The same loop is done for each of the other game object arrays--aEnemyObject, aEnemyBulletObject, aPowerUpObject, and aMiscObject
	// bTerminate is a boolean set on an object that dies, moves off-screen, etc.
	// Destroy() triggers any on-death visual effects, then removes the movieclip
}

This removes the need to call OptimizeArray() on this. It won’t leave ‘empty’ slots in the array. Keep in mind that my code will make the order of the array change if a bullet is Destroyed.

You need to follow this template and apply this to all the arrays that you are doing a similar method. (basically anything you call OptimizeArray() too.

As a warning note, I’m not too sure if arr.length--; works in AS2.

 
Flag Post

Nope, doesn’t work because AS2 sucks. (And I’m betting you meant aPlayerBulletObject[i] = aPlayerBulletObject[aPlayerbulletObject.length - 1];, but it still didn’t work either) I think I can try the same thing using splice though. I only worry that splice is also a fairly expensive operation, if memory serves. Hmm~

 
Flag Post

If arr.length— doesn’t work you can always do arr.splice(i,1) but I’m not sure if that works in AS2 also. Plus splicing is ridiculously slow.

 
Flag Post

The swap is important. If you are going to splice, splice the last value (which because of the swap, is a duplicate value) so everything else doesn’t get shifted.

 
Flag Post

Can you do aPlayerBulletObject.pop() in AS2, once you’ve swapped? And if you can, is popping faster then splicing the last element?

 
Flag Post

K, I’m full of crap. arr.length--; DOES work in AS2, I just had neglected to check for undefined instead of just the boolean termination flag. I shouldn’t need to check for undefined elements, but again, that’s the early learning-phase junk code talking, so there are clearly other parts of my code, elsewhere, that trying to delete/remove/whatever expired displayobjects. It might be time to clean some of that garbage up. Thanks guys. :D

 
Flag Post

i dumb

 
Flag Post

Well, as UG mentioned, the swap is important because without it, you’re only shrinking the array size by one by chopping off the last element. If bullet #3 is slated for removal and the array has 10 bullets total, you’d actually be cutting off the last one instead of #3. Whether that last bullet has already been checked and is still legit, or whether it has yet to be checked, it needs to be preserved somehow.

 
Flag Post

I’m not entirely sure what’s going on here but, if you’re trying to remove things from an array without screwing the position of the rest of the things, traverse that array backwards. That way, anything affected by your splicing is stuff you’ve already checked.

 
Flag Post

Did the code I posted help at all? Hopefully not doing that every frame will save a couple of ms off each frame.

 
Flag Post

Yeah, it did actually. There’s still a bit of lagginess going on, which I can probably reduce even more by taking the framerate to 45. I was going to do 30, but it looks SO AWFUL. Man, there’s so many timing things I’m going to have to adjust though. D:

Edit: Another problem area seems to be when the player tries to move or shoot. Not quite sure why, but that’s on the list to look at either tomorrow or monday.

 
Flag Post

Any more code that you think could be done faster? Post here! Might as well get most of the code changes for speed in before you redo all your timing. Just in case you are going to be forced to change it some more.

 
Flag Post

Random question: is uint faster than int? I know they take up the same amount of memory but is there any difference in incrementing/decrementing or performing operations on them?

 
Flag Post
Originally posted by Aesica:

Nope, doesn’t work because AS2 sucks.

Not unless your a flash wizard

 
Flag Post
Originally posted by DannyDaNinja:
Originally posted by Aesica:

Nope, doesn’t work because AS2 sucks.

Not unless your a flash wizard

What’s with the wizard, Danny!

 
Flag Post

Oh, the wizard again…

Oh, I think I get what UG is doing now.
So arr.length— is faster than arr.pop() is faster than arr.splice()?

 
Flag Post

The mouse movement is acting really laggy for some reason. This part isn’t making a lot of sense either, since the movement code is supposed to be checked every frame, just like the keyboard movement code. Yet, sometimes it lags (usually with several things on the screen) and by lags, I mean what you’d expect to see in an internet-based game: You move the cursor to a certain position, then to another position, and a few seconds later, the player moves to the first position, followed by the second position.

It’s as though the flash player itself lags when trying to read the mouse’s x & y. This phenomenon can be easily observed by waiting for the lag to hit, then swiping the mouse over the location the various buttons on the pause screen would be, then pausing the game. Seconds after pausing, the tooltips/sound mouseovers will manifest briefly, even though the mouse has already traveled over those locations.

It seems to happen primarily when several things are on the screen and the fire button is being held down. Can sustained keyboard input interfere with the flash player’s ability to track the mouse location?

 
Flag Post

That sounds really strange.

As I understand it, the application won’t continue until the whole logic cycle is done, so even if it’s taking it a while to process all the instructions (which will always happen in AS2), it should simply freeze/lag a bit and then continue, but what you’re describing is totally different; as if instructions were being stacked and the application was like “I’ll just keep running and run stuff whenever I have some free time”.

About optimizing it, I don’t want to sound pessimistic but let’s be honest; no ammount of optimization can make up for AS2’s crap performance. Let’s say you super optimize everything; what can you gain? 100%? 200%?

An unoptimized AS3 port would translate into >1000% speed.
It will be a fucking boring process, but I doubt trying to optimize AS2 would be any better, so you could consider it the lesser of two evils.
Also, depending on how well structured your documents are, porting it to AS3 could be a matter of spending a couple of days on it. The only problem when porting AS2 → AS3 is when the AS2 application is one of those multiframe, timeline/object code behemoths.

 
Flag Post

Could be just a lot of things are going on, or you did something.

I’ve incorrectly coded a button over sound once, where it repeatedly played it while the mouse was over. Caused a bit of lag. Also did the same with a save, where it repeatedly saved multiple times in a row. That was super laggy.

Are you hiding the pause menu properly during game play? What are you doing with the mouse code-wise? Have any code you might want to post?

 
Flag Post

@UnknownGuardian: Yeah, the pause menu is generated when the game container is created, then its visibility set to false until it’s used. The pause menu itself isn’t the issue, it’s just a way to observe the delayed mouse input. It’s not the normal type of AS2 lag, either. Everything still fires at the normal rate, bullets move at the normal rate, etc. The player location in relation to the mouse is the only thing that lags behind, and it’s great watching the poor character sit there and take bullets to the face because of mouse input lag.

I’m thinking the only real way to save it is, when the user chooses mouse input, to force autofire to always be on, and the left-click button would be used to toggle focus. That should free it up from sustained keyboard input.

@Senekis: The AS3 port was my initial idea, but uh…yeah. My documentation sucks. Like, horribly. I’d need a day or two just to get proper documentation in order before I could even begin, but it might come to that if this optimization fails.

Thankfully, the only timeline BS is a throwback from when I first started—each screen is a different frame, but the only actual timeline code on any given frame is stop();. Every symbol (aside from the preloader, because I had to use AS1 for it) is blank.

Aside from that messy garbage collection code I posted, everything else is pretty clean and trimmed down. I’m going to try scaling it back to 45 fps + what I mentioned regarding mouse input, but if that doesn’t work… Well, I guess I’ll be getting a crash course in AS3 and at least another week or two added to my completion time. ;)

 
Flag Post
Originally posted by Aesica:

The mouse movement is acting really laggy for some reason. This part isn’t making a lot of sense either, since the movement code is supposed to be checked every frame, just like the keyboard movement code. Yet, sometimes it lags (usually with several things on the screen) and by lags, I mean what you’d expect to see in an internet-based game: You move the cursor to a certain position, then to another position, and a few seconds later, the player moves to the first position, followed by the second position.

It’s as though the flash player itself lags when trying to read the mouse’s x & y. This phenomenon can be easily observed by waiting for the lag to hit, then swiping the mouse over the location the various buttons on the pause screen would be, then pausing the game. Seconds after pausing, the tooltips/sound mouseovers will manifest briefly, even though the mouse has already traveled over those locations.

If I’ve read this correctly, it sounds like the listeners on the pause menu’s buttons are still active when the pause screen isn’t visible. If that’s correct, maybe the “lag” isn’t really lag, but a listener conflict (IDK, just guessing; I’m thinking you might try removing the listeners to see if it still occurs)?

 
Flag Post

Does randomButton.onRollOver = function() { // ...crap here } count as a listener? I’m actually not sure if having that before it’s needed causes more overhead, but that’s not the problem. The best way to observe the phenomenon in action is to check out the version currently on FGL. Use mouse movement, shoot/focus with keyboard, and wait until the screen fills up. You’ll find that the firing still works, but the mouse movement is delayed because the flash player itself is being sluggish with getting the mouse location. The movement and firing controls are all handled in the same function, in the same (only) onEnterFrame. The only thing that makes sense is to blame the flash player itself.

Either way, it seems like isolating mouse controls (mouse movement = autofire always on, focus with left click, ignore keyboard input for both of those + movement) might’ve solved it. Keyboard-based control still seems to be a bit laggy though. I guess that’s next on the list!

 
Flag Post

OK, but you said that you mouse over the pause button locations and then open the pause menu and get the roll-overs, so I thought (since you also said the menu was there, just set to not visible) that it might be constantly listening for those buttons (even when not visible). Otherwise, it would have to be reading the mouse’s location and holding that until the pause menu is opened up, then dispatching to the listeners (which might’ve been what you had meant by “read(ing) the mouse’s x & y”; I assumed that that meant that the read was delayed, not the dispatch)… Or I just don’t know what I’m talking about, which is a common enough occurrance.
Addition: I guess either way, the roll-over effect itself is getting delayed, so unless you have a boolean that’s set or a queue or something (inside the onRollOver function, to “mark” it for sound/tooltip processing), that that wouldn’t explain it anyway…

As far as checking it out on FGL, I thought I had to have an invitation or something (don’t really remember, too lazy to read through the posts to find it)…?

 
Flag Post

Oh that’s just the result of the mouse lag finally catching up to where it should be. You can do the same thing ingame by simply releasing the firing buttons, which is annoying because not firing = things not dying = you probably dying. :D

Anyway, here’s the fgl link: https://www.fgl.com/view_game.php?from=dev&amp;game_id=25362

Edit: And FFS, I thought my new icon was a lot better, but it’s only rated 25%/1131. Are the only high-rated icons stupid, cartoony crap with oversaturated colors?

 
Flag Post
Are the only high-rated icons stupid, cartoony crap with oversaturated colors?

Yes. Just as most high rated games are stupid, cartoony crap with oversaturated colors… annoying music, boring mechanics, lack of quality/controls options and no storyline.