{"id":88,"date":"2015-08-21T01:26:00","date_gmt":"2015-08-21T01:26:00","guid":{"rendered":"https:\/\/therenaissanceraven.com\/?p=88"},"modified":"2015-08-21T01:26:00","modified_gmt":"2015-08-21T01:26:00","slug":"libgdx-complete-tutorial-how-to-make-a-simple-game-in-libgdx","status":"publish","type":"post","link":"https:\/\/therenaissanceraven.com\/?p=88","title":{"rendered":"*libGDX* Complete Tutorial: How to make a simple game in LibGDX."},"content":{"rendered":"<div dir=\"ltr\">This is a one page guide from start to finish on how to create your first libgdx game for android\/iOS\/html5\/desktop.<\/p>\n<\/div>\n<div dir=\"ltr\">I am however going to skip downloading java, SDK, and libgdx, as I&#8217;m assuming you already possess those if you are reading this. If you do not infact do, there are many various tutorials online that could explain it much better than I.<\/div>\n<div dir=\"ltr\"><\/div>\n<div dir=\"ltr\"><b>Step 1:<\/b><br \/>Design your game! Now this sounds like an obvious one, but many times it is easy to get carried away with a game idea without thought placed into the mechanics of the game. However, and possibly lucky for you, that is already completed for you in this tutorial. Here is how game planning takes place, for at least me:<\/div>\n<ul>\n<li>Idea: Static background with character on 1D plane that can slide left  and right to dodge icicles that fall from the cave ceiling.<\/li>\n<li>Graphics: minimal style<\/li>\n<li>Objective: to survive as long as possible without getting hit.<\/li>\n<li>Challenges: collision detection on triangular icicles. Spawn rate of  icicles (should be constantly random? Or increase over time?)<\/li>\n<\/ul>\n<div dir=\"ltr\"><b>Step 2:<\/b><br \/>Creating basic graphics. At this stage we want to create basic graphics for our game so we can help visualize our code as we are creating our masterpiece. However, we wish to keep this rudimentary as we might not have the perfect graphical ideas ready just yet, as those usually spark into life as we play and develop our game more in-depth. <\/div>\n<div dir=\"ltr\">For creating graphics, it is best to get using something else besides Microsoft paint. While it can physically make any object by pixel editing, it does lack the key aspect of an &#8220;alpha&#8221; value. This is necessary as it is the transparency of they object, which is key if we wish to display graphics without a white border of empty pixels around them. For this, i recommend paint.net as a very simple free editor that is easy to pick up.<\/div>\n<div dir=\"ltr\"><\/div>\n<div dir=\"ltr\"><i>Creating cave background:<\/i><br \/>We are starting with the background of the cave with the dimensions of 800px tall by 480px wide as this will be the entire size of screen. The key parts needed are the ground for the character to run on and the top section of the cave for the icicles to spawn on. Thus, my rendition is shown below (Note: I have pasted in all of the pictures as full size images, so that you can simply save them to your computer to use in the game):<\/div>\n<div style=\"clear: both; text-align: center;\"><a href=\"http:\/\/3.bp.blogspot.com\/-Cbas9vBtsyc\/VdSVc1rsz0I\/AAAAAAAAAZM\/DcSgbZiEFeA\/s1600\/cavebackground.png\" style=\"margin-left: 1em; margin-right: 1em;\"><img decoding=\"async\" border=\"0\" src=\"https:\/\/3.bp.blogspot.com\/-Cbas9vBtsyc\/VdSVc1rsz0I\/AAAAAAAAAZM\/DcSgbZiEFeA\/s1600\/cavebackground.png\" \/><\/a><\/div>\n<p><\/p>\n<div dir=\"ltr\"><i>Creating icicle:<\/i><br \/>Here we are creating the icicle, one again by sticking to just the basics we want to just create the shape that will need collision detection, instead of focusing on the appearance. We are going to create three different icicle forms as to break up the monotony that only one type might create.<\/div>\n<div dir=\"ltr\">Type A:&nbsp;<\/div>\n<div style=\"clear: both; text-align: center;\"><a href=\"http:\/\/2.bp.blogspot.com\/-dbAEidud0O8\/VdSVc6ht99I\/AAAAAAAAAZc\/dXZ44jiZ7m0\/s1600\/icicleA.png\" style=\"margin-left: 1em; margin-right: 1em;\"><img decoding=\"async\" border=\"0\" src=\"https:\/\/2.bp.blogspot.com\/-dbAEidud0O8\/VdSVc6ht99I\/AAAAAAAAAZc\/dXZ44jiZ7m0\/s1600\/icicleA.png\" \/><\/a><\/div>\n<div dir=\"ltr\"><\/div>\n<div dir=\"ltr\">Type B:&nbsp;<\/div>\n<div style=\"clear: both; text-align: center;\"><a href=\"http:\/\/3.bp.blogspot.com\/-d6lFQQ69sZ4\/VdSVc_vZp3I\/AAAAAAAAAZo\/JfyzttTq1fw\/s1600\/icicleB.png\" style=\"margin-left: 1em; margin-right: 1em;\"><img decoding=\"async\" border=\"0\" src=\"https:\/\/3.bp.blogspot.com\/-d6lFQQ69sZ4\/VdSVc_vZp3I\/AAAAAAAAAZo\/JfyzttTq1fw\/s1600\/icicleB.png\" \/><\/a><\/div>\n<div dir=\"ltr\"><\/div>\n<div dir=\"ltr\">Type C:&nbsp;<\/div>\n<div style=\"clear: both; text-align: center;\"><a href=\"http:\/\/2.bp.blogspot.com\/-M8u2yADm9WE\/VdSVdTJ4SaI\/AAAAAAAAAZk\/s_ng1ik6_d8\/s1600\/icicleC.png\" style=\"margin-left: 1em; margin-right: 1em;\"><img decoding=\"async\" border=\"0\" src=\"https:\/\/2.bp.blogspot.com\/-M8u2yADm9WE\/VdSVdTJ4SaI\/AAAAAAAAAZk\/s_ng1ik6_d8\/s1600\/icicleC.png\" \/><\/a><\/div>\n<p><\/p>\n<div dir=\"ltr\"><\/div>\n<div dir=\"ltr\"><i>Creating Guy:<\/i><\/div>\n<div dir=\"ltr\">This may be the hardest graphic decision you have to make, as with that, the motivation and inspiration will come over time. So to start simply, here is the guy we will use:<\/div>\n<div style=\"clear: both; text-align: center;\"><a href=\"http:\/\/4.bp.blogspot.com\/-i7DEJdTmkuQ\/VdSWmOK_8ZI\/AAAAAAAAAZw\/fRMO5H-nBB4\/s1600\/guy.png\" style=\"margin-left: 1em; margin-right: 1em;\"><img decoding=\"async\" border=\"0\" src=\"https:\/\/4.bp.blogspot.com\/-i7DEJdTmkuQ\/VdSWmOK_8ZI\/AAAAAAAAAZw\/fRMO5H-nBB4\/s1600\/guy.png\" \/><\/a><\/div>\n<div dir=\"ltr\"><b>Step 3:<\/b><\/div>\n<div dir=\"ltr\">Start creating the program! Open up your libGDX Project Generator and fill out the necessary package details. Also, if you run into issues with the destination folder, simply create a blank folder where you wish for the project to end up, and set the destination to that. (note: you do not need to use the same package name or game name as I have in this tutorial):<\/div>\n<div style=\"clear: both; text-align: center;\"><a href=\"http:\/\/4.bp.blogspot.com\/-gsNWnp_tRng\/VdSZDVXuXKI\/AAAAAAAAAZ0\/EtCvF9ZtWfg\/s1600\/Capture.PNG\" style=\"margin-left: 1em; margin-right: 1em;\"><img decoding=\"async\" border=\"0\" src=\"https:\/\/4.bp.blogspot.com\/-gsNWnp_tRng\/VdSZDVXuXKI\/AAAAAAAAAZ0\/EtCvF9ZtWfg\/s1600\/Capture.PNG\" \/><\/a><\/div>\n<div dir=\"ltr\">Now simply import the project into your preferred IDE, android studio for I, and we are ready to start programming.<\/div>\n<div dir=\"ltr\"><\/div>\n<div dir=\"ltr\"><b>Step 4:<\/b><\/div>\n<div dir=\"ltr\">(Note: Full Java class codes are at the end of Step 8) Start by entering the Core directory and finding your MyGdxGame.java file, this is where the programing will start. Below is the new code we will enter into our first java file, the code is commented for clarity.<\/div>\n<div dir=\"ltr\"><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;\">\n<table>\n<tbody>\n<tr>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\"> 1<br \/> 2<br \/> 3<br \/> 4<br \/> 5<br \/> 6<br \/> 7<br \/> 8<br \/> 9<br \/>10<br \/>11<br \/>12<br \/>13<br \/>14<br \/>15<br \/>16<br \/>17<br \/>18<br \/>19<br \/>20<br \/>21<br \/>22<br \/>23<br \/>24<br \/>25<br \/>26<br \/>27<br \/>28<br \/>29<br \/>30<br \/>31<br \/>32<br \/>33<br \/>34<br \/>35<br \/>36<br \/>37<br \/>38<br \/>39<\/pre>\n<\/td>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\"><span style=\"color: #008800; font-weight: bold;\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold;\">com.badlogic.gdx.Game<\/span><span style=\"color: #333333;\">;<\/span><br \/><span style=\"color: #008800; font-weight: bold;\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold;\">com.badlogic.gdx.graphics.g2d.BitmapFont<\/span><span style=\"color: #333333;\">;<\/span><br \/><span style=\"color: #008800; font-weight: bold;\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold;\">com.badlogic.gdx.graphics.g2d.SpriteBatch<\/span><span style=\"color: #333333;\">;<\/span><br \/><br \/><span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #008800; font-weight: bold;\">class<\/span> <span style=\"color: #bb0066; font-weight: bold;\">MyGdxGame<\/span> <span style=\"color: #008800; font-weight: bold;\">extends<\/span> Game <span style=\"color: #333333;\">{<\/span><br \/><br \/>    <span style=\"color: #888888;\">\/\/Define a public Spritebatch which we will use to render text onto the screen<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> SpriteBatch gameBatch<span style=\"color: #333333;\">;<\/span><br \/><br \/>    <span style=\"color: #888888;\">\/\/Define a public font that we will use for all text.<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> BitmapFont gameFont<span style=\"color: #333333;\">;<\/span><br \/><br \/>    <span style=\"color: #888888;\">\/\/Public void create() is ran when the program is started.<\/span><br \/> <span style=\"color: #555555; font-weight: bold;\">@Override<\/span><br \/> <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">create<\/span> <span style=\"color: #333333;\">()<\/span> <span style=\"color: #333333;\">{<\/span><br \/>        <span style=\"color: #888888;\">\/\/Creates the SpriteBatch for gameBatch to use<\/span><br \/>        gameBatch <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> SpriteBatch<span style=\"color: #333333;\">();<\/span><br \/><br \/>        <span style=\"color: #888888;\">\/\/Creates the font, which is the default font for LIBgdx.<\/span><br \/>        gameFont <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> BitmapFont<span style=\"color: #333333;\">();<\/span><br \/><br \/>        <span style=\"color: #888888;\">\/\/this will set the screen to our next class \"GameScreen\"<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">this<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">setScreen<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #008800; font-weight: bold;\">new<\/span> GameScreen<span style=\"color: #333333;\">(<\/span><span style=\"color: #008800; font-weight: bold;\">this<\/span><span style=\"color: #333333;\">));<\/span><br \/> <span style=\"color: #333333;\">}<\/span><br \/>    <br \/>    <span style=\"color: #888888;\">\/\/Called upon render<\/span><br \/> <span style=\"color: #555555; font-weight: bold;\">@Override<\/span><br \/> <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">render<\/span> <span style=\"color: #333333;\">()<\/span> <span style=\"color: #333333;\">{<\/span><br \/>        <span style=\"color: #888888;\">\/\/Calls our render() method in our GameScreen<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">super<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">render<\/span><span style=\"color: #333333;\">();<\/span><br \/> <span style=\"color: #333333;\">}<\/span><br \/><br \/>    <span style=\"color: #888888;\">\/\/Called when class is disposed<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">dispose<\/span><span style=\"color: #333333;\">()<\/span> <span style=\"color: #333333;\">{<\/span><br \/>        <span style=\"color: #888888;\">\/\/disposes both SpriteBatch and BitmapFont<\/span><br \/>        gameBatch<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">dispose<\/span><span style=\"color: #333333;\">();<\/span><br \/>        gameFont<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">dispose<\/span><span style=\"color: #333333;\">();<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><span style=\"color: #333333;\">}<\/span><br \/><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>The GameScreen(this) will be in error, and that is okay! We have not created the GameScreen yet. The GameScreen will be its own java file and will act as the screen the currently runs our game. But why do we have to create another java file? You don&#8217;t have to, and you could do it all in this file, but this system works great for when you wish to have multiple screens in games.. such as a game screen.. settings screen&#8230; menu screen&#8230; etc..<\/p>\n<p>Thus we now create GameScreen.java class in the same folder as our MyGdxGame.java class. The class below is outfited to the nearly bare minimum requirements for a functioning screen. It utilizes the functions of creating a camera, drawing to a screen, and handling screen and button inputs. The class is shown below:<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;\">\n<table>\n<tbody>\n<tr>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\">  1<br \/>  2<br \/>  3<br \/>  4<br \/>  5<br \/>  6<br \/>  7<br \/>  8<br \/>  9<br \/> 10<br \/> 11<br \/> 12<br \/> 13<br \/> 14<br \/> 15<br \/> 16<br \/> 17<br \/> 18<br \/> 19<br \/> 20<br \/> 21<br \/> 22<br \/> 23<br \/> 24<br \/> 25<br \/> 26<br \/> 27<br \/> 28<br \/> 29<br \/> 30<br \/> 31<br \/> 32<br \/> 33<br \/> 34<br \/> 35<br \/> 36<br \/> 37<br \/> 38<br \/> 39<br \/> 40<br \/> 41<br \/> 42<br \/> 43<br \/> 44<br \/> 45<br \/> 46<br \/> 47<br \/> 48<br \/> 49<br \/> 50<br \/> 51<br \/> 52<br \/> 53<br \/> 54<br \/> 55<br \/> 56<br \/> 57<br \/> 58<br \/> 59<br \/> 60<br \/> 61<br \/> 62<br \/> 63<br \/> 64<br \/> 65<br \/> 66<br \/> 67<br \/> 68<br \/> 69<br \/> 70<br \/> 71<br \/> 72<br \/> 73<br \/> 74<br \/> 75<br \/> 76<br \/> 77<br \/> 78<br \/> 79<br \/> 80<br \/> 81<br \/> 82<br \/> 83<br \/> 84<br \/> 85<br \/> 86<br \/> 87<br \/> 88<br \/> 89<br \/> 90<br \/> 91<br \/> 92<br \/> 93<br \/> 94<br \/> 95<br \/> 96<br \/> 97<br \/> 98<br \/> 99<br \/>100<br \/>101<br \/>102<br \/>103<br \/>104<br \/>105<br \/>106<br \/>107<br \/>108<br \/>109<br \/>110<br \/>111<br \/>112<br \/>113<br \/>114<br \/>115<br \/>116<br \/>117<br \/>118<br \/>119<br \/>120<br \/>121<br \/>122<br \/>123<br \/>124<br \/>125<br \/>126<br \/>127<br \/>128<br \/>129<br \/>130<br \/>131<br \/>132<br \/>133<br \/>134<\/pre>\n<\/td>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\"><span style=\"color: #008800; font-weight: bold;\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold;\">com.badlogic.gdx.Gdx<\/span><span style=\"color: #333333;\">;<\/span><br \/><span style=\"color: #008800; font-weight: bold;\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold;\">com.badlogic.gdx.Input<\/span><span style=\"color: #333333;\">;<\/span><br \/><span style=\"color: #008800; font-weight: bold;\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold;\">com.badlogic.gdx.InputProcessor<\/span><span style=\"color: #333333;\">;<\/span><br \/><span style=\"color: #008800; font-weight: bold;\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold;\">com.badlogic.gdx.Screen<\/span><span style=\"color: #333333;\">;<\/span><br \/><span style=\"color: #008800; font-weight: bold;\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold;\">com.badlogic.gdx.graphics.GL20<\/span><span style=\"color: #333333;\">;<\/span><br \/><span style=\"color: #008800; font-weight: bold;\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold;\">com.badlogic.gdx.graphics.OrthographicCamera<\/span><span style=\"color: #333333;\">;<\/span><br \/><br \/><br \/><span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #008800; font-weight: bold;\">class<\/span> <span style=\"color: #bb0066; font-weight: bold;\">GameScreen<\/span> <span style=\"color: #008800; font-weight: bold;\">implements<\/span> Screen<span style=\"color: #333333;\">,<\/span>InputProcessor <span style=\"color: #333333;\">{<\/span><br \/>    <br \/>    <span style=\"color: #888888;\">\/\/Creates a reference to hold our \"passed\" game.<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">private<\/span> MyGdxGame game<span style=\"color: #333333;\">;<\/span><br \/><br \/>    <span style=\"color: #888888;\">\/\/Defining the camera to be used<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">private<\/span> OrthographicCamera camera<span style=\"color: #333333;\">;<\/span><br \/><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #0066bb; font-weight: bold;\">GameScreen<\/span><span style=\"color: #333333;\">(<\/span>MyGdxGame game<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span><br \/>        <span style=\"color: #888888;\">\/\/assigns the game we passed to the placeholder<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">this<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">game<\/span> <span style=\"color: #333333;\">=<\/span> game<span style=\"color: #333333;\">;<\/span><br \/>        <span style=\"color: #888888;\">\/\/creates the camera<\/span><br \/>        camera <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> OrthographicCamera<span style=\"color: #333333;\">();<\/span><br \/>        <span style=\"color: #888888;\">\/\/Sets the screen to be 800 width by 480 height<\/span><br \/>        camera<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">setToOrtho<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #008800; font-weight: bold;\">false<\/span><span style=\"color: #333333;\">,<\/span> <span style=\"color: #0000dd; font-weight: bold;\">480<\/span><span style=\"color: #333333;\">,<\/span> <span style=\"color: #0000dd; font-weight: bold;\">800<\/span><span style=\"color: #333333;\">);<\/span><br \/>        <span style=\"color: #888888;\">\/\/very important, lets us use the Input methods!<\/span><br \/>        Gdx<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">input<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">setInputProcessor<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #008800; font-weight: bold;\">this<\/span><span style=\"color: #333333;\">);<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/>    <span style=\"color: #555555; font-weight: bold;\">@Override<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">render<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #333399; font-weight: bold;\">float<\/span> deltaTime<span style=\"color: #333333;\">){<\/span><br \/>        <span style=\"color: #888888;\">\/\/Sets the color to be applied after clearing the screen (R,G,B,A)<\/span><br \/>        Gdx<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gl<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">glClearColor<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">255<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">1<\/span><span style=\"color: #333333;\">);<\/span><br \/>        <span style=\"color: #888888;\">\/\/Clears the screen<\/span><br \/>        Gdx<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gl<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">glClear<\/span><span style=\"color: #333333;\">(<\/span>GL20<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">GL_COLOR_BUFFER_BIT<\/span><span style=\"color: #333333;\">);<\/span><br \/>        <span style=\"color: #888888;\">\/\/updates camera view<\/span><br \/>        camera<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">update<\/span><span style=\"color: #333333;\">();<\/span><br \/>        <span style=\"color: #888888;\">\/\/makes the camera fit onto the available screen<\/span><br \/>        game<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gameBatch<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">setProjectionMatrix<\/span><span style=\"color: #333333;\">(<\/span>camera<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">combined<\/span><span style=\"color: #333333;\">);<\/span><br \/>        <span style=\"color: #888888;\">\/\/Starts gameBatch for drawing<\/span><br \/>        game<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gameBatch<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">begin<\/span><span style=\"color: #333333;\">();<\/span><br \/>        <span style=\"color: #888888;\">\/\/All drawing needs to be done here<\/span><br \/>        <span style=\"color: #888888;\">\/\/Ends the gameBatch after drawing<\/span><br \/>        game<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gameBatch<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">end<\/span><span style=\"color: #333333;\">();<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/>    <span style=\"color: #888888;\">\/\/This method gets called when a key is pressed down<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">boolean<\/span> <span style=\"color: #0066bb; font-weight: bold;\">keyDown<\/span> <span style=\"color: #333333;\">(<\/span><span style=\"color: #333399; font-weight: bold;\">int<\/span> keycode<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span><br \/>        <span style=\"color: #888888;\">\/\/switches case for keycode variable<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">switch<\/span> <span style=\"color: #333333;\">(<\/span>keycode<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span><br \/>            <span style=\"color: #888888;\">\/\/if left key is pressed<\/span><br \/>            <span style=\"color: #008800; font-weight: bold;\">case<\/span> Input<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">Keys<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">LEFT<\/span><span style=\"color: #333333;\">:<\/span><br \/>                <span style=\"color: #008800; font-weight: bold;\">break<\/span><span style=\"color: #333333;\">;<\/span><br \/>            <span style=\"color: #008800; font-weight: bold;\">case<\/span> Input<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">Keys<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">RIGHT<\/span><span style=\"color: #333333;\">:<\/span><br \/>                <span style=\"color: #008800; font-weight: bold;\">break<\/span><span style=\"color: #333333;\">;<\/span><br \/>            <span style=\"color: #008800; font-weight: bold;\">case<\/span> Input<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">Keys<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">UP<\/span><span style=\"color: #333333;\">:<\/span><br \/>                <span style=\"color: #008800; font-weight: bold;\">break<\/span><span style=\"color: #333333;\">;<\/span><br \/>            <span style=\"color: #008800; font-weight: bold;\">case<\/span> Input<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">Keys<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">DOWN<\/span><span style=\"color: #333333;\">:<\/span><br \/>                <span style=\"color: #008800; font-weight: bold;\">break<\/span><span style=\"color: #333333;\">;<\/span><br \/>            <span style=\"color: #008800; font-weight: bold;\">default<\/span><span style=\"color: #333333;\">:<\/span><br \/>        <span style=\"color: #333333;\">}<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">return<\/span> <span style=\"color: #008800; font-weight: bold;\">false<\/span><span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/>    <span style=\"color: #888888;\">\/\/happens upon lifting finger off of key<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">boolean<\/span> <span style=\"color: #0066bb; font-weight: bold;\">keyUp<\/span> <span style=\"color: #333333;\">(<\/span><span style=\"color: #333399; font-weight: bold;\">int<\/span> keycode<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span><br \/>        <span style=\"color: #888888;\">\/\/switches key code of lifted key<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">switch<\/span> <span style=\"color: #333333;\">(<\/span>keycode<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span><br \/>            <span style=\"color: #888888;\">\/\/called upon left key lifted<\/span><br \/>            <span style=\"color: #008800; font-weight: bold;\">case<\/span> Input<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">Keys<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">LEFT<\/span><span style=\"color: #333333;\">:<\/span><br \/>                <span style=\"color: #008800; font-weight: bold;\">break<\/span><span style=\"color: #333333;\">;<\/span><br \/>            <span style=\"color: #008800; font-weight: bold;\">case<\/span> Input<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">Keys<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">RIGHT<\/span><span style=\"color: #333333;\">:<\/span><br \/>                <span style=\"color: #008800; font-weight: bold;\">break<\/span><span style=\"color: #333333;\">;<\/span><br \/>            <span style=\"color: #008800; font-weight: bold;\">case<\/span> Input<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">Keys<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">UP<\/span><span style=\"color: #333333;\">:<\/span><br \/>                <span style=\"color: #008800; font-weight: bold;\">break<\/span><span style=\"color: #333333;\">;<\/span><br \/>            <span style=\"color: #008800; font-weight: bold;\">case<\/span> Input<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">Keys<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">DOWN<\/span><span style=\"color: #333333;\">:<\/span><br \/>                <span style=\"color: #008800; font-weight: bold;\">break<\/span><span style=\"color: #333333;\">;<\/span><br \/>            <span style=\"color: #008800; font-weight: bold;\">default<\/span><span style=\"color: #333333;\">:<\/span><br \/>        <span style=\"color: #333333;\">}<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">return<\/span> <span style=\"color: #008800; font-weight: bold;\">false<\/span><span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">boolean<\/span> <span style=\"color: #0066bb; font-weight: bold;\">touchDown<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #333399; font-weight: bold;\">int<\/span> screenX<span style=\"color: #333333;\">,<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> screenY<span style=\"color: #333333;\">,<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> pointer<span style=\"color: #333333;\">,<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> button<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">return<\/span> <span style=\"color: #008800; font-weight: bold;\">false<\/span><span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">boolean<\/span> <span style=\"color: #0066bb; font-weight: bold;\">keyTyped<\/span> <span style=\"color: #333333;\">(<\/span><span style=\"color: #333399; font-weight: bold;\">char<\/span> character<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">return<\/span> <span style=\"color: #008800; font-weight: bold;\">false<\/span><span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">boolean<\/span> <span style=\"color: #0066bb; font-weight: bold;\">touchUp<\/span> <span style=\"color: #333333;\">(<\/span><span style=\"color: #333399; font-weight: bold;\">int<\/span> x<span style=\"color: #333333;\">,<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> y<span style=\"color: #333333;\">,<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> pointer<span style=\"color: #333333;\">,<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> button<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">return<\/span> <span style=\"color: #008800; font-weight: bold;\">false<\/span><span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">boolean<\/span> <span style=\"color: #0066bb; font-weight: bold;\">touchDragged<\/span> <span style=\"color: #333333;\">(<\/span><span style=\"color: #333399; font-weight: bold;\">int<\/span> x<span style=\"color: #333333;\">,<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> y<span style=\"color: #333333;\">,<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> pointer<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">return<\/span> <span style=\"color: #008800; font-weight: bold;\">false<\/span><span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">boolean<\/span> <span style=\"color: #0066bb; font-weight: bold;\">mouseMoved<\/span> <span style=\"color: #333333;\">(<\/span><span style=\"color: #333399; font-weight: bold;\">int<\/span> x<span style=\"color: #333333;\">,<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> y<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">return<\/span> <span style=\"color: #008800; font-weight: bold;\">false<\/span><span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">boolean<\/span> <span style=\"color: #0066bb; font-weight: bold;\">scrolled<\/span> <span style=\"color: #333333;\">(<\/span><span style=\"color: #333399; font-weight: bold;\">int<\/span> amount<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">return<\/span> <span style=\"color: #008800; font-weight: bold;\">false<\/span><span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/>    <span style=\"color: #555555; font-weight: bold;\">@Override<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">resize<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #333399; font-weight: bold;\">int<\/span> width<span style=\"color: #333333;\">,<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> height<span style=\"color: #333333;\">){<\/span><br \/><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/>    <span style=\"color: #555555; font-weight: bold;\">@Override<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">show<\/span><span style=\"color: #333333;\">(){<\/span><br \/><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/>    <span style=\"color: #555555; font-weight: bold;\">@Override<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">hide<\/span><span style=\"color: #333333;\">(){<\/span><br \/><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/>    <span style=\"color: #555555; font-weight: bold;\">@Override<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">pause<\/span><span style=\"color: #333333;\">(){<\/span><br \/><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/>    <span style=\"color: #555555; font-weight: bold;\">@Override<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">resume<\/span><span style=\"color: #333333;\">(){<\/span><br \/><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/>    <span style=\"color: #555555; font-weight: bold;\">@Override<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">dispose<\/span><span style=\"color: #333333;\">(){<\/span><br \/><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/><span style=\"color: #333333;\">}<\/span><br \/><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>So this is the skeleton that we will create our game from. It is time to start developing towards our game, and to do that, lets start with drawing our background onto the screen. First, lets place our assets into the game so we can access them, to do this, simply drag your .png graphic files (needs to be .png!) to the assets folder under the android directory. For example on my p.c, my graphics assets are located at (C:UsersGodDocumentsLIBgdxIcicleMayhemandroidassets).<\/p>\n<p>Thus, to get started, define the following new variable at the top of the GameScreen class:<br \/><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;\">\n<table>\n<tbody>\n<tr>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\">1<br \/>2<\/pre>\n<\/td>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\"><span style=\"color: #888888;\">\/\/Texture for the cave background<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">private<\/span> Texture caveBackground <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> Texture<span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"cavebackground.png\"<\/span><span style=\"color: #333333;\">);<\/span><br \/><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>Then place the following code in the render() function in the GameScreen section:<br \/><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;\">\n<table>\n<tbody>\n<tr>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\">1<br \/>2<br \/>3<br \/>4<br \/>5<br \/>6<br \/>7<\/pre>\n<\/td>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\">        <span style=\"color: #888888;\">\/\/Starts gameBatch for drawing<\/span><br \/>        game<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gameBatch<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">begin<\/span><span style=\"color: #333333;\">();<\/span><br \/>        <span style=\"color: #888888;\">\/\/All drawing needs to be done here<\/span><br \/>        <span style=\"color: #888888;\">\/\/Draws the Cave Background starting at x = 0, y = 0<\/span><br \/>        game<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gameBatch<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">draw<\/span><span style=\"color: #333333;\">(<\/span>caveBackground<span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">);<\/span><br \/>        <span style=\"color: #888888;\">\/\/Ends the gameBatch after drawing<\/span><br \/>        game<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gameBatch<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">end<\/span><span style=\"color: #333333;\">();<\/span><br \/><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>Then you may test your app either by running in desktop mode (I have a tutorial as well as many others on how to set it up) or deploying to your phone. The result should be a game that displays are cave background:<\/p>\n<div style=\"clear: both; text-align: center;\"><\/div>\n<div style=\"clear: both; text-align: center;\"><a href=\"http:\/\/1.bp.blogspot.com\/-_CbmVMMQ424\/VdSlcXlBpkI\/AAAAAAAAAaA\/hWA9Xu0IepI\/s1600\/Capture343.PNG\" style=\"margin-left: 1em; margin-right: 1em;\"><img decoding=\"async\" border=\"0\" src=\"https:\/\/1.bp.blogspot.com\/-_CbmVMMQ424\/VdSlcXlBpkI\/AAAAAAAAAaA\/hWA9Xu0IepI\/s1600\/Capture343.PNG\" \/><\/a><\/div>\n<p>Note: if running it straight to your android phone, the default screen layout is landscape. You will need to change it to portrait by editing the androidmanifest.xml file and change the layout attribute:<br \/><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;\">\n<table>\n<tbody>\n<tr>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\">1<\/pre>\n<\/td>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\"><span style=\"color: #997700; font-weight: bold;\">android:<\/span>screenOrientation<span style=\"color: #333333;\">=<\/span><span style=\"background-color: #fff0f0;\">\"portrait\"<\/span><br \/><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p><b>Step 5:<\/b><br \/>Creating the character!<br \/>First we are going to create another java class so that we may make our character an object in java. To do this, create another class in the same directory named Character.java and place the following code into it. It is commented for what each portion of the code is doing.<br \/><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;\">\n<table>\n<tbody>\n<tr>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\"> 1<br \/> 2<br \/> 3<br \/> 4<br \/> 5<br \/> 6<br \/> 7<br \/> 8<br \/> 9<br \/>10<br \/>11<br \/>12<br \/>13<br \/>14<br \/>15<br \/>16<br \/>17<br \/>18<br \/>19<br \/>20<br \/>21<br \/>22<br \/>23<br \/>24<br \/>25<br \/>26<br \/>27<br \/>28<br \/>29<br \/>30<br \/>31<br \/>32<br \/>33<br \/>34<br \/>35<br \/>36<br \/>37<br \/>38<br \/>39<br \/>40<br \/>41<br \/>42<br \/>43<br \/>44<br \/>45<br \/>46<br \/>47<br \/>48<br \/>49<br \/>50<br \/>51<br \/>52<\/pre>\n<\/td>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\"><span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #008800; font-weight: bold;\">class<\/span> <span style=\"color: #bb0066; font-weight: bold;\">Character<\/span> <span style=\"color: #333333;\">{<\/span><br \/>    <span style=\"color: #888888;\">\/\/stores x loc (start at 240)<\/span><br \/>    <span style=\"color: #333399; font-weight: bold;\">int<\/span> x <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">240<\/span><span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #888888;\">\/\/stores y loc (start at 167)<\/span><br \/>    <span style=\"color: #333399; font-weight: bold;\">int<\/span> y <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">167<\/span><span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #888888;\">\/\/texture for our character<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> Texture texture <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> Texture<span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"guy.png\"<\/span><span style=\"color: #333333;\">);<\/span><br \/>    <span style=\"color: #888888;\">\/\/speed for our character in pixels\/s<\/span><br \/>    <span style=\"color: #333399; font-weight: bold;\">int<\/span> speed <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">300<\/span><span style=\"color: #333333;\">;<\/span><br \/>    <br \/>    <span style=\"color: #888888;\">\/\/defining constants for direction<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">static<\/span> <span style=\"color: #008800; font-weight: bold;\">final<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> LEFT <span style=\"color: #333333;\">=<\/span> <span style=\"color: #333333;\">-<\/span><span style=\"color: #0000dd; font-weight: bold;\">1<\/span><span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">static<\/span> <span style=\"color: #008800; font-weight: bold;\">final<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> RIGHT <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">1<\/span><span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">static<\/span> <span style=\"color: #008800; font-weight: bold;\">final<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> STANDING <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #333399; font-weight: bold;\">int<\/span> direction <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">;<\/span><br \/><br \/>    <span style=\"color: #888888;\">\/\/initialization code<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #0066bb; font-weight: bold;\">Character<\/span><span style=\"color: #333333;\">(){}<\/span><br \/><br \/>    <span style=\"color: #888888;\">\/\/updates character's position<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">update<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #333399; font-weight: bold;\">float<\/span> deltaTime<span style=\"color: #333333;\">){<\/span><br \/>        <span style=\"color: #888888;\">\/\/stores the value of the last x<\/span><br \/>        <span style=\"color: #333399; font-weight: bold;\">int<\/span> lastx <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">this<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">x<\/span><span style=\"color: #333333;\">;<\/span><br \/>        <span style=\"color: #888888;\">\/\/change in distance = direction * speed * time<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">this<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">x<\/span> <span style=\"color: #333333;\">+=<\/span> direction<span style=\"color: #333333;\">*<\/span>speed<span style=\"color: #333333;\">*<\/span>deltaTime<span style=\"color: #333333;\">;<\/span><br \/>        <span style=\"color: #888888;\">\/\/if the new location of the character is off the screen to the left<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">if<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #008800; font-weight: bold;\">this<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">x<\/span> <span style=\"color: #333333;\">&lt;<\/span> <span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">){<\/span><br \/>            <span style=\"color: #888888;\">\/\/put the character back to last location<\/span><br \/>            <span style=\"color: #008800; font-weight: bold;\">this<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">x<\/span> <span style=\"color: #333333;\">=<\/span> lastx<span style=\"color: #333333;\">;<\/span><br \/>        <span style=\"color: #333333;\">}<\/span><br \/>        <span style=\"color: #888888;\">\/\/if the new location of the character is off the screen to the right<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">if<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #008800; font-weight: bold;\">this<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">x<\/span> <span style=\"color: #333333;\">&gt;<\/span> <span style=\"color: #0000dd; font-weight: bold;\">480<\/span> <span style=\"color: #333333;\">-<\/span> texture<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">getWidth<\/span><span style=\"color: #333333;\">()){<\/span><br \/>            <span style=\"color: #888888;\">\/\/put the character back to last location<\/span><br \/>            <span style=\"color: #008800; font-weight: bold;\">this<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">x<\/span> <span style=\"color: #333333;\">=<\/span> lastx<span style=\"color: #333333;\">;<\/span><br \/>        <span style=\"color: #333333;\">}<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/>    <span style=\"color: #888888;\">\/\/changes the character direction to right<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">goRight<\/span><span style=\"color: #333333;\">(){<\/span><br \/>        direction <span style=\"color: #333333;\">=<\/span> RIGHT<span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/>    <span style=\"color: #888888;\">\/\/changes character direction to left<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">goLeft<\/span><span style=\"color: #333333;\">(){<\/span><br \/>        direction <span style=\"color: #333333;\">=<\/span> LEFT<span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/>    <span style=\"color: #888888;\">\/\/changes character direction to standing<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">setStanding<\/span><span style=\"color: #333333;\">(){<\/span><br \/>        direction <span style=\"color: #333333;\">=<\/span> STANDING<span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><span style=\"color: #333333;\">}<\/span><br \/><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>Now that we have an object for our character, we need to make the object in our game screen. We can create our object by defining him as such:<br \/><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;\">\n<table>\n<tbody>\n<tr>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\">1<br \/>2<\/pre>\n<\/td>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\">    <span style=\"color: #888888;\">\/\/Creates a Reference for our character<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">private<\/span> Character character <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> Character<span style=\"color: #333333;\">();<\/span><br \/><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>Now we must also update him within the game, allowing him to move across time. We then place a call for him to update within the Render block in the GameScreen.Java class but before we draw him. Thus, at the end of the render function in the GameScreen class, it should look similar to this:<br \/><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;\">\n<table>\n<tbody>\n<tr>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\"> 1<br \/> 2<br \/> 3<br \/> 4<br \/> 5<br \/> 6<br \/> 7<br \/> 8<br \/> 9<br \/>10<br \/>11<\/pre>\n<\/td>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\">        <span style=\"color: #888888;\">\/\/updates the character<\/span><br \/>        character<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">update<\/span><span style=\"color: #333333;\">(<\/span>deltaTime<span style=\"color: #333333;\">);<\/span><br \/>        <span style=\"color: #888888;\">\/\/Starts gameBatch for drawing<\/span><br \/>        game<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gameBatch<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">begin<\/span><span style=\"color: #333333;\">();<\/span><br \/>        <span style=\"color: #888888;\">\/\/All drawing needs to be done here<\/span><br \/>        <span style=\"color: #888888;\">\/\/Draws the Cave Background starting at x = 0, y = 0<\/span><br \/>        game<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gameBatch<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">draw<\/span><span style=\"color: #333333;\">(<\/span>caveBackground<span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">);<\/span><br \/>        <span style=\"color: #888888;\">\/\/Draws the character at correct location<\/span><br \/>        game<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gameBatch<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">draw<\/span><span style=\"color: #333333;\">(<\/span>character<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">texture<\/span><span style=\"color: #333333;\">,<\/span>character<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">x<\/span><span style=\"color: #333333;\">,<\/span>character<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">y<\/span><span style=\"color: #333333;\">);<\/span><br \/>        <span style=\"color: #888888;\">\/\/Ends the gameBatch after drawing<\/span><br \/>        game<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gameBatch<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">end<\/span><span style=\"color: #333333;\">();<\/span><br \/><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>Now, we also need a way to process either key presses from a key board or screen touches from fingers. For screen presses, we call a function in the render block to check for the current location of the finger and to determine the direction the character should go, the function call in the render block and the function are as follows including the additional coding needed for key presses:<br \/><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;\">\n<table>\n<tbody>\n<tr>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\"> 1<br \/> 2<br \/> 3<br \/> 4<br \/> 5<br \/> 6<br \/> 7<br \/> 8<br \/> 9<br \/>10<br \/>11<br \/>12<br \/>13<br \/>14<br \/>15<br \/>16<br \/>17<br \/>18<br \/>19<br \/>20<br \/>21<br \/>22<br \/>23<br \/>24<br \/>25<br \/>26<br \/>27<br \/>28<br \/>29<br \/>30<br \/>31<br \/>32<br \/>33<br \/>34<br \/>35<br \/>36<br \/>37<br \/>38<br \/>39<br \/>40<br \/>41<br \/>42<br \/>43<br \/>44<br \/>45<br \/>46<br \/>47<br \/>48<br \/>49<br \/>50<br \/>51<br \/>52<br \/>53<br \/>54<br \/>55<br \/>56<br \/>57<br \/>58<br \/>59<br \/>60<br \/>61<br \/>62<br \/>63<br \/>64<br \/>65<br \/>66<br \/>67<br \/>68<br \/>69<br \/>70<br \/>71<br \/>72<\/pre>\n<\/td>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\"><span style=\"color: #555555; font-weight: bold;\">@Override<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">render<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #333399; font-weight: bold;\">float<\/span> deltaTime<span style=\"color: #333333;\">){<\/span><br \/>        <span style=\"color: #888888;\">\/\/Sets the color to be applied after clearing the screen (R,G,B,A)<\/span><br \/>        Gdx<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gl<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">glClearColor<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">255<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">1<\/span><span style=\"color: #333333;\">);<\/span><br \/>        <span style=\"color: #888888;\">\/\/Clears the screen<\/span><br \/>        Gdx<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gl<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">glClear<\/span><span style=\"color: #333333;\">(<\/span>GL20<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">GL_COLOR_BUFFER_BIT<\/span><span style=\"color: #333333;\">);<\/span><br \/>        <span style=\"color: #888888;\">\/\/updates camera view<\/span><br \/>        camera<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">update<\/span><span style=\"color: #333333;\">();<\/span><br \/>        <span style=\"color: #888888;\">\/\/makes the camera fit onto the available screen<\/span><br \/>        game<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gameBatch<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">setProjectionMatrix<\/span><span style=\"color: #333333;\">(<\/span>camera<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">combined<\/span><span style=\"color: #333333;\">);<\/span><br \/>        <span style=\"color: #888888;\">\/\/checks if teh screen is pressed<\/span><br \/>        checkScreenPress<span style=\"color: #333333;\">();<\/span><br \/>        <span style=\"color: #888888;\">\/\/updates the character<\/span><br \/>        character<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">update<\/span><span style=\"color: #333333;\">(<\/span>deltaTime<span style=\"color: #333333;\">);<\/span><br \/>        <span style=\"color: #888888;\">\/\/Starts gameBatch for drawing<\/span><br \/>        game<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gameBatch<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">begin<\/span><span style=\"color: #333333;\">();<\/span><br \/>        <span style=\"color: #888888;\">\/\/All drawing needs to be done here<\/span><br \/>        <span style=\"color: #888888;\">\/\/Draws the Cave Background starting at x = 0, y = 0<\/span><br \/>        game<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gameBatch<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">draw<\/span><span style=\"color: #333333;\">(<\/span>caveBackground<span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">);<\/span><br \/>        <span style=\"color: #888888;\">\/\/Draws the character at correct location<\/span><br \/>        game<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gameBatch<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">draw<\/span><span style=\"color: #333333;\">(<\/span>character<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">texture<\/span><span style=\"color: #333333;\">,<\/span>character<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">x<\/span><span style=\"color: #333333;\">,<\/span>character<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">y<\/span><span style=\"color: #333333;\">);<\/span><br \/>        <span style=\"color: #888888;\">\/\/Ends the gameBatch after drawing<\/span><br \/>        game<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gameBatch<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">end<\/span><span style=\"color: #333333;\">();<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/><span style=\"color: #888888;\">\/\/checks if the screen is pressed<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">checkScreenPress<\/span><span style=\"color: #333333;\">(){<\/span><br \/>        <span style=\"color: #888888;\">\/\/if screen is pressed<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">if<\/span><span style=\"color: #333333;\">(<\/span>Gdx<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">input<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">isTouched<\/span><span style=\"color: #333333;\">())<\/span> <span style=\"color: #333333;\">{<\/span><br \/>            <span style=\"color: #888888;\">\/\/gets the location of the press, and determines which half of the screen was pressed<\/span><br \/>            <span style=\"color: #008800; font-weight: bold;\">if<\/span> <span style=\"color: #333333;\">((<\/span><span style=\"color: #333399; font-weight: bold;\">float<\/span><span style=\"color: #333333;\">)<\/span> Gdx<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">input<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">getX<\/span><span style=\"color: #333333;\">()<\/span> <span style=\"color: #333333;\">\/<\/span> Gdx<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">graphics<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">getWidth<\/span><span style=\"color: #333333;\">()<\/span> <span style=\"color: #333333;\">&lt;=<\/span> <span style=\"color: #333333;\">.<\/span><span style=\"color: #0000dd; font-weight: bold;\">5<\/span><span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span><br \/>                <span style=\"color: #888888;\">\/\/if left half of screen, go left<\/span><br \/>                character<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">goLeft<\/span><span style=\"color: #333333;\">();<\/span><br \/>            <span style=\"color: #333333;\">}<\/span> <span style=\"color: #008800; font-weight: bold;\">else<\/span> <span style=\"color: #333333;\">{<\/span><br \/>                <span style=\"color: #888888;\">\/\/if not on the left half of screen, it must be going right<\/span><br \/>                character<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">goRight<\/span><span style=\"color: #333333;\">();<\/span><br \/>            <span style=\"color: #333333;\">}<\/span><br \/>        <span style=\"color: #333333;\">}<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/><span style=\"color: #888888;\">\/\/called when the person lifts their finger off of the screen<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">boolean<\/span> <span style=\"color: #0066bb; font-weight: bold;\">touchUp<\/span> <span style=\"color: #333333;\">(<\/span><span style=\"color: #333399; font-weight: bold;\">int<\/span> x<span style=\"color: #333333;\">,<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> y<span style=\"color: #333333;\">,<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> pointer<span style=\"color: #333333;\">,<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> button<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span><br \/>        <span style=\"color: #888888;\">\/\/set character to standing<\/span><br \/>        character<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">setStanding<\/span><span style=\"color: #333333;\">();<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">return<\/span> <span style=\"color: #008800; font-weight: bold;\">false<\/span><span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/><br \/><span style=\"color: #888888;\">\/\/This method gets called when a key is pressed down<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">boolean<\/span> <span style=\"color: #0066bb; font-weight: bold;\">keyDown<\/span> <span style=\"color: #333333;\">(<\/span><span style=\"color: #333399; font-weight: bold;\">int<\/span> keycode<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span><br \/>        <span style=\"color: #888888;\">\/\/switches case for keycode variable<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">switch<\/span> <span style=\"color: #333333;\">(<\/span>keycode<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span><br \/>            <span style=\"color: #888888;\">\/\/if left key is pressed<\/span><br \/>            <span style=\"color: #008800; font-weight: bold;\">case<\/span> Input<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">Keys<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">LEFT<\/span><span style=\"color: #333333;\">:<\/span><br \/>                <span style=\"color: #888888;\">\/\/sets character going left<\/span><br \/>                character<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">goLeft<\/span><span style=\"color: #333333;\">();<\/span><br \/>                <span style=\"color: #008800; font-weight: bold;\">break<\/span><span style=\"color: #333333;\">;<\/span><br \/>            <span style=\"color: #008800; font-weight: bold;\">case<\/span> Input<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">Keys<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">RIGHT<\/span><span style=\"color: #333333;\">:<\/span><br \/>                <span style=\"color: #888888;\">\/\/sets character going right<\/span><br \/>                character<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">goRight<\/span><span style=\"color: #333333;\">();<\/span><br \/>                <span style=\"color: #008800; font-weight: bold;\">break<\/span><span style=\"color: #333333;\">;<\/span><br \/>            <span style=\"color: #008800; font-weight: bold;\">default<\/span><span style=\"color: #333333;\">:<\/span><br \/>        <span style=\"color: #333333;\">}<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">return<\/span> <span style=\"color: #008800; font-weight: bold;\">false<\/span><span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/>    <span style=\"color: #888888;\">\/\/happens upon lifting finger off of key<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">boolean<\/span> <span style=\"color: #0066bb; font-weight: bold;\">keyUp<\/span> <span style=\"color: #333333;\">(<\/span><span style=\"color: #333399; font-weight: bold;\">int<\/span> keycode<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span><br \/>        <span style=\"color: #888888;\">\/\/sets character standing upon lifting off of key<\/span><br \/>        character<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">setStanding<\/span><span style=\"color: #333333;\">();<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">return<\/span> <span style=\"color: #008800; font-weight: bold;\">false<\/span><span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>Now upon testing your application, you can move the character on a 1D plane, with boundaries at the walls.<\/p>\n<div style=\"clear: both; text-align: center;\"><a href=\"http:\/\/4.bp.blogspot.com\/-63HtBJri5rs\/VdTM8tRXMNI\/AAAAAAAAAaM\/D_-gxgc4pGg\/s1600\/fads.PNG\" style=\"margin-left: 1em; margin-right: 1em;\"><img decoding=\"async\" border=\"0\" src=\"https:\/\/4.bp.blogspot.com\/-63HtBJri5rs\/VdTM8tRXMNI\/AAAAAAAAAaM\/D_-gxgc4pGg\/s1600\/fads.PNG\" \/><\/a><\/div>\n<p><b>Step 6:<\/b><br \/>It is now starting to take shape, now we are going to add icicles that spawn from the ceiling and drop at intervals. The first step is to create an Icicle.java class so that we may create an icicle object. We do that by the following:<br \/><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;\">\n<table>\n<tbody>\n<tr>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\"> 1<br \/> 2<br \/> 3<br \/> 4<br \/> 5<br \/> 6<br \/> 7<br \/> 8<br \/> 9<br \/>10<br \/>11<br \/>12<br \/>13<br \/>14<br \/>15<br \/>16<br \/>17<br \/>18<br \/>19<br \/>20<br \/>21<br \/>22<br \/>23<br \/>24<br \/>25<br \/>26<br \/>27<br \/>28<br \/>29<br \/>30<br \/>31<br \/>32<br \/>33<br \/>34<br \/>35<br \/>36<br \/>37<br \/>38<br \/>39<br \/>40<br \/>41<br \/>42<br \/>43<br \/>44<br \/>45<br \/>46<\/pre>\n<\/td>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\"><span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #008800; font-weight: bold;\">class<\/span> <span style=\"color: #bb0066; font-weight: bold;\">Icicle<\/span> <span style=\"color: #333333;\">{<\/span><br \/>    <span style=\"color: #888888;\">\/\/variables for x location, y location, and speed of dropping<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> x<span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> y<span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> speed<span style=\"color: #333333;\">;<\/span><br \/><br \/>    <span style=\"color: #888888;\">\/\/codes for the three different icicle types<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">static<\/span> <span style=\"color: #008800; font-weight: bold;\">final<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> typeA <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">static<\/span> <span style=\"color: #008800; font-weight: bold;\">final<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> typeB <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">1<\/span><span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">static<\/span> <span style=\"color: #008800; font-weight: bold;\">final<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> typeC <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">2<\/span><span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> code<span style=\"color: #333333;\">;<\/span><br \/><br \/>    <span style=\"color: #888888;\">\/\/placeholder for icicle texture<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> Texture texture<span style=\"color: #333333;\">;<\/span><br \/><br \/>    <span style=\"color: #888888;\">\/\/initiation code<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #0066bb; font-weight: bold;\">Icicle<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #333399; font-weight: bold;\">int<\/span> x<span style=\"color: #333333;\">,<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> y<span style=\"color: #333333;\">,<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> speed<span style=\"color: #333333;\">,<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> code<span style=\"color: #333333;\">){<\/span><br \/>        <span style=\"color: #888888;\">\/\/setting variables<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">this<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">x<\/span> <span style=\"color: #333333;\">=<\/span> x<span style=\"color: #333333;\">;<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">this<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">y<\/span> <span style=\"color: #333333;\">=<\/span> y<span style=\"color: #333333;\">;<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">this<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">speed<\/span> <span style=\"color: #333333;\">=<\/span> speed<span style=\"color: #333333;\">;<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">this<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">code<\/span> <span style=\"color: #333333;\">=<\/span> code<span style=\"color: #333333;\">;<\/span><br \/><br \/>        <span style=\"color: #888888;\">\/\/sets texture to icicle depending on code<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">switch<\/span><span style=\"color: #333333;\">(<\/span>code<span style=\"color: #333333;\">){<\/span><br \/>            <span style=\"color: #008800; font-weight: bold;\">case<\/span> <span style=\"color: #997700; font-weight: bold;\">typeA:<\/span><br \/>                <span style=\"color: #008800; font-weight: bold;\">this<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">texture<\/span> <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> Texture<span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"icicleA.png\"<\/span><span style=\"color: #333333;\">);<\/span><br \/>                <span style=\"color: #008800; font-weight: bold;\">break<\/span><span style=\"color: #333333;\">;<\/span><br \/>            <span style=\"color: #008800; font-weight: bold;\">case<\/span> <span style=\"color: #997700; font-weight: bold;\">typeB:<\/span><br \/>                <span style=\"color: #008800; font-weight: bold;\">this<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">texture<\/span> <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> Texture<span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"icicleB.png\"<\/span><span style=\"color: #333333;\">);<\/span><br \/>                <span style=\"color: #008800; font-weight: bold;\">break<\/span><span style=\"color: #333333;\">;<\/span><br \/>            <span style=\"color: #008800; font-weight: bold;\">case<\/span> <span style=\"color: #997700; font-weight: bold;\">typeC:<\/span><br \/>                <span style=\"color: #008800; font-weight: bold;\">this<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">texture<\/span> <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> Texture<span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"icicleC.png\"<\/span><span style=\"color: #333333;\">);<\/span><br \/>                <span style=\"color: #008800; font-weight: bold;\">break<\/span><span style=\"color: #333333;\">;<\/span><br \/>        <span style=\"color: #333333;\">}<\/span><br \/><br \/>        <span style=\"color: #888888;\">\/\/changes the y value so that irregardless of texture height, it will always start on the<\/span><br \/>        <span style=\"color: #888888;\">\/\/the top of the ice cave ceiling.<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">this<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">y<\/span> <span style=\"color: #333333;\">-=<\/span> <span style=\"color: #008800; font-weight: bold;\">this<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">texture<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">getHeight<\/span><span style=\"color: #333333;\">();<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/>    <span style=\"color: #888888;\">\/\/updates icicle's y position as it falls with time;<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">update<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #333399; font-weight: bold;\">float<\/span> deltaTime<span style=\"color: #333333;\">){<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">this<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">y<\/span> <span style=\"color: #333333;\">-=<\/span> speed<span style=\"color: #333333;\">*<\/span>deltaTime<span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><span style=\"color: #333333;\">}<\/span><br \/><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>Next we are going to create an IcicleManager.Java class that will manage the spawn rates of our objects.<br \/><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;\">\n<table>\n<tbody>\n<tr>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\"> 1<br \/> 2<br \/> 3<br \/> 4<br \/> 5<br \/> 6<br \/> 7<br \/> 8<br \/> 9<br \/>10<br \/>11<br \/>12<br \/>13<br \/>14<br \/>15<br \/>16<br \/>17<br \/>18<br \/>19<br \/>20<br \/>21<br \/>22<br \/>23<br \/>24<br \/>25<br \/>26<br \/>27<br \/>28<br \/>29<br \/>30<br \/>31<br \/>32<br \/>33<br \/>34<br \/>35<br \/>36<br \/>37<br \/>38<br \/>39<br \/>40<br \/>41<br \/>42<br \/>43<br \/>44<br \/>45<br \/>46<br \/>47<br \/>48<br \/>49<\/pre>\n<\/td>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\"><span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #008800; font-weight: bold;\">class<\/span> <span style=\"color: #bb0066; font-weight: bold;\">IcicleManager<\/span> <span style=\"color: #333333;\">{<\/span><br \/>    <span style=\"color: #888888;\">\/\/stores the refresh rates set for the icicles<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> aRefreshRate<span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> bRefreshRate<span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> cRefreshRate<span style=\"color: #333333;\">;<\/span><br \/><br \/>    <span style=\"color: #888888;\">\/\/keeps a timer for each icicle type<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">float<\/span> aTimer <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">float<\/span> bTimer <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">float<\/span> cTimer <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">;<\/span><br \/><br \/>    <span style=\"color: #888888;\">\/\/initializes icicle manager with our set refresh rates.<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #0066bb; font-weight: bold;\">IcicleManager<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #333399; font-weight: bold;\">int<\/span> aRefreshRate<span style=\"color: #333333;\">,<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> bRefreshRate<span style=\"color: #333333;\">,<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> cRefreshRate<span style=\"color: #333333;\">){<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">this<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">aRefreshRate<\/span> <span style=\"color: #333333;\">=<\/span> aRefreshRate<span style=\"color: #333333;\">;<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">this<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">bRefreshRate<\/span> <span style=\"color: #333333;\">=<\/span> bRefreshRate<span style=\"color: #333333;\">;<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">this<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">cRefreshRate<\/span> <span style=\"color: #333333;\">=<\/span> cRefreshRate<span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/>    <span style=\"color: #888888;\">\/\/receives the array of icicles and updates and returns the array<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> Array<span style=\"color: #333333;\">&lt;<\/span>Icicle<span style=\"color: #333333;\">&gt;<\/span> <span style=\"color: #0066bb; font-weight: bold;\">update<\/span><span style=\"color: #333333;\">(<\/span>Array<span style=\"color: #333333;\">&lt;<\/span>Icicle<span style=\"color: #333333;\">&gt;<\/span> array<span style=\"color: #333333;\">,<\/span> <span style=\"color: #333399; font-weight: bold;\">float<\/span> deltaTime<span style=\"color: #333333;\">){<\/span><br \/>        <span style=\"color: #888888;\">\/\/add the time passed to our timers<\/span><br \/>        aTimer <span style=\"color: #333333;\">+=<\/span> deltaTime<span style=\"color: #333333;\">;<\/span><br \/>        bTimer <span style=\"color: #333333;\">+=<\/span> deltaTime<span style=\"color: #333333;\">;<\/span><br \/>        cTimer <span style=\"color: #333333;\">+=<\/span> deltaTime<span style=\"color: #333333;\">;<\/span><br \/><br \/>        <span style=\"color: #888888;\">\/\/if timer value is greater than refresh rate<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">if<\/span><span style=\"color: #333333;\">(<\/span>aTimer <span style=\"color: #333333;\">&gt;=<\/span> aRefreshRate<span style=\"color: #333333;\">){<\/span><br \/>            <span style=\"color: #888888;\">\/\/create a new icicle at a random x Loc, 670 height, 300 speed, and a typeA icicle<\/span><br \/>            array<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">add<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #008800; font-weight: bold;\">new<\/span> Icicle<span style=\"color: #333333;\">(<\/span>MathUtils<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">random<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">460<\/span><span style=\"color: #333333;\">),<\/span><span style=\"color: #0000dd; font-weight: bold;\">670<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">300<\/span><span style=\"color: #333333;\">,<\/span>Icicle<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">typeA<\/span><span style=\"color: #333333;\">));<\/span><br \/>            <span style=\"color: #888888;\">\/\/reset Timer<\/span><br \/>            aTimer <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">;<\/span><br \/>        <span style=\"color: #333333;\">}<\/span><br \/>        <span style=\"color: #888888;\">\/\/if timer value is greater than refresh rate<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">if<\/span><span style=\"color: #333333;\">(<\/span>bTimer <span style=\"color: #333333;\">&gt;=<\/span> bRefreshRate<span style=\"color: #333333;\">){<\/span><br \/>            <span style=\"color: #888888;\">\/\/create a new icicle at a random x Loc, 670 height, 300 speed, and a typeB icicle<\/span><br \/>            array<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">add<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #008800; font-weight: bold;\">new<\/span> Icicle<span style=\"color: #333333;\">(<\/span>MathUtils<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">random<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">460<\/span><span style=\"color: #333333;\">),<\/span><span style=\"color: #0000dd; font-weight: bold;\">670<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">300<\/span><span style=\"color: #333333;\">,<\/span>Icicle<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">typeB<\/span><span style=\"color: #333333;\">));<\/span><br \/>            <span style=\"color: #888888;\">\/\/reset Timer<\/span><br \/>            bTimer <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">;<\/span><br \/>        <span style=\"color: #333333;\">}<\/span><br \/>        <span style=\"color: #888888;\">\/\/if timer value is greater than refresh rate<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">if<\/span><span style=\"color: #333333;\">(<\/span>cTimer <span style=\"color: #333333;\">&gt;=<\/span> cRefreshRate<span style=\"color: #333333;\">){<\/span><br \/>            <span style=\"color: #888888;\">\/\/create a new icicle at a random x Loc, 670 height, 300 speed, and a typeB icicle<\/span><br \/>            array<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">add<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #008800; font-weight: bold;\">new<\/span> Icicle<span style=\"color: #333333;\">(<\/span>MathUtils<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">random<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">460<\/span><span style=\"color: #333333;\">),<\/span><span style=\"color: #0000dd; font-weight: bold;\">670<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">300<\/span><span style=\"color: #333333;\">,<\/span>Icicle<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">typeC<\/span><span style=\"color: #333333;\">));<\/span><br \/>            <span style=\"color: #888888;\">\/\/reset Timer<\/span><br \/>            cTimer <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">;<\/span><br \/>        <span style=\"color: #333333;\">}<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">return<\/span> array<span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><span style=\"color: #333333;\">}<\/span><br \/><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>Working our way back to the implementing these classes into the game, we are going to define two more variables in our GameScreen class:<br \/><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;\">\n<table>\n<tbody>\n<tr>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\">1<br \/>2<br \/>3<br \/>4<br \/>5<\/pre>\n<\/td>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\">    <span style=\"color: #888888;\">\/\/Creates our icicle Manager with a description of how long to delay each icicle type<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> IcicleManager icicleManager <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> IcicleManager<span style=\"color: #333333;\">(<\/span><span style=\"color: #0000dd; font-weight: bold;\">2<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">5<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">10<\/span><span style=\"color: #333333;\">);<\/span><br \/><br \/>    <span style=\"color: #888888;\">\/\/creates an array to hold all of our icicles;<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> Array<span style=\"color: #333333;\">&lt;<\/span>Icicle<span style=\"color: #333333;\">&gt;<\/span> icicleArray <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> Array<span style=\"color: #333333;\">&lt;<\/span>Icicle<span style=\"color: #333333;\">&gt;();<\/span><br \/><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>Now we are going to have to add two additions to the render block of our game, one to update our icicles and one to facilitate the drawing of our icicles. The additions and new function are shown below:<br \/><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;\">\n<table>\n<tbody>\n<tr>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\"> 1<br \/> 2<br \/> 3<br \/> 4<br \/> 5<br \/> 6<br \/> 7<br \/> 8<br \/> 9<br \/>10<br \/>11<br \/>12<br \/>13<br \/>14<br \/>15<br \/>16<br \/>17<br \/>18<br \/>19<br \/>20<br \/>21<br \/>22<br \/>23<br \/>24<br \/>25<br \/>26<br \/>27<br \/>28<br \/>29<br \/>30<br \/>31<br \/>32<br \/>33<br \/>34<br \/>35<br \/>36<br \/>37<br \/>38<br \/>39<br \/>40<br \/>41<br \/>42<br \/>43<br \/>44<br \/>45<br \/>46<br \/>47<br \/>48<br \/>49<\/pre>\n<\/td>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\"> <span style=\"color: #555555; font-weight: bold;\">@Override<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">render<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #333399; font-weight: bold;\">float<\/span> deltaTime<span style=\"color: #333333;\">){<\/span><br \/>        <span style=\"color: #888888;\">\/\/Sets the color to be applied after clearing the screen (R,G,B,A)<\/span><br \/>        Gdx<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gl<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">glClearColor<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">255<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">1<\/span><span style=\"color: #333333;\">);<\/span><br \/>        <span style=\"color: #888888;\">\/\/Clears the screen<\/span><br \/>        Gdx<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gl<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">glClear<\/span><span style=\"color: #333333;\">(<\/span>GL20<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">GL_COLOR_BUFFER_BIT<\/span><span style=\"color: #333333;\">);<\/span><br \/>        <span style=\"color: #888888;\">\/\/updates camera view<\/span><br \/>        camera<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">update<\/span><span style=\"color: #333333;\">();<\/span><br \/>        <span style=\"color: #888888;\">\/\/makes the camera fit onto the available screen<\/span><br \/>        game<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gameBatch<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">setProjectionMatrix<\/span><span style=\"color: #333333;\">(<\/span>camera<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">combined<\/span><span style=\"color: #333333;\">);<\/span><br \/>        <span style=\"color: #888888;\">\/\/checks if the screen is pressed<\/span><br \/>        checkScreenPress<span style=\"color: #333333;\">();<\/span><br \/>        <span style=\"color: #888888;\">\/\/updates the character<\/span><br \/>        character<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">update<\/span><span style=\"color: #333333;\">(<\/span>deltaTime<span style=\"color: #333333;\">);<\/span><br \/>        <span style=\"color: #888888;\">\/\/updates Icicle Manager<\/span><br \/>        icicleManager<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">update<\/span><span style=\"color: #333333;\">(<\/span>icicleArray<span style=\"color: #333333;\">,<\/span>deltaTime<span style=\"color: #333333;\">);<\/span><br \/>        <span style=\"color: #888888;\">\/\/Starts gameBatch for drawing<\/span><br \/>        game<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gameBatch<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">begin<\/span><span style=\"color: #333333;\">();<\/span><br \/>        <span style=\"color: #888888;\">\/\/All drawing needs to be done here<\/span><br \/>        <span style=\"color: #888888;\">\/\/Draws the Cave Background starting at x = 0, y = 0<\/span><br \/>        game<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gameBatch<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">draw<\/span><span style=\"color: #333333;\">(<\/span>caveBackground<span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">);<\/span><br \/>        <span style=\"color: #888888;\">\/\/Draws the Icicles<\/span><br \/>        drawIcicles<span style=\"color: #333333;\">(<\/span>deltaTime<span style=\"color: #333333;\">);<\/span><br \/>        <span style=\"color: #888888;\">\/\/Draws the character at correct location<\/span><br \/>        game<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gameBatch<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">draw<\/span><span style=\"color: #333333;\">(<\/span>character<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">texture<\/span><span style=\"color: #333333;\">,<\/span>character<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">x<\/span><span style=\"color: #333333;\">,<\/span>character<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">y<\/span><span style=\"color: #333333;\">);<\/span><br \/>        <span style=\"color: #888888;\">\/\/Ends the gameBatch after drawing<\/span><br \/>        game<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gameBatch<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">end<\/span><span style=\"color: #333333;\">();<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/><span style=\"color: #888888;\">\/\/draws our icicles<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">drawIcicles<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #333399; font-weight: bold;\">float<\/span> deltaTime<span style=\"color: #333333;\">){<\/span><br \/>        <span style=\"color: #888888;\">\/\/creates an iterator which will analyze each icicile<\/span><br \/>        Iterator<span style=\"color: #333333;\">&lt;<\/span>Icicle<span style=\"color: #333333;\">&gt;<\/span> iterIcicle <span style=\"color: #333333;\">=<\/span> icicleArray<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">iterator<\/span><span style=\"color: #333333;\">();<\/span><br \/><br \/>        <span style=\"color: #888888;\">\/\/while there are more icicles to process...<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">while<\/span><span style=\"color: #333333;\">(<\/span>iterIcicle<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">hasNext<\/span><span style=\"color: #333333;\">())<\/span> <span style=\"color: #333333;\">{<\/span><br \/>            <span style=\"color: #888888;\">\/\/move to next icicle and set a reference to our icicle<\/span><br \/>            Icicle icicle <span style=\"color: #333333;\">=<\/span> iterIcicle<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">next<\/span><span style=\"color: #333333;\">();<\/span><br \/>            <span style=\"color: #888888;\">\/\/update our icicle<\/span><br \/>            icicle<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">update<\/span><span style=\"color: #333333;\">(<\/span>deltaTime<span style=\"color: #333333;\">);<\/span><br \/>            <span style=\"color: #888888;\">\/\/if icicle is below y = 0, remove icicle from the array<\/span><br \/>            <span style=\"color: #008800; font-weight: bold;\">if<\/span><span style=\"color: #333333;\">(<\/span>icicle<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">y<\/span> <span style=\"color: #333333;\">&lt;<\/span> <span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">){<\/span><br \/>               iterIcicle<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">remove<\/span><span style=\"color: #333333;\">();<\/span><br \/>            <span style=\"color: #333333;\">}<\/span><span style=\"color: #008800; font-weight: bold;\">else<\/span><span style=\"color: #333333;\">{<\/span><br \/>                <span style=\"color: #888888;\">\/\/else, draw the icicle on the screen.<\/span><br \/>                game<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gameBatch<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">draw<\/span><span style=\"color: #333333;\">(<\/span>icicle<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">texture<\/span><span style=\"color: #333333;\">,<\/span>icicle<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">x<\/span><span style=\"color: #333333;\">,<\/span>icicle<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">y<\/span><span style=\"color: #333333;\">);<\/span><br \/>            <span style=\"color: #333333;\">}<\/span><br \/>        <span style=\"color: #333333;\">}<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>Now we are able to test our game and are able to spawn icicles that fall from the ceiling and disappear when off screen:<\/p>\n<div style=\"clear: both; text-align: center;\"><a href=\"http:\/\/1.bp.blogspot.com\/-driDlXvdlJU\/VdTX-2dfbeI\/AAAAAAAAAaY\/9NbCoubzyUo\/s1600\/dasgafdgsdfg.PNG\" style=\"margin-left: 1em; margin-right: 1em;\"><img decoding=\"async\" border=\"0\" src=\"https:\/\/1.bp.blogspot.com\/-driDlXvdlJU\/VdTX-2dfbeI\/AAAAAAAAAaY\/9NbCoubzyUo\/s1600\/dasgafdgsdfg.PNG\" \/><\/a><\/div>\n<p><b>Step 7:<\/b><br \/>Dying! Woohoo! ha, but we do need to have an objective to this game, so we are going to need to create an object collision detection piece to facilitate losing in the game. Luckily for us, some of that work is done by utilizing libgdx&#8217;s rectangle class. With this rectangle class, we can make a rectangle in space, and be able to tell if that rectangle overlaps any other rectangle. However, we have a triangular shaped icicle that would not work well for collision detection if we were to stick a rectangle around it. Thus, we will create a series of 5 rectangles, you can do more if you wish, to encompasses the icicle. Example shown below:<\/p>\n<div style=\"clear: both; text-align: center;\"><a href=\"http:\/\/1.bp.blogspot.com\/-lrb-SbE0tLo\/VdXTR1jEUpI\/AAAAAAAAAas\/BkfGtJmpW54\/s1600\/icicleAcubes.png\" style=\"margin-left: 1em; margin-right: 1em;\"><img decoding=\"async\" border=\"0\" src=\"https:\/\/1.bp.blogspot.com\/-lrb-SbE0tLo\/VdXTR1jEUpI\/AAAAAAAAAas\/BkfGtJmpW54\/s1600\/icicleAcubes.png\" \/><\/a><\/div>\n<p>As one can see, especially if familiar with calculus, as we increase the number of rectangles we can get higher precision, but for sake of not needing perfection, I think 5 is sufficient. We then also need to worry about creating a rectangle around our character. To keep it simply, and how our character is almost a square, we will just make him a rectangle. Thus, we will need to add this function in our Character.Java class so that we can retrieve the character&#8217;s rectangle on demand:<br \/><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;\">\n<table>\n<tbody>\n<tr>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\">1<br \/>2<br \/>3<br \/>4<br \/>5<br \/>6<br \/>7<\/pre>\n<\/td>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\">    <span style=\"color: #888888;\">\/\/returns a rectangle shape of the object<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> Rectangle <span style=\"color: #0066bb; font-weight: bold;\">getRectangle<\/span><span style=\"color: #333333;\">(){<\/span><br \/>        Rectangle rectangle<span style=\"color: #333333;\">;<\/span><br \/>        <span style=\"color: #888888;\">\/\/creates a rectangle using the characters location and dimensions<\/span><br \/>        rectangle <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> Rectangle<span style=\"color: #333333;\">(<\/span>x<span style=\"color: #333333;\">,<\/span>y<span style=\"color: #333333;\">,<\/span>texture<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">getWidth<\/span><span style=\"color: #333333;\">(),<\/span>texture<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">getHeight<\/span><span style=\"color: #333333;\">());<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">return<\/span> rectangle<span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>So then to test if the rectangles of our icicle overlap that of our character, we will make our collision checker function, placed in our GameScreen.Java class is as follows:<\/p>\n<div style=\"background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;\">\n<table>\n<tbody>\n<tr>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\"> 1<br \/> 2<br \/> 3<br \/> 4<br \/> 5<br \/> 6<br \/> 7<br \/> 8<br \/> 9<br \/>10<br \/>11<br \/>12<br \/>13<br \/>14<br \/>15<br \/>16<br \/>17<br \/>18<br \/>19<br \/>20<br \/>21<br \/>22<br \/>23<\/pre>\n<\/td>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\">    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">checkCollision<\/span><span style=\"color: #333333;\">(){<\/span><br \/>        <span style=\"color: #888888;\">\/\/creates an iterator which will analyze each icicile<\/span><br \/>        Iterator<span style=\"color: #333333;\">&lt;<\/span>Icicle<span style=\"color: #333333;\">&gt;<\/span> iterIcicle <span style=\"color: #333333;\">=<\/span> icicleArray<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">iterator<\/span><span style=\"color: #333333;\">();<\/span><br \/><br \/>        <span style=\"color: #888888;\">\/\/while there are more icicles to process...<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">while<\/span><span style=\"color: #333333;\">(<\/span>iterIcicle<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">hasNext<\/span><span style=\"color: #333333;\">())<\/span> <span style=\"color: #333333;\">{<\/span><br \/>            <span style=\"color: #888888;\">\/\/move to next icicle and set a reference to our icicle<\/span><br \/>            Icicle icicle <span style=\"color: #333333;\">=<\/span> iterIcicle<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">next<\/span><span style=\"color: #333333;\">();<\/span><br \/>            <span style=\"color: #888888;\">\/\/creates 5 rectangles for the icicle<\/span><br \/>            <span style=\"color: #008800; font-weight: bold;\">for<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #333399; font-weight: bold;\">int<\/span> i <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">;<\/span> i <span style=\"color: #333333;\">&lt;<\/span> <span style=\"color: #0000dd; font-weight: bold;\">5<\/span><span style=\"color: #333333;\">;<\/span> i<span style=\"color: #333333;\">++){<\/span><br \/>                <span style=\"color: #333399; font-weight: bold;\">float<\/span> yPos <span style=\"color: #333333;\">=<\/span> icicle<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">y<\/span><span style=\"color: #333333;\">+<\/span>icicle<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">texture<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">getHeight<\/span><span style=\"color: #333333;\">()-((<\/span><span style=\"color: #333399; font-weight: bold;\">float<\/span><span style=\"color: #333333;\">)<\/span>i<span style=\"color: #333333;\">\/<\/span><span style=\"color: #0000dd; font-weight: bold;\">5<\/span><span style=\"color: #333333;\">)*<\/span>icicle<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">texture<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">getHeight<\/span><span style=\"color: #333333;\">();<\/span><br \/>                <span style=\"color: #333399; font-weight: bold;\">float<\/span> yThickness <span style=\"color: #333333;\">=<\/span> <span style=\"color: #333333;\">(<\/span><span style=\"color: #333399; font-weight: bold;\">float<\/span><span style=\"color: #333333;\">)(<\/span><span style=\"color: #0000dd; font-weight: bold;\">1<\/span><span style=\"color: #333333;\">\/<\/span><span style=\"color: #0000dd; font-weight: bold;\">5<\/span><span style=\"color: #333333;\">)*<\/span>icicle<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">texture<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">getHeight<\/span><span style=\"color: #333333;\">();<\/span><br \/>                <span style=\"color: #333399; font-weight: bold;\">float<\/span> xPos <span style=\"color: #333333;\">=<\/span> icicle<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">x<\/span><span style=\"color: #333333;\">+<\/span>icicle<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">texture<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">getWidth<\/span><span style=\"color: #333333;\">()\/<\/span><span style=\"color: #0000dd; font-weight: bold;\">2<\/span><span style=\"color: #333333;\">-(((<\/span><span style=\"color: #333399; font-weight: bold;\">float<\/span><span style=\"color: #333333;\">)(<\/span><span style=\"color: #0000dd; font-weight: bold;\">5<\/span><span style=\"color: #333333;\">-<\/span>i<span style=\"color: #333333;\">)\/(<\/span><span style=\"color: #333399; font-weight: bold;\">float<\/span><span style=\"color: #333333;\">)<\/span><span style=\"color: #0000dd; font-weight: bold;\">5<\/span><span style=\"color: #333333;\">)*<\/span>icicle<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">texture<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">getWidth<\/span><span style=\"color: #333333;\">())\/<\/span><span style=\"color: #0000dd; font-weight: bold;\">2<\/span><span style=\"color: #333333;\">;<\/span><br \/>                <span style=\"color: #333399; font-weight: bold;\">float<\/span> xThickness <span style=\"color: #333333;\">=<\/span> <span style=\"color: #333333;\">(((<\/span><span style=\"color: #333399; font-weight: bold;\">float<\/span><span style=\"color: #333333;\">)(<\/span><span style=\"color: #0000dd; font-weight: bold;\">5<\/span><span style=\"color: #333333;\">-<\/span>i<span style=\"color: #333333;\">)\/(<\/span><span style=\"color: #333399; font-weight: bold;\">float<\/span><span style=\"color: #333333;\">)<\/span><span style=\"color: #0000dd; font-weight: bold;\">5<\/span><span style=\"color: #333333;\">)*<\/span>icicle<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">texture<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">getWidth<\/span><span style=\"color: #333333;\">());<\/span><br \/>                <span style=\"color: #888888;\">\/\/creates a new rectangle with our dimensions<\/span><br \/>                Rectangle rectangle <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> Rectangle<span style=\"color: #333333;\">(<\/span>xPos<span style=\"color: #333333;\">,<\/span>yPos<span style=\"color: #333333;\">,<\/span>xThickness<span style=\"color: #333333;\">,<\/span>yThickness<span style=\"color: #333333;\">);<\/span><br \/>                <span style=\"color: #888888;\">\/\/if our created rectangle overlaps our character<\/span><br \/>                <span style=\"color: #008800; font-weight: bold;\">if<\/span><span style=\"color: #333333;\">(<\/span>rectangle<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">overlaps<\/span><span style=\"color: #333333;\">(<\/span>character<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">getRectangle<\/span><span style=\"color: #333333;\">())){<\/span><br \/>                    gameOver <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">true<\/span><span style=\"color: #333333;\">;<\/span><br \/>                <span style=\"color: #333333;\">}<\/span><br \/>            <span style=\"color: #333333;\">}<\/span><br \/>        <span style=\"color: #333333;\">}<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>Now to facilitate the game ending, we wish for a Game Over screen to appear and the player will simply need to tap to restart it. Thus I simply just created a gameOver.png file that is 480*800 to overlay on top of the screen:<\/p>\n<div style=\"clear: both; text-align: center;\"><a href=\"http:\/\/4.bp.blogspot.com\/-VdbRLdQT04s\/VdXVhxhwN5I\/AAAAAAAAAa4\/8vcQojAQqyg\/s1600\/gameOver.png\" style=\"margin-left: 1em; margin-right: 1em;\"><img decoding=\"async\" border=\"0\" src=\"https:\/\/4.bp.blogspot.com\/-VdbRLdQT04s\/VdXVhxhwN5I\/AAAAAAAAAa4\/8vcQojAQqyg\/s1600\/gameOver.png\" \/><\/a><\/div>\n<p>Now, upon the game becoming over we wish to display this screen, remove the icicles, and stop the player. Then we would like for the player to only need to press down on the screen to restart it, however, the moment the player dies, the finger will still be on the screen (due to reaction times and what not) and that will cause our game to restart. Thus, I will be adding another variable called &#8220;fingerUp&#8221; that will become true once the player lifts his finger off of the screen, then allowing the game to restart upon being pressed. All of the codes are shown below:<\/p>\n<p>Two new variables in GameScreen Class:<br \/><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;\">\n<table>\n<tbody>\n<tr>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\">1<br \/>2<br \/>3<\/pre>\n<\/td>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\"><span style=\"color: #888888;\">\/\/game over booleans<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">boolean<\/span> gameOver <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">false<\/span><span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">boolean<\/span> fingerUp <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">false<\/span><span style=\"color: #333333;\">;<\/span><br \/><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>Changing the Render Section in GameScreen Class:<br \/><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;\">\n<table>\n<tbody>\n<tr>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\"> 1<br \/> 2<br \/> 3<br \/> 4<br \/> 5<br \/> 6<br \/> 7<br \/> 8<br \/> 9<br \/>10<br \/>11<br \/>12<br \/>13<br \/>14<br \/>15<br \/>16<br \/>17<br \/>18<br \/>19<br \/>20<br \/>21<br \/>22<br \/>23<br \/>24<br \/>25<br \/>26<br \/>27<br \/>28<br \/>29<br \/>30<br \/>31<br \/>32<br \/>33<br \/>34<br \/>35<br \/>36<br \/>37<\/pre>\n<\/td>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\"><span style=\"color: #555555; font-weight: bold;\">@Override<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">render<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #333399; font-weight: bold;\">float<\/span> deltaTime<span style=\"color: #333333;\">){<\/span><br \/>        <span style=\"color: #888888;\">\/\/Sets the color to be applied after clearing the screen (R,G,B,A)<\/span><br \/>        Gdx<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gl<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">glClearColor<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">255<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">1<\/span><span style=\"color: #333333;\">);<\/span><br \/>        <span style=\"color: #888888;\">\/\/Clears the screen<\/span><br \/>        Gdx<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gl<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">glClear<\/span><span style=\"color: #333333;\">(<\/span>GL20<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">GL_COLOR_BUFFER_BIT<\/span><span style=\"color: #333333;\">);<\/span><br \/>        <span style=\"color: #888888;\">\/\/updates camera view<\/span><br \/>        camera<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">update<\/span><span style=\"color: #333333;\">();<\/span><br \/>        <span style=\"color: #888888;\">\/\/makes the camera fit onto the available screen<\/span><br \/>        game<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gameBatch<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">setProjectionMatrix<\/span><span style=\"color: #333333;\">(<\/span>camera<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">combined<\/span><span style=\"color: #333333;\">);<\/span><br \/>        <span style=\"color: #888888;\">\/\/checks if the screen is pressed<\/span><br \/>        checkScreenPress<span style=\"color: #333333;\">();<\/span><br \/>        <span style=\"color: #888888;\">\/\/if game is not over<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">if<\/span><span style=\"color: #333333;\">(!<\/span>gameOver<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span><br \/>            <span style=\"color: #888888;\">\/\/updates the character<\/span><br \/>            character<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">update<\/span><span style=\"color: #333333;\">(<\/span>deltaTime<span style=\"color: #333333;\">);<\/span><br \/>            <span style=\"color: #888888;\">\/\/updates Icicle Manager<\/span><br \/>            icicleManager<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">update<\/span><span style=\"color: #333333;\">(<\/span>icicleArray<span style=\"color: #333333;\">,<\/span>deltaTime<span style=\"color: #333333;\">);<\/span><br \/>        <span style=\"color: #333333;\">}<\/span><br \/>        <span style=\"color: #888888;\">\/\/Starts gameBatch for drawing<\/span><br \/>        game<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gameBatch<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">begin<\/span><span style=\"color: #333333;\">();<\/span><br \/>        <span style=\"color: #888888;\">\/\/All drawing needs to be done here<\/span><br \/>        <span style=\"color: #888888;\">\/\/Draws the Cave Background starting at x = 0, y = 0<\/span><br \/>        game<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gameBatch<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">draw<\/span><span style=\"color: #333333;\">(<\/span>caveBackground<span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">);<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">if<\/span><span style=\"color: #333333;\">(!<\/span>gameOver<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span><br \/>            <span style=\"color: #888888;\">\/\/Draws the Icicles<\/span><br \/>            drawIcicles<span style=\"color: #333333;\">(<\/span>deltaTime<span style=\"color: #333333;\">);<\/span><br \/>            <span style=\"color: #888888;\">\/\/checks for collisions of icicles<\/span><br \/>            checkCollision<span style=\"color: #333333;\">();<\/span><br \/>        <span style=\"color: #333333;\">}<\/span><span style=\"color: #008800; font-weight: bold;\">else<\/span><span style=\"color: #333333;\">{<\/span><br \/>            game<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gameBatch<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">draw<\/span><span style=\"color: #333333;\">(<\/span>gameOverTexture<span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">);<\/span><br \/>        <span style=\"color: #333333;\">}<\/span><br \/>        <span style=\"color: #888888;\">\/\/Draws the character at correct location<\/span><br \/>        game<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gameBatch<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">draw<\/span><span style=\"color: #333333;\">(<\/span>character<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">texture<\/span><span style=\"color: #333333;\">,<\/span>character<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">x<\/span><span style=\"color: #333333;\">,<\/span>character<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">y<\/span><span style=\"color: #333333;\">);<\/span><br \/>        <span style=\"color: #888888;\">\/\/Ends the gameBatch after drawing<\/span><br \/>        game<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gameBatch<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">end<\/span><span style=\"color: #333333;\">();<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>Changing the touchUp function in GameScreen:<br \/><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;\">\n<table>\n<tbody>\n<tr>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\"> 1<br \/> 2<br \/> 3<br \/> 4<br \/> 5<br \/> 6<br \/> 7<br \/> 8<br \/> 9<br \/>10<\/pre>\n<\/td>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\">    <span style=\"color: #888888;\">\/\/called when the person lifts their finger off of the screen<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">boolean<\/span> <span style=\"color: #0066bb; font-weight: bold;\">touchUp<\/span> <span style=\"color: #333333;\">(<\/span><span style=\"color: #333399; font-weight: bold;\">int<\/span> x<span style=\"color: #333333;\">,<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> y<span style=\"color: #333333;\">,<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> pointer<span style=\"color: #333333;\">,<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> button<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span><br \/>        <span style=\"color: #888888;\">\/\/set character to standing<\/span><br \/>        character<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">setStanding<\/span><span style=\"color: #333333;\">();<\/span><br \/>        <span style=\"color: #888888;\">\/\/if game over and lifts finger, fingerUp = true<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">if<\/span><span style=\"color: #333333;\">(<\/span>gameOver<span style=\"color: #333333;\">){<\/span><br \/>            fingerUp <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">true<\/span><span style=\"color: #333333;\">;<\/span><br \/>        <span style=\"color: #333333;\">}<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">return<\/span> <span style=\"color: #008800; font-weight: bold;\">false<\/span><span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>And finally changing the checkScreenPress function in GameScreen:<br \/><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;\">\n<table>\n<tbody>\n<tr>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\"> 1<br \/> 2<br \/> 3<br \/> 4<br \/> 5<br \/> 6<br \/> 7<br \/> 8<br \/> 9<br \/>10<br \/>11<br \/>12<br \/>13<br \/>14<br \/>15<br \/>16<br \/>17<br \/>18<br \/>19<br \/>20<br \/>21<br \/>22<br \/>23<br \/>24<\/pre>\n<\/td>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\"><span style=\"color: #888888;\">\/\/checks if the screen is pressed<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">checkScreenPress<\/span><span style=\"color: #333333;\">(){<\/span><br \/>        <span style=\"color: #888888;\">\/\/if screen is pressed<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">if<\/span><span style=\"color: #333333;\">(<\/span>Gdx<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">input<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">isTouched<\/span><span style=\"color: #333333;\">())<\/span> <span style=\"color: #333333;\">{<\/span><br \/>            <span style=\"color: #888888;\">\/\/gets the location of the press, and determines which half of the screen was pressed<\/span><br \/>            <span style=\"color: #008800; font-weight: bold;\">if<\/span> <span style=\"color: #333333;\">((<\/span><span style=\"color: #333399; font-weight: bold;\">float<\/span><span style=\"color: #333333;\">)<\/span> Gdx<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">input<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">getX<\/span><span style=\"color: #333333;\">()<\/span> <span style=\"color: #333333;\">\/<\/span> Gdx<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">graphics<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">getWidth<\/span><span style=\"color: #333333;\">()<\/span> <span style=\"color: #333333;\">&lt;=<\/span> <span style=\"color: #333333;\">.<\/span><span style=\"color: #0000dd; font-weight: bold;\">5<\/span><span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span><br \/>                <span style=\"color: #888888;\">\/\/if left half of screen, go left<\/span><br \/>                character<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">goLeft<\/span><span style=\"color: #333333;\">();<\/span><br \/>            <span style=\"color: #333333;\">}<\/span> <span style=\"color: #008800; font-weight: bold;\">else<\/span> <span style=\"color: #333333;\">{<\/span><br \/>                <span style=\"color: #888888;\">\/\/if not on the left half of screen, it must be going right<\/span><br \/>                character<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">goRight<\/span><span style=\"color: #333333;\">();<\/span><br \/>            <span style=\"color: #333333;\">}<\/span><br \/>            <span style=\"color: #888888;\">\/\/if screen is taped after game is over and finger is lifted off screen<\/span><br \/>            <span style=\"color: #008800; font-weight: bold;\">if<\/span><span style=\"color: #333333;\">(<\/span>gameOver <span style=\"color: #333333;\">&amp;&amp;<\/span> fingerUp<span style=\"color: #333333;\">){<\/span><br \/>                <span style=\"color: #888888;\">\/\/resets char x position<\/span><br \/>                character<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">x<\/span> <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">240<\/span><span style=\"color: #333333;\">;<\/span><br \/>                <span style=\"color: #888888;\">\/\/clears icicles by creating new array<\/span><br \/>                icicleArray <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> Array<span style=\"color: #333333;\">&lt;<\/span>Icicle<span style=\"color: #333333;\">&gt;();<\/span><br \/>                <span style=\"color: #888888;\">\/\/resets vars<\/span><br \/>                gameOver <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">false<\/span><span style=\"color: #333333;\">;<\/span><br \/>                fingerUp <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">false<\/span><span style=\"color: #333333;\">;<\/span><br \/>            <span style=\"color: #333333;\">}<\/span><br \/>        <span style=\"color: #333333;\">}<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>Now your game has an ending and restarting capabilities.<\/p>\n<div style=\"clear: both; text-align: center;\"><a href=\"http:\/\/3.bp.blogspot.com\/-SB1kdk6Q2Mk\/VdXbC2ID2WI\/AAAAAAAAAbQ\/vJIM9EF7JOY\/s1600\/sgadsgasfg.PNG\" style=\"margin-left: 1em; margin-right: 1em;\"><img decoding=\"async\" border=\"0\" src=\"https:\/\/3.bp.blogspot.com\/-SB1kdk6Q2Mk\/VdXbC2ID2WI\/AAAAAAAAAbQ\/vJIM9EF7JOY\/s1600\/sgadsgasfg.PNG\" \/><\/a><\/div>\n<p><b>Step 8:<\/b><br \/>The last necessary step in our game, keeping score and high score. We are going to do a simply method of simply +1 point for every icicle dodged, and we will keep track of the high score by writing it to an external file. First we will need to define three new variables in our game screen class:<br \/><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;\">\n<table>\n<tbody>\n<tr>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\">1<br \/>2<br \/>3<br \/>4<br \/>5<br \/>6<\/pre>\n<\/td>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\">    <span style=\"color: #888888;\">\/\/creates a reference to a local file<\/span><br \/>    FileHandle file <span style=\"color: #333333;\">=<\/span> Gdx<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">files<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">local<\/span><span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"myfile.txt\"<\/span><span style=\"color: #333333;\">);<\/span><br \/>    <span style=\"color: #888888;\">\/\/stores our highscore<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> highScore<span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #888888;\">\/\/our score<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> score<span style=\"color: #333333;\"> =<\/span> <span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">;<\/span><br \/><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>Then in our initialization code in GameScreen, we want to create a function that loads our high score before the game starts. So add a function call in the initialization code and create the following function:<br \/><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;\">\n<table>\n<tbody>\n<tr>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\"> 1<br \/> 2<br \/> 3<br \/> 4<br \/> 5<br \/> 6<br \/> 7<br \/> 8<br \/> 9<br \/>10<br \/>11<br \/>12<br \/>13<br \/>14<br \/>15<br \/>16<br \/>17<br \/>18<br \/>19<br \/>20<br \/>21<br \/>22<br \/>23<br \/>24<br \/>25<br \/>26<\/pre>\n<\/td>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\">    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #0066bb; font-weight: bold;\">GameScreen<\/span><span style=\"color: #333333;\">(<\/span>MyGdxGame game<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span><br \/>        <span style=\"color: #888888;\">\/\/assigns the game we passed to the placeholder<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">this<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">game<\/span> <span style=\"color: #333333;\">=<\/span> game<span style=\"color: #333333;\">;<\/span><br \/>        <span style=\"color: #888888;\">\/\/creates the camera<\/span><br \/>        camera <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> OrthographicCamera<span style=\"color: #333333;\">();<\/span><br \/>        <span style=\"color: #888888;\">\/\/Sets the screen to be 800 width by 480 height<\/span><br \/>        camera<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">setToOrtho<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #008800; font-weight: bold;\">false<\/span><span style=\"color: #333333;\">,<\/span> <span style=\"color: #0000dd; font-weight: bold;\">480<\/span><span style=\"color: #333333;\">,<\/span> <span style=\"color: #0000dd; font-weight: bold;\">800<\/span><span style=\"color: #333333;\">);<\/span><br \/>        <span style=\"color: #888888;\">\/\/very important, lets us use the Input methods!<\/span><br \/>        Gdx<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">input<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">setInputProcessor<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #008800; font-weight: bold;\">this<\/span><span style=\"color: #333333;\">);<\/span><br \/>        <span style=\"color: #888888;\">\/\/loads highscores<\/span><br \/>        loadHighScores<span style=\"color: #333333;\">();<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/>    <span style=\"color: #888888;\">\/\/function that loads the high scores<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">loadHighScores<\/span><span style=\"color: #333333;\">(){<\/span><br \/>        <span style=\"color: #888888;\">\/\/if the files exists go into loop, if it does not exist, it creates a new one.<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">if<\/span><span style=\"color: #333333;\">(<\/span>file<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">exists<\/span><span style=\"color: #333333;\">())<\/span> <span style=\"color: #333333;\">{<\/span><br \/>            <span style=\"color: #008800; font-weight: bold;\">try<\/span> <span style=\"color: #333333;\">{<\/span><br \/>                <span style=\"color: #888888;\">\/\/reads the first line of the file and reads it as an integer<\/span><br \/>                highScore <span style=\"color: #333333;\">=<\/span> Integer<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">parseInt<\/span><span style=\"color: #333333;\">(<\/span>file<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">readString<\/span><span style=\"color: #333333;\">());<\/span><br \/>            <span style=\"color: #333333;\">}<\/span> <span style=\"color: #008800; font-weight: bold;\">catch<\/span> <span style=\"color: #333333;\">(<\/span>NumberFormatException e<span style=\"color: #333333;\">){<\/span><br \/>                <span style=\"color: #888888;\">\/\/if there was no high score found, set it to 0<\/span><br \/>                highScore <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">;<\/span><br \/>            <span style=\"color: #333333;\">}<\/span><br \/>        <span style=\"color: #333333;\">}<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>Next, we want to be able to add to the score upon removing an icicle, change this section in drawIcicles to account for adding score:<br \/><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;\">\n<table>\n<tbody>\n<tr>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\">1<br \/>2<br \/>3<br \/>4<br \/>5<br \/>6<br \/>7<\/pre>\n<\/td>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\">            <span style=\"color: #008800; font-weight: bold;\">if<\/span><span style=\"color: #333333;\">(<\/span>icicle<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">y<\/span> <span style=\"color: #333333;\">&lt;<\/span> <span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">){<\/span><br \/>               iterIcicle<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">remove<\/span><span style=\"color: #333333;\">();<\/span><br \/>               score<span style=\"color: #333333;\">++;<\/span><br \/>            <span style=\"color: #333333;\">}<\/span><span style=\"color: #008800; font-weight: bold;\">else<\/span><span style=\"color: #333333;\">{<\/span><br \/>                <span style=\"color: #888888;\">\/\/else, draw the icicle on the screen.<\/span><br \/>                game<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gameBatch<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">draw<\/span><span style=\"color: #333333;\">(<\/span>icicle<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">texture<\/span><span style=\"color: #333333;\">,<\/span>icicle<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">x<\/span><span style=\"color: #333333;\">,<\/span>icicle<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">y<\/span><span style=\"color: #333333;\">);<\/span><br \/>            <span style=\"color: #333333;\">}<\/span><br \/><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>Now we need to add a code for writing out the new high score, we will place this in the checkScreenPress section as we have a code that is executed upon game over:<br \/><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;\">\n<table>\n<tbody>\n<tr>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\"> 1<br \/> 2<br \/> 3<br \/> 4<br \/> 5<br \/> 6<br \/> 7<br \/> 8<br \/> 9<br \/>10<br \/>11<br \/>12<br \/>13<br \/>14<br \/>15<br \/>16<br \/>17<br \/>18<br \/>19<br \/>20<br \/>21<br \/>22<br \/>23<br \/>24<br \/>25<br \/>26<br \/>27<br \/>28<br \/>29<br \/>30<br \/>31<br \/>32<br \/>33<\/pre>\n<\/td>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\"><span style=\"color: #888888;\">\/\/checks if the screen is pressed<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">checkScreenPress<\/span><span style=\"color: #333333;\">(){<\/span><br \/>        <span style=\"color: #888888;\">\/\/if screen is pressed<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">if<\/span><span style=\"color: #333333;\">(<\/span>Gdx<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">input<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">isTouched<\/span><span style=\"color: #333333;\">())<\/span> <span style=\"color: #333333;\">{<\/span><br \/>            <span style=\"color: #888888;\">\/\/gets the location of the press, and determines which half of the screen was pressed<\/span><br \/>            <span style=\"color: #008800; font-weight: bold;\">if<\/span> <span style=\"color: #333333;\">((<\/span><span style=\"color: #333399; font-weight: bold;\">float<\/span><span style=\"color: #333333;\">)<\/span> Gdx<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">input<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">getX<\/span><span style=\"color: #333333;\">()<\/span> <span style=\"color: #333333;\">\/<\/span> Gdx<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">graphics<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">getWidth<\/span><span style=\"color: #333333;\">()<\/span> <span style=\"color: #333333;\">&lt;=<\/span> <span style=\"color: #333333;\">.<\/span><span style=\"color: #0000dd; font-weight: bold;\">5<\/span><span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span><br \/>                <span style=\"color: #888888;\">\/\/if left half of screen, go left<\/span><br \/>                character<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">goLeft<\/span><span style=\"color: #333333;\">();<\/span><br \/>            <span style=\"color: #333333;\">}<\/span> <span style=\"color: #008800; font-weight: bold;\">else<\/span> <span style=\"color: #333333;\">{<\/span><br \/>                <span style=\"color: #888888;\">\/\/if not on the left half of screen, it must be going right<\/span><br \/>                character<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">goRight<\/span><span style=\"color: #333333;\">();<\/span><br \/>            <span style=\"color: #333333;\">}<\/span><br \/>            <span style=\"color: #888888;\">\/\/if screen is taped after game is over and finger is lifted off screen<\/span><br \/>            <span style=\"color: #008800; font-weight: bold;\">if<\/span><span style=\"color: #333333;\">(<\/span>gameOver <span style=\"color: #333333;\">&amp;&amp;<\/span> fingerUp<span style=\"color: #333333;\">){<\/span><br \/>                <span style=\"color: #888888;\">\/\/resets char x position<\/span><br \/>                character<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">x<\/span> <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">240<\/span><span style=\"color: #333333;\">;<\/span><br \/>                <span style=\"color: #888888;\">\/\/clears icicles by creating new array<\/span><br \/>                icicleArray <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> Array<span style=\"color: #333333;\">&lt;<\/span>Icicle<span style=\"color: #333333;\">&gt;();<\/span><br \/>                <span style=\"color: #888888;\">\/\/resets vars<\/span><br \/>                gameOver <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">false<\/span><span style=\"color: #333333;\">;<\/span><br \/>                fingerUp <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">false<\/span><span style=\"color: #333333;\">;<\/span><br \/>                <span style=\"color: #888888;\">\/\/if score was higher than the high score<\/span><br \/>                <span style=\"color: #008800; font-weight: bold;\">if<\/span><span style=\"color: #333333;\">(<\/span>score <span style=\"color: #333333;\">&gt;<\/span> highScore<span style=\"color: #333333;\">){<\/span><br \/>                    <span style=\"color: #888888;\">\/\/write value of score to our file<\/span><br \/>                    file<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">writeString<\/span><span style=\"color: #333333;\">(<\/span>String<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">valueOf<\/span><span style=\"color: #333333;\">(<\/span>score<span style=\"color: #333333;\">),<\/span><span style=\"color: #008800; font-weight: bold;\">false<\/span><span style=\"color: #333333;\">);<\/span><br \/>                    <span style=\"color: #888888;\">\/\/set our in-game high score to our new score<\/span><br \/>                    highScore <span style=\"color: #333333;\">=<\/span> score<span style=\"color: #333333;\">;<\/span><br \/>                <span style=\"color: #333333;\">}<\/span><br \/>                <span style=\"color: #888888;\">\/\/resets score<\/span><br \/>                score <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">;<\/span><br \/>            <span style=\"color: #333333;\">}<\/span><br \/>        <span style=\"color: #333333;\">}<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>Finally, we want the player to be able to see the score while he is playing, for this, we will simply just draw then onto the top of the screen using libgdx&#8217;s default text printer as such in the render section:<br \/><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;\">\n<table>\n<tbody>\n<tr>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\">1<br \/>2<\/pre>\n<\/td>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\"><span style=\"color: #888888;\">\/\/draws the score and high score<\/span><br \/>        game<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gameFont<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">draw<\/span><span style=\"color: #333333;\">(<\/span>game<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gameBatch<\/span><span style=\"color: #333333;\">,<\/span><span style=\"background-color: #fff0f0;\">\"Score: \"<\/span> <span style=\"color: #333333;\">+<\/span> score <span style=\"color: #333333;\">+<\/span> <span style=\"background-color: #fff0f0;\">\"       High Score: \"<\/span> <span style=\"color: #333333;\">+<\/span> highScore<span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">800<\/span><span style=\"color: #333333;\">);<\/span><br \/><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>Then upon running, you hopefully will be able to keep score!<\/p>\n<div style=\"clear: both; text-align: center;\"><a href=\"http:\/\/1.bp.blogspot.com\/-LQnBRYXvPWc\/VdXh7ImQivI\/AAAAAAAAAbk\/GKVMXqeNu3o\/s1600\/Captureretqt.PNG\" style=\"margin-left: 1em; margin-right: 1em;\"><img decoding=\"async\" border=\"0\" src=\"https:\/\/1.bp.blogspot.com\/-LQnBRYXvPWc\/VdXh7ImQivI\/AAAAAAAAAbk\/GKVMXqeNu3o\/s1600\/Captureretqt.PNG\" \/><\/a><\/div>\n<p>And you are complete! That is it! You have a complete game with an objective, an enemy, a restarting ability, and a score keeping function. You have created you first game! However there are two additional steps that are completely optional to continue on that I will include, but for completeness, I will now post the entire java files here:<\/p>\n<p>Character.Java:<\/p>\n<div style=\"background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;\">\n<table>\n<tbody>\n<tr>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\"> 1<br \/> 2<br \/> 3<br \/> 4<br \/> 5<br \/> 6<br \/> 7<br \/> 8<br \/> 9<br \/>10<br \/>11<br \/>12<br \/>13<br \/>14<br \/>15<br \/>16<br \/>17<br \/>18<br \/>19<br \/>20<br \/>21<br \/>22<br \/>23<br \/>24<br \/>25<br \/>26<br \/>27<br \/>28<br \/>29<br \/>30<br \/>31<br \/>32<br \/>33<br \/>34<br \/>35<br \/>36<br \/>37<br \/>38<br \/>39<br \/>40<br \/>41<br \/>42<br \/>43<br \/>44<br \/>45<br \/>46<br \/>47<br \/>48<br \/>49<br \/>50<br \/>51<br \/>52<br \/>53<br \/>54<br \/>55<br \/>56<br \/>57<br \/>58<br \/>59<br \/>60<\/pre>\n<\/td>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\"><span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #008800; font-weight: bold;\">class<\/span> <span style=\"color: #bb0066; font-weight: bold;\">Character<\/span> <span style=\"color: #333333;\">{<\/span><br \/>    <span style=\"color: #888888;\">\/\/stores x loc (start at 240)<\/span><br \/>    <span style=\"color: #333399; font-weight: bold;\">int<\/span> x <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">240<\/span><span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #888888;\">\/\/stores y loc (start at 167)<\/span><br \/>    <span style=\"color: #333399; font-weight: bold;\">int<\/span> y <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">167<\/span><span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #888888;\">\/\/texture for our character<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> Texture texture <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> Texture<span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"guy.png\"<\/span><span style=\"color: #333333;\">);<\/span><br \/>    <span style=\"color: #888888;\">\/\/speed for our character in pixels\/s<\/span><br \/>    <span style=\"color: #333399; font-weight: bold;\">int<\/span> speed <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">300<\/span><span style=\"color: #333333;\">;<\/span><br \/><br \/>    <span style=\"color: #888888;\">\/\/defining constants for direction<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">static<\/span> <span style=\"color: #008800; font-weight: bold;\">final<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> LEFT <span style=\"color: #333333;\">=<\/span> <span style=\"color: #333333;\">-<\/span><span style=\"color: #0000dd; font-weight: bold;\">1<\/span><span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">static<\/span> <span style=\"color: #008800; font-weight: bold;\">final<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> RIGHT <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">1<\/span><span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">static<\/span> <span style=\"color: #008800; font-weight: bold;\">final<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> STANDING <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #333399; font-weight: bold;\">int<\/span> direction <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">;<\/span><br \/><br \/>    <span style=\"color: #888888;\">\/\/initialization code<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #0066bb; font-weight: bold;\">Character<\/span><span style=\"color: #333333;\">(){}<\/span><br \/><br \/>    <span style=\"color: #888888;\">\/\/updates character's position<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">update<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #333399; font-weight: bold;\">float<\/span> deltaTime<span style=\"color: #333333;\">){<\/span><br \/>        <span style=\"color: #888888;\">\/\/stores the value of the last x<\/span><br \/>        <span style=\"color: #333399; font-weight: bold;\">int<\/span> lastx <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">this<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">x<\/span><span style=\"color: #333333;\">;<\/span><br \/>        <span style=\"color: #888888;\">\/\/change in distance = direction * speed * time<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">this<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">x<\/span> <span style=\"color: #333333;\">+=<\/span> direction<span style=\"color: #333333;\">*<\/span>speed<span style=\"color: #333333;\">*<\/span>deltaTime<span style=\"color: #333333;\">;<\/span><br \/>        <span style=\"color: #888888;\">\/\/if the new location of the character is off the screen to the left<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">if<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #008800; font-weight: bold;\">this<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">x<\/span> <span style=\"color: #333333;\">&lt;<\/span> <span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">){<\/span><br \/>            <span style=\"color: #888888;\">\/\/put the character back to last location<\/span><br \/>            <span style=\"color: #008800; font-weight: bold;\">this<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">x<\/span> <span style=\"color: #333333;\">=<\/span> lastx<span style=\"color: #333333;\">;<\/span><br \/>        <span style=\"color: #333333;\">}<\/span><br \/>        <span style=\"color: #888888;\">\/\/if the new location of the character is off the screen to the right<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">if<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #008800; font-weight: bold;\">this<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">x<\/span> <span style=\"color: #333333;\">&gt;<\/span> <span style=\"color: #0000dd; font-weight: bold;\">480<\/span> <span style=\"color: #333333;\">-<\/span> texture<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">getWidth<\/span><span style=\"color: #333333;\">()){<\/span><br \/>            <span style=\"color: #888888;\">\/\/put the character back to last location<\/span><br \/>            <span style=\"color: #008800; font-weight: bold;\">this<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">x<\/span> <span style=\"color: #333333;\">=<\/span> lastx<span style=\"color: #333333;\">;<\/span><br \/>        <span style=\"color: #333333;\">}<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/>    <span style=\"color: #888888;\">\/\/changes the character direction to right<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">goRight<\/span><span style=\"color: #333333;\">(){<\/span><br \/>        direction <span style=\"color: #333333;\">=<\/span> RIGHT<span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/>    <span style=\"color: #888888;\">\/\/changes character direction to left<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">goLeft<\/span><span style=\"color: #333333;\">(){<\/span><br \/>        direction <span style=\"color: #333333;\">=<\/span> LEFT<span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/>    <span style=\"color: #888888;\">\/\/changes character direction to standing<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">setStanding<\/span><span style=\"color: #333333;\">(){<\/span><br \/>        direction <span style=\"color: #333333;\">=<\/span> STANDING<span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/>    <span style=\"color: #888888;\">\/\/returns a rectangle shape of the object<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> Rectangle <span style=\"color: #0066bb; font-weight: bold;\">getRectangle<\/span><span style=\"color: #333333;\">(){<\/span><br \/>        Rectangle rectangle<span style=\"color: #333333;\">;<\/span><br \/>        <span style=\"color: #888888;\">\/\/creates a rectangle using the characters location and dimensions<\/span><br \/>        rectangle <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> Rectangle<span style=\"color: #333333;\">(<\/span>x<span style=\"color: #333333;\">,<\/span>y<span style=\"color: #333333;\">,<\/span>texture<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">getWidth<\/span><span style=\"color: #333333;\">(),<\/span>texture<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">getHeight<\/span><span style=\"color: #333333;\">());<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">return<\/span> rectangle<span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><span style=\"color: #333333;\">}<\/span><br \/><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>GameScreen.Java:<\/p>\n<div style=\"background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;\">\n<table>\n<tbody>\n<tr>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\">  1<br \/>  2<br \/>  3<br \/>  4<br \/>  5<br \/>  6<br \/>  7<br \/>  8<br \/>  9<br \/> 10<br \/> 11<br \/> 12<br \/> 13<br \/> 14<br \/> 15<br \/> 16<br \/> 17<br \/> 18<br \/> 19<br \/> 20<br \/> 21<br \/> 22<br \/> 23<br \/> 24<br \/> 25<br \/> 26<br \/> 27<br \/> 28<br \/> 29<br \/> 30<br \/> 31<br \/> 32<br \/> 33<br \/> 34<br \/> 35<br \/> 36<br \/> 37<br \/> 38<br \/> 39<br \/> 40<br \/> 41<br \/> 42<br \/> 43<br \/> 44<br \/> 45<br \/> 46<br \/> 47<br \/> 48<br \/> 49<br \/> 50<br \/> 51<br \/> 52<br \/> 53<br \/> 54<br \/> 55<br \/> 56<br \/> 57<br \/> 58<br \/> 59<br \/> 60<br \/> 61<br \/> 62<br \/> 63<br \/> 64<br \/> 65<br \/> 66<br \/> 67<br \/> 68<br \/> 69<br \/> 70<br \/> 71<br \/> 72<br \/> 73<br \/> 74<br \/> 75<br \/> 76<br \/> 77<br \/> 78<br \/> 79<br \/> 80<br \/> 81<br \/> 82<br \/> 83<br \/> 84<br \/> 85<br \/> 86<br \/> 87<br \/> 88<br \/> 89<br \/> 90<br \/> 91<br \/> 92<br \/> 93<br \/> 94<br \/> 95<br \/> 96<br \/> 97<br \/> 98<br \/> 99<br \/>100<br \/>101<br \/>102<br \/>103<br \/>104<br \/>105<br \/>106<br \/>107<br \/>108<br \/>109<br \/>110<br \/>111<br \/>112<br \/>113<br \/>114<br \/>115<br \/>116<br \/>117<br \/>118<br \/>119<br \/>120<br \/>121<br \/>122<br \/>123<br \/>124<br \/>125<br \/>126<br \/>127<br \/>128<br \/>129<br \/>130<br \/>131<br \/>132<br \/>133<br \/>134<br \/>135<br \/>136<br \/>137<br \/>138<br \/>139<br \/>140<br \/>141<br \/>142<br \/>143<br \/>144<br \/>145<br \/>146<br \/>147<br \/>148<br \/>149<br \/>150<br \/>151<br \/>152<br \/>153<br \/>154<br \/>155<br \/>156<br \/>157<br \/>158<br \/>159<br \/>160<br \/>161<br \/>162<br \/>163<br \/>164<br \/>165<br \/>166<br \/>167<br \/>168<br \/>169<br \/>170<br \/>171<br \/>172<br \/>173<br \/>174<br \/>175<br \/>176<br \/>177<br \/>178<br \/>179<br \/>180<br \/>181<br \/>182<br \/>183<br \/>184<br \/>185<br \/>186<br \/>187<br \/>188<br \/>189<br \/>190<br \/>191<br \/>192<br \/>193<br \/>194<br \/>195<br \/>196<br \/>197<br \/>198<br \/>199<br \/>200<br \/>201<br \/>202<br \/>203<br \/>204<br \/>205<br \/>206<br \/>207<br \/>208<br \/>209<br \/>210<br \/>211<br \/>212<br \/>213<br \/>214<br \/>215<br \/>216<br \/>217<br \/>218<br \/>219<br \/>220<br \/>221<br \/>222<br \/>223<br \/>224<br \/>225<br \/>226<br \/>227<br \/>228<br \/>229<br \/>230<br \/>231<br \/>232<br \/>233<br \/>234<br \/>235<br \/>236<br \/>237<br \/>238<br \/>239<br \/>240<br \/>241<br \/>242<br \/>243<br \/>244<br \/>245<br \/>246<br \/>247<br \/>248<br \/>249<br \/>250<br \/>251<br \/>252<br \/>253<br \/>254<br \/>255<br \/>256<br \/>257<br \/>258<br \/>259<br \/>260<br \/>261<br \/>262<br \/>263<br \/>264<br \/>265<br \/>266<br \/>267<br \/>268<br \/>269<\/pre>\n<\/td>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\"><span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #008800; font-weight: bold;\">class<\/span> <span style=\"color: #bb0066; font-weight: bold;\">GameScreen<\/span> <span style=\"color: #008800; font-weight: bold;\">implements<\/span> Screen<span style=\"color: #333333;\">,<\/span>InputProcessor <span style=\"color: #333333;\">{<\/span><br \/><br \/>    <span style=\"color: #888888;\">\/\/Creates a reference to hold our \"passed\" game.<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">private<\/span> MyGdxGame game<span style=\"color: #333333;\">;<\/span><br \/><br \/>    <span style=\"color: #888888;\">\/\/Defining the camera to be used<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">private<\/span> OrthographicCamera camera<span style=\"color: #333333;\">;<\/span><br \/><br \/>    <span style=\"color: #888888;\">\/\/Texture for the cave background<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">private<\/span> Texture caveBackground <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> Texture<span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"cavebackground.png\"<\/span><span style=\"color: #333333;\">);<\/span><br \/><br \/>    <span style=\"color: #888888;\">\/\/Texture for the game over<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">private<\/span> Texture gameOverTexture <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> Texture<span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"gameOver.png\"<\/span><span style=\"color: #333333;\">);<\/span><br \/><br \/>    <span style=\"color: #888888;\">\/\/Creates a Reference for our character<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">private<\/span> Character character <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> Character<span style=\"color: #333333;\">();<\/span><br \/><br \/>    <span style=\"color: #888888;\">\/\/Creates our icicle Manager with a description of how long to delay each icicle type<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> IcicleManager icicleManager <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> IcicleManager<span style=\"color: #333333;\">(<\/span><span style=\"color: #0000dd; font-weight: bold;\">2<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">5<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">10<\/span><span style=\"color: #333333;\">);<\/span><br \/><br \/>    <span style=\"color: #888888;\">\/\/creates an array to hold all of our icicles;<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> Array<span style=\"color: #333333;\">&lt;<\/span>Icicle<span style=\"color: #333333;\">&gt;<\/span> icicleArray <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> Array<span style=\"color: #333333;\">&lt;<\/span>Icicle<span style=\"color: #333333;\">&gt;();<\/span><br \/><br \/>    <span style=\"color: #888888;\">\/\/game over booleans<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">boolean<\/span> gameOver <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">false<\/span><span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">boolean<\/span> fingerUp <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">false<\/span><span style=\"color: #333333;\">;<\/span><br \/><br \/>    <span style=\"color: #888888;\">\/\/creates a reference to a local file<\/span><br \/>    FileHandle file <span style=\"color: #333333;\">=<\/span> Gdx<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">files<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">local<\/span><span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"myfile.txt\"<\/span><span style=\"color: #333333;\">);<\/span><br \/>    <span style=\"color: #888888;\">\/\/stores our highscore<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> highScore<span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #888888;\">\/\/our score<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> score <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">;<\/span><br \/><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #0066bb; font-weight: bold;\">GameScreen<\/span><span style=\"color: #333333;\">(<\/span>MyGdxGame game<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span><br \/>        <span style=\"color: #888888;\">\/\/assigns the game we passed to the placeholder<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">this<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">game<\/span> <span style=\"color: #333333;\">=<\/span> game<span style=\"color: #333333;\">;<\/span><br \/>        <span style=\"color: #888888;\">\/\/creates the camera<\/span><br \/>        camera <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> OrthographicCamera<span style=\"color: #333333;\">();<\/span><br \/>        <span style=\"color: #888888;\">\/\/Sets the screen to be 800 width by 480 height<\/span><br \/>        camera<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">setToOrtho<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #008800; font-weight: bold;\">false<\/span><span style=\"color: #333333;\">,<\/span> <span style=\"color: #0000dd; font-weight: bold;\">480<\/span><span style=\"color: #333333;\">,<\/span> <span style=\"color: #0000dd; font-weight: bold;\">800<\/span><span style=\"color: #333333;\">);<\/span><br \/>        <span style=\"color: #888888;\">\/\/very important, lets us use the Input methods!<\/span><br \/>        Gdx<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">input<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">setInputProcessor<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #008800; font-weight: bold;\">this<\/span><span style=\"color: #333333;\">);<\/span><br \/>        <span style=\"color: #888888;\">\/\/loads highscores<\/span><br \/>        loadHighScores<span style=\"color: #333333;\">();<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/>    <span style=\"color: #555555; font-weight: bold;\">@Override<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">render<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #333399; font-weight: bold;\">float<\/span> deltaTime<span style=\"color: #333333;\">){<\/span><br \/>        <span style=\"color: #888888;\">\/\/Sets the color to be applied after clearing the screen (R,G,B,A)<\/span><br \/>        Gdx<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gl<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">glClearColor<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">255<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">1<\/span><span style=\"color: #333333;\">);<\/span><br \/>        <span style=\"color: #888888;\">\/\/Clears the screen<\/span><br \/>        Gdx<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gl<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">glClear<\/span><span style=\"color: #333333;\">(<\/span>GL20<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">GL_COLOR_BUFFER_BIT<\/span><span style=\"color: #333333;\">);<\/span><br \/>        <span style=\"color: #888888;\">\/\/updates camera view<\/span><br \/>        camera<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">update<\/span><span style=\"color: #333333;\">();<\/span><br \/>        <span style=\"color: #888888;\">\/\/makes the camera fit onto the available screen<\/span><br \/>        game<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gameBatch<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">setProjectionMatrix<\/span><span style=\"color: #333333;\">(<\/span>camera<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">combined<\/span><span style=\"color: #333333;\">);<\/span><br \/>        <span style=\"color: #888888;\">\/\/checks if the screen is pressed<\/span><br \/>        checkScreenPress<span style=\"color: #333333;\">();<\/span><br \/>        <span style=\"color: #888888;\">\/\/if game is not over<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">if<\/span><span style=\"color: #333333;\">(!<\/span>gameOver<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span><br \/>            <span style=\"color: #888888;\">\/\/updates the character<\/span><br \/>            character<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">update<\/span><span style=\"color: #333333;\">(<\/span>deltaTime<span style=\"color: #333333;\">);<\/span><br \/>            <span style=\"color: #888888;\">\/\/updates Icicle Manager<\/span><br \/>            icicleManager<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">update<\/span><span style=\"color: #333333;\">(<\/span>icicleArray<span style=\"color: #333333;\">,<\/span>deltaTime<span style=\"color: #333333;\">);<\/span><br \/>        <span style=\"color: #333333;\">}<\/span><br \/>        <span style=\"color: #888888;\">\/\/Starts gameBatch for drawing<\/span><br \/>        game<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gameBatch<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">begin<\/span><span style=\"color: #333333;\">();<\/span><br \/>        <span style=\"color: #888888;\">\/\/All drawing needs to be done here<\/span><br \/>        <span style=\"color: #888888;\">\/\/Draws the Cave Background starting at x = 0, y = 0<\/span><br \/>        game<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gameBatch<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">draw<\/span><span style=\"color: #333333;\">(<\/span>caveBackground<span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">);<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">if<\/span><span style=\"color: #333333;\">(!<\/span>gameOver<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span><br \/>            <span style=\"color: #888888;\">\/\/Draws the Icicles<\/span><br \/>            drawIcicles<span style=\"color: #333333;\">(<\/span>deltaTime<span style=\"color: #333333;\">);<\/span><br \/>            <span style=\"color: #888888;\">\/\/checks for collisions of icicles<\/span><br \/>            checkCollision<span style=\"color: #333333;\">();<\/span><br \/>        <span style=\"color: #333333;\">}<\/span><span style=\"color: #008800; font-weight: bold;\">else<\/span><span style=\"color: #333333;\">{<\/span><br \/>            game<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gameBatch<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">draw<\/span><span style=\"color: #333333;\">(<\/span>gameOverTexture<span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">);<\/span><br \/>        <span style=\"color: #333333;\">}<\/span><br \/>        <span style=\"color: #888888;\">\/\/Draws the character at correct location<\/span><br \/>        game<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gameBatch<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">draw<\/span><span style=\"color: #333333;\">(<\/span>character<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">texture<\/span><span style=\"color: #333333;\">,<\/span>character<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">x<\/span><span style=\"color: #333333;\">,<\/span>character<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">y<\/span><span style=\"color: #333333;\">);<\/span><br \/>        <span style=\"color: #888888;\">\/\/draws the score and high score<\/span><br \/>        game<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gameFont<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">draw<\/span><span style=\"color: #333333;\">(<\/span>game<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gameBatch<\/span><span style=\"color: #333333;\">,<\/span><span style=\"background-color: #fff0f0;\">\"Score: \"<\/span> <span style=\"color: #333333;\">+<\/span> score <span style=\"color: #333333;\">+<\/span> <span style=\"background-color: #fff0f0;\">\"       High Score: \"<\/span> <span style=\"color: #333333;\">+<\/span> highScore<span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">800<\/span><span style=\"color: #333333;\">);<\/span><br \/>        <span style=\"color: #888888;\">\/\/Ends the gameBatch after drawing<\/span><br \/>        game<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gameBatch<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">end<\/span><span style=\"color: #333333;\">();<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/>    <span style=\"color: #888888;\">\/\/draws our icicles<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">drawIcicles<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #333399; font-weight: bold;\">float<\/span> deltaTime<span style=\"color: #333333;\">){<\/span><br \/>        <span style=\"color: #888888;\">\/\/creates an iterator which will analyze each icicile<\/span><br \/>        Iterator<span style=\"color: #333333;\">&lt;<\/span>Icicle<span style=\"color: #333333;\">&gt;<\/span> iterIcicle <span style=\"color: #333333;\">=<\/span> icicleArray<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">iterator<\/span><span style=\"color: #333333;\">();<\/span><br \/><br \/>        <span style=\"color: #888888;\">\/\/while there are more icicles to process...<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">while<\/span><span style=\"color: #333333;\">(<\/span>iterIcicle<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">hasNext<\/span><span style=\"color: #333333;\">())<\/span> <span style=\"color: #333333;\">{<\/span><br \/>            <span style=\"color: #888888;\">\/\/move to next icicle and set a reference to our icicle<\/span><br \/>            Icicle icicle <span style=\"color: #333333;\">=<\/span> iterIcicle<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">next<\/span><span style=\"color: #333333;\">();<\/span><br \/>            <span style=\"color: #888888;\">\/\/update our icicle<\/span><br \/>            icicle<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">update<\/span><span style=\"color: #333333;\">(<\/span>deltaTime<span style=\"color: #333333;\">);<\/span><br \/>            <span style=\"color: #888888;\">\/\/if icicle is below y = 0, remove icicle from the array<\/span><br \/>            <span style=\"color: #008800; font-weight: bold;\">if<\/span><span style=\"color: #333333;\">(<\/span>icicle<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">y<\/span> <span style=\"color: #333333;\">&lt;<\/span> <span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">){<\/span><br \/>               iterIcicle<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">remove<\/span><span style=\"color: #333333;\">();<\/span><br \/>               score<span style=\"color: #333333;\">++;<\/span><br \/>            <span style=\"color: #333333;\">}<\/span><span style=\"color: #008800; font-weight: bold;\">else<\/span><span style=\"color: #333333;\">{<\/span><br \/>                <span style=\"color: #888888;\">\/\/else, draw the icicle on the screen.<\/span><br \/>                game<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">gameBatch<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">draw<\/span><span style=\"color: #333333;\">(<\/span>icicle<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">texture<\/span><span style=\"color: #333333;\">,<\/span>icicle<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">x<\/span><span style=\"color: #333333;\">,<\/span>icicle<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">y<\/span><span style=\"color: #333333;\">);<\/span><br \/>            <span style=\"color: #333333;\">}<\/span><br \/><br \/>        <span style=\"color: #333333;\">}<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">checkCollision<\/span><span style=\"color: #333333;\">(){<\/span><br \/>        <span style=\"color: #888888;\">\/\/creates an iterator which will analyze each icicile<\/span><br \/>        Iterator<span style=\"color: #333333;\">&lt;<\/span>Icicle<span style=\"color: #333333;\">&gt;<\/span> iterIcicle <span style=\"color: #333333;\">=<\/span> icicleArray<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">iterator<\/span><span style=\"color: #333333;\">();<\/span><br \/><br \/>        <span style=\"color: #888888;\">\/\/while there are more icicles to process...<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">while<\/span><span style=\"color: #333333;\">(<\/span>iterIcicle<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">hasNext<\/span><span style=\"color: #333333;\">())<\/span> <span style=\"color: #333333;\">{<\/span><br \/>            <span style=\"color: #888888;\">\/\/move to next icicle and set a reference to our icicle<\/span><br \/>            Icicle icicle <span style=\"color: #333333;\">=<\/span> iterIcicle<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">next<\/span><span style=\"color: #333333;\">();<\/span><br \/>            <span style=\"color: #888888;\">\/\/creates 5 rectangles for the icicle<\/span><br \/>            <span style=\"color: #008800; font-weight: bold;\">for<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #333399; font-weight: bold;\">int<\/span> i <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">;<\/span> i <span style=\"color: #333333;\">&lt;<\/span> <span style=\"color: #0000dd; font-weight: bold;\">5<\/span><span style=\"color: #333333;\">;<\/span> i<span style=\"color: #333333;\">++){<\/span><br \/>                <span style=\"color: #333399; font-weight: bold;\">float<\/span> yPos <span style=\"color: #333333;\">=<\/span> icicle<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">y<\/span><span style=\"color: #333333;\">+<\/span>icicle<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">texture<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">getHeight<\/span><span style=\"color: #333333;\">()-((<\/span><span style=\"color: #333399; font-weight: bold;\">float<\/span><span style=\"color: #333333;\">)<\/span>i<span style=\"color: #333333;\">\/<\/span><span style=\"color: #0000dd; font-weight: bold;\">5<\/span><span style=\"color: #333333;\">)*<\/span>icicle<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">texture<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">getHeight<\/span><span style=\"color: #333333;\">();<\/span><br \/>                <span style=\"color: #333399; font-weight: bold;\">float<\/span> yThickness <span style=\"color: #333333;\">=<\/span> <span style=\"color: #333333;\">(<\/span><span style=\"color: #333399; font-weight: bold;\">float<\/span><span style=\"color: #333333;\">)(<\/span><span style=\"color: #0000dd; font-weight: bold;\">1<\/span><span style=\"color: #333333;\">\/<\/span><span style=\"color: #0000dd; font-weight: bold;\">5<\/span><span style=\"color: #333333;\">)*<\/span>icicle<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">texture<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">getHeight<\/span><span style=\"color: #333333;\">();<\/span><br \/>                <span style=\"color: #333399; font-weight: bold;\">float<\/span> xPos <span style=\"color: #333333;\">=<\/span> icicle<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">x<\/span><span style=\"color: #333333;\">+<\/span>icicle<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">texture<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">getWidth<\/span><span style=\"color: #333333;\">()\/<\/span><span style=\"color: #0000dd; font-weight: bold;\">2<\/span><span style=\"color: #333333;\">-(((<\/span><span style=\"color: #333399; font-weight: bold;\">float<\/span><span style=\"color: #333333;\">)(<\/span><span style=\"color: #0000dd; font-weight: bold;\">5<\/span><span style=\"color: #333333;\">-<\/span>i<span style=\"color: #333333;\">)\/(<\/span><span style=\"color: #333399; font-weight: bold;\">float<\/span><span style=\"color: #333333;\">)<\/span><span style=\"color: #0000dd; font-weight: bold;\">5<\/span><span style=\"color: #333333;\">)*<\/span>icicle<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">texture<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">getWidth<\/span><span style=\"color: #333333;\">())\/<\/span><span style=\"color: #0000dd; font-weight: bold;\">2<\/span><span style=\"color: #333333;\">;<\/span><br \/>                <span style=\"color: #333399; font-weight: bold;\">float<\/span> xThickness <span style=\"color: #333333;\">=<\/span> <span style=\"color: #333333;\">(((<\/span><span style=\"color: #333399; font-weight: bold;\">float<\/span><span style=\"color: #333333;\">)(<\/span><span style=\"color: #0000dd; font-weight: bold;\">5<\/span><span style=\"color: #333333;\">-<\/span>i<span style=\"color: #333333;\">)\/(<\/span><span style=\"color: #333399; font-weight: bold;\">float<\/span><span style=\"color: #333333;\">)<\/span><span style=\"color: #0000dd; font-weight: bold;\">5<\/span><span style=\"color: #333333;\">)*<\/span>icicle<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">texture<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">getWidth<\/span><span style=\"color: #333333;\">());<\/span><br \/>                <span style=\"color: #888888;\">\/\/creates a new rectangle with our dimensions<\/span><br \/>                Rectangle rectangle <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> Rectangle<span style=\"color: #333333;\">(<\/span>xPos<span style=\"color: #333333;\">,<\/span>yPos<span style=\"color: #333333;\">,<\/span>xThickness<span style=\"color: #333333;\">,<\/span>yThickness<span style=\"color: #333333;\">);<\/span><br \/>                <span style=\"color: #888888;\">\/\/if our created rectangle overlaps our character<\/span><br \/>                <span style=\"color: #008800; font-weight: bold;\">if<\/span><span style=\"color: #333333;\">(<\/span>rectangle<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">overlaps<\/span><span style=\"color: #333333;\">(<\/span>character<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">getRectangle<\/span><span style=\"color: #333333;\">())){<\/span><br \/>                    gameOver <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">true<\/span><span style=\"color: #333333;\">;<\/span><br \/>                <span style=\"color: #333333;\">}<\/span><br \/>            <span style=\"color: #333333;\">}<\/span><br \/>        <span style=\"color: #333333;\">}<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/><br \/>    <span style=\"color: #888888;\">\/\/This method gets called when a key is pressed down<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">boolean<\/span> <span style=\"color: #0066bb; font-weight: bold;\">keyDown<\/span> <span style=\"color: #333333;\">(<\/span><span style=\"color: #333399; font-weight: bold;\">int<\/span> keycode<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span><br \/>        <span style=\"color: #888888;\">\/\/switches case for keycode variable<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">switch<\/span> <span style=\"color: #333333;\">(<\/span>keycode<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span><br \/>            <span style=\"color: #888888;\">\/\/if left key is pressed<\/span><br \/>            <span style=\"color: #008800; font-weight: bold;\">case<\/span> Input<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">Keys<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">LEFT<\/span><span style=\"color: #333333;\">:<\/span><br \/>                <span style=\"color: #888888;\">\/\/sets character going left<\/span><br \/>                character<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">goLeft<\/span><span style=\"color: #333333;\">();<\/span><br \/>                <span style=\"color: #008800; font-weight: bold;\">break<\/span><span style=\"color: #333333;\">;<\/span><br \/>            <span style=\"color: #008800; font-weight: bold;\">case<\/span> Input<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">Keys<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">RIGHT<\/span><span style=\"color: #333333;\">:<\/span><br \/>                <span style=\"color: #888888;\">\/\/sets character going right<\/span><br \/>                character<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">goRight<\/span><span style=\"color: #333333;\">();<\/span><br \/>                <span style=\"color: #008800; font-weight: bold;\">break<\/span><span style=\"color: #333333;\">;<\/span><br \/>            <span style=\"color: #008800; font-weight: bold;\">default<\/span><span style=\"color: #333333;\">:<\/span><br \/>        <span style=\"color: #333333;\">}<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">return<\/span> <span style=\"color: #008800; font-weight: bold;\">false<\/span><span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/>    <span style=\"color: #888888;\">\/\/happens upon lifting finger off of key<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">boolean<\/span> <span style=\"color: #0066bb; font-weight: bold;\">keyUp<\/span> <span style=\"color: #333333;\">(<\/span><span style=\"color: #333399; font-weight: bold;\">int<\/span> keycode<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span><br \/>        <span style=\"color: #888888;\">\/\/sets character standing upon lifting off of key<\/span><br \/>        character<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">setStanding<\/span><span style=\"color: #333333;\">();<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">return<\/span> <span style=\"color: #008800; font-weight: bold;\">false<\/span><span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/>    <span style=\"color: #888888;\">\/\/checks if the screen is pressed<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">checkScreenPress<\/span><span style=\"color: #333333;\">(){<\/span><br \/>        <span style=\"color: #888888;\">\/\/if screen is pressed<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">if<\/span><span style=\"color: #333333;\">(<\/span>Gdx<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">input<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">isTouched<\/span><span style=\"color: #333333;\">())<\/span> <span style=\"color: #333333;\">{<\/span><br \/>            <span style=\"color: #888888;\">\/\/gets the location of the press, and determines which half of the screen was pressed<\/span><br \/>            <span style=\"color: #008800; font-weight: bold;\">if<\/span> <span style=\"color: #333333;\">((<\/span><span style=\"color: #333399; font-weight: bold;\">float<\/span><span style=\"color: #333333;\">)<\/span> Gdx<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">input<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">getX<\/span><span style=\"color: #333333;\">()<\/span> <span style=\"color: #333333;\">\/<\/span> Gdx<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">graphics<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">getWidth<\/span><span style=\"color: #333333;\">()<\/span> <span style=\"color: #333333;\">&lt;=<\/span> <span style=\"color: #333333;\">.<\/span><span style=\"color: #0000dd; font-weight: bold;\">5<\/span><span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span><br \/>                <span style=\"color: #888888;\">\/\/if left half of screen, go left<\/span><br \/>                character<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">goLeft<\/span><span style=\"color: #333333;\">();<\/span><br \/>            <span style=\"color: #333333;\">}<\/span> <span style=\"color: #008800; font-weight: bold;\">else<\/span> <span style=\"color: #333333;\">{<\/span><br \/>                <span style=\"color: #888888;\">\/\/if not on the left half of screen, it must be going right<\/span><br \/>                character<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">goRight<\/span><span style=\"color: #333333;\">();<\/span><br \/>            <span style=\"color: #333333;\">}<\/span><br \/>            <span style=\"color: #888888;\">\/\/if screen is taped after game is over and finger is lifted off screen<\/span><br \/>            <span style=\"color: #008800; font-weight: bold;\">if<\/span><span style=\"color: #333333;\">(<\/span>gameOver <span style=\"color: #333333;\">&amp;&amp;<\/span> fingerUp<span style=\"color: #333333;\">){<\/span><br \/>                <span style=\"color: #888888;\">\/\/resets char x position<\/span><br \/>                character<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">x<\/span> <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">240<\/span><span style=\"color: #333333;\">;<\/span><br \/>                <span style=\"color: #888888;\">\/\/clears icicles by creating new array<\/span><br \/>                icicleArray <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> Array<span style=\"color: #333333;\">&lt;<\/span>Icicle<span style=\"color: #333333;\">&gt;();<\/span><br \/>                <span style=\"color: #888888;\">\/\/resets vars<\/span><br \/>                gameOver <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">false<\/span><span style=\"color: #333333;\">;<\/span><br \/>                fingerUp <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">false<\/span><span style=\"color: #333333;\">;<\/span><br \/>                <span style=\"color: #888888;\">\/\/if score was higher than the high score<\/span><br \/>                <span style=\"color: #008800; font-weight: bold;\">if<\/span><span style=\"color: #333333;\">(<\/span>score <span style=\"color: #333333;\">&gt;<\/span> highScore<span style=\"color: #333333;\">){<\/span><br \/>                    <span style=\"color: #888888;\">\/\/write value of score to our file<\/span><br \/>                    file<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">writeString<\/span><span style=\"color: #333333;\">(<\/span>String<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">valueOf<\/span><span style=\"color: #333333;\">(<\/span>score<span style=\"color: #333333;\">),<\/span><span style=\"color: #008800; font-weight: bold;\">false<\/span><span style=\"color: #333333;\">);<\/span><br \/>                    <span style=\"color: #888888;\">\/\/set our in-game high score to our new score<\/span><br \/>                    highScore <span style=\"color: #333333;\">=<\/span> score<span style=\"color: #333333;\">;<\/span><br \/>                <span style=\"color: #333333;\">}<\/span><br \/>                <span style=\"color: #888888;\">\/\/resets score<\/span><br \/>                score <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">;<\/span><br \/>            <span style=\"color: #333333;\">}<\/span><br \/>        <span style=\"color: #333333;\">}<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/>    <span style=\"color: #888888;\">\/\/called when the person lifts their finger off of the screen<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">boolean<\/span> <span style=\"color: #0066bb; font-weight: bold;\">touchUp<\/span> <span style=\"color: #333333;\">(<\/span><span style=\"color: #333399; font-weight: bold;\">int<\/span> x<span style=\"color: #333333;\">,<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> y<span style=\"color: #333333;\">,<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> pointer<span style=\"color: #333333;\">,<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> button<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span><br \/>        <span style=\"color: #888888;\">\/\/set character to standing<\/span><br \/>        character<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">setStanding<\/span><span style=\"color: #333333;\">();<\/span><br \/>        <span style=\"color: #888888;\">\/\/if game over and lifts finger, fingerUp = true<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">if<\/span><span style=\"color: #333333;\">(<\/span>gameOver<span style=\"color: #333333;\">){<\/span><br \/>            fingerUp <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">true<\/span><span style=\"color: #333333;\">;<\/span><br \/>        <span style=\"color: #333333;\">}<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">return<\/span> <span style=\"color: #008800; font-weight: bold;\">false<\/span><span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/>    <span style=\"color: #888888;\">\/\/function that loads the high scores<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">loadHighScores<\/span><span style=\"color: #333333;\">(){<\/span><br \/>        <span style=\"color: #888888;\">\/\/if the files exists go into loop, if it does not exist, it creates a new one.<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">if<\/span><span style=\"color: #333333;\">(<\/span>file<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">exists<\/span><span style=\"color: #333333;\">())<\/span> <span style=\"color: #333333;\">{<\/span><br \/>            <span style=\"color: #008800; font-weight: bold;\">try<\/span> <span style=\"color: #333333;\">{<\/span><br \/>                <span style=\"color: #888888;\">\/\/reads the first line of the file and reads it as an integer<\/span><br \/>                highScore <span style=\"color: #333333;\">=<\/span> Integer<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">parseInt<\/span><span style=\"color: #333333;\">(<\/span>file<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">readString<\/span><span style=\"color: #333333;\">());<\/span><br \/>            <span style=\"color: #333333;\">}<\/span> <span style=\"color: #008800; font-weight: bold;\">catch<\/span> <span style=\"color: #333333;\">(<\/span>NumberFormatException e<span style=\"color: #333333;\">){<\/span><br \/>                <span style=\"color: #888888;\">\/\/if there was no high score found, set it to 0<\/span><br \/>                highScore <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">;<\/span><br \/>            <span style=\"color: #333333;\">}<\/span><br \/>        <span style=\"color: #333333;\">}<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">boolean<\/span> <span style=\"color: #0066bb; font-weight: bold;\">touchDown<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #333399; font-weight: bold;\">int<\/span> screenX<span style=\"color: #333333;\">,<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> screenY<span style=\"color: #333333;\">,<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> pointer<span style=\"color: #333333;\">,<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> button<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">return<\/span> <span style=\"color: #008800; font-weight: bold;\">false<\/span><span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">boolean<\/span> <span style=\"color: #0066bb; font-weight: bold;\">keyTyped<\/span> <span style=\"color: #333333;\">(<\/span><span style=\"color: #333399; font-weight: bold;\">char<\/span> character<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">return<\/span> <span style=\"color: #008800; font-weight: bold;\">false<\/span><span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">boolean<\/span> <span style=\"color: #0066bb; font-weight: bold;\">touchDragged<\/span> <span style=\"color: #333333;\">(<\/span><span style=\"color: #333399; font-weight: bold;\">int<\/span> x<span style=\"color: #333333;\">,<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> y<span style=\"color: #333333;\">,<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> pointer<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">return<\/span> <span style=\"color: #008800; font-weight: bold;\">false<\/span><span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">boolean<\/span> <span style=\"color: #0066bb; font-weight: bold;\">mouseMoved<\/span> <span style=\"color: #333333;\">(<\/span><span style=\"color: #333399; font-weight: bold;\">int<\/span> x<span style=\"color: #333333;\">,<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> y<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">return<\/span> <span style=\"color: #008800; font-weight: bold;\">false<\/span><span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">boolean<\/span> <span style=\"color: #0066bb; font-weight: bold;\">scrolled<\/span> <span style=\"color: #333333;\">(<\/span><span style=\"color: #333399; font-weight: bold;\">int<\/span> amount<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">return<\/span> <span style=\"color: #008800; font-weight: bold;\">false<\/span><span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/>    <span style=\"color: #555555; font-weight: bold;\">@Override<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">resize<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #333399; font-weight: bold;\">int<\/span> width<span style=\"color: #333333;\">,<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> height<span style=\"color: #333333;\">){<\/span><br \/><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/>    <span style=\"color: #555555; font-weight: bold;\">@Override<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">show<\/span><span style=\"color: #333333;\">(){<\/span><br \/><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/>    <span style=\"color: #555555; font-weight: bold;\">@Override<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">hide<\/span><span style=\"color: #333333;\">(){<\/span><br \/><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/>    <span style=\"color: #555555; font-weight: bold;\">@Override<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">pause<\/span><span style=\"color: #333333;\">(){<\/span><br \/><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/>    <span style=\"color: #555555; font-weight: bold;\">@Override<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">resume<\/span><span style=\"color: #333333;\">(){<\/span><br \/><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/>    <span style=\"color: #555555; font-weight: bold;\">@Override<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">dispose<\/span><span style=\"color: #333333;\">(){<\/span><br \/><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/><span style=\"color: #333333;\">}<\/span><br \/><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>Icicle.Java:<\/p>\n<div style=\"background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;\">\n<table>\n<tbody>\n<tr>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\"> 1<br \/> 2<br \/> 3<br \/> 4<br \/> 5<br \/> 6<br \/> 7<br \/> 8<br \/> 9<br \/>10<br \/>11<br \/>12<br \/>13<br \/>14<br \/>15<br \/>16<br \/>17<br \/>18<br \/>19<br \/>20<br \/>21<br \/>22<br \/>23<br \/>24<br \/>25<br \/>26<br \/>27<br \/>28<br \/>29<br \/>30<br \/>31<br \/>32<br \/>33<br \/>34<br \/>35<br \/>36<br \/>37<br \/>38<br \/>39<br \/>40<br \/>41<br \/>42<br \/>43<br \/>44<br \/>45<br \/>46<br \/>47<\/pre>\n<\/td>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\"><span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #008800; font-weight: bold;\">class<\/span> <span style=\"color: #bb0066; font-weight: bold;\">Icicle<\/span> <span style=\"color: #333333;\">{<\/span><br \/>    <span style=\"color: #888888;\">\/\/variables for x location, y location, and speed of dropping<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> x<span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> y<span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> speed<span style=\"color: #333333;\">;<\/span><br \/><br \/>    <span style=\"color: #888888;\">\/\/codes for the three different icicle types<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">static<\/span> <span style=\"color: #008800; font-weight: bold;\">final<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> typeA <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">static<\/span> <span style=\"color: #008800; font-weight: bold;\">final<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> typeB <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">1<\/span><span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">static<\/span> <span style=\"color: #008800; font-weight: bold;\">final<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> typeC <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">2<\/span><span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> code<span style=\"color: #333333;\">;<\/span><br \/><br \/>    <span style=\"color: #888888;\">\/\/placeholder for icicle texture<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> Texture texture<span style=\"color: #333333;\">;<\/span><br \/><br \/>    <span style=\"color: #888888;\">\/\/initiation code<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #0066bb; font-weight: bold;\">Icicle<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #333399; font-weight: bold;\">int<\/span> x<span style=\"color: #333333;\">,<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> y<span style=\"color: #333333;\">,<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> speed<span style=\"color: #333333;\">,<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> code<span style=\"color: #333333;\">){<\/span><br \/>        <span style=\"color: #888888;\">\/\/setting variables<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">this<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">x<\/span> <span style=\"color: #333333;\">=<\/span> x<span style=\"color: #333333;\">;<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">this<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">y<\/span> <span style=\"color: #333333;\">=<\/span> y<span style=\"color: #333333;\">;<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">this<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">speed<\/span> <span style=\"color: #333333;\">=<\/span> speed<span style=\"color: #333333;\">;<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">this<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">code<\/span> <span style=\"color: #333333;\">=<\/span> code<span style=\"color: #333333;\">;<\/span><br \/><br \/>        <span style=\"color: #888888;\">\/\/sets texture to icicle depending on code<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">switch<\/span><span style=\"color: #333333;\">(<\/span>code<span style=\"color: #333333;\">){<\/span><br \/>            <span style=\"color: #008800; font-weight: bold;\">case<\/span> <span style=\"color: #997700; font-weight: bold;\">typeA:<\/span><br \/>                <span style=\"color: #008800; font-weight: bold;\">this<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">texture<\/span> <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> Texture<span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"icicleA.png\"<\/span><span style=\"color: #333333;\">);<\/span><br \/>                <span style=\"color: #008800; font-weight: bold;\">break<\/span><span style=\"color: #333333;\">;<\/span><br \/>            <span style=\"color: #008800; font-weight: bold;\">case<\/span> <span style=\"color: #997700; font-weight: bold;\">typeB:<\/span><br \/>                <span style=\"color: #008800; font-weight: bold;\">this<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">texture<\/span> <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> Texture<span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"icicleB.png\"<\/span><span style=\"color: #333333;\">);<\/span><br \/>                <span style=\"color: #008800; font-weight: bold;\">break<\/span><span style=\"color: #333333;\">;<\/span><br \/>            <span style=\"color: #008800; font-weight: bold;\">case<\/span> <span style=\"color: #997700; font-weight: bold;\">typeC:<\/span><br \/>                <span style=\"color: #008800; font-weight: bold;\">this<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">texture<\/span> <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> Texture<span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"icicleC.png\"<\/span><span style=\"color: #333333;\">);<\/span><br \/>                <span style=\"color: #008800; font-weight: bold;\">break<\/span><span style=\"color: #333333;\">;<\/span><br \/>        <span style=\"color: #333333;\">}<\/span><br \/><br \/>        <span style=\"color: #888888;\">\/\/changes the y value so that irregardless of texture height, it will always start on the<\/span><br \/>        <span style=\"color: #888888;\">\/\/the top of the ice cave ceiling.<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">this<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">y<\/span> <span style=\"color: #333333;\">-=<\/span> <span style=\"color: #008800; font-weight: bold;\">this<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">texture<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">getHeight<\/span><span style=\"color: #333333;\">();<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/>    <span style=\"color: #888888;\">\/\/updates icicle's y position as it falls with time;<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">update<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #333399; font-weight: bold;\">float<\/span> deltaTime<span style=\"color: #333333;\">){<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">this<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">y<\/span> <span style=\"color: #333333;\">-=<\/span> speed<span style=\"color: #333333;\">*<\/span>deltaTime<span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/><span style=\"color: #333333;\">}<\/span><br \/><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>IcicleManager.Java:<\/p>\n<div style=\"background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;\">\n<table>\n<tbody>\n<tr>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\"> 1<br \/> 2<br \/> 3<br \/> 4<br \/> 5<br \/> 6<br \/> 7<br \/> 8<br \/> 9<br \/>10<br \/>11<br \/>12<br \/>13<br \/>14<br \/>15<br \/>16<br \/>17<br \/>18<br \/>19<br \/>20<br \/>21<br \/>22<br \/>23<br \/>24<br \/>25<br \/>26<br \/>27<br \/>28<br \/>29<br \/>30<br \/>31<br \/>32<br \/>33<br \/>34<br \/>35<br \/>36<br \/>37<br \/>38<br \/>39<br \/>40<br \/>41<br \/>42<br \/>43<br \/>44<br \/>45<br \/>46<br \/>47<br \/>48<br \/>49<\/pre>\n<\/td>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\"><span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #008800; font-weight: bold;\">class<\/span> <span style=\"color: #bb0066; font-weight: bold;\">IcicleManager<\/span> <span style=\"color: #333333;\">{<\/span><br \/>    <span style=\"color: #888888;\">\/\/stores the refresh rates set for the icicles<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> aRefreshRate<span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> bRefreshRate<span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> cRefreshRate<span style=\"color: #333333;\">;<\/span><br \/><br \/>    <span style=\"color: #888888;\">\/\/keeps a timer for each icicle type<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">float<\/span> aTimer <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">float<\/span> bTimer <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">float<\/span> cTimer <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">;<\/span><br \/><br \/>    <span style=\"color: #888888;\">\/\/initializes icicle manager with our set refresh rates.<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #0066bb; font-weight: bold;\">IcicleManager<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #333399; font-weight: bold;\">int<\/span> aRefreshRate<span style=\"color: #333333;\">,<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> bRefreshRate<span style=\"color: #333333;\">,<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> cRefreshRate<span style=\"color: #333333;\">){<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">this<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">aRefreshRate<\/span> <span style=\"color: #333333;\">=<\/span> aRefreshRate<span style=\"color: #333333;\">;<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">this<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">bRefreshRate<\/span> <span style=\"color: #333333;\">=<\/span> bRefreshRate<span style=\"color: #333333;\">;<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">this<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">cRefreshRate<\/span> <span style=\"color: #333333;\">=<\/span> cRefreshRate<span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><br \/>    <span style=\"color: #888888;\">\/\/receives the array of icicles and updates and returns the array<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> Array<span style=\"color: #333333;\">&lt;<\/span>Icicle<span style=\"color: #333333;\">&gt;<\/span> <span style=\"color: #0066bb; font-weight: bold;\">update<\/span><span style=\"color: #333333;\">(<\/span>Array<span style=\"color: #333333;\">&lt;<\/span>Icicle<span style=\"color: #333333;\">&gt;<\/span> array<span style=\"color: #333333;\">,<\/span> <span style=\"color: #333399; font-weight: bold;\">float<\/span> deltaTime<span style=\"color: #333333;\">){<\/span><br \/>        <span style=\"color: #888888;\">\/\/add the time passed to our timers<\/span><br \/>        aTimer <span style=\"color: #333333;\">+=<\/span> deltaTime<span style=\"color: #333333;\">;<\/span><br \/>        bTimer <span style=\"color: #333333;\">+=<\/span> deltaTime<span style=\"color: #333333;\">;<\/span><br \/>        cTimer <span style=\"color: #333333;\">+=<\/span> deltaTime<span style=\"color: #333333;\">;<\/span><br \/><br \/>        <span style=\"color: #888888;\">\/\/if timer value is greater than refresh rate<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">if<\/span><span style=\"color: #333333;\">(<\/span>aTimer <span style=\"color: #333333;\">&gt;=<\/span> aRefreshRate<span style=\"color: #333333;\">){<\/span><br \/>            <span style=\"color: #888888;\">\/\/create a new icicle at a random x Loc, 670 height, 300 speed, and a typeA icicle<\/span><br \/>            array<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">add<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #008800; font-weight: bold;\">new<\/span> Icicle<span style=\"color: #333333;\">(<\/span>MathUtils<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">random<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">460<\/span><span style=\"color: #333333;\">),<\/span><span style=\"color: #0000dd; font-weight: bold;\">670<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">300<\/span><span style=\"color: #333333;\">,<\/span>Icicle<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">typeA<\/span><span style=\"color: #333333;\">));<\/span><br \/>            <span style=\"color: #888888;\">\/\/reset Timer<\/span><br \/>            aTimer <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">;<\/span><br \/>        <span style=\"color: #333333;\">}<\/span><br \/>        <span style=\"color: #888888;\">\/\/if timer value is greater than refresh rate<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">if<\/span><span style=\"color: #333333;\">(<\/span>bTimer <span style=\"color: #333333;\">&gt;=<\/span> bRefreshRate<span style=\"color: #333333;\">){<\/span><br \/>            <span style=\"color: #888888;\">\/\/create a new icicle at a random x Loc, 670 height, 300 speed, and a typeB icicle<\/span><br \/>            array<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">add<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #008800; font-weight: bold;\">new<\/span> Icicle<span style=\"color: #333333;\">(<\/span>MathUtils<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">random<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">460<\/span><span style=\"color: #333333;\">),<\/span><span style=\"color: #0000dd; font-weight: bold;\">670<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">300<\/span><span style=\"color: #333333;\">,<\/span>Icicle<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">typeB<\/span><span style=\"color: #333333;\">));<\/span><br \/>            <span style=\"color: #888888;\">\/\/reset Timer<\/span><br \/>            bTimer <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">;<\/span><br \/>        <span style=\"color: #333333;\">}<\/span><br \/>        <span style=\"color: #888888;\">\/\/if timer value is greater than refresh rate<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">if<\/span><span style=\"color: #333333;\">(<\/span>cTimer <span style=\"color: #333333;\">&gt;=<\/span> cRefreshRate<span style=\"color: #333333;\">){<\/span><br \/>            <span style=\"color: #888888;\">\/\/create a new icicle at a random x Loc, 670 height, 300 speed, and a typeB icicle<\/span><br \/>            array<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">add<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #008800; font-weight: bold;\">new<\/span> Icicle<span style=\"color: #333333;\">(<\/span>MathUtils<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">random<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">460<\/span><span style=\"color: #333333;\">),<\/span><span style=\"color: #0000dd; font-weight: bold;\">670<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">300<\/span><span style=\"color: #333333;\">,<\/span>Icicle<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">typeC<\/span><span style=\"color: #333333;\">));<\/span><br \/>            <span style=\"color: #888888;\">\/\/reset Timer<\/span><br \/>            cTimer <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">0<\/span><span style=\"color: #333333;\">;<\/span><br \/>        <span style=\"color: #333333;\">}<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">return<\/span> array<span style=\"color: #333333;\">;<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><span style=\"color: #333333;\">}<\/span><br \/><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>MyGdxGame.Java:<\/p>\n<div style=\"background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;\">\n<table>\n<tbody>\n<tr>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\"> 1<br \/> 2<br \/> 3<br \/> 4<br \/> 5<br \/> 6<br \/> 7<br \/> 8<br \/> 9<br \/>10<br \/>11<br \/>12<br \/>13<br \/>14<br \/>15<br \/>16<br \/>17<br \/>18<br \/>19<br \/>20<br \/>21<br \/>22<br \/>23<br \/>24<br \/>25<br \/>26<br \/>27<br \/>28<br \/>29<br \/>30<br \/>31<br \/>32<br \/>33<br \/>34<br \/>35<\/pre>\n<\/td>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\"><span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #008800; font-weight: bold;\">class<\/span> <span style=\"color: #bb0066; font-weight: bold;\">MyGdxGame<\/span> <span style=\"color: #008800; font-weight: bold;\">extends<\/span> Game <span style=\"color: #333333;\">{<\/span><br \/><br \/>    <span style=\"color: #888888;\">\/\/Define a public Spritebatch which we will use to render text onto the screen<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> SpriteBatch gameBatch<span style=\"color: #333333;\">;<\/span><br \/><br \/>    <span style=\"color: #888888;\">\/\/Define a public font that we will use for all text.<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> BitmapFont gameFont<span style=\"color: #333333;\">;<\/span><br \/><br \/>    <span style=\"color: #888888;\">\/\/Public void create() is ran when the program is started.<\/span><br \/> <span style=\"color: #555555; font-weight: bold;\">@Override<\/span><br \/> <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">create<\/span> <span style=\"color: #333333;\">()<\/span> <span style=\"color: #333333;\">{<\/span><br \/>        <span style=\"color: #888888;\">\/\/Creates the SpriteBatch for gameBatch to use<\/span><br \/>        gameBatch <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> SpriteBatch<span style=\"color: #333333;\">();<\/span><br \/><br \/>        <span style=\"color: #888888;\">\/\/Creates the font, which is the default font for LIBgdx.<\/span><br \/>        gameFont <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> BitmapFont<span style=\"color: #333333;\">();<\/span><br \/><br \/>        <span style=\"color: #888888;\">\/\/this will set the screen to our next class \"GameScreen\"<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">this<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">setScreen<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #008800; font-weight: bold;\">new<\/span> GameScreen<span style=\"color: #333333;\">(<\/span><span style=\"color: #008800; font-weight: bold;\">this<\/span><span style=\"color: #333333;\">));<\/span><br \/> <span style=\"color: #333333;\">}<\/span><br \/><br \/>    <span style=\"color: #888888;\">\/\/Called upon render<\/span><br \/> <span style=\"color: #555555; font-weight: bold;\">@Override<\/span><br \/> <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">render<\/span> <span style=\"color: #333333;\">()<\/span> <span style=\"color: #333333;\">{<\/span><br \/>        <span style=\"color: #888888;\">\/\/Calls our render() method in our GameScreen<\/span><br \/>        <span style=\"color: #008800; font-weight: bold;\">super<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">render<\/span><span style=\"color: #333333;\">();<\/span><br \/> <span style=\"color: #333333;\">}<\/span><br \/><br \/>    <span style=\"color: #888888;\">\/\/Called when class is disposed<\/span><br \/>    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">dispose<\/span><span style=\"color: #333333;\">()<\/span> <span style=\"color: #333333;\">{<\/span><br \/>        <span style=\"color: #888888;\">\/\/disposes both SpriteBatch and BitmapFont<\/span><br \/>        gameBatch<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">dispose<\/span><span style=\"color: #333333;\">();<\/span><br \/>        gameFont<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">dispose<\/span><span style=\"color: #333333;\">();<\/span><br \/>    <span style=\"color: #333333;\">}<\/span><br \/><span style=\"color: #333333;\">}<\/span><br \/><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p><b>(Optional) Step 9:<\/b><br \/>Creating better graphics! I will create better graphics for this game as to show how much of a difference it can make, but I want you to let your imiganation take hold of this one! You could even change everything such as the icicles are missiles instead and you are a tank trying to dodge them, the ideas are endless! Just a heads up, I am not by any means an artist, I only spent about 25 minutes on changing the graphics, and here is the end result first, so you may see if it is worth your time to copy the images.<\/p>\n<div style=\"clear: both; text-align: center;\"><a href=\"http:\/\/4.bp.blogspot.com\/-d6a0KMd1w7c\/VdXuaCH5y8I\/AAAAAAAAAb4\/p1d6q2Pbpw4\/s1600\/Capture345.PNG\" style=\"margin-left: 1em; margin-right: 1em;\"><img decoding=\"async\" border=\"0\" src=\"https:\/\/4.bp.blogspot.com\/-d6a0KMd1w7c\/VdXuaCH5y8I\/AAAAAAAAAb4\/p1d6q2Pbpw4\/s1600\/Capture345.PNG\" \/><\/a><\/div>\n<p>If you do enjoy the newer images, here they all are, simply just overwrite the existing ones:<br \/>cavebackground.png <\/p>\n<div style=\"clear: both; text-align: center;\"><a href=\"http:\/\/3.bp.blogspot.com\/-sWlGSj6Tay8\/VdXuuGNO5bI\/AAAAAAAAAcA\/zkHtq_FgPuw\/s1600\/cavebackground.png\" style=\"margin-left: 1em; margin-right: 1em;\"><img decoding=\"async\" border=\"0\" src=\"https:\/\/3.bp.blogspot.com\/-sWlGSj6Tay8\/VdXuuGNO5bI\/AAAAAAAAAcA\/zkHtq_FgPuw\/s1600\/cavebackground.png\" \/><\/a><\/div>\n<div style=\"clear: both; text-align: left;\">guy.png: <\/div>\n<p><\/p>\n<div style=\"clear: both; text-align: center;\"><a href=\"http:\/\/4.bp.blogspot.com\/-3S_Wyxupts0\/VdXuuPBXheI\/AAAAAAAAAcg\/vafzbGrcAaE\/s1600\/guy.png\" style=\"margin-left: 1em; margin-right: 1em;\"><img decoding=\"async\" border=\"0\" src=\"https:\/\/4.bp.blogspot.com\/-3S_Wyxupts0\/VdXuuPBXheI\/AAAAAAAAAcg\/vafzbGrcAaE\/s1600\/guy.png\" \/><\/a><\/div>\n<div style=\"clear: both; text-align: left;\">icicleA.png: <\/div>\n<p><\/p>\n<div style=\"clear: both; text-align: center;\"><a href=\"http:\/\/2.bp.blogspot.com\/-4VPCtoG2X4o\/VdXuuHpfghI\/AAAAAAAAAcE\/5GD-6eRbWzs\/s1600\/icicleA.png\" style=\"margin-left: 1em; margin-right: 1em;\"><img decoding=\"async\" border=\"0\" src=\"https:\/\/2.bp.blogspot.com\/-4VPCtoG2X4o\/VdXuuHpfghI\/AAAAAAAAAcE\/5GD-6eRbWzs\/s1600\/icicleA.png\" \/><\/a><\/div>\n<div style=\"clear: both; text-align: left;\">icicleB.png:&nbsp; <\/div>\n<p><\/p>\n<div style=\"clear: both; text-align: center;\"><\/div>\n<div style=\"clear: both; text-align: center;\"><\/div>\n<div style=\"clear: both; text-align: center;\"><\/div>\n<div style=\"clear: both; text-align: center;\"><\/div>\n<div style=\"clear: both; text-align: center;\"><\/div>\n<div style=\"clear: both; text-align: center;\"><\/div>\n<div style=\"clear: both; text-align: center;\"><\/div>\n<div style=\"clear: both; text-align: center;\"><\/div>\n<div style=\"clear: both; text-align: center;\"><\/div>\n<div style=\"clear: both; text-align: center;\"><\/div>\n<div style=\"clear: both; text-align: center;\"><\/div>\n<div style=\"clear: both; text-align: center;\"><\/div>\n<div style=\"clear: both; text-align: center;\"><\/div>\n<div style=\"clear: both; text-align: center;\"><\/div>\n<div style=\"clear: both; text-align: center;\"><\/div>\n<div style=\"clear: both; text-align: center;\"><\/div>\n<div style=\"clear: both; text-align: center;\"><\/div>\n<div style=\"clear: both; text-align: center;\"><img decoding=\"async\" border=\"0\" src=\"https:\/\/4.bp.blogspot.com\/-0ZHDP0aZaIA\/VdXuvIG6P_I\/AAAAAAAAAcI\/vV4oKrL_lxQ\/s1600\/icicleB.png\" \/><\/div>\n<p>&nbsp;icicleC.png:<\/p>\n<div style=\"clear: both; text-align: center;\"><a href=\"http:\/\/2.bp.blogspot.com\/-lDTrxFmM5uA\/VdXuvARgMlI\/AAAAAAAAAcc\/jlGuTxhqkcc\/s1600\/icicleC.png\" style=\"margin-left: 1em; margin-right: 1em;\"><img decoding=\"async\" border=\"0\" src=\"https:\/\/2.bp.blogspot.com\/-lDTrxFmM5uA\/VdXuvARgMlI\/AAAAAAAAAcc\/jlGuTxhqkcc\/s1600\/icicleC.png\" \/><\/a><\/div>\n<p>And with that simply upgrade, the game, atleast to me, looks a lot better! I am sure many of you have a fantastic imagination and most likely better artist skills than I, so let your ideas fly.<\/p><\/div>\n<div dir=\"ltr\"><\/div>\n<div dir=\"ltr\"><\/div>\n<div dir=\"ltr\"><\/div>\n<div dir=\"ltr\"><\/div>\n<div dir=\"ltr\"><\/div>\n<div dir=\"ltr\"><b>(Optional) Step 10:<\/b><\/div>\n<div dir=\"ltr\">In this step, I am going to show you how to add AdMob into an libgdx game for android if that is something you wish. We will be adding a simple banner add to the bottom of the screen that will display at all times. First you will need to add the google ads library into your project. To do this, go to project structure -&gt; android -&gt; dependencies -&gt; green plus on left side -&gt; add library depedency -&gt; com.google.android.gms:play-services:6.5.87 -&gt; apply -&gt; ok.&nbsp;&nbsp;&nbsp; It will then do a gradle sync.<\/div>\n<div dir=\"ltr\"><\/div>\n<div dir=\"ltr\"><\/div>\n<div dir=\"ltr\"><\/div>\n<div dir=\"ltr\"><\/div>\n<div dir=\"ltr\">Then in your manifest, you will need to add permisions, a meta-data, and an applicaiton, my manifest is shown below:<br \/><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;\">\n<table>\n<tbody>\n<tr>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\"> 1<br \/> 2<br \/> 3<br \/> 4<br \/> 5<br \/> 6<br \/> 7<br \/> 8<br \/> 9<br \/>10<br \/>11<br \/>12<br \/>13<br \/>14<br \/>15<br \/>16<br \/>17<br \/>18<br \/>19<br \/>20<br \/>21<br \/>22<br \/>23<br \/>24<br \/>25<br \/>26<br \/>27<br \/>28<br \/>29<br \/>30<br \/>31<br \/>32<\/pre>\n<\/td>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\"><span style=\"color: #333333;\">&lt;?<\/span>xml version<span style=\"color: #333333;\">=<\/span><span style=\"background-color: #fff0f0;\">\"1.0\"<\/span> encoding<span style=\"color: #333333;\">=<\/span><span style=\"background-color: #fff0f0;\">\"utf-8\"<\/span><span style=\"color: #333333;\">?&gt;<\/span><br \/><span style=\"color: #333333;\">&lt;<\/span>manifest <span style=\"color: #997700; font-weight: bold;\">xmlns:<\/span>android<span style=\"color: #333333;\">=<\/span><span style=\"background-color: #fff0f0;\">\"http:\/\/schemas.android.com\/apk\/res\/android\"<\/span><br \/>    package<span style=\"color: #333333;\">=<\/span><span style=\"background-color: #fff0f0;\">\"com.chewystudios.iciclemayhem.android\"<\/span><br \/>    <span style=\"color: #997700; font-weight: bold;\">android:<\/span>versionCode<span style=\"color: #333333;\">=<\/span><span style=\"background-color: #fff0f0;\">\"1\"<\/span><br \/>    <span style=\"color: #997700; font-weight: bold;\">android:<\/span>versionName<span style=\"color: #333333;\">=<\/span><span style=\"background-color: #fff0f0;\">\"1.0\"<\/span> <span style=\"color: #333333;\">&gt;<\/span><br \/>    <span style=\"color: #333333;\">&lt;<\/span>uses<span style=\"color: #333333;\">-<\/span>permission <span style=\"color: #997700; font-weight: bold;\">android:<\/span>name<span style=\"color: #333333;\">=<\/span><span style=\"background-color: #fff0f0;\">\"android.permission.INTERNET\"<\/span><span style=\"color: #333333;\">\/&gt;<\/span><br \/>    <span style=\"color: #333333;\">&lt;<\/span>uses<span style=\"color: #333333;\">-<\/span>permission <span style=\"color: #997700; font-weight: bold;\">android:<\/span>name<span style=\"color: #333333;\">=<\/span><span style=\"background-color: #fff0f0;\">\"android.permission.ACCESS_NETWORK_STATE\"<\/span><span style=\"color: #333333;\">\/&gt;<\/span><br \/>    <span style=\"color: #333333;\">&lt;<\/span>uses<span style=\"color: #333333;\">-<\/span>sdk <span style=\"color: #997700; font-weight: bold;\">android:<\/span>minSdkVersion<span style=\"color: #333333;\">=<\/span><span style=\"background-color: #fff0f0;\">\"9\"<\/span> <span style=\"color: #997700; font-weight: bold;\">android:<\/span>targetSdkVersion<span style=\"color: #333333;\">=<\/span><span style=\"background-color: #fff0f0;\">\"21\"<\/span> <span style=\"color: #333333;\">\/&gt;<\/span><br \/><br \/>    <span style=\"color: #333333;\">&lt;<\/span>application<br \/>        <span style=\"color: #997700; font-weight: bold;\">android:<\/span>allowBackup<span style=\"color: #333333;\">=<\/span><span style=\"background-color: #fff0f0;\">\"true\"<\/span><br \/>        <span style=\"color: #997700; font-weight: bold;\">android:<\/span>icon<span style=\"color: #333333;\">=<\/span><span style=\"background-color: #fff0f0;\">\"@drawable\/ic_launcher\"<\/span><br \/>        <span style=\"color: #997700; font-weight: bold;\">android:<\/span>label<span style=\"color: #333333;\">=<\/span><span style=\"background-color: #fff0f0;\">\"@string\/app_name\"<\/span><br \/>        <span style=\"color: #997700; font-weight: bold;\">android:<\/span>theme<span style=\"color: #333333;\">=<\/span><span style=\"background-color: #fff0f0;\">\"@style\/GdxTheme\"<\/span> <span style=\"color: #333333;\">&gt;<\/span><br \/>        <span style=\"color: #333333;\">&lt;<\/span>meta<span style=\"color: #333333;\">-<\/span>data <span style=\"color: #997700; font-weight: bold;\">android:<\/span>name<span style=\"color: #333333;\">=<\/span><span style=\"background-color: #fff0f0;\">\"com.google.android.gms.version\"<\/span><br \/>            <span style=\"color: #997700; font-weight: bold;\">android:<\/span>value<span style=\"color: #333333;\">=<\/span><span style=\"background-color: #fff0f0;\">\"@integer\/google_play_services_version\"<\/span> <span style=\"color: #333333;\">\/&gt;<\/span><br \/>        <span style=\"color: #333333;\">&lt;<\/span>activity<br \/>            <span style=\"color: #997700; font-weight: bold;\">android:<\/span>name<span style=\"color: #333333;\">=<\/span><span style=\"background-color: #fff0f0;\">\"com.chewystudios.iciclemayhem.android.AndroidLauncher\"<\/span><br \/>            <span style=\"color: #997700; font-weight: bold;\">android:<\/span>label<span style=\"color: #333333;\">=<\/span><span style=\"background-color: #fff0f0;\">\"@string\/app_name\"<\/span> <br \/>            <span style=\"color: #997700; font-weight: bold;\">android:<\/span>screenOrientation<span style=\"color: #333333;\">=<\/span><span style=\"background-color: #fff0f0;\">\"portrait\"<\/span><br \/>            <span style=\"color: #997700; font-weight: bold;\">android:<\/span>configChanges<span style=\"color: #333333;\">=<\/span><span style=\"background-color: #fff0f0;\">\"keyboard|keyboardHidden|orientation|screenSize\"<\/span><span style=\"color: #333333;\">&gt;<\/span><br \/>            <span style=\"color: #333333;\">&lt;<\/span>intent<span style=\"color: #333333;\">-<\/span>filter<span style=\"color: #333333;\">&gt;<\/span><br \/>                <span style=\"color: #333333;\">&lt;<\/span>action <span style=\"color: #997700; font-weight: bold;\">android:<\/span>name<span style=\"color: #333333;\">=<\/span><span style=\"background-color: #fff0f0;\">\"android.intent.action.MAIN\"<\/span> <span style=\"color: #333333;\">\/&gt;<\/span><br \/>                <span style=\"color: #333333;\">&lt;<\/span>category <span style=\"color: #997700; font-weight: bold;\">android:<\/span>name<span style=\"color: #333333;\">=<\/span><span style=\"background-color: #fff0f0;\">\"android.intent.category.LAUNCHER\"<\/span> <span style=\"color: #333333;\">\/&gt;<\/span><br \/>            <span style=\"color: #333333;\">&lt;\/<\/span>intent<span style=\"color: #333333;\">-<\/span>filter<span style=\"color: #333333;\">&gt;<\/span><br \/>        <span style=\"color: #333333;\">&lt;\/<\/span>activity<span style=\"color: #333333;\">&gt;<\/span><br \/>        <span style=\"color: #333333;\">&lt;<\/span>activity <span style=\"color: #997700; font-weight: bold;\">android:<\/span>name<span style=\"color: #333333;\">=<\/span><span style=\"background-color: #fff0f0;\">\"com.google.android.gms.ads.AdActivity\"<\/span><br \/>            <span style=\"color: #997700; font-weight: bold;\">android:<\/span>configChanges<span style=\"color: #333333;\">=<\/span><span style=\"background-color: #fff0f0;\">\"keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize\"<\/span><br \/>            <span style=\"color: #997700; font-weight: bold;\">android:<\/span>theme<span style=\"color: #333333;\">=<\/span><span style=\"background-color: #fff0f0;\">\"@android:style\/Theme.Translucent\"<\/span> <span style=\"color: #333333;\">\/&gt;<\/span><br \/>    <span style=\"color: #333333;\">&lt;\/<\/span>application<span style=\"color: #333333;\">&gt;<\/span><br \/><br \/><span style=\"color: #333333;\">&lt;\/<\/span>manifest<span style=\"color: #333333;\">&gt;<\/span><br \/><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>Then you are going to need to edit AndroidLauncher.java under the android directory. I will not explain what each step does to just save some time, but if you simply change your AndroidLauncher.java to the following, and you have made it so far, it will most likely make some sense to you. One hint, we are simply creating two views on the screen, one for the ad, and on for the game, and placcing them together onto the screen:<br \/><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #ffffff; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;\">\n<table>\n<tbody>\n<tr>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\"> 1<br \/> 2<br \/> 3<br \/> 4<br \/> 5<br \/> 6<br \/> 7<br \/> 8<br \/> 9<br \/>10<br \/>11<br \/>12<br \/>13<br \/>14<br \/>15<br \/>16<br \/>17<br \/>18<br \/>19<br \/>20<br \/>21<br \/>22<br \/>23<br \/>24<br \/>25<br \/>26<br \/>27<br \/>28<br \/>29<br \/>30<br \/>31<br \/>32<br \/>33<\/pre>\n<\/td>\n<td>\n<pre style=\"line-height: 125%; margin: 0;\">        <span style=\"color: #555555; font-weight: bold;\">@Override<\/span><br \/> <span style=\"color: #008800; font-weight: bold;\">protected<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">onCreate<\/span> <span style=\"color: #333333;\">(<\/span>Bundle savedInstanceState<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span><br \/>  <span style=\"color: #008800; font-weight: bold;\">super<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">onCreate<\/span><span style=\"color: #333333;\">(<\/span>savedInstanceState<span style=\"color: #333333;\">);<\/span><br \/>  AndroidApplicationConfiguration config <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> AndroidApplicationConfiguration<span style=\"color: #333333;\">();<\/span><br \/>  <span style=\"color: #888888;\">\/\/initialize(new MyGdxGame(), config);<\/span><br \/><br \/>        <span style=\"color: #888888;\">\/\/ADMOB STUFF\/\/\/<\/span><br \/>        requestWindowFeature<span style=\"color: #333333;\">(<\/span>Window<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">FEATURE_NO_TITLE<\/span><span style=\"color: #333333;\">);<\/span><br \/>        getWindow<span style=\"color: #333333;\">().<\/span><span style=\"color: #0000cc;\">setFlags<\/span><span style=\"color: #333333;\">(<\/span>WindowManager<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">LayoutParams<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">FLAG_FULLSCREEN<\/span><span style=\"color: #333333;\">,<\/span><br \/>                WindowManager<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">LayoutParams<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">FLAG_FULLSCREEN<\/span><span style=\"color: #333333;\">);<\/span><br \/>        getWindow<span style=\"color: #333333;\">().<\/span><span style=\"color: #0000cc;\">clearFlags<\/span><span style=\"color: #333333;\">(<\/span>WindowManager<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">LayoutParams<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">FLAG_FORCE_NOT_FULLSCREEN<\/span><span style=\"color: #333333;\">);<\/span><br \/><br \/>        AdView adView <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> AdView<span style=\"color: #333333;\">(<\/span><span style=\"color: #008800; font-weight: bold;\">this<\/span><span style=\"color: #333333;\">);<\/span><br \/>        adView<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">setAdSize<\/span><span style=\"color: #333333;\">(<\/span>AdSize<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">BANNER<\/span><span style=\"color: #333333;\">);<\/span><br \/>        adView<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">setAdUnitId<\/span><span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"Add Your Ad UNIT ID Here\"<\/span><span style=\"color: #333333;\">);<\/span><br \/>        AdRequest<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">Builder<\/span> adRequestBuilder <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> AdRequest<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">Builder<\/span><span style=\"color: #333333;\">();<\/span><br \/>        adRequestBuilder<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">addTestDevice<\/span><span style=\"color: #333333;\">(<\/span>AdRequest<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">DEVICE_ID_EMULATOR<\/span><span style=\"color: #333333;\">);<\/span><br \/>        adView<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">loadAd<\/span><span style=\"color: #333333;\">(<\/span>adRequestBuilder<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">build<\/span><span style=\"color: #333333;\">());<\/span><br \/><br \/>        RelativeLayout layout <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> RelativeLayout<span style=\"color: #333333;\">(<\/span><span style=\"color: #008800; font-weight: bold;\">this<\/span><span style=\"color: #333333;\">);<\/span><br \/>        View gameView <span style=\"color: #333333;\">=<\/span> initializeForView<span style=\"color: #333333;\">(<\/span><span style=\"color: #008800; font-weight: bold;\">new<\/span> MyGdxGame<span style=\"color: #333333;\">(),<\/span> config<span style=\"color: #333333;\">);<\/span><br \/><br \/>        RelativeLayout<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">LayoutParams<\/span> adParams <span style=\"color: #333333;\">=<\/span><br \/>                <span style=\"color: #008800; font-weight: bold;\">new<\/span> RelativeLayout<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">LayoutParams<\/span><span style=\"color: #333333;\">(<\/span>RelativeLayout<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">LayoutParams<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">WRAP_CONTENT<\/span><span style=\"color: #333333;\">,<\/span><br \/>                        RelativeLayout<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">LayoutParams<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">WRAP_CONTENT<\/span><span style=\"color: #333333;\">);<\/span><br \/>        adParams<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">addRule<\/span><span style=\"color: #333333;\">(<\/span>RelativeLayout<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">ALIGN_PARENT_BOTTOM<\/span><span style=\"color: #333333;\">);<\/span><br \/><br \/><br \/>        layout<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">addView<\/span><span style=\"color: #333333;\">(<\/span>gameView<span style=\"color: #333333;\">);<\/span><br \/>        layout<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">addView<\/span><span style=\"color: #333333;\">(<\/span>adView<span style=\"color: #333333;\">,<\/span> adParams<span style=\"color: #333333;\">);<\/span><br \/>        setContentView<span style=\"color: #333333;\">(<\/span>layout<span style=\"color: #333333;\">);<\/span><br \/>        <span style=\"color: #888888;\">\/\/END ADMOB STUFF\/\/<\/span><br \/> <span style=\"color: #333333;\">}<\/span><br \/><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>If you have futher issues with the admob addition, please let me know by leaving a comment, i&#8217;ll be happy to help.<br \/><b><br \/><\/b><b>Final Step:<\/b><br \/>Your game is complete, you can upload it to the marketplace! We did leave out one step of changing the launch icon for your app, but it is rather simple to look up how to do, the launch icon is located in the androidmanifest.xml file. Now it is time to publish and immediatly start having a flush of new ideas you wish to have for the game. As I was placing the final touches, some ideas have came into my head such as adding walking animation and making the icicles fall more realisticly, heck, I might even create a part 2 to this, just so we can start doing complicated things. Anyways, let me know if you have any questions! Happy to help.<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>This is a one page guide from start to finish on how to create your first libgdx game for android\/iOS\/html5\/desktop. I am however going to skip downloading java, SDK, and libgdx, as I&#8217;m assuming you already possess those if you are reading this. If you do not infact do, there are many various tutorials online&#8230;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-88","post","type-post","status-publish","format-standard","hentry","category-programming"],"_links":{"self":[{"href":"https:\/\/therenaissanceraven.com\/index.php?rest_route=\/wp\/v2\/posts\/88","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/therenaissanceraven.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/therenaissanceraven.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/therenaissanceraven.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/therenaissanceraven.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=88"}],"version-history":[{"count":0,"href":"https:\/\/therenaissanceraven.com\/index.php?rest_route=\/wp\/v2\/posts\/88\/revisions"}],"wp:attachment":[{"href":"https:\/\/therenaissanceraven.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=88"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/therenaissanceraven.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=88"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/therenaissanceraven.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=88"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}