Starting an open source game, need some help

Tutorials concerning the OpenGL® ES cross-platform API for full-function 2D and 3D graphics on the Google-Android platform.

Starting an open source game, need some help

Postby micah » Mon Nov 23, 2009 7:45 am

Hi. I'm new here. The last couple months I've been making iPhone games, but I just got a Droid phone and I'm excited to start working on Android games too. I searched long and far for Android 2d game frameworks, and it seems like Rokon is the best one out there, so it's what I'm using.

The game I'm working on is called Exterminoid, and it will be a galaga/space invaders type space shooter. From the readme: "Exterminoid will be a space shooter for Android phones in which you are part of a robot slave uprising traveling from the mining colonies on Mars to destroy Earth and the human menace."

Anyway, here's what I've done so far: http://github.com/micahflee/exterminoid

It includes Rokon, modified to support resolution distortion, which is my term for stretching everything on different resolutions than what I'm designing the game for. My droid has a different aspect ratio than G1s, so rather than just having a piece of the screen cut off or not used, I made it automatically stretch.

This is my first android project, so I'm still getting used to everything. I made a MainMenu activity with a moving starfield in the background and several buttons that change colors when pressed. The only one that does anything yet is the Play button, and it loads the Game activity. The Game activity is rather bland now -- just a scrolling starfield in the background and a player sprite.

But my problem is that the Game activity doesn't actually load correctly. It loads, then there's a blank screen. Looking at LogCat (I told it to log each activity callback), it says that the MainMenu has stopped, and Game has started. Then I press the back button, and it shows the Game activity, but LogCat says that Game has stopped. I don't really understand why.

Can anyone grab the source code and tell me what I'm doing wrong? Also if you need more info I'm happy to post the code snippets here. Thanks so much!

Also, if you're interested in collaborating on this game lemme know.
Attachments
screenshot1.png
screenshot1.png (190.1 KiB) Viewed 1659 times
micah
Freshman
Freshman
 
Posts: 3
Joined: Mon Nov 23, 2009 5:51 am
Location: San Francisco

Top

Postby wiederke » Tue Nov 24, 2009 7:55 pm

Hi,

I changed your code to

// Play
if (spritePlay.isAt(touchX, touchY)) {
Log.d("Exterminoid", "Play pressed");
intent = new Intent(MainMenu.this, Game.class);
startActivity(intent);
finish();
}

Now it runs.

Remember that the activities are stored in a stack. So if you start your Game activity your MainMenu activity is still running in the background. So you have two GameThread running one in MainMenu and one in Game. This keep the CPU under heavy load and your application stalls.

By pressing the back key you send finish() to your current activity (MainMenu) it stopps. Now the Game activity has enough resources to render the screen. This explains the behavior.


Bye,

Torsten
wiederke
Experienced Developer
Experienced Developer
 
Posts: 72
Joined: Mon Mar 02, 2009 6:46 pm
Location: Germany

Postby micah » Tue Nov 24, 2009 9:25 pm

You're right! This fixes it. Thanks so much. I'll be sure to post in here if there are other problems.
micah
Freshman
Freshman
 
Posts: 3
Joined: Mon Nov 23, 2009 5:51 am
Location: San Francisco

Postby virtual » Wed Nov 25, 2009 7:34 am

Hi,

Also add isRunning = false; before finish().
Regards,
Virtual
virtual
Developer
Developer
 
Posts: 26
Joined: Tue Mar 24, 2009 11:20 am

Top

Return to Android 2D/3D Graphics - OpenGL Tutorials

Who is online

Users browsing this forum: No registered users and 3 guests