Recent posts by Draco18s on Kongregate

Flag Post

Topic: Game Programming / [Solved I think] How to _copy_ semi-transparent pixels?

Originally posted by Aesica:
Originally posted by Draco18s:

Copy Pixels can’t do transparency. You have to use Draw()

I hope I’m just misinterpreting something here, because copyPixels most certainly will copy partially-transparent BMDs. I suspect what’s going on is what Amibtious said, and the only workaround I can think of involves either drawing the circle with more opacity or using lines thicker than 1 pixel.

It will copy, but it won’t blend. It’ll overwrite the destination color value rather than multiplying.

 
Flag Post

Topic: Game Programming / GiTD #42 - *Pirates*

God, you have no idea how much I want someone to remix those lyrics with the theme from Pirates of the Caribbean.

 
Flag Post

Topic: Game Programming / [Solved I think] How to _copy_ semi-transparent pixels?

Copy Pixels can’t do transparency. You have to use Draw()

 
Flag Post

Topic: Game Programming / Can i upload javascript or java games in kongragate

http://developers.kongregate.com/docs/resources/faq#format

There is support for iframe games, but I am not sure if you need to contact staff about those or not, and either way, you’d have to host it on your own server.

 
Flag Post

Topic: Game Programming / {AS2} New Game !

1) Use AS3, there’s really no reason not to.
2) If you’re having trouble showing a movieclip on button-press you’re going to only encounter more problems.
3) Here:

on(release) {
   theThing.visible = true;
}
 
Flag Post

Topic: Game Programming / GiTD #42 - *Pirates*

Transmogrification would be interesting. And not easy.

 
Flag Post

Topic: Game Programming / [Urgent]Problems with additional files.

http://lmgtfy.com/?q=unity+how+to+use+cross+domain+policy&l=1

 
Flag Post

Topic: Game Programming / [Urgent]Problems with additional files.

https://www.google.com/search?q=cross%20domain%20security

Also, private messages do not get your problem solved faster.

 
Flag Post

Topic: Game Programming / [Urgent]Problems with additional files.

That’s not additional files. Additional files aren’t executable code, they’re data.

PHP requires a server to be hosted on (that’s not Kongregate) and to “access” them you need to make an external call.

 
Flag Post

Topic: Game Programming / Need Help

var money = 0;
addEventListener(Event.ENTER_FRAME, doTheThing);
function doTheThing(e:Event) {
   money++;
}

I’ll take my cut in cash, thanks.

 
Flag Post

Topic: Game Programming / [Advice] Unity Optimization

Originally posted by Zerakil:

Thanks for the info, I know static batching is best practice, but must admit that I have not had any real need for optimization when it comes to Occlusion, But guess it get more importan if working on large 3d levels for FPS or true 3d Games.

Basically anything with a ton of small and complex models will benefit.

 
Flag Post

Topic: Game Programming / [Advice] Unity Optimization

Originally posted by Zerakil:

As for Occlusion I’m not sure if I read it wrong, I missed something, to Occlusion work rather well in Unity Pro. And if I remember correct its not even possible in the free version.

It is. Sorry, I’ve got access to Pro so I’ve got Fancy Features.1 Occlusion is really only about a 30% gain, whereas static batching will get you closer to 90% (if both are set up properly and you follow the “as few shaders” rule).

1 Like intersection shaders using the depth buffer (that’s actually a custom shader that is both an intersection shader and a rim shader, on Free only the rim works). I may actually buy Unity 5 for personal use, depending on a couple of factors.

 
Flag Post

Topic: Game Programming / as3 what is the most efficient way to use enterframes

Nope, because you have 1 event listener rather than thousands. Sending an event has a small amount of overhead that a basic loop doesn’t have.

 
Flag Post

Topic: Game Programming / [Advice] Unity Optimization

