Tag Archives: libgdx

Day 30 – Learning Android Development

The Game

The app has been published! you can find it HERE or you can just search “Steel’s Run” in the Playstore (Developer: Sierens Apps).  Would be nice to receive some feedback!
The free desktop version can be found HERE (left arrow to jump, right one to shoot).

Today

Before publishing the app, I designed the icon. Here’s how it looks:

 

 

 

 

 

 

 

 

 

 

 

 

 

I think it looks good enough, especially the background. The character could get better graphics but that would’ve taken hours and hours so i just enlarged the existing sprites. I could have also added the typical glow in the center of the icon but opted out from doing it.

Then I went on to create a feature graphic, which is just a rearrangement of the title. You can see it on the playstore.

After that I published my first real app! The challenge is done!

The Journey

It feels good to have achieved my goal. Looking back at my first post, I set out to develop and publish an app in 30 days, all the month of September. No more, no less, and I stuck to it. It doesn’t matter if my app doesn’t even get 50 downloads. What really matters to me is that I set an intrinsic goal and I achieved it. I started something and finished it. I created something instead of consuming. I feel really satisfied with all this.

Then there’s also everything I learned along the way. I developed a good base for programming in java, having had no experience with it before. I got introduced to XML and learned how to deal with it, and how it is a very powerful language for representing content. I got some experience with Eclipse, together with the Android SDK and the ADT. The combination of Eclipse and the ADT provide an amazing development environment experience. I can’t live without them anymore. Not to mention the awesome libgdx library for making games, which lets me easily create a desktop and android version of the game.

I will focus on getting my master’s degree now but that doesn’t mean I wont start new projects in the near future. I look forward to expanding Steel’s Run, adding new levels, new features,etc. Creating something has always felt amazing and I wont stop doing it.

Day 29 – Learning Android Development

The game is done. Get the desktop version HERE. The only keys to press are the left arrow key(touch left in android) and the right arrow key(touch right in android). I have done everything I wanted with it before I release it tomorrow. I still need to do the app icon design but I’ll do that tomorrow.

I did the title and credits, it’s the best I could do in 1 hour. OpenDyslexic is very pretty!

I also worked on transitioning from title to game. The first time you open the game, you get the title. If you die or win, you go back to the title, but only in the android version. I don’t know why in the desktop version the title gets skipped when you die or win and it jumps back right to the start of the game. It works fine when you open the game for the first time though. I’m happy all works well in Android.

I also added sound. Whenever there’s a collision there’s sound. I used Bfxr for it.

I’m happy with how the game is so far. It is very challenging, and yes, it can be finished. I have tested all sections of it and have been able to do them. I look forward to adding more levels when I have more time.

To remind you, the desktop version is free and the one I linked here at the beginning of the post will be the last one fro quite a while. The Android version will be paid, I’m thinking somewhere around 0.70 to 0.85 cents and will be available, hopefully, tomorrow or Monday.

Day 28 – Learning Android Development

Today I had a productive afternoon. I set up a screen capture software that captures my screen. I set it up to take a picture every 10 seconds. Later I made a video out of it so you can see my productive 3.5 hours in just 1 minute!

As you can see on the video, I was able to make the whole boss encounter under that time  plus a few screens for when you lose or win. A commenter on the last post mentioned I could use OpenDyslexic as a font instead of my crappy one so i did! It’s a free to use font made -but not only- for  dyslexic people. The maker is Abelardo Gonzalez. He says:

you can sell anything that uses this font. But I’m not going to give permission for you to sell this font, by itself, alone. But you can sell a book with this font,programs with this font, etc. And if you do use this font commercially, let me know, and I’ll promote it here, and to others that can use it.:)

So there’s no problem with me using the font 🙂 I’ll contact him to let him know my game uses his font. Here’s the numbers in OpenDyslexic, they are the ones I use for the position of Steel:

I also used the same font for making the win and lose screen you see on the video. Here’s the lose screen:

