Bacon and Games

Year: 2011 (page 1 of 2)

Find All Strings Within a String with AS3

I’m working on a training simulator that allows people to virtually highlight text (like in iBooks) in a textField. I’ll probably post the code for the highlighting portion when the project is done.

For now, I thought I’d post this simple AS3 utility function I wrote, which allows you to find all instances of string inside another string. It accepts two arguments:

  • searchFor:String – string you wish to search FOR
  • searchIn:String – string you wish to search IN
  • caseSensitive:Boolean=true – (optional) determines whether comparisons are case sensitive

It will return an array containing the indices at which searchFor is found in searchIn. You can check the length of the array returned to get the number of times the search string appears in the search text. If the length is 0, searchFor does not appear in searchIn.

package com.baconandgames.utils{
public class Strings{
// returns an array of indexes for each occurance of searchFor in searchString
// var s:String = "Haw many cats are in this sentence about cats?";
// Strings.findAllStringsInString("cats",s); // returns [9,41];
public static function findAllStringsInString(searchFor:String,searchIn:String,caseSensitive:Boolean=true):Array{   
    searchFor = searchFor.toLocaleLowerCase();        
    searchIn = searchIn.toLocaleLowerCase();   
  var a:Array = new Array();       
  var i:int = -1;     
  while ((i = searchIn.indexOf(searchFor, i+1)) != -1) a.push(i);      
  return a;

*simplified with suggestions by my good buddy and web-ninja Rob Colburn

From something like 2007-2011 I was with a company called Brandissimo. Through them I worked on probably 100 different games, sometimes as a programmer, designer, producer and even a few times as an artist. My biggest focus was on web games for the NFL, though we also worked with a wide range of clients including Power Rangers, Urbaniacs and even Always… yes, that Always. Don’t ask.

While this video only includes a tiny slice of what we created in that time it does highlight some of my favorites.

The games in this video feature art by the talented likes of Ajay Karat, Mark Aguilar, Rich Cando, Jimmy Cross and Randy Hutchins. All wildly talented, good friends of mine :)

How Stephen King Can Make You a Better Game Designer

In Stephen King’s book, On Writing, he talks about “situational writing”. Sometimes, rather than writing towards a specific end, he’ll create a scenario and write around it.

You wake up to find yourself in an unfamiliar room. A man is unconscious on the floor and he’s bleeding, but you can’t see his face. The door is locked from the inside but you don’t remember how you got there. In your pocket you find a few bus tokens, a note in a foreign language and a cell phone… no batteries.

This scene raises a lot of questions for and about the man who woke up:

  • How did he get here?
  • Who is the man on the floor and does our character know him?
  • Who locked the door and why?
  • Did he take the bus there or was he on his way to the bus? Does this character normally ride the bus or is that outside his normal routine? If so, why did he end up taking the bus?
  • What country are they in and is it a familiar one?
  • How do they get out of the room?
  • What good is a cell phone with no batteries…?
  • Is the other man alive? Friend or foe? How did he get hurt?

The questions could go on forever. But as you start to answer them, you build backstory, you move the story forward and you ask yourself (as the writer) questions about the characters that will start to give them personality. From there a story is born.

Whether you’re trying to come up with a concept, the same technique can be used in game design. Let’s try a quick one:

It’s a post-apocalyptic world. Some devastating event has massacred not only the plant and animal life on the planet, but it’s disrupted the very planet itself. Everything is in chaos: Constant earthquakes, lava and steam vents spew randomly from the surface of the planet. The planet is experiencing violent and dramatic weather changes… climates that would normally be thousands of miles apart are now tangled up against one another. From the shadows you hear awful shrieking, groaning and hellish cries from sources unknown.

Now, certainly this paints a vivid picture that will drive the story. Who is the character and why did HE survive? How many others survived? Is he searching for someone? What is making those awful noises? Is this planet Earth or another planet all together? What year is it? And so on…

These are all great questions that will get you well on your way to an interesting game with a rich story. But you can also use situational writing to come up with a type of game and your mechanics, both of which will drive what makes your game fun, unique and challenging. Some questions I’d ask myself about this world…

  • How does the hero react to the different climates? Can he stand extreme heat and cold?
  • Does he need special suits to withstand extreme temperaturs? Is there a puzzle element here, like The Lost Vikings?
  • Strong steel and concrete structures would probably have survived. Maybe the character is making his way across the ruins of a city, the remains of which are mostly the twisted skeletal structures of skyscrapers and subway tunnels.
  • How does he move across this landscape? Does he slide down twisted beams? How does he react to heights? Maybe his movement slows or gets wobbly the higher he gets. Can he wall jump?
  • I bet our hero would have his dog with him. How can a dog fit into this game? Is he protection, like a shield who takes hits for us? Can we play as the dog? Does the dog sniff out food or other hidden items? If so, he’s a privilege, something that makes the game easier. So what in our game can take the dog away and how do we prevent it? How do we get him back when we lose him?
  • If this isn’t Earth, what’s the gravity like? Is it weak like the moon? What kinds of challenges and benefits are there to moon gravity? What about heavy gravity?
  • Maybe now the planet has screwy magnetism and the hero has crafted metal boots to take advantage of that. What kinds of challenges can be born out of this concept?
  • What about shifting gravity? How about strong winds or shifting landscapes? Is there a trigger that warns us of upcoming shifts or do these things just happen at will? Can I find or make something later in the game that gives us this warning? Maybe it’s the dog… if we still have him.
  • What about all of this makes the character fun to play?
  • What about all of this will make him difficult to master?

The questions can go on and on. But you can see how very quickly you’ll find a place to start. Once you start fleshing this stuff out, you’ll begin to identify the hero’s strengths and weaknesses. You’ll define the types of challenges he’ll face, the enemies he (or she) will encounter and how they behave, react and use this landscape to their advantage. Just a few sentences can pose a ton of questions, probably more than you can answer. But situational writing is a great way to get started building the world your hero will live in and the rules, advantages and challenges that will make playing as him (or her) fun.

By the way, if somebody wants to make this game… go for it. If not, maybe I will ;)

UPDATE: I received some good feedback on this article and it appears that I wasn’t clear on how story and mechanics interrelate. Typically, they do not or at least they do not have to. If you changed the characters and objects in Super Mario Bros. the mechanics of the game probably wouldn’t change . The story doesn’t dictate how he jumps, how fast he runs and certainly not why Flower + Person = Fire. The intention of this article was to suggest one way you can get yourself started if you’re staring at a blank page. If you’ve got nothing, thins kind of thinking can shake ideas loose. You can reverse engineer a story into a game, then work forward as if you had started from the mechanics you stumbled on through situational writing. Thanks for the feedback!

Bfxr Builds on Sfxr, Adds Mixer and More

Back in February I wrote about as3sfxr-b, a free sound effect generator written in AS3. Increpare, the editor’s author, has recently updated to a version dubbed Bfxr, which extends the already fantastic AS3-based sfx generator.

Bfxr Screenshot Mixer

The biggest addition in this version is the inclusion of a mixer. That’s right, you can now create sfx with this editor and then mix several tracks together to create a much more complex, layered sfx. You don’t even have to leave the browser. All these years I’ve been using audio editing tools like a sucker. OK, ok… you can’t completely abandon your audio tools, but it is an extremely handy feature.

He’s also added some additional waveforms, filters and some other fun features. But your head is still spinning from the news about the mixer, I know. So I’ll give you a moment.


Go check out Bfxr now.

Original GTA Game Doc

GTA Header Image

The original game design document for GTA 1 surfaced on Reddit recently. It’s a quick read and totally worth it if you’re into game design. A few noteworthy nuggets:

  • The working title was Race ‘n’ Chase. > Good move going with GTA instead, Rockstar.
  • They reference other games in their doc, including Sim City and Doom. > A game made by gamers. It’s neat to get a glimpse at some of their influences.
  • There’s a decent mix of design and technical notes in here. It’s all very high level, but interesting to see the technical challenges and solutions they addressed even this early on.
  • The only pedestrians listed in this doc are “Schoolchildren, lollipop ladies and dogs.” – This list is immediately preceded by “[Pedestrians] can be run over cars”. Rockstar knew exactly where they were going with this franchise from the very beginning ;)

The article on Reddit offered up a 10mb download of 12 jpeg pages. I stitched them together into smaller, single pdf for your convenience. It’s an interesting read. You can download the original GTA game doc here.

GTA and other old games of theirs are available for free download on Rockstar’s website. And for more info on the original game, they have a deliciously 90’s GTA website still up for browsing.

Many thanks to Ajay Karat of The Devil’s Garage for the article tip.


Copyright © 2017 Bacon and Games

Theme by Anders NorenUp ↑