GameObject.Destroy() isn’t that intensive. It’s the garbage collection that comes along a few frames later that will om nom CPU cycles. In the first TD I did in Unity I batched the creep destruction by turning off their scripts and throwing them under the map until the end of the level, then calling Destroy() on all of them. The lag spike for the one frame was largely unnoticed.

I don’t recall what I did with bullets.

 
Flag Post

Topic: Game Programming / [Advice] Unity Optimization

Optimization is one of those things that I’ve learned little bits and pieces of over time as it’s been needed. As there isn’t a good list of the different kinds of topics that help to make a Unity game run well on mobile devices I thought I’d start a thread with various factors. These will not be in-depth instructions on how to utilize each technique, but rather an overview of what the technique is, what it’s called, etc.

Feel free to add to this list.

  • Draw Counts
  • This is the primary cause of lag in a unity game. There are a number of contributors (below) but this number (which can be found by looking at the game view and clicking the “stats” button in the upper right) is the easiest go-to number to look at to see if a change positively or negatively impacted performance.
  • Shaders
  • Complex shaders are slow. That color doodad that lets you tweak how a texture looks requires an extra multiplication step during rendering. Additional textures require a second lookup and second multiplication. Bumpmaps take even more (texture point lookup, lighting inputs, multiplication…). While these won’t inherently cause more draw calls, they are slower than simpler shaders. If you can get away with it, use the shaders under Mobile. If you absolutely need X feature, use the default shaders. Avoid reflections!
  • Lighting
  • Bake your lightmaps! For the love of god, bake your lightmaps. You do not need every single light to be real-time rendered with high quality shadows. Every light you have causes an additional draw pass. A draw pass is essentially “take your draw counts, add that many again.” A scene with 50 draw counts, just for meshes, with 5 real-time lights will require 1600 draw counts! (This is approximate, if a point light doesn’t overlap with a given mesh, then that mesh is not included in the increased count, but even a couple of small point lights can double your draw counts).
  • Vertex Lighting. If you can get away with it, vertex lighting requires fewer lighting calculations and will result in lower draw counts. At the per-shader level, the savings will be small, if you can get away with it, set the camera to use Vertex Lighting instead of forward or deferred. You’ll lose some detail, like bump mapping, but it will cut your draw counts by 60% easily.
  • For dynamic objects, you will want to set up light probes so that as objects move through the scene they can approximate their lighting more accurately from the baked lightmaps.
  • Textures
  • Use a texture atlas / sprite sheet. If you have two shaders that are identical except for the texture used, find a way to combine those textures and use a single shader. Every mesh with a unique shader causes an additional draw count.
  • MaterialPropertyBlock. This is a better way to make run-time alterations to a shader than editing the renderer’s material. A MaterialPropertyBlock doesn’t create a new material, rather it alters the parameters just before the material goes to the renderer. Thus it can be used with Combine Children or other batching (although there are some limitations).
  • Meshes
  • Combine your meshes whenever possible. Unity can render one 100,000 vertex mesh faster than it can render four 25,000 vertex meshes, even if they have the same texture. The best way to do this is to set the mesh as static (upper right corner of the Inspector panel). There’s a dropdown that will let you specify what kind of static it is, including occlusion, navigation, and lightmapping.
  • The Combine Children utility will also work, but static batching is pretty fast already and does basically the same thing (static objects can’t be combined with CombineChildren either).
  • Occlusion
  • While Unity will automatically cull objects outside the view fructum, it will still render everything in front of it, even if its completely hidden by another object.
  • Not-rendering things that can’t be seen is good. Make all of your small meshes as “occludees” and your large ones as “occulders” (mid-size ones should be both, if they occlude a large portion of things). Don’t forget to set up occlusion volumes for places the camera can go. This is similar to Valve and the Source Engine’s Visleaf system, although done by hand.
  • Animators
  • Remove any unused animator components from your imported mesh objects. They prevent the object from being statically batched as they are rendered as if they were a dynamic moving object, even if they’re not doing anything.
  • Other
  • If you can get away with not-drawing something at certain points of the game—such as a GUI indicator that can’t readily be acted upon for a length of time—turn it off. For instance, I had a bunch of meter-bars in a Tower Defense game that pointed out certain bonuses when a tower was built there. As the player was less likely to be building towers when a wave was in progress (and with the increased draw counts that enemies caused) it was a big performance increase to turn those bars off and save on their draw counts.
  • For mobile games the ideal draw count is as close to 0 as you can manage. I’m currently getting away with ~150 for a project on an iPad 2, but under 300 should “work” although “under 30” should be your target. At 800 the lag is noticeable. At 8000 its downright unacceptable (this project started at 8800!). For desktop applications you get get away with more, my machine was capable of handling the 8800 draw counts and still maintaining 30 FPS (at 150 it gets 200-250 FPS).
 
