Categories
General Linux Game Development

Better Flash Support for Mozilla, GNU/Linux?

I never thought I would be posting anything from Happy News, but then I saw the article entitled Adobe Gives Mozilla Some Computer Code. Basically, Adobe shared some code with the Mozilla Project related to ActionScript, which is what the Flash player uses.

Mozilla created a new project called Tamarin to “implement a high-performance, open source implementation of the ECMAScript 4th edition (ES4) language specification.” The FAQ answers the question of what exactly is being contributed:

The Tamarin release will include the following components:

* Source code from the ActionScript Virtual Machine (AVM2) as currently shipping in Adobe Flash Player 9, including the Just In Time (JIT) runtime compiler and conservative garbage collector.
* A partial implementation of a prototype compiler written in ActionScript, which will be developed by the open source community to implement all of the ECMAScript 4th edition specification. This will be a “self-hosted” compiler that is written in the language it compiles.

I’m surprised more open source news sites haven’t mentioned this news. Maybe I am jumping the gun a bit here, but if the source is being made available, doesn’t it stand to reason that open source implementations of Flash Player will be much better on Gnu/Linux? If so, it means that web-based games will have more reliably available players. To indie game developers, it translates into more potential customers. To us Gnu/Linux users, it means we’ll finally be able to view Flash movies or play Flash games without missing text or wondering if it froze.

That is not to say that Flash Player itself has been open sourced, as Frank Hecker clarifies. Still, if the basic scripting language is going to get better, then Flash might, too.

Categories
Game Development Linux Game Development Personal Development

Thousander Club Update: November 6th

For this week’s Thousander Club update:

Game Hours: 216 / 1000
Game Ideas: 445 / 1000

Target: 861

I spent this past week researching autotools in order that I might use them in my projects. Basically, if I can use autotools in my game projects, I will have less of a problem when porting to various Unix-like systems, including different Gnu/Linux distros. In fact, if I do use autotools, I can use CheckInstall to create various distro packages, such as RPM or .deb files. Of course, there is still the problem of porting to Windows, but it seems that my code is quite portable, and there are various installers available for that platform anyway. As for the Mac, I imagine that a third party will be involved, such as Red Marble Games which provides a porting and marketing service.

This week is the 45th of the year; the year is almost over. I hope that I can make a better effort for these last few weeks.

Categories
Game Development General Linux Game Development

Relative Path to Game Directory on Gnu/Linux

One thing I discovered when trying to run my Pong clone is that I had to change to the same directory as the binary in order to run it. I should be able to just type “sdl-pong” from the command line and have it run without caring which directory is my current working directory. Now, I didn’t hardcode it to use the exact path name for files, so I could move the entire game directory and it could still run just fine. I haven’t made that mistake since I was actively using QBasic almost 10 years ago. B-)

I don’t want to require the user to need to use the command line interface to run the game, so I need to solve this problem. No matter where the user is currently running the game from, the game should run. So what can be done?

Well, luckily, this problem has been solved. I checked, and sure enough, the games I currently have installed do almost the same thing.

The games are launched using a shell script. When you type “darwinia” or “dhlore” or “drod-jtrh-demo”, the thing that you are running is a shell script. In some cases, the path is hardcoded, but the best way is to use the script to find the actual path to the game binary, then run it.

How does one find the path? Sam Lantinga, of Loki Software and libsdl fame, had created a script called FindPath(). Details can be found in this mailing list post.

I don’t know why something so simple and easily solved isn’t more readily available to new developers. I just checked, and “Programming Linux Games” does not seem to use such a script for Penguin Warrior, the example game provided. “Linux Game Programming” mentions path names, but only when talking about the difference between Windows separators (“\”) and everyone else’s separators (“/”).

It took me some time before I found the script online, but now that I know what to look for, it is easy to find.

