Skip to content

Commit

Permalink
INTEGRATION ALMOST COMPLETE
Browse files Browse the repository at this point in the history
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
jgiandel committed Oct 30, 2012
1 parent 17fbc58 commit f9e0725
Show file tree
Hide file tree
Showing 21 changed files with 1,214 additions and 520 deletions.
2 changes: 1 addition & 1 deletion .classpath
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>
2 changes: 1 addition & 1 deletion .project
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>BallSlapper</name>
<name>ballslappers</name>
<comment></comment>
<projects>
</projects>
Expand Down
108 changes: 108 additions & 0 deletions AI.java
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
}


}
8 changes: 8 additions & 0 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@

</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>
Expand Down
37 changes: 28 additions & 9 deletions bin/AndroidManifest.xml
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 modified bin/classes.dex
Binary file not shown.
Binary file added libs/android-support-v4.jar
Binary file not shown.
20 changes: 20 additions & 0 deletions proguard-project.txt
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 *;
#}
6 changes: 3 additions & 3 deletions project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt

# Project target.
target=android-10
android.library.reference.1=../../../../../../workspace/AndEngine
android.library.reference.2=../../../../../../workspace/AndEnginePhysicsBox2DExtension
target=android-16
android.library.reference.1=../../Desktop/New folder/AndEngine
android.library.reference.2=../../Desktop/New folder/AndEnginePhysicsBox2DExtension
132 changes: 77 additions & 55 deletions res/layout/activity_home_screen.xml
Original file line number Diff line number Diff line change
@@ -1,63 +1,85 @@
<LinearLayout xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearLayout1"
android:id="@+id/LinearLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:background="@drawable/background_test_1"
android:gravity="center|center_horizontal|center_vertical"
android:background="#434343"
android:orientation="vertical" >
<LinearLayout
xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/Menu_Layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="125dp"
android:gravity="center_horizontal"
android:orientation="vertical" >

<Button
android:id="@+id/singlePlayerButton"
style="@color/TransparentColor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/Dim10"
android:layout_marginBottom="49dp"
android:layout_marginRight="40dp"
android:background="@drawable/home_single_player_button"
android:onClick="SinglePlayerCreate" />

<Button
android:id="@+id/multiplayerButton"
style="@color/TransparentColor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/Dim10"
android:layout_marginBottom="112dp"
android:layout_marginLeft="12dp"
android:background="@drawable/home_multiplayer_button"
android:onClick="MultiplayerCreate" />

<Button
android:id="@+id/tutorialButton"
style="@color/TransparentColor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/Dim10"
android:layout_marginBottom="73dp"
android:background="@drawable/home_tutorial_button"
android:onClick="TutorialScreen" />

<Button
android:id="@+id/optionsButton"
style="@color/TransparentColor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/Dim10"
android:layout_marginBottom="82dp"
android:background="@drawable/home_options_button"
android:onClick="OptionsScreen" />

<Button
android:id="@+id/singlePlayerButton"
style="@color/TransparentColor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/Dim10"
android:layout_marginBottom="49dp"
android:layout_marginRight="40dp"
android:background="@drawable/home_single_player_button"
android:onClick="SinglePlayerCreate" />

<Button
android:id="@+id/multiplayerButton"
style="@color/TransparentColor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/Dim10"
android:layout_marginBottom="112dp"
android:layout_marginLeft="12dp"
android:background="@drawable/home_multiplayer_button"
android:onClick="MultiplayerCreate" />

<Button
android:id="@+id/tutorialButton"
style="@color/TransparentColor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/Dim10"
android:layout_marginBottom="73dp"
android:background="@drawable/home_tutorial_button"
android:onClick="TutorialScreen" />

<Button
android:id="@+id/optionsButton"
style="@color/TransparentColor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/Dim10"
android:layout_marginBottom="82dp"
android:background="@drawable/home_options_button"
android:onClick="OptionsScreen" />
<ToggleButton
android:id="@+id/toggleSound"
style="@color/TransparentColor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right"
android:background="@drawable/home_sound_button"
android:gravity="center_vertical|center_horizontal|center"
android:textOn="@android:string/yes" />
</LinearLayout>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/Sound_Layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp" >

<ToggleButton
android:id="@+id/toggleSound"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginRight="5dp"
android:background="@drawable/home_sound_button"
android:textOn="@android:string/yes" />

</RelativeLayout>

</LinearLayout>
Expand Down
Loading

0 comments on commit f9e0725

Please sign in to comment.