Day 16 & 17 – Learning Android Development

Day 16

I spent the whole day finishing star-assault. The idea was to implement what was missing from the tutorial. On day 15 I had implemented turning and collision detection between bob and blocks. In total, what follows was what I added to the game:

Gravity: Bob now falls down at a constant speed if there’s no blocks beneath him and stops when there are.

Jumping: now bob can jump whenever space is pressed or the lower-center part of the android device is touched. He jumps at a constant speed, and can keep hovering in the air, so it’s basically flying but whatever.

Pigs: The enemy, they have simple AI where they just stand in place and turn and shoot left if bobs left of them and shoot right if bob’s right of them. They have 10 points of health, one bullet takes down 1 point of health. If the health reaches 0 they die.

Humanoid Pig
Dead Pig

 

 

 

 

 

 

 

 

Bullets: bullets comes out automatically from bob and the pigs, I didn’t opt for touch to shoot because the player already has to touch the screen for walking and jumping.

bullet

Collision: Between bob and pigs, between bullets and bob, between bullets and pigs, between bullets and blocks.

Level: I added another level, as in another window like the original but with rearranged blocks, with a pig in it. I could have done more “levels” but I wanted to finish this game.

Health: Three little hearts represent bob’s health, one bullet hit is one heart.

Win and Lose: When you kill the second pig and walk to his spot, a win screen appears. when you lose your health, a lose screen appears.

Here’s a short video of the whole game:

[youtube http://www.youtube.com/watch?v=t2qODmLsTpM]

I ran across a few problems during the development. One was that on my android device, I could only pass the game once, and when I closed and opened the app, the win screen would still be there, even though I was at the starting spot again. After searching I realized it was the static variables that persisted even though the app was destroyed, so i changed them into public instead.

I call the main activity on the onStart() method for android and not on the onCreate() because I want the game to restart every time you go away from the activity.

Day 17

I designed an icon for the app, a quick google taught me some of the basics but I didn’t spend much time on it.

 

 

 

 

 

 

Then I wanted to see if I could publish it (for free of course) on the Google playstore, just to see the process.Turns out I need to create a developer profile, and then pay 25$ via google checkout, which you need a credit card for, and I don’t have one. I’ve been avoiding a credit card for years but I guess I’ll have to get one in order to reach my 30 day goal of publishing an app.

I don’t consider this to be my first app, as the base of the code is not mine even though it’s open source. I want my first app to be all mine, I know I’m going to use some of the code from the tutorial as I will be using libgdx as well, but it will be for building an entirely different game.

The Game:

Desktop version, Android version, Source code (only includes the classes).

credits go to Tamas Jano for the tutorial, and I’ll take credits for what I added :)


Comments

5 responses to “Day 16 & 17 – Learning Android Development”

  1. Thanks for this dude.

    1. No problem :)

      1. Hey, your code was a great starting point, thanks. I have done quite a lot of changes now, one of the big ones being the collision detection. Anyways, feel free to keep track of my progress. :) https://github.com/markn86/my-gdx-game/commits/master

        1. Hey!

          That’s great to hear, I’ll certainly take a look when I have the chance :)

  2. Over the project , I am getting error to cofigure build path in just one file which is desktop even if configured correctly

    same problem with newly downloaded zip file
    any solution plz?

    I am new to libgdx
    why is there different codes for desktop, android,html??
    which apk file will be used when uploading to google play?

    waiting , thanks

Leave a Reply

Your email address will not be published. Required fields are marked *