Categories
Unity3D Unity3D-tips

Unity Custom Editors: dragging handles in 3D

Here’s two quick tips for people writing custom 3D editor controls (something you should be doing a lot of in Unity, because it’s very good at it, and it saves a lot of dev time and design time!)

Categories
GamesThatTeach

Games that teach: Code Combat

http://codecombat.com/campaign = Tower Defence clone where instead of just placing towers … you write basic commands in javascript to manipulate your troops around the map:

This is an early preview build, so it ONLY WORKS WITH CHROME (EDIT: (deleted off topic personal commentary) … Chrome’s native plugin stuff is great, I can see why a lot of devs use it for prototyping … but the politics around Google, and their actions to edge-out more inclusive, free, open browsers is distressing)

Screen Shot 2013-06-10 at 19.36.04

Categories
entity systems

Entity System game on Steam Greenlight: The Few (WW2 planes RTS)

http://steamcommunity.com/sharedfiles/filedetails/?id=130180383

Categories
programming

SVGKit 2013 – Recipes (part 2)

(see also the first set of SVGKit recipes)

Change the color of a SVG element like a Path or Circle after the user click on it

[objc]
CALayer* layerUserClickedOn = …

if( [layerUserClickedOn isKindOfClass:[CAShapeLayer class]] ) // should ALWAYS be true, but just in case you write your code wrong…
{
CAShapeLayer* shapeLayer = (CAShapeLayer*) layerUserClickedOn;
shapeLayer.fillColor = [UIColor redColor].CGColor;
}
[/objc]

Find the CALayer that was generated from a particular SVGElement

NB: Apple/ObjectiveC uses “id” as a keyword, so we had to rename the SVG name “id” to “identifier”.

If your SVG file is legal, and has a unique “id” attribute for every SVGElement, then you can find the CALayer directly from the SVGElement, using the “id” attribute. If your SVG file has no “id” attributes, or the SVGElement you’re searching has no “id” element, then you’ll have to do more work – or fix the SVG file (edit it, add an “id” attribute to the SVGElement that matters, save it … then use this recipe)!

[objc]
SVGKImage* svgImage = …
SVGElement* element = … // see previous SVGKit recipes
CALayer* layer = [svgImage layerWithIdentifier:element.identifier];
… // do something with it…
[/objc]

Clone part of the image, and move it around / change it

First of all, find the part of the SVG you want to clone, e.g. using “Search an SVG file for particular tags / nodes / elements” from the first set of SVGKit recipes.

That gives you an (SVGElement*). Use the previous recipe to get the CALayer. Finally, clone it and use it:

[objc]
#import "CALayer+RecursiveClone.h" // requires SVGKit version 1.1.0 or later


-(void) someMethod
{
SVGKImage* svgImage = …
SVGElement* elementToClone = … // see previous SVGKit recipes
CALayer* layerToClone = … // see recipe above

CALayer* newLayer = [layerToClone cloneRecursively];
newLayer.frame = layerToClone.bounds; // reset it to be positioned at (0,0)

// if you want the clone to start in same position as original
// add this code
if( calculatePositionOfOriginalLayer )
{
CGFloat xOffsetOriginal = 0.0f;
CGFloat yOffsetOriginal = 0.0f;
CALayer* parentLayer = layerToClone;
while( nil != (parentLayer = parentLayer.superlayer) )
{
xOffsetOriginal += parentLayer.frame.origin.x;
yOffsetOriginal += parentLayer.frame.origin.y;
}
CGPoint positionOfOriginalLayer = CGPointApplyTransform( layerToClone.position, CGAffineMakeTranslation( xOffsetOriginal, yOffsetOriginal ) );
}
}
[/objc]

Edit the polygons / lines / shapes after loading

Every “shape” is stored as some form of Apple CGPath object.

[objc]
CALayer* layerInSVG = … // use a previous recipe to get the layer from the SVG element
CAShapeLayer* shapeLayer = (CAShapeLayer*) layerInSVG; // if you chose wrong, this will error at runtime
CGPath pathToEdit = shapeLayer.path;

… // edit the path, and create a replacement path

shapeLayer.path = myEditedPath;
[/objc]

