ID:1294689
 
(See the best response by Tom.)
Code:
Not Applicable


Problem description:

This might belong in a different subforum, like Design Philosophy. oops.

I am developing an isometric BYOND game for the Mazes Contest that's going on right now. Since I've been planning to make this game singleplayer-only, I decided to not pull any punches with things that you usually don't see in BYOND games because of the network lag bottleneck, like particle effects, lighting, responsive controls, and so forth.


This is a screenshot of the game.

However, this was not without its problems. I've been noticing framerate dips, and huge spikes in CPU usage.
Right now, when I am sitting and there are no moving objects (the particles here are just sitting still with animated icons), the framerate hovers at around 20 (the world is set to 25fps), and the CPU hovers around 25%!

The CPU hovering around 25% for a game that's essentially doing nothing is unacceptable.. so I started running profiler tests.

None of my functions had a total CPU value of over 5.000, and most of them had over 10,000 calls (even the ones with the highest CPU value)... so it wasn't my code.

So I went and disabled the particles, and I saw that the CPU would hover around 15% in a similar game state. That's really odd, I thought, so I made particles that didn't have an animated icon but were animated via pixel offset, and the CPU usage rose back up to 25% with the same dips in framerate.

Right now, my world is set to 40x40 icon size, isometric, and 22x26 view size (960x520 screen size in pixels).

Then I turned the map_format bit back to TOPDOWN_MAP, and I put the game in the same usual gamestate, with no moving objects and lots of animated particles. The framerate was a constant 25fps, like it should have been, and the CPU usage sat below 6%.

So I've come to the conclusion that BYOND isometric is completely incapable of displaying animated icons. This is a huge disappointment, because I have invested a lot of time into making my stuff work in isometric, like the shading on the walls and a private library for turning normal square tiles into isometric tiles, and creating an isometric tileset(which was the most time-consuming), and so forth.

I don't know what to do from here.
I can't continue working on this in BYOND isometric because of how incapable it's proven to be.

Should I just drop isometric and make the game with a traditional camera angle? Should I make my own isometric stuff in TOPDOWN_MAP?

tl;dr: I've invested a crapload of time making a game in BYOND isometric, but it turns out that BYOND isometric isn't capable of showing animations so it isn't an acceptable medium for this project. I don't know what to do anymore.

[EDIT]: Here is a demo of the game with DEBUG enabled so you can see for yourself the problems I'm describing: http://files.byondhome.com/D4RK354B3R/Apprentice.zip
If you host the game with Dream Daemon and join with Dream Seeker, which one uses the CPU? If Dream Seeker, are you using hardware or software graphics rendering?

If you lower the target framerate to 20fps, is it stable and is the game still playable? What if you lowered the view to 20x24?

Are the "spark" particles a single atom or many atoms? If many, could you dynamically blend them into one state so it only required one atom?

Just spit-balling here, but it seems like a lot of work to throw away (although hopefully you would be able to salvage a fair amount of it).
There are 20 little spark particles. All they do is sit there with a flicked icon state, and then disappear after 0.5 seconds.
I tested it with up to 60 spark particles and they made a negligible impact to the CPU usage and framerate. Then I tried it with 0 and made only 1, and the CPU usage spiked from 15% to 25% and then back to 15% when that one particle's 0.5 seconds were up.

Lowering world.fps to 20 reduces the CPU usage from 25% to 22%. There are still a few dips in framerate here and there.

Running it in dream daemon and then connecting to dreamseeker... DreamDaemon is using 0% CPU and DreamSeeker is using 25%. I am running with hardware graphics rendering enabled. I don't think software graphics rendering would be capable of anything above 10fps.

I've tried lowering the view to 20x20, and it improved the framerate and the CPU usage went from 25% to ~20%. For just sitting there not doing anything but creating the particles and deleting them...

You might say that's an improvement and roll with it, but what about when there's actually a game that's running, with like 10 enemies chasing you and you're slinging spells left and right? It's not going to be enough.
When can we start taking bets on how much more efficient your yet to be released isometric engine is over BYOND's built-in isometric mode?
I don't have the time to make another isometric engine for TOPDOWN maps (I've done it before years ago but it's tile based and kind of crappy) and still be able to submit a completed entry for the Maze contest.
Off Topic - that looks epic.
Honestly. I know for a fact that Isometric hasn't been used much in BYOND, and troubles with it have been reported even less than it has been used. Now, with that in mind, and how great this image looks I really think you should report this as a bug.

I know that it may or may not get fixed, and it may or may not be fixed in time for the contest even if it is fixed, but with how common using animations is I really think something could and would be done about this somehow.

Now if you can design something similar to this without using BYOND's isometric, then that would be great. If not, maybe you can give up the animations in order to keep the rest? I'm not sure how severe of a loss that would be, but I imagine it's not one you want to endure; so if that's the case then you'll probably have to return to a more common style of view in order to make it for the contest unfortunately.
I'm sure we can fix that if it's really lagging in steady state. It's probably just a single routine in our code that is called unnecessarily. File it as a bug. We'll be getting back to optimizations for 500 . Obviously the intent is for isometric to be just as functional as topdown and we simpy haven't had enough cases to expose the issues.
In response to SuperAntx
SuperAntx wrote:
When can we start taking bets on how much more efficient your yet to be released isometric engine is over BYOND's built-in isometric mode?

FYI this is the kind of post that makes me want to quit the project.
In response to Tom
Chin up Tom almost at the 5k mark, I think SuperAntx needs to understand that BYOND has next to no isometric games..
In response to Tom
Tom wrote:
FYI this is the kind of post that makes me want to quit the project.

That was a jab at Darke's habit of disliking something about a lib then obsessively optimizing his own version instead of working on his damn game.


Gosh it disappoints me so much how boring this looks in comparison to how it was with isometric... :(
But now the CPU sits at 4% idle rather than the ridiculous 25%...
Turn it back for the love of god turn it back!!!!!
Best response
We'll figure out what's going on here.
...

All I can say is I am SO glad there has been a response so quickly, and that this will be getting fixed.

Somewhat Off Topic: Did you actually make something that converts the tiles into isometric? or the player? or both? If any of these are a yes, then I'm very intrigued by this. Might be easier for me to learn how to do that than to try and practice doing isometric art if I ever want to make something in it.
In response to D4RK3 54B3R
Wow, that's really drastic. Hopefully that'll make it easy to profile and track down for Tom and Lummox JR (fingers crossed!)

It sounds like Tom's on the case, but if you feel like fiddling in the mean time, have you tried using the TOPDOWN_LAYER and seeing if it causes the same CPU usage? If the bottleneck is the isometric depth sorting, then that should bypass it. Although, it'll appear above walls and cause other side-effects, so it may not be a practical solution.

<edit>
Also, I noticed in your bug report that your particle icon is 5x40. What happens if you change the dimensions to multiples of 4? Powers of 2?
I'm telling you... Those screenshots are like BYOND High Definition. :| He's got the skills of ten eighty pee coding and iconning. :3