Unfortunately, I found out that it may be a problem. At least, it isn’t recognized as THE way to do handle the relative path problem. It seems that while the Filesystem Hierarchy Standard mentions using /usr/local/games for your installation directory, there seems to be some contention. Do you use /usr/local/games, or do you use /opt? What files should belong where? Is it even ok to worry about relative pathnames, or should your game assume that the files will be in the standard locations? If you distribute binary-only games, is it safe to ignore some documents because they assume that everything should be distributed as source?

After spending only a couple of days on this topic, I no longer wonder why hardly anyone makes games for Gnu/Linux. Even if you decide to do the actual development of the game, just packaging it up and distributing it is a big hassle. I believe Apple provides developer resources that specify details such as these, as does Microsoft. Until there is a definitive answer as to how to do something, one solution seems as good as another.

Of course, I could do worse than to follow the example of Introversion or Loki.

Categories
Games General Linux Game Development

Non-Profit for Linux-based Games

I learned that linuX-gamers.org has formed a non-profit organization in Germany, which is where it is located. I’ve found linuX-gamers to be a great source of news about games on the Gnu/Linux platform.

Major parts of our work will involve the support of communication, free exchange of knowledge and the linuX-gamers.net community through the linuX-gamers.net portal. We will care about developement and free distribution of open source software. Furthermore our work will cover organization of and participation in public events to make information available to a broad spectrum of people and to strengthen educational and scientific work on linux gaming related topics.

I don’t know the details of such work, but if it helps to improve the state of game development on Gnu/Linux and increases the number of games we can play, I welcome it. Good luck, everyone at linuX-gamers!

Categories
Game Development Linux Game Development

Programming on Gnu/Linux: We Need Better Tools

I’m relatively new to programming on Gnu/Linux, so forgive me if I seem impertinent, but what the heck is up with some of the tools available? Specifically, I’m talking about GDB and the lack of C++/STL support.

You know what would be nice? If I could look into the contents of a vector or list from the debugger. Maybe even change a value here or there. But no. GDB, which is past v6.0 now, has no support for such constructs. You’ll have to write very complicated print statements if you want to see the value of just one element. Simple views of STL containers are not possible otherwise. People periodically post to the GDB mailing list about this issue, but no one ever responds to them. There are bugs in the GDB bug database that have been there for years with no one assigned to them.

It seems that no one is even talking about adding such features to GDB. There is no real mention of this problem in their errata list, and so I am not even sure if these kinds of features will ever be introduced by the developers.

I did find gdb_stl_utils, but it didn’t seem to work in my initial tests. When trying to view a vector, I got the following:

Vector Element 0: History has not yet reached $1

Is there a better debugger out there? I found Zero, but it has a strange license agreement at this time. Still, it might be worth a look if it can make debugging C++ programs easier.

Are there open source debuggers out there that would allow me to see the data in STL containers without tediously following almost endless pointers? Am I doomed to use std::cout and std::cerr, requiring changes to the source of my code and any libraries that make use of the STL? Is GDB really the state of the art for Gnu/Linux debuggers?

On the plus side, if it gets frustrating enough, I suppose I could always hire a programmer to make the changes to GDB for me. It worked for Evolution, after all.

Categories
Game Development Games Linux Game Development

Can You Make Pong?

Since I’ve decided to start with the basics and create a simple Pong clone, I figured I would do some research. I found quite a few tutorials and other articles, but the following is one I wish I would have found months ago: But Can You Make Pong?

Well, there it is. The good old game Pong can be quite a challenge, and certainly not something you finish in a day or two. And this is exactly the reason I believe Pong is the perfect game to test your skills as an all-round developer and/or studio. It’s not overly ambitious, yet it requires a good amount of discipline. Look at it this way: If you can’t finish a simple game of Pong, do you truly think you are ready for the big games?

I have already worked a couple of hours on my Pong clone, and I can see it taking multiple days, and knowing how I seem to like to underestimate myself, probably a couple of weeks or months. Yeesh, that’s a sobering thought: Pong requiring many, many hours to complete.

I’m not too intimidated. I mean, even with my lack of experience, it is just Pong. It’s not even Massively Multiplayer Pong. I just can’t claim to have made such an “easy” game.