Flag Post

Topic: Game Programming / Feedback to my new game (critics are very welcome)

Everything a3lex33 said.

There also appear to be some spikes just below where you start on the first level that serve no purpose. They’re in a corner where they can be utterly non-threatening.

 
Flag Post

Topic: Game Programming / GiTD #41 - *Congratulations Aesica*

No, its not. I haven’t had the time to do a lot of things. I meant to get around to looking at the entries and then…got busy and never got to it.

 
Flag Post

Topic: Game Programming / [AS2]Cursor question *please help!*

Not with Flash.

You have to do tricks to get it to work. And by “tricks” I mean, tell the player to put their cursor where you want it and when they do then start the game.

 
Flag Post

Topic: Game Programming / [AS3] Kong Username display

Based on the timestamps (you can hover over the “2 days ago” part and see the exact time including timezone offset) it was a little over 3 hours later.

 
Flag Post

Topic: Game Programming / GiTD #41 - *Random Generation*

I wasn’t attempting to do anything as part of the 10 day contest, but I’ll totally share a tech-build that I did up earlier this afternoon. Except for status effects (weakness, slow, etc.) everything works (‘cause I commented out the stuff that doesn’t).

http://www.pages.drexel.edu/~mmj29/temp/pgtd.html

The AI’s a little dumb, and there’s only one wave (testing purposes!) but its awesome to see things work the way they should. Also…fixed seed ‘cause I was testing something last minute and forgot to fix that. There’s still a good representative collection of functioning objects though! There’s one tower that can only point in a single direction, a tower that fires explosive shots, and a tower that can only attack-back (the three working targeting algorithms). I think one of the bullet towers has a predictive aiming and the other doesn’t, but I don’t remember if that’s the case or not (and that difference is not currently displayed in the UI).

There’s also a smart-aiming for AOE towers, but I don’t think the one blast tower uses it. It’s pretty smart though. It looks at every creep it can hit and looks to see how many other creeps would get caught in the blast, then shoots at the best result.

 
Flag Post

Topic: Game Programming / [AS3] Kong Username display

Sure…

 
Flag Post

Topic: Game Design / New to game design...

I’m not even sure I’ve hit 11 games yet…

 
Flag Post

Topic: Game Programming / Revolving Circles'

Textbox.

 
Flag Post

Topic: Game Programming / Revolving Circles'

It would be cool if we had a way to share designs with each other. I got a really weird one where it creates ever-growing loops that hit a max-size and then start shrinking again.

The reason it’s interesting is not the resulting pattern, but how it arrived there.

The lower-left one started close to the center and grew outward and is now half-way back in the “getting smaller” portion.

0: 32.3, 6.5
1: 13.1, 6.4
2: 24.1, 6.6
3: 26.8, -9.7
4: 21.5, 8.1

 
Flag Post

Topic: Game Programming / GiTD #41 - *Random Generation*

Those do sound a little like what I’m doing. But just a little!

Basically I’m doing a procedurally generated RTS, and that was one result (of hundreds?) for a tower. The creeps are going to be proc-gen as well: actively designed to try and penetrate your defenses…