Monthly Archives: June 2013

Coding Trick of the Day: Removing event listeners on naked functions

This is mainly an ActionScript coding trick. I think it works in JavaScript but I’m not sure.

Many time, you want an event listener that only gets called once, or being able to stop the listener after a particular condition. For instance, you need the ENTER_FRAME event on a bullet until it reaches its destination or goes offscreen. When that happens, you need to remove the event listener. However, if you’re lazy like me, you will not define your listener like this:

addEventListener(Event.ENTER_FRAME, functionName);

but like this:

addEventListener(Event.ENTER_FRAME, function(e:Event):void { .... } );

That’s called using a naked function. It’s just convenient and easier to do than defining a whole new function somewhere for that. Also, if your function is small and not really important, it improves readability.

The problems comes when you have to remove the listener, because you don’t have any function name to do this:

removeEventListener(Event.ENTER_FRAME, functionName);

Fortunately, there’s a trick to remove the event listener within the function itself. It goes like this:

     function(e:Event):void {
          if(condition) {

This will make the event listener remove itself.


Motivation for making game

My plan for this blog was to have posts about making games. So you might ask…

Where on earth are the posts about making games!?!

Ok, I guess I should realize keeping up a blog is not that easy. I always have this game making tutorial in mind I’m planning, but that’s actual work. I shouldn’t really feel work when I write this blog. After all, I do this partly to feel relaxed.

Ok, but where comes the part about making game?

Well, I’ll tell you what. I’m just gonna blable about motivation for making game. That’s gonna fill up one post, and it’s not as energy consuming as writing up a tutorial.

So some of you might want to create a game, but it’s either too hard to do, too time consuming, or the simplest and purest excuse: I have no idea how to do that.

Well, that’s kinda the thing. There aren’t many schools that actually teach how to make a game. A lot of things in life won’t be learned by sitting in a classroom (things like learning how to cook, how to dance, or how to play video games). Making a game is one of them. I could tell you all the blabble that it’s all about passion, etc… but I don’t think it would help. It’s true though that it’s all about passion, and that’s the reason you’ll have to self-learn.

Self-learning might come from books, online tutorial, but primarily it needs to come yourself… ok that didn’t make any sense. By that, I mean that you have to be curious about some aspect in making games. There are little small things that make up a game. When I made my first game, I didn’t think about a whole “Super Mario”, a whole “Zelda” or “Street Fighter”. I simply thought about making a circle go up when I press “UP”, go left when I press “LEFT”… Then I got curious about making something disappear when the circle overlaps another circle… eventually, all the small interactions where building blocks that allowed me to produce my first game (World of Turtle, all in ASCII characters).

Basically you have to start small. Even if you have no coding experience, there are some simple basic interactions that you can implement with minimal learning. How about an adventure game, where you click on links to decide what actions to do. This can be done simply with a webpage editor!

To produce a game, you can have your dream set on the big thing, but you should have actual goals set on small achievable tasks. Once you become proficient at making a circle move around, you can move on to think about gravity, collisions, keeping score… things like that.

By planning small achievable goals, you turn your attitude to “active”, rather than passively waiting for things to get done. Of course you can’t develop the next Starcraft without a whole team of artists and engineers. There are so many elements: animation, UI, path finding, networking… but you can definitely make a circle move with your arrow keys, and with some imagination, you can turn that into a game.

Even if what you make doesn’t turn into a successful game, it is still worth the time, because you learn from it. Eventually, you’re accumulating skills and experience about making games, which can lead you to work on projects involving more people. On top of that, you’ll know what it takes to make a game, you’ll be able to learn independently, and you’ll have the confidence to make a game knowing it’s not all witchcraft.

The road to making a game might be long and difficult, but it is clear and visible. Don’t just believe that you can do it, but know that you can do it… and do it!

Coding Trick of the Day: The Comment Swapper

On many occasion when I am programming, I want to test out a piece of code, then try another one, and go back and forth between the two. Sometimes, it’s to compare performance, other times I just want to compare the behaviors (It happens very often when testing animation).

It can be tedious to constantly comment/uncomment code. But thanks to the “Comment Swapper”, I can do this in one keystroke!

1   //*******
2   object.foobar1();
3   /*/
4   object.foobar2();
5   //*/

Try it out: by deleting/adding the slash (/) character at the beginning of line 1, you can instantly swap between the two chunks of code.


What do I need first to produce a game?

Jack: So, you want to create a game?

GameDev Wannabe: Yes, I do! But how?

Jack: Well, you came to the right place. This blog is about game development?

GameDev Wannabe: Really? I didn’t find any posts about game development.

Jack: This is the first one.

GameDev Wannabe: ah.

Jack: Do you know, what you need first to produce a game?

GameDev Wannabe: Flash Pro?

Jack: No.

GameDev Wannabe: Coding experience? Motivation? A brain?

Jack: What you need first is an audience.

GameDev Wannabe: Plait-il?

Jack: When you create a game, you have to keep in mind that the goal is to share it with an audience. It is the same if you want to produce movies, art, music…

GameDev: Where can I find an audience?

Jack: The audience can be your friends, your peers, anyone around you.

GameDev: What if I have no friends?

Jack: Your audience can also be people online. There are several games portal with people who enjoy trying new games. Your audience can also be in the future. People will eventually find your game and play it. 

GameDev: So I don’t really NEED an audience to start making a game.

Jack: The point is not to look for the audience, but keep it in mind as you create a new game. You don’t create for yourself, but in order to share for others. If you simply create a game for the sake of creating, it will be difficult to finish it because you don’t have incentive to do it. You won’t have someone waiting to play it, and you won’t have any real rewards at the end. I think before starting a project, it’s good to think about the people who will experience your game.

GameDev: How do I do that?

Jack: A good place to look are game portals like Newgrounds or Kongregate. You should have a plan of putting your games there and get an audience. There are also game competitions like Ludum Dare in which your game will be tried and voted on by other competitors. Find a portal with a community you feel comfortable with, where you feel you will get a response.

GameDev: Got it.

Saint Seiya Fan Game

ImageFor a while, I’ve been wanting to produce a game about Saint Seiya. I’m a big fan since I was young, and recently I’ve been watching the old episodes again. I thought eventually, when I get some free time in the future, I’d start working on it. Here’s the thing about “eventually”, “when I get free time”, or “in the future”. It never comes. Somehow, when God sees you slacking, he finds a way to give you a push. So Today, I just found out about another one of those game competitions: Zodiac Attack 2013

The idea is to create a game about the Zodiac sign. Well, that sounds like the perfect opportunity and incentive to start producing my Saint Seiya fan game! Unfortunately, the competition started in April, and it expired… this monday at 9am. Basically, there was about half a day left to submit a game… that means… I STILL had half a day to create my Saint Seiya game and submit it! ;-D

So that’s what I did. I rushed the production with doodle graphics, crappy UI and spaghetti programming, and delivered the first level of Knights of the Zodiac (the english translation of the french title “Les Chevaliers du Zodiaque”, which is Saint Seiya). The only thing not produced today was the music, which I composed in high school. Not sure if that abides to the rules of the compos, but it’s ok, I don’t expect to win anything. I’m just glad I finally started this project before “eventually getting some free time”.

Link to the game.

Ce sont tes yeux noirs

There exists those bands, those songs, that hit you right in the heart.

Those songs, you can hear repeatedly over and over, yet it’s never enough.

Before those songs, you did not really understand words like fans, idols.

Before that, you did not believe that music could bring out a tear in the corner in your eye.

There’s this song you find so beautiful, that you can’t even conceive another person listening to this song without loving it

However irrational that sounds.

After all, words in this song don’t make much sense, even for a French.

Translated, it might go like this: “Where do you go, when you go in the street towards nowhere…”

Who on Earth would fall for something like that?

Me. I fell for it

And I can’t conceive someone not falling for it.

I already know, I’ll never be a fan of any band other than Indochine

And I’ll never love any song more than Tes Yeux Noirs.

Indochine - Tes Yeux Noirs (Acoustic)

Indochine – Tes Yeux Noirs (Acoustic)

Julie - Tes Yeux Noirs
Julie – Tes Yeux Noirs

I have decided to write a blog. Reading the blog, you might know Jack Le Hamster a little better, even though you might never know who he really is. This first post is about my favorite song Tes Yeux Noirs, from my favorite band of all time, Indochine. It sets the tone for my blog: yeah, it’s all about me and what I like. Why putting this paragraph at the end? Well, it’s just blah blah blah. I couldn’t possibly begin my first post like that, right? So as you can tell, I’m a big fan of Indochine.

When I first heard the band, I was torn between finding it absolutely amazing, and borderline unbearable to listen to. Really, I think at that age, it was shameful to tell my peers I loved Indochine because it was considered by a lot of people to be so bad. Out of curiosity, I kept digging further into their albums. When I first heard Tes Yeux Noirs, time just stopped. Suddenly, I didn’t want to get out of my bedroom. I just wanted to sit there and listen to more Indochine songs. That’s how it all started.