-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
this push includes: 2<n<4 players pause menu single player ui mulitplayer ui AI that can handle all angles ball redirect on collision with paddle
- Loading branch information
Showing
21 changed files
with
1,214 additions
and
520 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry kind="src" path="gen"/> | ||
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/> | ||
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/> | ||
<classpathentry kind="output" path="bin/classes"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
|
||
package com.android.packages.ballslappers; | ||
|
||
import static org.andengine.extension.physics.box2d.util.constants.PhysicsConstants.PIXEL_TO_METER_RATIO_DEFAULT; | ||
|
||
import android.util.Log; | ||
|
||
import com.badlogic.gdx.math.Vector2; | ||
import com.badlogic.gdx.physics.box2d.Body; | ||
|
||
public class AI { | ||
/* Vector2 for the position the ball should move to */ | ||
private Vector2 newAIPos = new Vector2(); | ||
private static final float speed = 20; | ||
private Slapper slapper; | ||
private int t = 0; | ||
|
||
public AI(Slapper s) { | ||
this.slapper = s; | ||
} | ||
|
||
public Slapper getSlapper() { | ||
return slapper; | ||
} | ||
|
||
public Vector2 update(Body ball, Slapper slapper2, int type) { | ||
this.t = type; | ||
this.newAIPos = ball.getPosition(); | ||
int ballx = Math.round(PIXEL_TO_METER_RATIO_DEFAULT*newAIPos.x); | ||
int bally = Math.round(PIXEL_TO_METER_RATIO_DEFAULT*newAIPos.y); | ||
float orientation = slapper.getSlapperOrientation(); | ||
float xmove = (float)(speed*Math.cos(orientation)); | ||
float ymove = (float)(speed*Math.sin(orientation)); | ||
float slapperX = slapper.getSlapperX(); | ||
float slapperY = slapper.getSlapperY(); | ||
float height = slapper.getHeight()*(float)Math.sin(orientation); | ||
//float width = slapper.getHeight()*(float)Math.cos(orientation); | ||
|
||
if(orientation !=0) { //if it is not horizontal then it should move based on y axis solely | ||
|
||
if(slapperY > bally - ymove) { | ||
//paddleconverted -= speed; | ||
slapperX = slapperX-xmove; | ||
slapperY = slapperY-ymove; | ||
if (slapperY <= -518.475+40){ //trial and error niggas suck a dick coined by james(mike) | ||
slapperX= slapperX+xmove; | ||
slapperY = slapperY+ymove; | ||
} | ||
|
||
} | ||
//else if(slapper.getX() < ballx - speed) { | ||
else if(slapperY <bally+ymove) { | ||
//paddleconverted += speed; | ||
slapperX = slapperX+xmove; | ||
slapperY = slapperY+ymove; | ||
if (slapperY >= 223.53-80 && MainActivity.NUM_SLAPPERS==3){ //trial and error niggas suck a dick coined by james(mike) | ||
slapperX= slapperX-xmove; | ||
slapperY = slapperY-ymove; | ||
} | ||
//slapper.setSlapperX(slapperX+xmove); | ||
//slapper.setSlapperY(slapperY+ymove); | ||
} | ||
} else if (orientation==0) { //if it is horizontal it should move based on x axis only | ||
if(slapperX > ballx - xmove) { | ||
//paddleconverted -= speed; | ||
slapperX = slapperX-xmove; | ||
//slapperY = slapperY-ymove; | ||
} | ||
//else if(slapper.getX() < ballx - speed) { | ||
else if(slapperX <ballx+xmove) { | ||
//paddleconverted += speed; | ||
slapperX = slapperX+xmove; | ||
//slapperY = slapperY+ymove; | ||
//slapper.setSlapperX(slapperX+xmove); | ||
//slapper.setSlapperY(slapperY+ymove); | ||
} | ||
} | ||
|
||
slapper.setSlapperX(slapperX); | ||
slapper.setSlapperY(slapperY); | ||
/* | ||
if (t ==0 && MainActivity.NUM_SLAPPERS==3) { | ||
slapper.setSlapperY(slapper.bound((-518.475f+50f), (223.53f-50f), slapperY)); | ||
slapper.setSlapperX(slapper.bound((-176.47f+50f), (174.345f-50f), slapperX)); | ||
} | ||
if (t ==1 && MainActivity.NUM_SLAPPERS==3) { | ||
slapper.setSlapperY(slapper.bound((-518.475f+50f), (223.53f-50f), slapperY)); | ||
slapper.setSlapperX(slapper.bound((800f+50f), (800f+174.345f-50f), slapperX)); | ||
} | ||
*/ | ||
newAIPos.x = slapper.getSlapperX()/PIXEL_TO_METER_RATIO_DEFAULT; | ||
newAIPos.y = slapper.getSlapperY()/PIXEL_TO_METER_RATIO_DEFAULT; | ||
return newAIPos; | ||
|
||
|
||
|
||
} | ||
|
||
private Vector2 bound(float x, float y) { | ||
int num = MainActivity.NUM_SLAPPERS; | ||
|
||
|
||
|
||
return new Vector2(x,y); //change before testing | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,37 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.android.packages.ballslappers" | ||
android:versionCode="1" | ||
android:versionName="1.0"> | ||
<uses-sdk android:minSdkVersion="8" /> | ||
package="com.android.packages.ballslappers" | ||
android:versionCode="1" | ||
android:versionName="1.0"> | ||
|
||
<application android:icon="@drawable/icon" android:label="@string/app_name"> | ||
<activity android:name="MainActivity" | ||
android:label="@string/app_name"> | ||
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="15" /> | ||
|
||
<application android:label="@string/app_name" | ||
android:icon="@drawable/ic_launcher" | ||
android:theme="@style/AppTheme"> | ||
|
||
<activity android:name="HomeScreenActivity"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
|
||
<activity android:name="SinglePlayerCreateActivity"> | ||
|
||
</activity> | ||
|
||
<activity | ||
android:name=".MultiplayerCreateActivity" | ||
android:label="@string/title_activity_multiplayer_create" > | ||
<meta-data | ||
android:name="android.support.PARENT_ACTIVITY" | ||
android:value="com.example.ballslappers.HomeScreenActivity" /> | ||
</activity> | ||
|
||
<activity android:name="MainActivity"> | ||
|
||
</activity> | ||
|
||
</application> | ||
</manifest> | ||
|
||
</manifest> |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# To enable ProGuard in your project, edit project.properties | ||
# to define the proguard.config property as described in that file. | ||
# | ||
# Add project specific ProGuard rules here. | ||
# By default, the flags in this file are appended to flags specified | ||
# in ${sdk.dir}/tools/proguard/proguard-android.txt | ||
# You can edit the include path and order by changing the ProGuard | ||
# include property in project.properties. | ||
# | ||
# 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 *; | ||
#} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.