Wednesday, January 20, 2010

Volumetric lines 2

I promised I was going to do a follow up on the Volumetric Lines episode, so here it is.

Like I said, it was very easy to change from regular lines, to using volumetric lines in PewPew. In fact, I already changed once the way lines are drawn: the early versions of PewPew used SDL without OpenGL, so the lines were drawn in software using the good old Bresenham. Switching to OpenGL forced me to reduce the coupling between the renderer, and the game engine. Here is all I had to do to make the switch to volumetric lines, besides the initialization:

#ifdef USE_VOLUMETRIC_LINES
for (int index=0; index < numberOfVertex; index+=6)
VolumeLineRenderer::getInstance().renderLine(
&vertexes[index],&vertexes[index+3]);
#else
glVertexPointer(3, VERTEX_TYPE, 0, vertexes);
glDrawArrays(GL_LINES, 0, numberOfVertex);
#endif



Here are some new screenshots comparing the regular render to Sebastien Hillaire's one with different line width.







Now this is running on a PC, not on an iPhone. I previously said that I could maybe port this glowing effect to a real iPhone/iPod Touch, but it requires programmable shaders, which are only available on the iPod Touch 3G and the iPhone 3GS. I only have an iPod Touch 2G, so I wouldn't be able to test it.

Anyway, if you do not like the glowing effect do not worry, because if I do manage to get this effect to work on a real device at a decent frame rate, I would put an option to keep the classic look :-)

Friday, January 8, 2010

Automatic .caf file creation

As I said in the previous post, I am currently working on adding sound effects to PewPew 2. The preferred format for sound effects with OpenAL on the iPhone is the .caf (Core Audio Format), but audio softwares usually output .wav files.
Fortunately, there's an easy way to convert one format to the other, using a built in command in OS X:
afconvert -f caff -d LEI16@44100 -c 1 in.wav out.caf

Being a programmer, I am lazy, so I started thinking about automatizing the conversion for all my .wav files using a small python script that would look like that:
for every file in the directory:
exec "afconvert -f caff -d LEI16@44100 -c 1 file.wav file.caf"

But it was not going to be efficient: every time I would want to regenerate a single .caf file, the script would regenerate all of them.

And then it hit me: makefiles are made to solve this exact problem. I tested my idea with a small makefile that looked like:
test.caf: test.wav
afconvert -f caff -d LEI16@44100 -c 1 test.wav test.caf
and it worked as expected :-)

I am sure lots of other people thought about using make for stuff other than compilation, but I am still satisfied of having found this on my own.

While I was at it, I did a small python script to generate the makefile. Everytime I create a new wav file, I simply have to run the makefile generator.

Now what's pretty cool is that you can make the makefile run automatically in xCode every time you compile your project. Even cooler is that by executing the makefile with make -j 2 (or make -j 8 for some lucky bastards), you get to exploit all the cores of your CPU for the conversion. Indeed, man make explains that the -j switch "Specifies the number of jobs (commands) to run simultaneously".

Try doing this in Windows. For me, it's clear that OS X and Linux are the best OS for programmers!

Thursday, January 7, 2010

Happy new year

First of all, happy new year. For some, 2009 was the year of the Ox and 2010 will be the year of the Tiger. For me, 2009 was the year of PewPew, and 2010 will be the year of PewPew 2!

In 2009, most of my time was spent on creating the engine and getting to know the iPhone. Now that the engine is done, I am almost exclusively working on the content: I am creating tons of new ennemies and even more levels.
I say "almost exclusively", because I actually did improve the engine. I did an important (though obvious) optimisation regarding the collision system (Chromatic Conflict is smoother now because of that), I made explosions luminous, and I am in the process of adding sound effects.

The light added to the explosions is just an expanding texture (not even billboarded) whose transparency increases until it becomes totally transparent. It's simple, but it looks real good, I can't wait to post a video.

The sound effects are handled with OpenAL. OpenAL enables you to specify the relative position of the sounds, though I don't know yet whether I will use this feature or not. Basically, this feature allows you to changes the volume of a sound effect, depending on the player's position. For instance, the nearer an explosion happens to the player, the higher the volume of the explosion will be. What's even more interesting is that the volume of an explosion happening to the left of the player would be higher in the left earbud than in the right earbud. You can create other effects, such as the doppler effect, but that would be overkill for PewPew ;-)

Friday, December 11, 2009

PewPew 2

Here's a news that will make a lot of people happy: PewPew 2 is in development!
It will feature (among other things) new game modes unlock-able by completing some levels (there's a campaign mode), additional sound tracks, and medals and ships to earn.

The release date of PewPew 2 is "When it's done", but I hope to finish it before March 2010.
Programming the levels in the campaign mode is one of the task that is taking me the most time. I want all the levels to have a distinct look as well as a different gameplay. Right now, creating one level takes approximately one week (20% of the time is spent creating the level, 80% is spent polishing it)...

Of course, if you have any ideas or suggestions for PewPew 2, feel free to send me an email (jfgeyelin@gmail.com) or post a comment.

Monday, October 26, 2009

PewPew 1.2 is out!

And the scores are pouring in... can you guess when did Apple publish the update?
So far, I've used 0.6% of the maximum CPU load (and 0% of the bandwidth), so I should be OK!

Sunday, October 25, 2009

URL time

PewPew 1.2 should be accepted anytime now, so the scores are going to start to pour in... luckily I have just completed PewPew's website:

The most important features are the score board and the forum. I made the score board myself in python, and found the code for the forum here. The forum is pretty cool, because it allows you to post with your Google account, or without login at all.

Everything is hosted on the Google App Engine, so if the traffic stays under a limit, I will never have to pay for the servers, and the website will stay up and running for ever.
According to my estimations, I can handle 100 000 score submissions per day without paying for additional bandwidth. Since "only" 50 000 people have installed PewPew, I should be fine.
I have no idea what to expect regarding the CPU utilization, but I have cached a lot of database calls, so I should be OK.
At worse, I might have to pay 1 or 2$ per day during the first week; after the first week, the traffic should decrease significantly.

Thursday, October 8, 2009

PewPew v1.2

I uploaded the 1.2 update to PewPew yesterday. I have been working on it for several weeks, so there's a lot of changes!

First of all, there is a new game mode! I was not planning on adding one right away, but the survey made me change my mind. I won't spoil the surprise about how it's played, but I guarantee it is without a doubt the best mode yet.
Not shown here: insane amount of enemies.

Secondly, there is now an online high score board! In a couple of days, I will post about a small website with all the scores.


Thirdly, all the old game modes have been tweaked: I added a bonus to reward speed in "Dodge This", and there is a new type of enemy in "Assault".

Of course, there are some small new optimizations that should improve the frame rate a bit on the old iPhones and iPods Touch.

Here's the complete list of what is new:
  • new game mode, called "megagore"
  • online scores
  • the possibility to move the camera freely when watching a replay
  • the possibility to flip the screen (useful for iPhone owners)
  • the possibility to disable the text notifications during the game
  • a tougher enemy in "Assault", forcing the player to move
  • an efficiency bonus in "Dodge This"
  • colors in the nick names
  • lots of small optimizations
  • one less spelling mistake (thanks for pointing it out in the comments Anonymous)

Announcing PewPew and PewPew 2 Remasters

PP (PewPew) and PP2 (PewPew 2) haven't been compatible with modern devices for a couple of years now as I focused on PPL (PewPew Live), ...