I did a bit of research, thinking I could find some simple tutorials. I found some C# ones, which do me no good, but I did find some general Pong physics tips which might come in handy later: ball physics and Pong “physics” .

The gold mine came from the LinuxDevCenter at O’Reilly: Retro Gaming Hacks, Part 1: Clone Pong, Using Only SDL (and Your Brain) by Josh Glover, a contributer to Retro Gaming Hacks. It’s basically a step-by-step tutorial on writing a Pong clone using SDL. I am not too happy with the example code, but it is called a “hack” for a reason. My goal is to implement Pong, but I will use this tutorial as a guide rather than try to mimic the code very closely.

Categories
Game Development Geek / Technical General Linux Game Development

Physics, Collision Detection, and Porting Code

As I develop Oracle’s Eye Prime using component-based methods, I have found myself thinking about how to implement features in a general way. For example, if I am trying to make Pong, I shouldn’t hardcode the Ball and Paddle and Walls. Instead, I should have a more general way to detect collisions. After all, even if I have a Ball entity bouncing off of a wall entity in Pong, I might want to do Space Invaders next and have bullet entities that destroy alien entities.

There are two aspects to collision detection with which I am grappling. The first problem is determining how to detect collisions between different, arbitrarily defined objects, which generally are represented by sprites on the screen, while still knowing where it collided. In Pong, I would like to know if the Ball hit the front or the sides of the Paddle since it would bounce differently. The second problem is figuring out what to do when a collision happens. If the Ball hits a Paddle, it should bounce off depending on the side it hit. If the Ball hits the goal, or goes out on one side, it should result in the score increasing for one of the players.

Metanet Software’s N Tutorials section helped me to figure out the solution to the first problem. While the code examples use ActionScript, the interactive example animations demonstrate the concepts and make them easy to grasp.

However, in the forums, there was a mention of Erin Catto’s GDC presentation on sequential impulses. Sequential impulses for “fast and easy” physics? It technically takes care of both problems? Count me in!

My first task: port the code.

It was originally written in Visual C++, but I am using an entirely different operating system and compiler. I obviously had to remove the #include for “windows.h”. The application used GLUT so I didn’t need to worry about WinMain or anything specific to VC++. On Windows, filenames are case-insensitive, so including <GL/glut.h> is the same as including <gl/glut.h> is the same as including <gL/Glut.H>. On Gnu/Linux, filenames are case-sensitive, so I had to determine which name was needed.

The next problem I encountered was a bit trickier. The code makes use of the class Arbiter, which basically regulates the collisions between different bodies. The World class has makes use of std::set to hold and sort through the Arbiters. The problem?


for (ArbIter arb = arbiters.begin(); arb != arbiters.end(); ++arb)
{
(*arb).PreStep(inv_dt);
}

g++ won’t compile the above code. It complains that it is modifying a const Arbiter, even though ArbIter is not a const iterator. VC++ will compile it just fine, obviously. Which one is correct?

It turns out that both are correct. At least, the standard library implementations are both correct. See, std::set’s keys must be ordered, and if a key can be modified, the ordering can’t be guaranteed. A set could be implemented so that std::set<T>::iterator is equivalent to const_iterator, which is how it is implemented for g++. If the key is only accessible through const methods, then there is no concern that the key can be changed in a way that would change the order. Other implementations can allow modification of a set’s keys so long as the parts relevant to ordering don’t change.

The problem is that the code as written wasn’t portable, and I didn’t like the idea of using const_cast or mutable to work around it.

Scott Meyers, author of “Effective C++” and “Effective STL”, provided the safe and portable solution.


ArbIter arb = arbiters.begin();
while (arb != arbiters.end())
{
// Erase key from set, modify it, then add it again.
Arbiter newArb((*arb).body1, (*arb).body2);
newArb.PreStep(inv_dt);
arbiters.erase(arb++);
arbiters.insert(newArb);
}

As the comment above states, you modify a copy of the key, erase the original, and then insert the copy. The above code should compile on any implementation, which means that it works with g++ on Gnu/Linux or VC++ on Windows.