Apple doesn’t provide an API to directly edit CGPath objects. They have a C API that let’s you create a callback function that turns the CGPath into a list of draw-calls, that you can then work with. But it takes quite a bit of code to read this, and then convert it back into a CGPath that Apple can draw.

So far, no-one has open-sourced their code for this (I’ve got a private version I wrote for a previous project, but it’s thousands of lines of code). Either petition Apple to add the missing APIs, or find someone to write it for you / license it to you, or write it yourself.

Categories
entity systems games design programming

Designing Bomberman with an Entity System: Which Components?

Today I found a new article on implementing a Bomberman clone using an Entity System (in C#) – but I feel it doesn’t quite work.

It’s a well-written article, with some great illustrations. But the authors “Components” struck me as over-complicated and too behaviour-focussed. If you’re designing a game based on an ES, this isn’t a great way to do it – it feels too much towards old-style OOP gameobjects.

This is an opportunity to talk about good and bad directions in Component design. I really like the author’s idea of using Bomberman as a reference – it’s simple, it’s a well-known game, but it’s got a lot of depth. Read the original article to refresh your memory on Bomberman and how it works. Then come back here, and we’ll do a worked example on choosing components for a game. I’ll completely ignore the programming issues, and only look at the design issues.

Categories
computer games games design programming Unity3D

Creating real-time Mirrors in Unity Free (attempt 2)

OK, a completely different approach this time (based on the “new technique for Render to Texture” that I mentioned last time). And it works a lot better – lighting, shaders, etc is all there for free (but something is wrong with the side-to-side)

Categories
games industry

All you need to know about the new Xbox One, in a single picture

http://fbcdn-sphotos-g-a.akamaihd.net/hphotos-ak-frc3/970105_610268872319582_1123059051_n.png

Categories
programming Unity3D

Mirrors in Unity Free version – almost works

UPDATE: see end of post for another idea…

One of the ways they make you buy Unity Pro is gimping the non-Pro version by taking away Stencil Buffer and Render-to-Texture (needed for … many (most?) of the truly interesting effect you can think of). Except … it’s only needed by old-school OpenGL programmers, because everything RtT does can be mimicked in Shaders. Stencils … maybe also?

Anyway, I’m working on a hobby project and don’t need or want the Pro version for now (I’d like to support Unity, but these days the jump in price is way too expensive, at $X000 (they price-gouge you if you’re purchasing from within EU) for a simple hobby project). If/when we’re using it at work, and I have lots of cash, sure – but for now: can’t find that much money.

For the most part, I’m happy to go without RtT for now – generally speaking, hobby projects don’t “need” those kind of effects (and if they do: maybe it’s not a hobby any more?). There’s just one exception: reflections.

Categories
fixing your desktop server admin

WordPress: Add logo top right in Twenty-Twelve theme

I’m not sure why, but out-of-the-box, WordPress’s excellent TwentyTwelve theme prevents you from putting anything in the (empty!) top-right area of the page. It’s a great place for a “contact” link or similar (and check out the Suffusion theme to see how many widget areas a good WP theme ought to have…).

Categories
amusing education iphone programming reputation systems

Over 9,000…


profile for Adam at Stack Overflow, Q&A for professional and enthusiast programmers

I never imagined I’d reach anything even close to 10k rep. Lots of thoughts and some analysis to come on this in a future post – but I’ve got two deadlines coming up, so very rushed right now.

Categories
computer games games industry games publishing

Indie Developers do an AMA…

A bunch of indie game devs (including various friends of mine) are doing an AMA right now on Reddit. Go have a look (and ask some questions) if interested.

I found the answers this question a bit depressing though, given that the audience has increased 100-fold in the last 2 decades. Sad that indie developers still find it almost exactly as hard today as they did in the 1990’s :(.

Categories
fixing your desktop programming

App takes all the RAM on a Windows tablet; turns out to be debug code the manufacturer left in by accident

http://www.veracode.com/blog/2013/05/executable-archaeology-the-case-of-the-stupid-thing-eating-all-my-ram/ – Doh!

Everyone has had that dreaded experience: you open up the task manager on your computer… and there’s a program name you don’t recognize. It gets worse when you google the name and can’t find a concrete answer on what it is and why it’s there. It gets even worse when you remove it from Autoruns and it comes back. It gets terrible when you realize it has keylogger functionality. The icing on the cake, however, is when the mystery program is also eating up all your RAM.

The application does not store or transmit or even display the information polled. It does nothing. I spent the better part of two hours scouring the obscure corners of the binary, thinking surely I must be missing some cleverly hidden method that actually uses this data. I couldn’t find one.

that still leaves the question of why it’s doing this at all. The clues are there, vestigial remnants of removed code, exciting to any Executable Archaeologist: The generically named “Form1” of the application contains several widgets which are never actually displayed: a start button, a stop button, a place for displaying mouse coordinates, and a text box for displaying some other unspecified data. I believe this was originally a debugging utility used by “Spacer” engineers to calibrate the accelerometer so that it would not go off when one simply tapped on the touchscreen (triggering a mouse event or keyboard event). They didn’t bother to rigorously prevent memory leaks because it was never intended to run for more than a few minutes at a time. Somehow, through some miscommunication, a copy of this program with the logic for rendering the visuals stripped ended up on the list of utilities that needed to be kept in the final version of “Spacer’s” Windows 8 image for this model of tablet.

Categories
Google? Doh!

Why programmers (engineers) don’t want to work for Google any more…

Kev wrote a short Tumblr on why he no longer wants to work at Google.

I am fairly sure this is a wider, expanding trend: great programmers have lost interest/faith in Google as an employer. I’ve tried (ineffectually) to explain this to some of my Googler friends – but I’ve tended to cite too much info, and I think Kev pinpoints it quite nicely:

“Google’s foundation is it’s image. … For years we’ve all loved them. Even if sometimes their products fail and don’t provide the experience we want we’re all thinking it’s Google, their nice, they do things for free…The long and the short of it is Google has done very off the good feeling they’ve generated in the user community at large. The vision of the philanthropic behemoth doing things for the people. Not acting like a huge faceless corporation and doing things “the right way”.

Looking at it now though … Google are starting down that slippery path to the dark side. Reader is the obvious case but if you look a bit deeper you’ll see a general tend towards money first – people second culture.

So, why would I want to work for Google now? I could choose any big company with a big chunk of cash and a whole bunch of crazy ideas. There’s plenty of them around and Google is heading rapidly toward being “just another”. It’s Google right? Wrong.”

Google went from being the forefront of modern, healthy, human-centric company culture … to a mid-tier, second-rate excuse for bad practices and “it sucks but we can’t change it” culture. Like Kev, I noticed this (and you’ll see my Google-related blog posts over the years see-sawing between praise and hatred, like a manic depressive). But for the most part I convinced myself it was probably the teething-pains of corporate growth; mis-reported; sensationalized.

That was until I had first-hand experience of Google Europe’s disastrous hiring process. I went through a recruiter who repeatedly forgot to turn up, staff with no relevance to the role (and who declared their hatred of it), 1950’s mock-psychological interview questions, and a wilful avoidance of Employment/Privacy Law (I hit them with a DPA when I caught their HR lying to me).

… well, after all that … if you got the job, and accepted … what kind of team-members do you think you’d end up with? Is this a process that attracts great people – or turns them off?

That’s the critical point: when joining a company you expect to work for more than just a half year or so, the interview is as much a chance for you to feel that they’re recruiting people you like, people you respect – your current and future team-mates.

I know Kev (author of the post linked above) – and he’s not the kind of person to turn Sour Grapes on a failed interview. He’s a great programmer, skilled, innovative, and pragmatic. Very much the kind of engineer I’d want to work with – but also the kind I’d expect to smile and politely decline when confronted with the Google hiring process.

Which is what decided me against them for good. Although it’s a wonderful environment, and in many ways I’d love to work there … life’s too short to go without: colleagues you respect, and a culture you love.

Categories
security web 2.0

Yahoo’s “unusual activity” detector…

I rather like this. I guess it could feel like an invasion of privacy – but the truth is: all web companies have been tracking you like this since the late 1990’s. Until now … they used the data, but never shared it with the you, the user. This is so much better:

Screen Shot 2013-05-06 at 10.56.42

Categories
games design

Skyrim level-design: transcript (+ notes) from GDC 2013 talk

A well-written text+images version of their GDC 2013 talk.

TL;DR: A couple of things that jumped out at me:

  • The total dev team for Skyrim (TES 5) is 90 people (less than normal for this size game)
    • Oblivion (TES 4) had a mere 45 staff!
  • They strategically embrace modular levels as the way to produce enough content in time
    • Added together: explains the recurring Art problem in Elder Scrolls games, where after an hour or so everywhere starts to look very similar
    • …NB: while I resent that (and I know many people who won’t play the games, they hate it so much), the tradeoff is IMHO worth it: broad story-content in a huge world. So it’s a big loss, but a compromise I’ve always been willing to accept as a player
    • …in the article, they call this “art fatigue”
  • Allegedly only in Skyrim (but … I’m sure I saw this in Oblivion too), they put arbitrary-rotated wall segments inside rooms to break the sense of “rectangular” walls everywhere. They called this “Shell Based” building
  • “It’s common at the start of a project to strongly associate a particular setting with specific types of inhabitants or gameplay. You may want to only see soldiers in military bases, and zombies in crypts, for example. Resist this.”
    • …IMHO: obvious (it’s basic art-composition theory), but worth pointing out to anyone non-art background looking at game and level design
  • There was some pushback in the team against mix/matching modules from different kits: “The notion of [an artist’s] art being used in unforeseen ways could lead to bad intersections or lighting issues, for example.”
    • …Stupid of me, I’d never thought about how the team artists would react to this kind of mix/match (the only games I’ve worked on with modular art kits … were 2-3 person indie projects, so the atmosphere was very different)
    • …This also explains a *lot* of the geometry bugs in TES games (where you get stuck in angles of the wall, temporarily, or items drop in places you are blocked from reaching for no apparent reason): the combination of assets wasn’t designed-for / tested-for, so there were bajillions too many combinations to test!
    • “when you’re trying to identify somebody with the the aptitude and interest to be a great kit artist, you’re basically looking for a unicorn. They’re rare.”

    Art Fatigue

    The author initially cites this with respect to:

    “the same rock or farmhouse or tapestry used again and again. And another two dozen times after.”

    …IME, that’s not the problem at all. The problem is that every internal environment appears to have bought their walls, floor, and ceilings from the same branch of Viking Ikea ™. As demonstrated in the screenshot of “blatantly modular pipes” in the article:

    …and when talking about Oblivion, it sounds like my experience was reflected in their testing with large groups of players too:

    you’re more likely to pick up on repeated clutter first, then the repeated architecture. This is especially true in actual gameplay from a first-person perspective. To minimize needless repetition, we abolished the use of warehouse cells as they existed in Oblivion.

    To be honest, I’ve long been surprised that Bethesda stuck with “square-based grids” for so long (other games were using non-square grids decades ago). As one of the commenters points out:

    Square meshes and ‘cubic’ tile-blocks on naturalistic indoor environments (eg natural caves) can be a challenge – how about equilateral triangular meshes, or for 3d space rhombic-dodecahedrons? – Xu En

    Common AAA art/design/level-design problem: handoff

    This is rarely written about but the kind of thing that Leads, Producers, EPs and Project managers spend ages dealing with:

    “They’ll do an art pass and make the level visually appealing Once they’re at a place they’re happy with, they send it back to design for final markup and scripting. Once design has done that, the level should theoretically be done – right?

    Not usually. Level designers often inherit a litany of unforeseen problems when receiving final art for their levels. Cover along a street has been converted into poles too thin to take cover behind. A wall intended as a visual blocker is now a see-though chain-link fence. A bridge now has support beams which occlude sight lines in a major gunfight you had planned.”

    (my emphasis)

    Common level-design problem: reference sizes

    Obviously, you need to know how “tall” your characters are. But how do you translate that into a practical measurement when working on a scene?

    “One thing we’ve found very useful is to determine a uniform dimension for door frames. This has a few benefits. It allows us to transition from kit to kit without unique pieces, as well as allowing easy re-use of doors between kits. More importantly, it gives AI and animation a fixed standard to work from, which can be reinforced throughout the game.”

    A little bit of the Agile/Scrum mindset

    Some of their approach is inherently Scrum:

    “we get our kits to a “functional-but-ugly” state as soon as possible”

    “The level designer should be constantly stress testing throughout these stages. The artist should deliver pieces as soon as they are even rudimentarily functional, and the level designer should use them in non-ideal conditions. ”

    They don’t go into detail, but imply that this has caused a lot of friction in the past with individual developers who found it emotionally difficult to work in this way. I would have liked some more info on that – dealing with this kind of “mindset” issue on game teams is a major challenge.

Categories
computer games entity systems

Game on Kickstarter using an Entity System

“Magnetic by Nature” is using the C# version of Artemis, an Entity System based in part on my original ES posts.

Go back it now (they only want $10k total!) …

Categories
bitching

Southern Rail redefines Customer Service

For a 45 minute train that they planned to run 1.5 hours late, they told everyone it was:

“On Time”

…until 60 seconds after leaving the station.

The train was sat there for 15 minutes beforehand, with no announcement. Instead, they waited for the earliest moment when no-one could leave or seek alternative routes.

Now, that’s what I call Customer Service ;)

Categories
iphone programming

Parse.com install is broken; silently requires Facebook SDK

…and the last working version of Parse.com’s SDK isn’t listed on their website any more.

So … if you see this (which you probably will, on any non-trivial project):

Undefined symbols for architecture i386:
“_FBTokenInformationExpirationDateKey”, referenced from:

…then you MUST download and install the Facebook API into your iOS / Xcode project. Especially if you’re not actually using Facebook!

Why?

Parse.com for iOS is currently setup so that you CANNOT use ANY LIBRARIES AT ALL, unless you ALSO use the Facebook library. Oops.

A little bit of naive linking by the Parse.com engineers. C-linking is a PITA to get right, so I don’t blame them.

More problems

1. Facebook won’t let you download their API / library any more.

Instead you have to “install an application” on your system that spews to random places on your machine (where? Well … the app won’t tell you, but on the Facebook website they say it all goes in ~/Documents) – and you’re not allowed to change them.

Wrong place, wrong installer (shouldn’t be hard-coded, shouldn’t “hide” the location). And a pain to deal with, when all that was needed or wanted was a simple ZIP file…

2. Facebook’s latest SDK requires iOS 6 to even compile it – even if you’re not using iOS 6. No-one should be hard-coding to iOS 6, though – so I’m surprised that FB is targetting it as default. iOS 5 is the main target version of iOS for now.

3. Once you find a 6 SDK, you have to add a bunch of extra frameworks which don’t exist except on iOS 6, and set them to “Optional” in the “Project Settings > Build Phases > Link with Libraries” phase.

Details are on the FB iOS Getting Started page, although they’re pretty hard to find (they’re hidden inside a drop-down with an unrelated title).

(incidentally: the FB iOS install page has always been way too long, so I suspect someone decided to “tidy it up” by hiding 95% of it. I think a better solution would have been to remove all the cruft, and fix the install process :))

…anyway, once you get past all that, things go smoothly. NB: when I wrote this, I was on a hack-day at Facebook’s offices, and it took 30 minutes to get Parse’s API installed, because of the above problems. It would have been even longer if I’d not used Facebook in the past, and knew how to navigate their install page.

Categories
games design GamesThatTeach programming

SVGs, silhouettes, and … dinosaurs

With my recent fixes to “auto-scaling” in SVGKit, I can now take in images, apply various effects, and lay them out in a grid:

Screen Shot 2013-04-14 at 16.04.11

  • Top row: input SVGs of arbitrary size, auto-scaled to fit
  • Middle row: applying a 2 lines of code filter to remove the colours
  • Bottom row: applying a 2 lines of code filter to convert to a solid silhouette

…next step: get this stickers-game working…

Categories
programming

SVGKit: scaling SVG images

This is very easy, but lots of people find this difficult with good reason!

Here’s a quick guide to how image-scaling is implemented with SVGKit, so you can effortlessly scale your images.