Hi, I have a very basic project for android studio. I need to create a bouncing ball app with at least two control threads. The sample code for bouncing ball is already given.(you must remove one ball...

Hi, I have a very basic project for android studio.
I need to create a bouncing ball app with at least two control threads.
The sample code for bouncing ball is already given.(you must remove one ball since there are two)
I have to add one bar/stick to the project and make it a simple game.

If the ball hits the bar/stick the score increases whereas if it fails game is over.

You can customize this project in any way you like. (i.e add the stick anywhere in the field ) The only requirement is that it must have atleast two control threads !

It is very simple project and can be done in few hours. Let me know if you have further questions !


BouncingBall/app/proguard-rules.pro # Add project specific ProGuard rules here. # By default, the flags in this file are appended to flags specified # in /Applications/Android Studio.app/sdk/tools/proguard/proguard-android.txt # You can edit the include path and order by changing the proguardFiles # directive in build.gradle. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html # Add any project specific keep options here: # If your project uses WebView with JS, uncomment the following # and specify the fully qualified class name to the JavaScript interface # class: #-keepclassmembers class fqcn.of.javascript.interface.for.webview { # public *; #} BouncingBall/app/.gitignore /build BouncingBall/app/build.gradle apply plugin: 'com.android.application' android { compileSdkVersion 27 defaultConfig { applicationId "com.cornez.bouncingball" minSdkVersion 19 targetSdkVersion 27 versionCode 1 versionName "1.0" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) } BouncingBall/app/src/androidTest/java/com/cornez/bouncingball/ApplicationTest.java BouncingBall/app/src/androidTest/java/com/cornez/bouncingball/ApplicationTest.java package com.cornez.bouncingball; import android.app.Application; import android.test.ApplicationTestCase; /**  * Testing Fundamentals  */ public class ApplicationTest extends ApplicationTestCase {     public ApplicationTest() {         super(Application.class);     } } BouncingBall/app/src/main/res/values-w820dp/dimens.xml 64dp BouncingBall/app/src/main/res/layout/activity_my.xml BouncingBall/app/src/main/res/values/dimens.xml 16dp 16dp BouncingBall/app/src/main/res/values/styles.xml BouncingBall/app/src/main/res/values/strings.xml Bouncing Ball Hello world! Settings BouncingBall/app/src/main/res/drawable-xhdpi/ic_launcher.png BouncingBall/app/src/main/res/drawable-xxhdpi/ic_launcher.png BouncingBall/app/src/main/res/drawable-hdpi/ic_launcher.png BouncingBall/app/src/main/res/menu/my.xml BouncingBall/app/src/main/res/drawable-mdpi/ic_launcher.png BouncingBall/app/src/main/AndroidManifest.xml BouncingBall/app/src/main/java/com/cornez/bouncingball/AnimationArena.java BouncingBall/app/src/main/java/com/cornez/bouncingball/AnimationArena.java package com.cornez.bouncingball; import android.graphics.Canvas; public class AnimationArena {     private Ball mBall,mBall1;     public AnimationArena () {         //INSTANTIATE THE BALL         mBall = new Ball();         mBall1 = new Ball();     }     public void update (int width, int height) {         mBall.move(0, 0, width, height);         mBall1.move(0, 0, width, height);     }     public void draw (Canvas canvas) {         //WIPE THE CANVAS CLEAN         canvas.drawRGB(156, 174, 216);         //DRAW THE BALL         mBall.draw(canvas);         mBall1.draw(canvas);     } } BouncingBall/app/src/main/java/com/cornez/bouncingball/BounceSurfaceView.java BouncingBall/app/src/main/java/com/cornez/bouncingball/BounceSurfaceView.java package com.cornez.bouncingball; import android.content.Context; import android.graphics.Canvas; import android.util.AttributeSet; import android.view.SurfaceHolder; import android.view.SurfaceView; public class BounceSurfaceView extends SurfaceView implements         SurfaceHolder.Callback {     private BounceThread bounceThread;     public BounceSurfaceView (Context context, AttributeSet attrs){         super (context, attrs);         SurfaceHolder holder = getHolder();         holder.addCallback(this);         //CREATE A NEW THREAD         bounceThread = new BounceThread(holder);     }     //IMPLEMENT THE INHERITED ABSTRACT METHODS     public void surfaceChanged (SurfaceHolder holder, int format,                                 int width, int height) {}     public void surfaceCreated (SurfaceHolder holder) {         bounceThread.start();     }     public void surfaceDestroyed (SurfaceHolder holder) {         bounceThread.endBounce();         Thread dummyThread = bounceThread;         bounceThread = null;         dummyThread.interrupt();     } } BouncingBall/app/src/main/java/com/cornez/bouncingball/MyActivity.java BouncingBall/app/src/main/java/com/cornez/bouncingball/MyActivity.java package com.cornez.bouncingball; import android.app.Activity; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.widget.FrameLayout; public class MyActivity extends Activity {     @Override     protected void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         // INFLATE THE LAYOUT CONTAINING THE FRAMELAYOUT ELEMENT         setContentView(R.layout.activity_my);         // REFERENCE THE FRAMELAYOUT ELEMENT         FrameLayout frameLayout = (FrameLayout) findViewById(R.id.frameLayout);         // INSTANTIATE A CUSTOM SURFACE VIEW         // ADD IT TO THE FRAMELAYOUT         BounceSurfaceView bounceSurfaceView = new BounceSurfaceView(this, null);         frameLayout.addView(bounceSurfaceView);     }     @Override     public boolean onCreateOptionsMenu(Menu menu) {         // Inflate the menu.         getMenuInflater().inflate(R.menu.my, menu);         return true;     }     @Override     public boolean onOptionsItemSelected(MenuItem item) {         // Handle action bar item clicks here. The action bar will         // automatically handle clicks on the Home/Up button, so long         // as you specify a parent activity in AndroidManifest.xml.         int id = item.getItemId();         if (id == R.id.action_settings) {             return true;         }         return super.onOptionsItemSelected(item);     } } BouncingBall/app/src/main/java/com/cornez/bouncingball/Ball.java BouncingBall/app/src/main/java/com/cornez/bouncingball/Ball.java package com.cornez.bouncingball; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.util.Log; import java.util.Random; public class Ball {     private final int RADIUS = 50;     private final int REVERSE = -1;     private int x, oldx;     private int y, oldy;     private int velX;     private int velY;     public Ball() {         Random r=new Random();         x = r.nextInt(200);         y = r.nextInt(200);         velX = 10+r.nextInt(10);         velY = 10+r.nextInt(10);     }     public int getOldxX() {         return oldx;     }     public int getOldyY() {         return oldy;     }     public int getRADIUS() {         return RADIUS;     }     public void move(int leftWall, int topWall,                      int rightWall, int bottomWall) {         //MOVE BALL         x += velX;         y += velY;         //CHECK FOR COLLISIONS ALONG WALLS         if (y > bottomWall - RADIUS) {             y = bottomWall - RADIUS;             velY *= REVERSE;         } else if (y < topwall + radius) {             y =" topWall + RADIUS;"             vely *=" REVERSE;"         }=""         if (x =""> rightWall - RADIUS) {             x = rightWall - RADIUS;             velX *= REVERSE;         } else if (x < leftwall + radius) {             x =" leftWall + RADIUS;"             velx *=" REVERSE;"         }=""     }=""     public void draw(canvas canvas) {=""         paint paint =" new Paint();"         paint.setcolor(color.rgb(211, 216, 156));=""         canvas.drawcircle(x, y, radius, paint);=""     }="" }="" bouncingball/app/src/main/java/com/cornez/bouncingball/bouncethread.java="" bouncingball/app/src/main/java/com/cornez/bouncingball/bouncethread.java="" package com.cornez.bouncingball;="" import android.graphics.canvas;="" import android.view.surfaceholder;="" public class bouncethread extends thread {=""     private surfaceholder surfaceholder;=""     private animationarena animationarena;=""     private boolean isrunning;=""    public bouncethread (surfaceholder sh){=""         isrunning =" true;"         surfaceholder =" sh;"         animationarena =" new AnimationArena();"     }=""     public void run() {=""         try {=""             while (isrunning) {=""                 canvas canvas =" surfaceHolder.lockCanvas();"                 //synchronized (canvas) {=""                     animationarena.update(canvas.getwidth(),=""                             canvas.getheight());=""                     animationarena.draw(canvas);=""                 //}=""                 surfaceholder.unlockcanvasandpost(canvas);=""                 //thread.sleep(1000);=""             }=""         }catch (exception e){=""             e.printstacktrace();=""         }=""     }=""     public void endbounce() {=""         isrunning =" false;"     }="" }="" bouncingball/gradle/wrapper/gradle-wrapper.jar="" meta-inf/manifest.mf="" manifest-version:="" 1.0="" implementation-title:="" gradle="" implementation-version:="" 1.6-20130404052254+0000="" org/gradle/wrapper/download$1.class="" package="" org.gradle.wrapper;="" synchronized="" class="" download$1="" {="" }="" org/gradle/wrapper/download$systempropertiesproxyauthenticator.class="" package="" org.gradle.wrapper;="" synchronized="" class="" download$systempropertiesproxyauthenticator="" extends="" java.net.authenticator="" {="" private="" void="" download$systempropertiesproxyauthenticator();="" protected="" java.net.passwordauthentication="" getpasswordauthentication();="" }="" org/gradle/wrapper/idownload.class="" package="" org.gradle.wrapper;="" public="" abstract="" interface="" idownload="" {="" public="" abstract="" void="" download(java.net.uri,="" java.io.file)="" throws="" exception;="" }="" org/gradle/wrapper/exclusivefileaccessmanager.class="" package="" org.gradle.wrapper;="" public="" synchronized="" class="" exclusivefileaccessmanager="" {="" public="" static="" final="" string="" lock_file_suffix=".lck;" private="" final="" int="" timeoutms;="" private="" final="" int="" pollintervalms;="" public="" void="" exclusivefileaccessmanager(int,="" int);="" public="" object="" access(java.io.file,="" java.util.concurrent.callable);="" private="" static="" void="" maybeclosequietly(java.io.closeable);="" }="" org/gradle/wrapper/wrapperconfiguration.class="" package="" org.gradle.wrapper;="" public="" synchronized="" class="" wrapperconfiguration="" {="" private="" java.net.uri="" distribution;="" private="" string="" distributionbase;="" private="" string="" distributionpath;="" private="" string="" zipbase;="" private="" string="" zippath;="" public="" void="" wrapperconfiguration();="" public="" java.net.uri="" getdistribution();="" public="" void="" setdistribution(java.net.uri);="" public="" string="" getdistributionbase();="" public="" void="" setdistributionbase(string);="" public="" string="" getdistributionpath();="" public="" void="" setdistributionpath(string);="" public="" string="" getzipbase();="" public="" void="" setzipbase(string);="" public="" string="" getzippath();="" public="" void="" setzippath(string);="" }="" org/gradle/wrapper/systempropertieshandler.class="" package="" org.gradle.wrapper;="" public="" synchronized="" class="" systempropertieshandler="" {="" public="" void="" systempropertieshandler();="" public="" static="" java.util.map="" getsystemproperties(java.io.file);="" }="" org/gradle/wrapper/pathassembler.class="" package="" org.gradle.wrapper;="" public="" synchronized="" class="" pathassembler="" {="" public="" static="" final="" string="" gradle_user_home_string="GRADLE_USER_HOME;" public="" static="" final="" string="" project_string="PROJECT;" private="" java.io.file="" gradleuserhome;="" public="" void="" pathassembler();="" public="" void="" pathassembler(java.io.file);="" public="" pathassembler$localdistribution="" getdistribution(wrapperconfiguration);="" private="" string="" rootdirname(string,="" wrapperconfiguration);="" private="" string="" getmd5hash(string);="" private="" string="" removeextension(string);="" private="" string="" getdistname(java.net.uri);="" private="" java.io.file="" getbasedir(string);="" }="" org/gradle/wrapper/install.class="" package="" org.gradle.wrapper;="" public="" synchronized="" class="" install="" {="" public="" static="" final="" string="" default_distribution_path="wrapper/dists;" private="" final="" idownload="" download;="" private="" final="" pathassembler="" pathassembler;="" private="" final="" exclusivefileaccessmanager="" exclusivefileaccessmanager;="" public="" void="" install(idownload,="" pathassembler);="" public="" java.io.file="" createdist(wrapperconfiguration)="" throws="" exception;="" private="" java.io.file="" getdistributionroot(java.io.file,="" string);="" private="" java.util.list="" listdirs(java.io.file);="" private="" void="" setexecutablepermissions(java.io.file);="" private="" boolean="" iswindows();="" private="" boolean="" deletedir(java.io.file);="" private="" void="" unzip(java.io.file,="" java.io.file)="" throws="" java.io.ioexception;="" private="" void="" copyinputstream(java.io.inputstream,="" java.io.outputstream)="" throws="" java.io.ioexception;="" }="" org/gradle/wrapper/bootstrapmainstarter.class="" package="" org.gradle.wrapper;="" public="" synchronized="" class="" bootstrapmainstarter="" {="" public="" void="" bootstrapmainstarter();="" public="" void="" start(string[],="" java.io.file)="" throws="" exception;="" private="" java.io.file="" findlauncherjar(java.io.file);="" }="" org/gradle/wrapper/wrapperexecutor.class="" package="" org.gradle.wrapper;="" public="" synchronized="" class="" wrapperexecutor="" {="" public="" static="" final="" string="" distribution_url_property="distributionUrl;" public="" static="" final="" string="" distribution_base_property="distributionBase;" public="" static="" final="" string="" zip_store_base_property="zipStoreBase;" public="" static="" final="" string="" distribution_path_property="distributionPath;" public="" static="" final="" string="" zip_store_path_property="zipStorePath;" private="" final="" java.util.properties="" properties;="" private="" final="" java.io.file="" propertiesfile;="" private="" final="" appendable="" warningoutput;="" private="" final="" wrapperconfiguration="" config;="" public="" static="" wrapperexecutor="" forprojectdirectory(java.io.file,="" appendable);="" public="" static="" wrapperexecutor="" forwrapperpropertiesfile(java.io.file,="" appendable);="" void="" wrapperexecutor(java.io.file,="" java.util.properties,="" appendable);="" private="" java.net.uri="" preparedistributionuri()="" throws="" java.net.urisyntaxexception;="" private="" java.net.uri="" readdistrourl()="" throws="" java.net.urisyntaxexception;="" private="" java.net.uri="" readdistrourldeprecatedway()="" throws="" java.net.urisyntaxexception;="" private="" static="" void="" loadproperties(java.io.file,="" java.util.properties)="" throws="" java.io.ioexception;="" public="" java.net.uri="" getdistribution();="" public="" wrapperconfiguration="" getconfiguration();="" public="" void="" execute(string[],="" install,="" bootstrapmainstarter)="" throws="" exception;="" private="" string="" getproperty(string);="" private="" string="" getproperty(string,="" string);="" private="" string="" reportmissingproperty(string);="" }="" org/gradle/wrapper/gradlewrappermain.class="" package="" org.gradle.wrapper;="" public="" synchronized="" class="" gradlewrappermain="" {="" public="" static="" final="" string="" default_gradle_user_home;="" public="" static="" final="" string="" gradle_user_home_property_key="gradle.user.home;" public="" static="" final="" string="" gradle_user_home_env_key="GRADLE_USER_HOME;" public="" void="" gradlewrappermain();="" public="" static="" void="" main(string[])="" throws="" exception;="" private="" static="" java.util.map="" parsesystempropertiesfromargs(string[]);="" private="" static="" void="" addsystemproperties(java.io.file);="" private="" static="" java.io.file="" rootdir(java.io.file);="" private="" static="" java.io.file="" wrapperproperties(java.io.file);="" private="" static="" java.io.file="" wrapperjar();="" static="" string="" wrapperversion();="" private="" static="" java.io.file="" gradleuserhome();="" static="" void="">(); } org/gradle/wrapper/Install$1.class package org.gradle.wrapper; synchronized class Install$1 implements java.util.concurrent.Callable { void Install$1(Install, java.io.File, java.io.File, java.net.URI); public java.io.File call() throws Exception; } org/gradle/wrapper/PathAssembler$LocalDistribution.class package org.gradle.wrapper; public synchronized class PathAssembler$LocalDistribution { private final java.io.File distZip; private final java.io.File distDir; public void PathAssembler$LocalDistribution(PathAssembler, java.io.File, java.io.File); public java.io.File getDistributionDir(); public java.io.File getZipFile(); } org/gradle/wrapper/Download.class package org.gradle.wrapper; public synchronized class Download implements IDownload { private static final int PROGRESS_CHUNK = 20000; private static final int BUFFER_SIZE = 10000; private final String applicationName; private final String applicationVersion; public void Download(String, String); private void configureProxyAuthentication();
May 22, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here