Moments later, I was able to get the physics demos to run on Gnu/Linux.

The next step: integration with Oracle’s Eye Prime.

Categories
Game Development Linux Game Development Personal Development

Thousander Club Update: August 7th

For this week’s Thousander Club update:

Game Hours: 161 / 1000
Game Ideas: 432 / 1000

Target: 588

There are 33 days left until the deadline for entering a game in IGF 2007: Countdown to IGF 2007

There is a deadline for a project at my day job, and so I haven’t had as much time to work on my own projects.

On top of it all, I had upgraded to a new version of SDL, which broke compatibility with the Kyra Sprite Engine. I couldn’t compile Kyra because there was a compile error in a certain file that has not changed for a number of versions. I have no idea why it wouldn’t work, but I had to change a line in it to get it to compile.

Unfortunately, after I did the new build and built my project against it, I couldn’t run it. Something else was updated on my system which prevented me from running applications that aren’t installed, such as Oracle’s Eye Prime and the Professor Fizzwizzle demo. I decided to upgrade everything on my system, since I was spending as much time as I was just trying to get these things working.

The result: I am typing this post from my girlfriend’s computer while waiting for the kernel to recompile so that I can create new Nvidia kernel modules in order to use Xorg (as I was using XFree86 before). I was able to get some work done this weekend, but I lost a lot of productivity.

I need to look into setting up virtualization so that I can get a clean image of a Gnu/Linux build without needing to worry about breaking anything when upgrading.

Categories
Game Development Linux Game Development Personal Development

Thousander Club Update: July 31st

For this week’s Thousander Club update:

Game Hours: 154.5 / 1000
Game Ideas: 432 / 1000

Target: 567

There are 40 days left until the deadline for entering a game in IGF 2007: Countdown to IGF 2007

I was sick again at the beginning of this past week, but I still managed to log quite a few hours. A lot of it was spent researching physics code, but I finally found something I could use at the Game Physics blog. As I am using g++ as my compiler, code found online can result in compile-time errors that Visual C++ and other compilers might allow. I spent some time trying to figure out how to change the code so that it not only works correctly but also conforms to standard C++. I was figuring out how to work with std::set to change existing members while satisfying the compiler, but the book C++ In A Nutshell had the answer. The code at Game Physics updated the set’s contents directly, but a set’s members are supposed to be immutable. I guess VC++ was fine with it, but g++ was complaining. If you need to change a key in a set, you must first erase it from the set, then you can update the key and add it to the set again.

I went to a LAN party this weekend, and while I didn’t stay long, I did manage to play various sessions in Unreal Tournament 2004. I was already planning on getting the game someday since it has a Gnu/Linux client right out of the box, but now that I know that there is a map in which you can attack a space station using ships, it’s a must-have.

I am worried that I’ll be working a bunch of late nights at my day job this coming week due to a looming deadline. I doubt I will be able to work as many hours on Oracle’s Eye Prime as I did this past week. Still, I am making steady progress. It’s just a question of making a finished game by September 9th for IGF 2007.

Categories
Geek / Technical Linux Game Development Marketing/Business Politics/Government

Open Source Java

A friend pointed me to this article: Sun Promises to Open Source Java.

If Sun does make Java open source, it is good news for people who prefer to run Free operating systems. It’s one less technology that they have to do without. Existing open source solutions are always behind the one provided by Sun.

Now the choice for Free software developers is “Do I switch to Java or do I continue to use the language I have been using?”

It is interesting that Sun’s main concern is fragmentation of the codebase. When you give people the right to redistribute the source, it is bound to happen; however, the worst-case scenario nightmare that opponents of Free software think of is not typical. There aren’t exactly hundreds of forks of the Linux kernel, for example. Everyone basically works off of the main branch of development. If someone wants to take Linux in a different direction, they are free to do so. Of course, if everyone is sticking with Linus’ original project, then the fork won’t exactly be a problem in terms of “fragmentation”. And with Free software, forks are free to merge back into the original project anyway. Contrast the situation with software under the BSD license, which would allow someone to fork a project without giving anything back.