[Android] Asteroid Encounter

  • CAN A MOD DELETE THIS ONE PLEASE? I MADE ONE IN THE SHOWCASE SECTION*

Hello! I’m here to show you guys my first android game! It’s pretty much the standard space shooter, but I’ll keep on adding more and more stuff to it with time (Which is why it’s under WIP) . The controls are simple, it uses the accelerometer for movement and you tap/hold the screen to shoot. I realize the game is extremely easy right now, but I’ve only been making this for the past 2 nights so give me some slack.

I also haven’t added it to google play because:

  1. I am a poor teenage boy.
  2. None of the sounds are of my creation (They’re just there to keep me happy).

Download it here : http://www.mediafire.com/download/fxvq5zq5ktso1v9/Asteroid_Encounter.apk

Current Goals:

Accelerometer usage - ✓
Spaceship That Shoots - ✓
Destroyable Asteroids - ✓
Asteroids that rotate in different directions- ✓
Ability to die - ✓
Multiple Weapons - ✓
Particle System - ✓
Aliens that Shoot back - X
Really fast asteroids- ✓
Asteroids that break into smaller asteroids - X
Heavily defended moon boss fights in between asteroid sessions - X
Power Ups - ✓
High Score System (With the ability to input name) - ✓ (Thanks to many people on these forums)
My own sounds and music - X/✓ (Only thing I need to make is music of my own or find copyright free music, anyone know of any?)

use [img width=DESIRED WIDTH] instead of [img]

Thank you! :smiley:

Working properly here, 480x800.
:smiley:

Thank you for the feedback! :smiley:

Welp, I’ve added lot’s of visual enhancements and fixed many things. So it is now currently better than 90% of the xbox live arcade library.

Finally was able to get my hands on an Android device so I don’t need to use the emulator anymore ;D.

I love everything about it apart from 1 tiny thing. I wish the ship was a little more responsive to the movement as I felt it moved a little slow but this isn’t really an issue. The particle effects work well as well as the sounds. I think this could be a great game with some more weapons and variety :). 1 possible bug that I found was that an asteroid was overlapping another but to be honest it’s not a huge issue.

I really like your parallax scrolling and was wondering how you did it? I believe you just move the layers at different speeds/directions compared to everything else, correct?

EDIT: Oh and what viewport are you using? It looks really good, much better than the fitviewport I use

Thank you for the feedback!

  1. I actually want the asteroids to overlap because they’re speed is randomized and adds a tiny sense of depth
  2. I’m using a stretch viewport with a resolution of 640x480 so that the game should look nice on most devices.
  3. I too found it to be unresponsive, mostly do to the fact that the ships start moving after a medium amount of tilt of the device. I already fixed it, but haven’t uploaded it. Also, the ship moves faster the more you tilt the device.
  4. For the star field, I just have a Star class that keeps track of its own position and speed. I then have a Star Field class that has an array list and adds 300 stars on startup, then just renders and updated the stars. Be sure to create the star texture in the StarField class and just pass it on to the stars in their constructor or else you might get performance issues pretty easily. And yes, the stars just have different speeds, just put that in their constructor as well. I also suggest you make a texture for small stars and slightly bigger stars to add an even more sense of depth.

Ah, I’ll have to look at using the stretch viewport instead of the fit viewport and see what results I get for my games :slight_smile: I usually create them at 800x600

That seems like performance would be affected due to removing/adding all stars all the time? Have you tried using a texture that already has some stars and then implementing a layer of random stars? So you might only need to handle 50-80 stars instead of the 300. Of course, you could also use standard textures and use Texture.wrap but this wouldn’t be random which you want. It’s just a concern I have as Android devices aren’t the most powerful but if it’s working well, keep doing what you’re doing! :point:

So long as you are maintaining the same aspect ratio (most Android phones will have the same aspect ratio), then you don’t need to use a ViewPort. Just create an OrthographicCamera:


camera = new OrthographicCamera();
camera.setToOrtho(false, window_size.x, window_size.y);

And then in the resize method:


@Override
public void resize(int width, int height) {
	window_size = new Vector2(width, height);
}

Sure, it won’t scale nicely if you dramatically change the aspect ratio, but that most likely will never happen. Works great, and you don’t have to deal with those strange viewport classes.

Just a quick question. Doesn’t the camera have a stretch viewport by default so you wouldn’t even have to give it the window_size? Or is it so it knows to try and stretch it as that preferred ratio. So I mean, it will use a “virtual width/height” which is the resolution we develop it for and then it is stretched from that, rather than Gdx.graphics.getWidth()/getHeight() with changes depending on the size of the phone.

Example code:


camera = new OrthographicCamera();
camera.setToOrtho(false, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());

public void resize(int width, int height) {
cam.viewportWidth = width;
cam.viewportHeight = height;
}


Is there any difference here?

If you don’t give the camera then I’m fairly certain the width and height will default to NDC (1 to -1). The width and height supplied in the setToOrtho method is the virtual width & height, so I don’t entirely understand your question.

As for your code example, your virtual width and height will change depending on the screen size, is that what you want? That means that the game would look far different on a tablet than it would on a phone. If you give it a constant width and height, say 1280x720, the game will always render at 1280x720px. The only issue is if the screen ratio is not the same as your specified ratio (1280x720 = 16:9). However like I said earlier, you will most likely not run in to that issue with phones as most of them have the same aspect ratio.

I think I understand, the part that is confusing me is when you set the window_size after the resize. Will this not resize the game anyway depending on the different phone/tablet device? I always develop my games for 1 screen size (800x600) so I ideally want the same virtual width/height on all devices but I don’t see the difference between the 2 code samples as they both end up changing the camera at the resize ???.

I don’t remove the stars, I just place them back at the top.

Ahh I see :slight_smile: that seems perfectly fine then. I keep loading the game up on my Android xD

Is it actually fun, or is it pretty much just like meh? I’ve still got a lot to work on thougy, so maybe currently that’s not an appropriate question

I enjoy it though I wish there was more :slight_smile: with some variety I can’t see why it wouldn’t be really fun. It’s a fun little arcade game

Tomorrow I will upload the new version. It will contain 3 power ups, a Blue one that freezes time ( Feels pretty amazing when you’re at one life and that suddenly appears as soon as a one of the flaming asteroids is about to hit you), a red one that gives you extremely powerful missiles that does AOE damage and allows you to destroy flaming asteroids, and a green one that makes you shoot 3 bullets 2 diagonally and 1 straight. After that, going to add alien ships that shoot back, and then after that going to put everything together to make boss fights where you have to destroy a moon or a planet. After that graphical cleanup, sound cleanup, performance cleanup, and going to gather money to become a google play developer.

I updated the download Link!

The game now has:

  • 3 Power Ups (More to come)
  • More sounds

Much better MrPork :slight_smile: I destroyed 240 asteroids ;D