I really like it! I’m looking into the sound right now. It wont be anything serious just simple jump/collision sounds. I also need a title screen.

Day 26 & 27 – Learning Android Development

HERE’S the latest version of the game

I haven’t done much over these two days. As I said on my last post, I just started my master so I’m busy with that, but from tomorrow until Sunday I’ll be free to work on and finish Steel’s Run. The last push!

Nevertheless, I’ve been able to implement some things to the game on the little free time I got these 2 days. For one, I finished the level design. So the obstacles are all set. The level is now 400 units long. It’s hard, it’s very hard, for those who like a challenge this will be a good game to play on your android while you’re waiting on the bus, or at the wait room of your dentist’s office, etc..

I also added a progress status on the top right corner, this gives you an idea of how far in you are in the level, and what’s left to go. Mind the crappy font design, at least it’s mine :p.

What I still want to add before first release: sound! some basic event sounds like when Steel runs against a chopped tree. A boss to complete the level, which will come after you do 100% of the obstacle course, and more things.

Day 23 – Learning Android Development

HERE is the latest version as of today of Steel’s Run. Remember, left arrow to jump and right arrow to shoot. I changed the level’s layout of obstacles (robot insects and chopped trees), making it less monotone and less harder than yesterday. The level is not yet complete, I’d say its around 33% complete, so if you manage to get where there’s no obstacles you have won, but remember that you only did 33% of what’s to come :). also the game still has no ending so stop when there’s no obstacles anymore.

Here’s the layout of the level so far. green dots are grass, red dots are insect robots and brown dots are chopped trees.

I changed the insect’s speed back to the same as the grass’. It makes it easier to design the level. They still patrol up and down. I also changed the trees’ color to a more pale tone, that way you no longer get distracted by them

What I would like to add is a percentage on the top right corner which indicates how far you got. Say you died half way, it will said 50% complete. That way you can brag to your friends!

What do you think of my game? or my progress overall? Please leave me a comment! I would like nothing more than to hear your constructive criticism or feedback.

Off-topic

For some reason, I got a lot of traffic to my blog today. After some investigation I saw that around 20 people (of which I presume most are tweet-bots) tweeted my blog post of yesterday. No idea why, maybe they just snatched it randomly out of Hacker News as some of them had a variant of HN in their twitter names. Still, lots of traffic compared to the other days! see for yourself.

 

Day 22 – Learning Android Development

Click here for the latest version of the game. Remember, left-arrow key to jump and right-arrow key to blast. Beware, it’s extremely hard right now because I was testing how far Steel can jump (3 chopped trees is the max) and the insects have gotten harder to kill. If you make it to where there is no ground beneath you anymore, consider it a win. I have yet to implement a finish.

I know this is an android dev blog post. I am testing it on the android as well so don’t worry.   Android is my primary target, but for implementing things I first test them all on the desktop version because it compiles way faster. I have only released the desktop version out on this blog because I plan on putting a price on the android version. Probably somewhere around €0.60, but I’ll release the final version on the PC as well and for free if you don’t feel like paying for the mobile version.

First thing I added today, or rather removed, is the range the sunblast can go. Now the sunblast can only go 7 units ahead of Steel before dissappearing ( if sunblast.position().x – steel.position().x >= 7). This was implemented to prevent you from firing like crazy in the beginning so that the blasts reach and kill the insects way before you actually get to them.

I also added some improvements to the world (read: made it harder). Everything’s faster now, blocks move at a speed of 6 units per second instead of 4, and insects at a speed of 4. That means insects will be going backwards a bit while patrolling up and down so it’s harder to evade them.

I also implemented a second background, I’m not really sure about it. It does give the game some more depth, but at the same time I feel the colors are a bit distracting. I probably will make it more grayish to avoid that.

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:

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 🙂

Day 12 and 13 – Learning Android Development

