Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 19 20 [21] 22 23 ... 31

Author Topic: Proceedurally Generated RTS  (Read 57059 times)

Fayrik

  • Bay Watcher
    • View Profile
Re: Proceedurally Generated RTS
« Reply #300 on: April 06, 2011, 02:28:50 pm »

Wait, you're telling me Flash can't handle RNGing like 60 times then rendering the output of 20 odd random stars coloured circles (Seeing as, that's going to be the sum of it).

Pfft, doesn't sound like it's living up to it's name, to be honest.
Logged
So THIS is how migrations start.
"Hey, dude, there's this crazy bastard digging in the ground for stuff. Let's go watch."

Virex

  • Bay Watcher
  • Subjects interest attracted. Annalyses pending...
    • View Profile
Re: Proceedurally Generated RTS
« Reply #301 on: April 06, 2011, 02:52:43 pm »

Nebulas tend to be distant. Or very foggy. :P

Eh, whatever.  I just googled around for "space" images of exceedingly large size (over 2400x2400) and found one that looked nice.

I'm beginning to wonder if I could dynamically render a starscape graphic as well.  It wouldn't be fast to generate by any means (my large asteroids* are taking 600 ms for some reason) but it would at least have the same style.  I'll take a crack at it at some point and if I get a good result, it'll get saved and imported as a bitmap (rather than generated at run time every time).

I have never done so much dynamic art in my life, and I'm quite enjoying the process.  Frustrating sometimes, but enjoyable.

*Have I intentionally shown these?  I know I've been updating the same swf on my server, but I don't know if anyone here has looked at it recently.
Have you tried tossing a profiler at it yet? You may be assigning much more memory then needed somewhere, which would create a large overhead.
Logged

Draco18s

  • Bay Watcher
    • View Profile
Re: Proceedurally Generated RTS
« Reply #302 on: April 06, 2011, 02:58:48 pm »

Wait, you're telling me Flash can't handle RNGing like 60 times then rendering the output of 20 odd random stars coloured circles (Seeing as, that's going to be the sum of it).

Pfft, doesn't sound like it's living up to it's name, to be honest.

Actually, its not that. :)

It was the 5000 iteration loop it had to go through.  It had to iterate over every pixel and do a little bit of math to determine if that pixel was "inside," "outside," or "outline" of the sprite.

I cut down the operation time by half, though.  So now it takes 200 ms (on this computer, which is slightly faster than my one at home) where it used to be taking 450.

(Why 5000 iterations?  Well...a 96 by 72 pixel bitmap has 5084 pixels.  The ships by comparison only go through 288 iterations, because A) they're smaller--24x24 or 48x48 pixels--and B) they get mirrored, only having to actually touch half the pixels in the expensive math portion).

If I am going to generate a 2700 by 2000 pixel bitmap to use as a background I'm going to need more than 60 stars.  And each star is going to encompass more than 1 pixel.  And they might have a "glow" to them, so if two stars are near each other, they'll need to overlap (mmm...alpha multiplication...).

Assuming each pixel is touched once, then the loop would be 5,400,000 iterations.  Function overhead (ah haha, bitmapdata.setPixel(x,y) is a function!) is pretty significant at that number of loops.

Anyway, all I'm saying is:
It will take about 5 whole seconds to generate the bitmap, at best.  Which is pretty intensive for flash (as during that time the program (and its container, eg. Firefox) will be unresponsive).  And at worst, it cannot take more than 14.99 seconds, or Flash will abort the operation for having taken too long (default script timeout duration is 15 seconds).
Logged

Fayrik

  • Bay Watcher
    • View Profile
Re: Proceedurally Generated RTS
« Reply #303 on: April 06, 2011, 03:07:11 pm »

I wouldn't run dynamic sprites for stars, simply for time's sake.
Would it be possible to have like 6 or 12 static star-sprites, all in white which then have different colours assigned to them at run?
Logged
So THIS is how migrations start.
"Hey, dude, there's this crazy bastard digging in the ground for stuff. Let's go watch."

Draco18s

  • Bay Watcher
    • View Profile
Re: Proceedurally Generated RTS
« Reply #304 on: April 06, 2011, 03:12:59 pm »

I wouldn't run dynamic sprites for stars, simply for time's sake.
Would it be possible to have like 6 or 12 static star-sprites, all in white which then have different colours assigned to them at run?

What approach I take I haven't determined yet.  I'm just stating the possibility that it might be too intensive to do at run time.

I'll probably also be exporting the asteroid sprites and pulling them in as assets, rather than having every single one be generated at runtime.  Simply because I'm already cheating and having duplicates and because I have no easy way of saving them between sessions (so that a loaded game has the same asteroid sprites as when it was saved).

And in any case, the "5 second generation time" is a one-time deal.  Flash would only need to do that once, not every frame (in case that wasn't clear).
Logged

Fayrik

  • Bay Watcher
    • View Profile
Re: Proceedurally Generated RTS
« Reply #305 on: April 06, 2011, 04:33:24 pm »

Yeah, I realise it was one time. I just didn't realise how many tasks it had in the initial load.
For an initial load, you've probably got a lot more time to spare. As you said, it only really happens once.
Logged
So THIS is how migrations start.
"Hey, dude, there's this crazy bastard digging in the ground for stuff. Let's go watch."

Draco18s

  • Bay Watcher
    • View Profile
Re: Proceedurally Generated RTS
« Reply #306 on: April 06, 2011, 04:38:06 pm »

Its something I'll toy with, but I'm willing to say "I don't need this" and let it go, for whatever reason.
Logged

Draco18s

  • Bay Watcher
    • View Profile
Re: Proceedurally Generated RTS
« Reply #307 on: April 06, 2011, 10:08:17 pm »

Metaball uses Render.  It's super effective!



Old rocks on left, new rocks on right.

The old way was slooow and ugly.  The new method uses metaballs, is 10 times faster, and looks loads better.
Logged

Aklyon

  • Bay Watcher
  • Fate~
    • View Profile
Re: Proceedurally Generated RTS
« Reply #308 on: April 06, 2011, 10:12:42 pm »

Woo for metaballs.
Logged
Crystalline (SG)
Sigtext
Quote from: RedKing
It's known as the Oppai-Kaiju effect. The islands of Japan generate a sort anti-gravity field, which allows breasts to behave as if in microgravity. It's also what allows Godzilla and friends to become 50 stories tall, and lets ninjas run up the side of a skyscraper.

Draco18s

  • Bay Watcher
    • View Profile
Re: Proceedurally Generated RTS
« Reply #309 on: April 06, 2011, 10:26:43 pm »

Woo for metaballs.

Yeah, the old method was just ugly.  That screenshot is a particularly ugly one.  I kinda miss the scoop-outs, but eh.  They only looked ok in some cases, not all.
Logged

Virex

  • Bay Watcher
  • Subjects interest attracted. Annalyses pending...
    • View Profile
Re: Proceedurally Generated RTS
« Reply #310 on: April 07, 2011, 07:18:10 am »

For a moment I read that as meatballs, which is an appropriate name as well.
Logged

Draco18s

  • Bay Watcher
    • View Profile
Re: Proceedurally Generated RTS
« Reply #311 on: April 07, 2011, 09:32:44 am »

For a moment I read that as meatballs, which is an appropriate name as well.

Meatballs are nice and saucy.  Really thick goopy sauce that makes the meatballs stick together and form a larger cohesive blob.
Logged

Draco18s

  • Bay Watcher
    • View Profile
Re: Proceedurally Generated RTS
« Reply #312 on: April 07, 2011, 10:28:53 pm »

I think I'm starting to see a game...

There's no AI, I just set up an enemy mothership to build 40 units at random (ignoring resources, as I don't have an AI script to store its resource count yet!).  But those units have the same low-level AI yours do, so they will shoot at each other (prioritizing units they kill faster over ones that kill them*).  They'll also target the mothership if its in range, over everything else, which I need to fix.  But that's a targetting logic issue that I want to make more sophisticated.

There's also still a lingering error where the resource collector will fill up but not return to the mothership, but instead be looking for a new asteroid: the one it just left, be unable to harvest and decide that it needs to find a new asteroid.... Not sure what's causing it yet, haven't had it happen since I added in some debug statements.

And a lingering infinite loop.  Grr. Damn health bar drawing.

*Designed units will likely throw an error.  I haven't set them up to determine those numbers yet.
« Last Edit: April 07, 2011, 10:33:39 pm by Draco18s »
Logged

Akhier the Dragon hearted

  • Bay Watcher
  • I'm a Dragon, Roar
    • View Profile
    • My YouTube Channel
Re: Proceedurally Generated RTS
« Reply #313 on: April 07, 2011, 10:34:36 pm »

Good progress so far!
Logged
Quote
Join us. The crazy is at a perfect temperature today.
So it seems I accidentally put my canteen in my wheelbarrow and didn't notice... and then I got really thirsty... so right before going to sleep I go to take a swig from my canteen and... end up snorting a line of low-grade meth.

Draco18s

  • Bay Watcher
    • View Profile
Re: Proceedurally Generated RTS
« Reply #314 on: April 07, 2011, 10:38:28 pm »

Fixed the infinite loop.  Again.  Math.min(a,1) is not what I want!  Derp.

Maybe fixed the collector, I had it bug out trying to collect, so we'll see.

Tomorrow I'll work on having dead ships drop "wrecks" that can be collected for resources (namely that all-important ship-cap crystal).

Also looks like some invalid targetting is going on (I keep seeing some bullets flicker into and then out of existence), as well as weirdness in either damage, or health bars.
« Last Edit: April 07, 2011, 10:44:45 pm by Draco18s »
Logged
Pages: 1 ... 19 20 [21] 22 23 ... 31