{"id":1315,"date":"2012-05-03T13:00:00","date_gmt":"2012-05-03T10:00:00","guid":{"rendered":"http:\/\/www.javacodegeeks.com\/2012\/10\/android-game-development-with-libgdx-prototype-in-a-day-part-1a.html"},"modified":"2013-02-12T11:13:36","modified_gmt":"2013-02-12T09:13:36","slug":"android-game-development-with-libgdx","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2012\/05\/android-game-development-with-libgdx.html","title":{"rendered":"Android Game Development with libgdx &#8211; Prototype in a day, Part 1a"},"content":{"rendered":"<div dir=\"ltr\" style=\"text-align: left\">In this article I will take a detour from the building blocks of a game engine and components and I will demonstrate how to prototype a game quickly using the <a href=\"http:\/\/libgdx.com\/\" target=\"_blank\">libgdx<\/a> library.   <\/p>\n<p>What you will learn:   <\/p>\n<ul>\n<li>Create a very simple 2D shooter platformer game.<\/li>\n<li>What a complete game architecture looks like.<\/li>\n<li>How to use 2D Graphics with OpenGL without knowing anything about OpenGL.<\/li>\n<li>What different entities make up a game and how they are tied together in a game world.<\/li>\n<li>How to add sound to your game.<\/li>\n<li>How to build your game on the desktop and deploy in onto Android \u2013 yes, it\u2019s that magic.<\/li>\n<\/ul>\n<p><strong>Steps to create a game<\/strong>  <\/p>\n<ul>\n<li>1. Have an idea for a game.<\/li>\n<li>2. Draft up some scenarios on paper to resemble your vision and how will it look like.<\/li>\n<li>3. Analyse the idea, iterate over a few versions by tweaking it and decide what the game will have in its initial version.<\/li>\n<li>4. Pick a technology and start prototyping.<\/li>\n<li>5. Start coding and creating the assets for the game.<\/li>\n<li>6. Play-test, improve, and continuously make small steps towards finishing it.<\/li>\n<li>7. Polish and release!<\/li>\n<\/ul>\n<p><strong>The Game Idea<\/strong>  <\/p>\n<p>Because this will be a one day project, there is very limited time at disposal and the goal is to learn the technology to make games, not the actual process. For this purpose I took the liberty to borrow ideas from other games and focus on the technical aspects of this process.<br \/>\nI will be borrowing heavily from a game called <a href=\"http:\/\/vacuumflowers.com\/star_guard\/\" target=\"_blank\">Star Guard<\/a>. It\u2019s a little gem made by <a href=\"http:\/\/vacuumflowers.com\/\" target=\"_blank\">Vacuum Flowers<\/a>. Go get the game and check it out. A very simple shooter platformer with a simplistic style and old school arcade feel.<br \/>\nThe idea is to guide our hero through the levels by killing enemies and and dodging everything that tries to kill us.<br \/>\nThe <strong>controls<\/strong> are simple, the <strong>arrow keys<\/strong> move the hero to the left or right, <strong>Z<\/strong> jumps and <strong>X<\/strong> shoots the laser. The longer the jump button is held, the higher the hero jumps. He can change direction in the air and also shoot. We\u2019ll see how we can translate these controls to Android later on.   <\/p>\n<p>The next steps (2 and 3) can be skipped over as we will already have this taken care of because of the functioning game.  <\/p>\n<p><strong>Start your Eclipse<\/strong>  <\/p>\n<p>This is where we start. I will be using <a href=\"http:\/\/libgdx.badlogicgames.com\/\" target=\"_blank\">libgdx<\/a> library to create the game. Why libgdx? It\u2019s the best library (in my opinion) that makes developing games easy without knowing much about the underlying technology. It allows developers to create their games on the desktop and deploy it to Android without any modification. It offers all the elements to use it in games and hides the complexity of dealing with specific technologies and hardware. It will become more obvious as we go along.  <\/p>\n<p><strong>Setting up the project<\/strong>  <\/p>\n<p>By following the instructions from libgdx\u2019s documentation we have to first download the library.<br \/>\nGo to <a href=\"http:\/\/libgdx.badlogicgames.com\/nightlies\/\">http:\/\/libgdx.badlogicgames.com\/nightlies\/<\/a> and download the <code>libgdx-nightly-latest.zip<\/code> file and unpack it.   <\/p>\n<p>Create a simple java project in eclipse. I will call it <code>star-assault<\/code>.<\/p>\n<div class=\"separator\" style=\"clear: both;text-align: center\"><a href=\"http:\/\/2.bp.blogspot.com\/-xsTxMLvjpUc\/T6JHZWSv-TI\/AAAAAAAAATE\/ATiLdITop6Q\/s1600\/Screen-shot-2012-02-20-at-11_44_07-261x300.png\"><img decoding=\"async\" border=\"0\" height=\"320\" src=\"http:\/\/2.bp.blogspot.com\/-xsTxMLvjpUc\/T6JHZWSv-TI\/AAAAAAAAATE\/ATiLdITop6Q\/s320\/Screen-shot-2012-02-20-at-11_44_07-261x300.png\" width=\"278\" \/><\/a><\/div>\n<p>Leave the default settings and once the project was created, <strong>right click<\/strong> on it and select <strong>New-&gt;Folder<\/strong> and create a directory named <code>libs<\/code>.<br \/>\nFrom the unpacked <code>libgdx-nighly-latest<\/code> directory, copy the <code>gdx.jar<\/code> file into the newly created <code>libs<\/code> directory. Also copy the the <code>gdx-sources.jar<\/code> file into the <code>libs<\/code> directory. It is in the <code>sources<\/code> sub-directory of the unpacked gdx directory. You can do this by simply dragging the jar files into your directories in eclipse. If you copy them using explorer, or finder or any other means, don\u2019t forget to refresh your eclipse project after by pressing F5.<\/p>\n<p>The structure should look like the following image:<\/p>\n<div class=\"separator\" style=\"clear: both;text-align: center\"><a href=\"http:\/\/1.bp.blogspot.com\/-BgFhDsMM-AE\/T6JHmar2VII\/AAAAAAAAATM\/3qmYR7ukecQ\/s1600\/Screen-shot-2012-02-20-at-12_33_34.png\"><img decoding=\"async\" border=\"0\" height=\"203\" src=\"http:\/\/1.bp.blogspot.com\/-BgFhDsMM-AE\/T6JHmar2VII\/AAAAAAAAATM\/3qmYR7ukecQ\/s320\/Screen-shot-2012-02-20-at-12_33_34.png\" width=\"320\" \/><\/a><\/div>\n<p>Add <code>gdx.jar<\/code> as a dependency to the project. Do this by <strong>right-clicking the project<\/strong> title and select <strong>Properties<\/strong>. On this screen pick <strong>Java Build Path<\/strong> and click onto the <strong>Libraries<\/strong> tab. Click <strong>Add JARs\u2026<\/strong>, navigate to the <code>libs<\/code> directory and select <code>gdx.jar<\/code>, then click <strong>OK<\/strong>.<\/p>\n<p>In order to have access to the gdx source code and to be able to debug our game easily, it\u2019s a good idea to add the sources to the gdx.jar file. To do this, expand the <code>gdx.jar<\/code> node, select <strong>Source attachment<\/strong>, click <strong>Edit\u2026<\/strong>, then <strong>Workspace\u2026<\/strong> and pick <code>gdx-sources.jar<\/code> then <strong>OK<\/strong> until all the pop-up windows are closed.<\/p>\n<div class=\"separator\" style=\"clear: both;text-align: center\"><a href=\"http:\/\/4.bp.blogspot.com\/-z7shuTf_tqE\/T6JH3L80RKI\/AAAAAAAAATU\/J0iRK2M2GO8\/s1600\/Screen-shot-2012-02-20-at-12_41_21.png\"><img decoding=\"async\" border=\"0\" height=\"356\" src=\"http:\/\/4.bp.blogspot.com\/-z7shuTf_tqE\/T6JH3L80RKI\/AAAAAAAAATU\/J0iRK2M2GO8\/s400\/Screen-shot-2012-02-20-at-12_41_21.png\" width=\"400\" \/><\/a><\/div>\n<p>The complete documentation for setting up projects with libgdx can be found on the official <a href=\"http:\/\/code.google.com\/p\/libgdx\/wiki\/ProjectSetup\">wiki<\/a>.   <\/p>\n<p>This project will be the core project for the game. It will contain the game mechanics, the engine, everything. We will need to create two more projects, basically launchers for the 2 platforms we are targeting. One for Android and one for Desktop. These projects will be extremely simple and will contain only the dependencies required to run the game on the respective platforms. Think of them as the class containing the main method.<\/p>\n<p>Why do we need separate projects for these? Because libgdx hides the complexity of dealing with the underlying operating system (graphics, audio, user input, file i\/o, etc.), Each platform has a specific implementation and we will need to include only those implementations (bindings) that are required targeted. Also because the application life-cycle, the asset loading (loading of images, sounds, etc) and other common aspects of an application are heavily simplified, the platform specific implementations reside in different JAR files and only those need to be included that are required for the platform we are targeting.  <\/p>\n<p><strong>The Desktop Version<\/strong>  <\/p>\n<p>Create a simple java project as in the previous step and name it <code>star-assault-desktop<\/code>. Also follow the steps to create the <code>libs<\/code> directory. This time the required <code>jar<\/code> files from the downloaded <code>zip<\/code> file are:<br \/>\n<code>gdx-natives.jar<\/code>,<br \/>\n<code>gdx-backend-lwjgl.jar<\/code>,<br \/>\n<code>gdx-backend-lwjgl-natives.jar<\/code>.<br \/>\nAlso add these <code>jar<\/code> files as dependencies to the project as in the previous project. (<strong>right click the project<\/strong> -&gt; <strong>Properties<\/strong> -&gt;<strong> Java Build Path<\/strong> -&gt; <strong>Libraries<\/strong> -&gt; <strong>Add JARs<\/strong>, select the three JARs and click <strong>OK<\/strong>.)<br \/>\nWe also need to add the <code>star-assault<\/code> project to the dependencies. To do this, click the <strong>Projects<\/strong> tab, click <strong>Add<\/strong>, check the <code>star-assault<\/code> project and click <strong>OK<\/strong>.   <\/p>\n<p><strong>Important!<\/strong> We need to make the  <code>star-assault<\/code> project a transitive dependency, meaning that dependencies for this project to be made dependencies of projects depending on this. To do this:  <strong>right click on the main project<\/strong> -&gt;  <strong>Properties<\/strong> -&gt;  <strong>Java Build Path<\/strong> -&gt;  <strong>Order and Export<\/strong> -&gt;  <strong>check the gdx.jar file <\/strong>and click  <strong>OK<\/strong>. <div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<p><strong>The Android Version<\/strong>  <\/p>\n<p>For this you will need the <a href=\"http:\/\/developer.android.com\/sdk\/installing.html\" target=\"_blank\">Android SDK<\/a> installed.<br \/>\nCreate a new Android project in eclipse: <strong>File<\/strong> -&gt; <strong>New<\/strong> -&gt; <strong>Project<\/strong> -&gt; <strong>Android Project<\/strong>.<br \/>\nName it <code>star-assault-android<\/code>. For build target, check \u201cAndroid 2.3?. Specify a package name <code>net.obviam<\/code> or your own preference. Next to \u201cCreate Activity\u201d enter <code>StarAssaultActivity<\/code>. Click <strong>Finish<\/strong>.<\/p>\n<div class=\"separator\" style=\"clear: both;text-align: center\"><a href=\"http:\/\/1.bp.blogspot.com\/-i92CxhdzvIg\/T6JICPMQ5TI\/AAAAAAAAATc\/_i03KrdNUjU\/s1600\/Screen-shot-2012-02-20-at-13_57_36.png\"><img decoding=\"async\" border=\"0\" height=\"368\" src=\"http:\/\/1.bp.blogspot.com\/-i92CxhdzvIg\/T6JICPMQ5TI\/AAAAAAAAATc\/_i03KrdNUjU\/s400\/Screen-shot-2012-02-20-at-13_57_36.png\" width=\"400\" \/><\/a><\/div>\n<p>Go to the project directory and create a sub-directory named libs (you can do this from eclipse). From the <code>nightly zip<\/code>, place <code>gdx-backend-android.jar<\/code> and the <code>armeabi<\/code> and <code>armeabi-v7a<\/code> directories in the newly created <code>libs<\/code> directory.<br \/>\nIn eclipse, <strong>right click the project<\/strong> -&gt; <strong>Properties<\/strong> -&gt; <strong>Java Build Path<\/strong> -&gt; <strong>Libraries<\/strong> -&gt; <strong>Add JARs<\/strong>, select <code>gdx-backend-android.jar<\/code> and click <strong>OK<\/strong>.<\/p>\n<p>Click Add JARs again, select <strong>gdx.jar<\/strong> under the main project (<code>star-assault<\/code>) and click <strong>OK<\/strong>.<br \/>\nClick the <strong>Projects<\/strong> tab, click <strong>Add<\/strong>, check the main project and click <strong>OK<\/strong> twice.<br \/>\nThis is how the structure should look like:<\/p>\n<div class=\"separator\" style=\"clear: both;text-align: center\"><a href=\"http:\/\/1.bp.blogspot.com\/-zENVTX-gAXI\/T6JIPj-wmgI\/AAAAAAAAATk\/xrHndMCcy78\/s1600\/Screen-shot-2012-02-20-at-14_08_36.png\"><img decoding=\"async\" border=\"0\" height=\"400\" src=\"http:\/\/1.bp.blogspot.com\/-zENVTX-gAXI\/T6JIPj-wmgI\/AAAAAAAAATk\/xrHndMCcy78\/s400\/Screen-shot-2012-02-20-at-14_08_36.png\" width=\"175\" \/><\/a><\/div>\n<p><strong>Important!<\/strong><br \/>\nFor ADT release 17 and newer, the <code>gdx jar<\/code> files need to be explicitly marked to be exported.<br \/>\nTo do this<br \/>\nClick on the Android Project<br \/>\nSelect <strong>Properties<\/strong><br \/>\nSelect <strong>Java Build Path<\/strong> (step 1)<br \/>\nSelect <strong>Order and Export<\/strong> (step 2)<br \/>\nCheck all the references, e.g. the <code>gdx.jar<\/code>, the <code>gdx-backend-android.jar<\/code>, the main project etc. (step 3).<br \/>\nThe following image shows the new state.<\/p>\n<div class=\"separator\" style=\"clear: both;text-align: center\"><a href=\"http:\/\/4.bp.blogspot.com\/-WT3yDh--l1A\/T6JIdx_0noI\/AAAAAAAAATs\/JxTR6vPAMz0\/s1600\/adt-fix.png\"><img decoding=\"async\" border=\"0\" height=\"283\" src=\"http:\/\/4.bp.blogspot.com\/-WT3yDh--l1A\/T6JIdx_0noI\/AAAAAAAAATs\/JxTR6vPAMz0\/s400\/adt-fix.png\" width=\"400\" \/><\/a><\/div>\n<p>Also, more information on this issue <a href=\"http:\/\/www.badlogicgames.com\/wordpress\/?p=2362\">here<\/a>.  <\/p>\n<p><strong>Sharing the Assets (images, sounds and other data)<\/strong>  <\/p>\n<p>Because the game will be identical on both desktop and Android but each version requires to be built separately from different projects, we want to keep the images, sounds and other data files in a shared location. Ideally this would be in the main project as it is included in both Android and desktop bu because Android has a strict rule on where to keep all these files, we will have to keep the assets there. It is in the automatically created <code>assets<\/code> directory in the Android project. In eclipse there is the possibility to link directories as in symbolic links on linux\/mac or shortcuts in windows. To link the <code>assets<\/code> directory from the Android project to the desktop project do the following:<br \/>\n<strong>Right click<\/strong> the <code>star-assault-desktop<\/code> project -&gt; <strong>Properties<\/strong> -&gt; <strong>Java Build Path<\/strong> -&gt; <strong>Source<\/strong> tab -&gt; <strong>Link Source\u2026<\/strong> -&gt; <strong>Browse\u2026<\/strong> -&gt; browse to the <code>asssets<\/code> directory in the <code>star-assault-android<\/code> project and click <strong>Finish<\/strong>. You can also <strong>extend<\/strong> the <strong>Variables\u2026<\/strong> instead of browsing to the <code>assets<\/code> directory. It is recommended as it makes the project file system independent.   <\/p>\n<p>Also make sure the <code>assets<\/code> directory is included as a source folder. To do that, <strong>right click<\/strong> on the <code>assets<\/code> directory in eclipse (the desktop project), select <strong>Build Path<\/strong> -&gt; <strong>Use as Source Folder<\/strong>.    <\/p>\n<p>At this stage we are ready with the setup and we can go ahead to work on the game.  <\/p>\n<p><strong>Creating the Game<\/strong>  <\/p>\n<p>A computer application is a piece of software that runs on a machine. It starts up, does something (even if that\u2019s nothing) and stops in a way or another. A computer game is a specific type of application in which the \u201cdoes something\u201d part is filled with a game. The start and end is common to all applications. Also the game has a very straight forward architecture based around an continuous loop. You can find out more about the <a href=\"http:\/\/obviam.net\/index.php\/2-1-a-little-about-game-architecture\/\">architecture<\/a> and the <a href=\"http:\/\/obviam.net\/index.php\/a-very-basic-the-game-loop-for-android\/\">loop<\/a> here and here.   <\/p>\n<p>Thanks to libgdx our game can be pieced together as a staged play in a theatre. All you need to do is, to think of the game as a theatrical play. We will define the stages, the actors, their roles and behaviours, but we will delegate the choreography to the player.   <\/p>\n<p>So to set up our game\/play we need to take the following steps:   <\/p>\n<ul>\n<li>1. Start application.<\/li>\n<li>2. Load up all the images and sounds and store them in memory.<\/li>\n<li>3. Create the stages for our play along with the actors and their behaviours (rules for interactions between them).<\/li>\n<li>4. Hand the control to the player.<\/li>\n<li>5. Create the engine that will manipulate the actors on the stage based on the input received from the controller.<\/li>\n<li>6. Determine when the play ends.<\/li>\n<li>7. End the show.<\/li>\n<\/ul>\n<p>It looks quite simple and it really is. I will be introducing the notions and elements as they appear.   <\/p>\n<p>To create the Game we simply need just one class.<br \/>\nLet\u2019s create <code>StarAssault.java<\/code> in the <code>star-assault<\/code> project. Every class will be created in this project with 2 exceptions.   <\/p>\n<pre class=\"brush:java\">package net.obviam.starassault;\r\n\r\nimport com.badlogic.gdx.ApplicationListener;\r\n\r\npublic class StarAssault implements ApplicationListener {\r\n\r\n @Override\r\n public void create() {\r\n  \/\/ TODO Auto-generated method stub\r\n }\r\n\r\n @Override\r\n public void resize(int width, int height) {\r\n  \/\/ TODO Auto-generated method stub\r\n }\r\n\r\n @Override\r\n public void render() {\r\n  \/\/ TODO Auto-generated method stub\r\n }\r\n\r\n @Override\r\n public void pause() {\r\n  \/\/ TODO Auto-generated method stub\r\n }\r\n\r\n @Override\r\n public void resume() {\r\n  \/\/ TODO Auto-generated method stub\r\n }\r\n\r\n @Override\r\n public void dispose() {\r\n  \/\/ TODO Auto-generated method stub\r\n }\r\n}\r\n<\/pre>\n<p>Just implement <code>ApplicationListener<\/code> from <code>gdx<\/code> and eclipse will generate the stubs for the methods needed to be implemented.<br \/>\nThese are all the methods that we need to implement from the application lifecycle. It is very simple considering all the setup code needed for Android, or on desktop to initialise the OpenGL context and all those boring (and difficult) tasks.   <\/p>\n<p>The method <code>create()<\/code> is called first. This happens when the application is ready and we can start loading our assets and create the stage and actors. Think of building the stage for the play in a theatre AFTER all the things have been shipped there and prepared. Depending on where the theatre is and how you get there, the logistic can be a nightmare. You can ship things by hand, or by plane or trucks\u2026we don\u2019t know. We\u2019re inside and have the stuff ready and we can start to assemble it. This is what libgdx is doing for us. Shipping our stuff and delivering it regardless of the platform.<\/p>\n<p>The method <code>resize(int width, int height)<\/code> is called every time the drawable surface is resized. This gives us the chance to rearrange the bits before we go on to start the play. It happens when the window (if the game runs in one) is resized for example.<\/p>\n<p>The heart of every game is the <code>render()<\/code> method which is nothing more than the infinite loop. This gets called continuously until we decide that the game is over and want to terminate the program. This is the play in progress.<\/p>\n<p><strong>Note<\/strong>: For computers the game over is not equivalent of program over. So it\u2019s just a state. The program is in a state of game over, but is still running.<\/p>\n<p>Of course that the play can be interrupted bu pauses and they can be resumed. The <code>pause()<\/code> method will be called whenever the application enters into the background on the desktop or Android. When the application comes to the foreground it resumes and the <code>resume()<\/code> method is being called.<br \/>\nWhen the game is done and the application is being closed, the <code>dispose()<\/code> is called and this is the time to do some cleanup. It\u2019s similar when the play is over, spectators have left and the stage is being dismantled. No more coming back. More on the lifecycle <a href=\"http:\/\/code.google.com\/p\/libgdx\/wiki\/ApplicationLifecycle\">here<\/a>.  <\/p>\n<p><strong>The Actors<\/strong>  <\/p>\n<p>Let\u2019s start taking steps towards the actual game. The first mile-stone is to have a world in which our guy can move. The world is composed of levels and each level is composed of a terrain. The terrain is nothing more than some blocks through which our guy can\u2019t go.<\/p>\n<p>Identifying the actors and entities so far in the game is easy.<\/p>\n<p>We have the guy (let\u2019s call him Bob \u2013 libgdx has tutorials with Bob) and the blocks that make up the world.   <\/p>\n<p>Having played Star Guard we can see that Bob has a few states. When we don\u2019t touch anything, Bob is idle. He can also move (in both directions) and he can also jump. Also when he\u2019s dead, he can\u2019t do anything. Bob can be in only one of the 4 identified states at any given time. There are other states as well but we\u2019ll leave them out for now.   <\/p>\n<p>The states for Bob:   <\/p>\n<ul>\n<li>Idle \u2013 when not moving or jumping and is alive<\/li>\n<li>Moving \u2013 either left or right at a constant speed.<\/li>\n<li>Jumping \u2013 also facing left or right and high or low.<\/li>\n<li>Dead \u2013 he\u2019s not even visible and respawning.<\/li>\n<\/ul>\n<p>The Blocks are the other actors. For simplicity we have just blocks. The level consists of blocks placed in a 2 dimensional space. For simplicity we will use a grid.<br \/>\nTurn the start of Star Guard into a block and Bob structure, will look something like this:<\/p>\n<div class=\"separator\" style=\"clear: both;text-align: center\"><a href=\"http:\/\/2.bp.blogspot.com\/-Aq1yWShLJ9U\/T6JIsOYyFtI\/AAAAAAAAAT0\/SvXdFt_fIbU\/s1600\/Screen-shot-2012-02-20-at-11_25_081.png\"><img decoding=\"async\" border=\"0\" height=\"238\" src=\"http:\/\/2.bp.blogspot.com\/-Aq1yWShLJ9U\/T6JIsOYyFtI\/AAAAAAAAAT0\/SvXdFt_fIbU\/s400\/Screen-shot-2012-02-20-at-11_25_081.png\" width=\"400\" \/><\/a><\/div>\n<div class=\"separator\" style=\"clear: both;text-align: center\"><a href=\"http:\/\/4.bp.blogspot.com\/-FfHyUtESr1g\/T6JI2Au8NDI\/AAAAAAAAAT8\/xbS4RHTlheM\/s1600\/level01.png\"><img decoding=\"async\" border=\"0\" height=\"266\" src=\"http:\/\/4.bp.blogspot.com\/-FfHyUtESr1g\/T6JI2Au8NDI\/AAAAAAAAAT8\/xbS4RHTlheM\/s400\/level01.png\" width=\"400\" \/><\/a><\/div>\n<p>The top one is the original and the bottom one is our world representation.   <\/p>\n<p>We have imagined the world but we need to work in a measure system that we can make sense of. For simplicity we will say that one block in the world is one unit wide and 1 unit tall. We can use meters to make it even simpler but because Bob is half a unit, it makes him half a meter. Let\u2019s say 4 units in the game world make up 1 meter so Bob will be 2 meters tall.<\/p>\n<div class=\"separator\" style=\"clear: both;text-align: center\"><a href=\"http:\/\/2.bp.blogspot.com\/-BA6dJuvcLG8\/T6JJBjkBpOI\/AAAAAAAAAUE\/SlIw7kGpkKQ\/s1600\/unit_system1.png\"><img decoding=\"async\" border=\"0\" height=\"320\" src=\"http:\/\/2.bp.blogspot.com\/-BA6dJuvcLG8\/T6JJBjkBpOI\/AAAAAAAAAUE\/SlIw7kGpkKQ\/s400\/unit_system1.png\" width=\"400\" \/><\/a><\/div>\n<p>It is important because when we will calculate the speed with which Bob runs for example, we need to know what we\u2019re doing.   <\/p>\n<p>Let\u2019s create the world.   <\/p>\n<p>Our main playable character is <code>Bob<\/code>.<br \/>\nThe <code>Bob.java<\/code> class looks like this:   <\/p>\n<pre class=\"brush:java\">package net.obviam.starassault.model;\r\n\r\nimport com.badlogic.gdx.math.Rectangle;\r\nimport com.badlogic.gdx.math.Vector2;\r\n\r\npublic class Bob {\r\n\r\n public enum State {\r\n  IDLE, WALKING, JUMPING, DYING\r\n }\r\n\r\n static final float SPEED = 2f; \/\/ unit per second\r\n static final float JUMP_VELOCITY = 1f;\r\n static final float SIZE = 0.5f; \/\/ half a unit\r\n\r\n Vector2  position = new Vector2();\r\n Vector2  acceleration = new Vector2();\r\n Vector2  velocity = new Vector2();\r\n Rectangle  bounds = new Rectangle();\r\n State  state = State.IDLE;\r\n boolean  facingLeft = true;\r\n\r\n public Bob(Vector2 position) {\r\n  this.position = position;\r\n  this.bounds.height = SIZE;\r\n  this.bounds.width = SIZE;\r\n }\r\n}\r\n<\/pre>\n<p>Lines <strong>#16-#21<\/strong> define the attributes of Bob. The values of these attributes define Bob\u2019s state at any given time.<br \/>\n<code>position<\/code> \u2013 Bob\u2019s position in the world. This is expressed in world coordinates (more on this later).<br \/>\n<code>acceleration<\/code> \u2013 This will determine the acceleration when Bob jumps.<br \/>\n<code>velocity<\/code> \u2013 Will be calculated and used for moving Bob around.<br \/>\n<code>bounds<\/code> \u2013 Each element in the game will have a bounding box. This is nothing more than a rectangle, in order to know if Bob ran into a wall, got killed by a bullet or shot an enemy and hit. It will be used for collision detection. Think of playing with cubes.<br \/>\n<code>state<\/code> \u2013 the current state of Bob. When we issue the walk action, the state will be <code>WALKING<\/code> and based on this state, we know what to draw onto the screen.<br \/>\n<code>facingLeft<\/code> \u2013 represents Bob\u2019s bearing. Being a simple 2D platformer, we have just 2 facings. Left and right.   <\/p>\n<p>Lines <strong>#12-#15<\/strong> define some constants we will use to calculate the speed and positions in the world. These will be tweaked later on.   <\/p>\n<p>We also need some blocks to make up the world.<br \/>\nThe <code>Block.java<\/code> class looks like this:   <\/p>\n<pre class=\"brush:java\">package net.obviam.starassault.model;\r\n\r\nimport com.badlogic.gdx.math.Rectangle;\r\nimport com.badlogic.gdx.math.Vector2;\r\n\r\npublic class Block {\r\n\r\n static final float SIZE = 1f;\r\n\r\n Vector2  position = new Vector2();\r\n Rectangle  bounds = new Rectangle();\r\n\r\n public Block(Vector2 pos) {\r\n  this.position = pos;\r\n  this.bounds.width = SIZE;\r\n  this.bounds.height = SIZE;\r\n }\r\n}\r\n<\/pre>\n<p>Blocks are nothing more than rectangles placed in the world. We will use these blocks to make up the terrain. We have one simple rule. Nothing can penetrate them.   <\/p>\n<p><strong>libgdx note<\/strong><\/p>\n<p>You might have noticed that we are using the  <code>Vector2<\/code> type from libgdx. This makes our life considerably easier as it provides everything we need to work with Euclidean vectors. We will use vectors to position entities, to calculate speeds, and to move thing around.  <\/p>\n<p><strong>About the coordinate system and units<\/strong>  <\/p>\n<p>As the real world, our world has dimensions. Think of a room in a flat. It has a width, height and depth. We will make it 2 dimensional and will get rid of the depth. If the room is 5 meters wide and 3 meters tall we can say that we described the room in the metric system. It is easy to imagine placing a table 1 meter wide and 1 meter tall in the middle. We can\u2019t go through the table, to cross it, we will need to jump on top of it, walk 1 meter and jump off. We can use multiple tables to create a pyramid and create some weird designs in the room.<\/p>\n<p>In our star assault world, the world represents the room, the blocks the table and the unit, the meter in the real world.<\/p>\n<p>If I run with <strong>10km\/h<\/strong> that translates to <strong>2.77777778 metres \/ second ( 10 * 1000 \/ 3600)<\/strong>. To translate this to Star Assault world coordinates, we will say that to resemble a 10km\/h speed, we will use 2.7 units\/second.<\/p>\n<p>Examine the following diagram of representing the bounding boxes and Bob in the world coordinate system.   <\/p>\n<div class=\"separator\" style=\"clear: both;text-align: center\"><a href=\"http:\/\/1.bp.blogspot.com\/-sKL9IRmoKbo\/T6JJRP8cmkI\/AAAAAAAAAUM\/cc5Nh3Gccok\/s1600\/coordinate-system.png\"><img decoding=\"async\" border=\"0\" height=\"281\" src=\"http:\/\/1.bp.blogspot.com\/-sKL9IRmoKbo\/T6JJRP8cmkI\/AAAAAAAAAUM\/cc5Nh3Gccok\/s400\/coordinate-system.png\" width=\"400\" \/><\/a><\/div>\n<p>The red squares are the bounding boxes of the blocks. The green square is Bob\u2019s bounding box. The empty squares are just empty air. The grid is just for reference. This is the world we will be creating our simulations in. The coordinate system\u2019s origin is at the bottom left, so walking left at 10.000 units\/hour means that Bob\u2019s position\u2019s X coordinate will <strong>decrease<\/strong> with <strong>2.7 units every second<\/strong>.   <\/p>\n<p>Also note that the access to the members is package default and the models are in a separate package. We will have to create accessor methods (getters and setters) to get access to them from the engine.  <\/p>\n<p><strong>Creating the World<\/strong>  <\/p>\n<p>As a first step we will just create the world as a hard-coded tiny room. It will be 10 units wide and 7 units tall. We will place Bob and the blocks following the image shown below.<\/p>\n<div class=\"separator\" style=\"clear: both;text-align: center\"><a href=\"http:\/\/2.bp.blogspot.com\/--jbdeqKWJ80\/T6JJdvMOmzI\/AAAAAAAAAUU\/gGFySbB5IBY\/s1600\/level011.png\"><img decoding=\"async\" border=\"0\" height=\"266\" src=\"http:\/\/2.bp.blogspot.com\/--jbdeqKWJ80\/T6JJdvMOmzI\/AAAAAAAAAUU\/gGFySbB5IBY\/s400\/level011.png\" width=\"400\" \/><\/a><\/div>\n<p>The <code>World.java<\/code> looks like this:   <\/p>\n<pre class=\"brush:java\">package net.obviam.starassault.model;\r\n\r\nimport com.badlogic.gdx.math.Vector2;\r\nimport com.badlogic.gdx.utils.Array;\r\n\r\npublic class World {\r\n\r\n \/** The blocks making up the world **\/\r\n Array&lt;Block&gt; blocks = new Array&lt;Block&gt;();\r\n \/** Our player controlled hero **\/\r\n Bob bob;\r\n\r\n \/\/ Getters -----------\r\n public Array&lt;Block&gt; getBlocks() {\r\n  return blocks;\r\n }\r\n public Bob getBob() {\r\n  return bob;\r\n }\r\n \/\/ --------------------\r\n\r\n public World() {\r\n  createDemoWorld();\r\n }\r\n\r\n private void createDemoWorld() {\r\n  bob = new Bob(new Vector2(7, 2));\r\n\r\n  for (int i = 0; i &lt; 10; i++) {\r\n   blocks.add(new Block(new Vector2(i, 0)));\r\n   blocks.add(new Block(new Vector2(i, 7)));\r\n   if (i &gt; 2)\r\n    blocks.add(new Block(new Vector2(i, 1)));\r\n  }\r\n  blocks.add(new Block(new Vector2(9, 2)));\r\n  blocks.add(new Block(new Vector2(9, 3)));\r\n  blocks.add(new Block(new Vector2(9, 4)));\r\n  blocks.add(new Block(new Vector2(9, 5)));\r\n\r\n  blocks.add(new Block(new Vector2(6, 3)));\r\n  blocks.add(new Block(new Vector2(6, 4)));\r\n  blocks.add(new Block(new Vector2(6, 5)));\r\n }\r\n}\r\n<\/pre>\n<p>It is a simple container class for the entities in the world. Currently the entities are the blocks and Bob. In the constructor the blocks are added to the <code>blocks<\/code> array and <code>Bob<\/code> is created. It\u2019s all hard-coded for the time being.<\/p>\n<p>Remember that the origin is in the bottom left corner.  <\/p>\n<p>Check out the rest of the tutorial <a href=\"http:\/\/www.javacodegeeks.com\/2012\/05\/android-game-development-with-libgdx_03.html\">here<\/a>.<\/p>\n<p><strong><i>Reference: <\/i><\/strong><a href=\"http:\/\/obviam.net\/index.php\/getting-started-in-android-game-development-with-libgdx-create-a-working-prototype-in-a-day-tutorial-part-1\/\">Getting Started in Android Game Development with libgdx \u2013 Create a Working Prototype in a Day \u2013 Tutorial Part 1<\/a> from our <a href=\"http:\/\/www.javacodegeeks.com\/p\/jcg.html\">JCG partner<\/a> Impaler at the <a href=\"http:\/\/obviam.net\/\">Against the Grain<\/a> blog. <\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>In this article I will take a detour from the building blocks of a game engine and components and I will demonstrate how to prototype a game quickly using the libgdx library. What you will learn: Create a very simple 2D shooter platformer game. What a complete game architecture looks like. How to use 2D &hellip;<\/p>\n","protected":false},"author":27,"featured_media":46,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[723],"class_list":["post-1315","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-android-games","tag-libgdx"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Android Game Development with libgdx - Prototype in a day, Part 1a - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"In this article I will take a detour from the building blocks of a game engine and components and I will demonstrate how to prototype a game quickly using\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javacodegeeks.com\/2012\/05\/android-game-development-with-libgdx.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Android Game Development with libgdx - Prototype in a day, Part 1a - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"In this article I will take a detour from the building blocks of a game engine and components and I will demonstrate how to prototype a game quickly using\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2012\/05\/android-game-development-with-libgdx.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2012-05-03T10:00:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2013-02-12T09:13:36+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/android-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Impaler\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Impaler\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"18 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/05\\\/android-game-development-with-libgdx.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/05\\\/android-game-development-with-libgdx.html\"},\"author\":{\"name\":\"Impaler\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/6bad1a2db4fb0129703629617c049f8c\"},\"headline\":\"Android Game Development with libgdx &#8211; Prototype in a day, Part 1a\",\"datePublished\":\"2012-05-03T10:00:00+00:00\",\"dateModified\":\"2013-02-12T09:13:36+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/05\\\/android-game-development-with-libgdx.html\"},\"wordCount\":3219,\"commentCount\":9,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/05\\\/android-game-development-with-libgdx.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/android-logo.jpg\",\"keywords\":[\"libgdx\"],\"articleSection\":[\"Android Games\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/05\\\/android-game-development-with-libgdx.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/05\\\/android-game-development-with-libgdx.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/05\\\/android-game-development-with-libgdx.html\",\"name\":\"Android Game Development with libgdx - Prototype in a day, Part 1a - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/05\\\/android-game-development-with-libgdx.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/05\\\/android-game-development-with-libgdx.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/android-logo.jpg\",\"datePublished\":\"2012-05-03T10:00:00+00:00\",\"dateModified\":\"2013-02-12T09:13:36+00:00\",\"description\":\"In this article I will take a detour from the building blocks of a game engine and components and I will demonstrate how to prototype a game quickly using\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/05\\\/android-game-development-with-libgdx.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/05\\\/android-game-development-with-libgdx.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/05\\\/android-game-development-with-libgdx.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/android-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/android-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/05\\\/android-game-development-with-libgdx.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Android\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/android\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Android Games\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/android\\\/android-games\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Android Game Development with libgdx &#8211; Prototype in a day, Part 1a\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/6bad1a2db4fb0129703629617c049f8c\",\"name\":\"Impaler\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/def7cf34ac1eee0f6c2de98be951379d6bf14fd498acf7d3864e2e570ece357c?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/def7cf34ac1eee0f6c2de98be951379d6bf14fd498acf7d3864e2e570ece357c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/def7cf34ac1eee0f6c2de98be951379d6bf14fd498acf7d3864e2e570ece357c?s=96&d=mm&r=g\",\"caption\":\"Impaler\"},\"sameAs\":[\"http:\\\/\\\/obviam.net\\\/\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/Impaler\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Android Game Development with libgdx - Prototype in a day, Part 1a - Java Code Geeks","description":"In this article I will take a detour from the building blocks of a game engine and components and I will demonstrate how to prototype a game quickly using","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.javacodegeeks.com\/2012\/05\/android-game-development-with-libgdx.html","og_locale":"en_US","og_type":"article","og_title":"Android Game Development with libgdx - Prototype in a day, Part 1a - Java Code Geeks","og_description":"In this article I will take a detour from the building blocks of a game engine and components and I will demonstrate how to prototype a game quickly using","og_url":"https:\/\/www.javacodegeeks.com\/2012\/05\/android-game-development-with-libgdx.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2012-05-03T10:00:00+00:00","article_modified_time":"2013-02-12T09:13:36+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/android-logo.jpg","type":"image\/jpeg"}],"author":"Impaler","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Impaler","Est. reading time":"18 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2012\/05\/android-game-development-with-libgdx.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/05\/android-game-development-with-libgdx.html"},"author":{"name":"Impaler","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/6bad1a2db4fb0129703629617c049f8c"},"headline":"Android Game Development with libgdx &#8211; Prototype in a day, Part 1a","datePublished":"2012-05-03T10:00:00+00:00","dateModified":"2013-02-12T09:13:36+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/05\/android-game-development-with-libgdx.html"},"wordCount":3219,"commentCount":9,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/05\/android-game-development-with-libgdx.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/android-logo.jpg","keywords":["libgdx"],"articleSection":["Android Games"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2012\/05\/android-game-development-with-libgdx.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2012\/05\/android-game-development-with-libgdx.html","url":"https:\/\/www.javacodegeeks.com\/2012\/05\/android-game-development-with-libgdx.html","name":"Android Game Development with libgdx - Prototype in a day, Part 1a - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/05\/android-game-development-with-libgdx.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/05\/android-game-development-with-libgdx.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/android-logo.jpg","datePublished":"2012-05-03T10:00:00+00:00","dateModified":"2013-02-12T09:13:36+00:00","description":"In this article I will take a detour from the building blocks of a game engine and components and I will demonstrate how to prototype a game quickly using","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/05\/android-game-development-with-libgdx.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2012\/05\/android-game-development-with-libgdx.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2012\/05\/android-game-development-with-libgdx.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/android-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/android-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2012\/05\/android-game-development-with-libgdx.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Android","item":"https:\/\/www.javacodegeeks.com\/category\/android"},{"@type":"ListItem","position":3,"name":"Android Games","item":"https:\/\/www.javacodegeeks.com\/category\/android\/android-games"},{"@type":"ListItem","position":4,"name":"Android Game Development with libgdx &#8211; Prototype in a day, Part 1a"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/6bad1a2db4fb0129703629617c049f8c","name":"Impaler","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/def7cf34ac1eee0f6c2de98be951379d6bf14fd498acf7d3864e2e570ece357c?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/def7cf34ac1eee0f6c2de98be951379d6bf14fd498acf7d3864e2e570ece357c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/def7cf34ac1eee0f6c2de98be951379d6bf14fd498acf7d3864e2e570ece357c?s=96&d=mm&r=g","caption":"Impaler"},"sameAs":["http:\/\/obviam.net\/"],"url":"https:\/\/www.javacodegeeks.com\/author\/Impaler"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/1315","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/27"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=1315"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/1315\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/46"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=1315"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=1315"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=1315"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}