I decided to start with game development on android. I will use a free library called libgdx and follow a tutorial on making a little 2D game with it. libgdx is a java library that allows its users to create games on their desktop and then deploy it to Android. The author of the tutorial says that it is based on OpenGL, but you don’t touch the OpenGL yourself,  like in pygame. You let libgdx deal with the complex stuff while you focus on the actual game. Sounds like something good right now, as I want to publish my first app in a short time.

The Tutorial

Everything that follows is what I did by following the tutorial which is linked on the paragraph above. The author is Tamas Jano, all credits for this game go to him. Here is the game’s source. The game is based off another game called Star Guard.

I started off by installing libgdx and by creating three projects, star-assault, the main project, and star-assault-android along with star-assault-desktop. The last two serve as launchers for the two platforms. Then i added the libgdx JARS into their corresponding build paths within the project so I can use/implement the methods.

After the setting up, I started with the game. I created the game class StarAssault and then implemented the interface ApplicationListener. Which has the core methods create(), resize(), render(), pause(), resume(), dispose(). Most of them correspond to the app lifecycle phases. The render() method is the heart of the game, there is where I put the main loop and resize() id when the screen dimensions are changed.

After just implementing the methods without filling them up, the player class which is called Bob is created. The game is 2D tile based, so 1 block is 1 unit of height and 1 unit of width. Bob is 1/2 unit tall. Bob has several attributes, like a position in the world, acceleration when jumping, velocity when moving, etc. Bob will be running at 2.7 units per second. Because a running speed of 10km/h is 2.7 meters per second, and 1 meter = 1 unit.

Then follow the Block class, which is another actor just like Bob. Blocks  have some attributes as well, a position, bounds so that nothing penetrates them and sizeBoth Bob and Block use a vector class from libgdx for the position, this helps because it provides help with position, velocity, collition etc.

Next is the World class, which is a container class for Bob and Block. An array is created for several instantiated Blocks and Bob is of course uniquely instantiated unless I want more Bobs around.

To render the world, a screen is needed, so I created the class GameScreen . Screen is an interface from libgdx, I implement that to the GameScreen class. The Game class from libgdx has tools that are needed so I extended the StarAssault class with Game. Gamescreen is then called/instantiated under StarAssault.

StarAssault will use the create() method, which will instantiate a GameScreen object. The GameScreen object will then use the show() method and subsequently the render() method for every cycle. So the game loop will be situated in the GameScreen class.

What follows is the WorldRenderer class, this one get’s instantiated under the show() method in GameScreen . Then under the GameScreen’s render() method, the method render() from WorldRenderer gets invoked. WorlRenderer.render()  gets all the information from the world and its actors and renders them.

After setting up the renderer, the positions, without setting up an event handler, or proper images, and setting up the desktop launcher, I got this:

Desktop Launcher
on my Samsung Galaxy SII

The blocks are wider on my phone because I used a dimension of 480×320 for the desktop version, which is apparently not the same ratio as the Samsung’s.

Remember I said height and width were the same? well, only for the engine, not visually. The engine is told to render a screen equivalent to 10×7 blocks and each block measures 1(unit). But it is also told to fill out the screen and so the width of the blocks are visually bigger, because a phone’s horizontal view has a wide aspect. And so when an image is inserted, it will be distorted by OpenGL in order to fill out the screen.

With the Textures
On the SII

I made the block 20×20 pixels and Bob 6×10. On the desktop, the resolution of the window is 480×320, so that means each block should have a width of 48 so each pixel matches the screen pixels, but there’s only 20 pixels in the width of each block, so that means the image gets distorted (it gets wider) to fill out. Doesn’t really matter for this game though.

for the event handling, I created a new package and in it the class WorldController. The class is able to handle both touch input for android and key input for the PC. Bob is able to move now, but only horizontally.

Conclusion

This is as far as the tutorial goes, a second part was promised where the game would be completed with features like terrain interaction, animations, sounds, AI, etc. but seeing as the post was released on February 2012, I doubt a second part will ever come. Nonetheless this was a great tutorial and I will probably take another look at how this game was made again step by step. I liked the library too. Thanks Tamas.