1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/GCA-BCS/.classpath Wed Oct 19 19:08:10 2011 -0400
1.3 @@ -0,0 +1,7 @@
1.4 +<?xml version="1.0" encoding="UTF-8"?>
1.5 +<classpath>
1.6 + <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
1.7 + <classpathentry kind="src" path="src"/>
1.8 + <classpathentry kind="src" path="gen"/>
1.9 + <classpathentry kind="output" path="bin"/>
1.10 +</classpath>
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/GCA-BCS/.project Wed Oct 19 19:08:10 2011 -0400
2.3 @@ -0,0 +1,33 @@
2.4 +<?xml version="1.0" encoding="UTF-8"?>
2.5 +<projectDescription>
2.6 + <name>Appathon</name>
2.7 + <comment></comment>
2.8 + <projects>
2.9 + </projects>
2.10 + <buildSpec>
2.11 + <buildCommand>
2.12 + <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
2.13 + <arguments>
2.14 + </arguments>
2.15 + </buildCommand>
2.16 + <buildCommand>
2.17 + <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
2.18 + <arguments>
2.19 + </arguments>
2.20 + </buildCommand>
2.21 + <buildCommand>
2.22 + <name>org.eclipse.jdt.core.javabuilder</name>
2.23 + <arguments>
2.24 + </arguments>
2.25 + </buildCommand>
2.26 + <buildCommand>
2.27 + <name>com.android.ide.eclipse.adt.ApkBuilder</name>
2.28 + <arguments>
2.29 + </arguments>
2.30 + </buildCommand>
2.31 + </buildSpec>
2.32 + <natures>
2.33 + <nature>com.android.ide.eclipse.adt.AndroidNature</nature>
2.34 + <nature>org.eclipse.jdt.core.javanature</nature>
2.35 + </natures>
2.36 +</projectDescription>
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/GCA-BCS/.settings/org.eclipse.jdt.core.prefs Wed Oct 19 19:08:10 2011 -0400
3.3 @@ -0,0 +1,5 @@
3.4 +#Fri Sep 30 17:23:57 EDT 2011
3.5 +eclipse.preferences.version=1
3.6 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
3.7 +org.eclipse.jdt.core.compiler.compliance=1.5
3.8 +org.eclipse.jdt.core.compiler.source=1.5
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/GCA-BCS/AndroidManifest.xml Wed Oct 19 19:08:10 2011 -0400
4.3 @@ -0,0 +1,19 @@
4.4 +<?xml version="1.0" encoding="utf-8"?>
4.5 +<manifest package="com.blackcloverstudios.appathon"
4.6 + android:versionCode="1"
4.7 + android:versionName="1.0" xmlns:android="http://schemas.android.com/apk/res/android">
4.8 + <uses-sdk android:minSdkVersion="10" />
4.9 +
4.10 + <application android:icon="@drawable/icon" android:label="@string/app_name">
4.11 + <activity android:name=".StartActivity"
4.12 + android:label="@string/app_name" android:screenOrientation="unspecified">
4.13 + <intent-filter>
4.14 + <action android:name="android.intent.action.MAIN" />
4.15 + <category android:name="android.intent.category.LAUNCHER" />
4.16 + </intent-filter>
4.17 + </activity>
4.18 + <activity android:screenOrientation="landscape" android:name="GameActivity"></activity>
4.19 + <activity android:name="InstrActivity"></activity>
4.20 +
4.21 + </application>
4.22 +</manifest>
4.23 \ No newline at end of file
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
5.2 +++ b/GCA-BCS/default.properties Wed Oct 19 19:08:10 2011 -0400
5.3 @@ -0,0 +1,11 @@
5.4 +# This file is automatically generated by Android Tools.
5.5 +# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
5.6 +#
5.7 +# This file must be checked in Version Control Systems.
5.8 +#
5.9 +# To customize properties used by the Ant build system use,
5.10 +# "build.properties", and override values to adapt the script to your
5.11 +# project structure.
5.12 +
5.13 +# Project target.
5.14 +target=android-10
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
6.2 +++ b/GCA-BCS/placeholder.txt Wed Oct 19 19:08:10 2011 -0400
6.3 @@ -0,0 +1,2 @@
6.4 +
6.5 +blah
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
7.2 +++ b/GCA-BCS/proguard.cfg Wed Oct 19 19:08:10 2011 -0400
7.3 @@ -0,0 +1,40 @@
7.4 +-optimizationpasses 5
7.5 +-dontusemixedcaseclassnames
7.6 +-dontskipnonpubliclibraryclasses
7.7 +-dontpreverify
7.8 +-verbose
7.9 +-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
7.10 +
7.11 +-keep public class * extends android.app.Activity
7.12 +-keep public class * extends android.app.Application
7.13 +-keep public class * extends android.app.Service
7.14 +-keep public class * extends android.content.BroadcastReceiver
7.15 +-keep public class * extends android.content.ContentProvider
7.16 +-keep public class * extends android.app.backup.BackupAgentHelper
7.17 +-keep public class * extends android.preference.Preference
7.18 +-keep public class com.android.vending.licensing.ILicensingService
7.19 +
7.20 +-keepclasseswithmembernames class * {
7.21 + native <methods>;
7.22 +}
7.23 +
7.24 +-keepclasseswithmembers class * {
7.25 + public <init>(android.content.Context, android.util.AttributeSet);
7.26 +}
7.27 +
7.28 +-keepclasseswithmembers class * {
7.29 + public <init>(android.content.Context, android.util.AttributeSet, int);
7.30 +}
7.31 +
7.32 +-keepclassmembers class * extends android.app.Activity {
7.33 + public void *(android.view.View);
7.34 +}
7.35 +
7.36 +-keepclassmembers enum * {
7.37 + public static **[] values();
7.38 + public static ** valueOf(java.lang.String);
7.39 +}
7.40 +
7.41 +-keep class * implements android.os.Parcelable {
7.42 + public static final android.os.Parcelable$Creator *;
7.43 +}
8.1 Binary file GCA-BCS/res/drawable-hdpi/baseball4.png has changed
9.1 Binary file GCA-BCS/res/drawable-hdpi/baseball_1.png has changed
10.1 Binary file GCA-BCS/res/drawable-hdpi/baseball_2.png has changed
11.1 Binary file GCA-BCS/res/drawable-hdpi/baseball_3.png has changed
12.1 Binary file GCA-BCS/res/drawable-hdpi/baseball_guy_back.png has changed
13.1 Binary file GCA-BCS/res/drawable-hdpi/baseball_guy_back_45_left.png has changed
14.1 Binary file GCA-BCS/res/drawable-hdpi/baseball_guy_back_45_left_throw.png has changed
15.1 Binary file GCA-BCS/res/drawable-hdpi/baseball_guy_back_45_left_walk1.png has changed
16.1 Binary file GCA-BCS/res/drawable-hdpi/baseball_guy_back_45_left_walk2.png has changed
17.1 Binary file GCA-BCS/res/drawable-hdpi/baseball_guy_back_45_right.png has changed
18.1 Binary file GCA-BCS/res/drawable-hdpi/baseball_guy_back_45_right_throw.png has changed
19.1 Binary file GCA-BCS/res/drawable-hdpi/baseball_guy_back_45_right_walk1.png has changed
20.1 Binary file GCA-BCS/res/drawable-hdpi/baseball_guy_back_45_right_walk2.png has changed
21.1 Binary file GCA-BCS/res/drawable-hdpi/baseball_guy_back_throw.png has changed
22.1 Binary file GCA-BCS/res/drawable-hdpi/baseball_guy_back_walk1.png has changed
23.1 Binary file GCA-BCS/res/drawable-hdpi/baseball_guy_back_walk2.png has changed
24.1 Binary file GCA-BCS/res/drawable-hdpi/baseball_guy_dead1.png has changed
25.1 Binary file GCA-BCS/res/drawable-hdpi/baseball_guy_dead2.png has changed
26.1 Binary file GCA-BCS/res/drawable-hdpi/baseball_guy_front.png has changed
27.1 Binary file GCA-BCS/res/drawable-hdpi/baseball_guy_front_45_left.png has changed
28.1 Binary file GCA-BCS/res/drawable-hdpi/baseball_guy_front_45_left_throw.png has changed
29.1 Binary file GCA-BCS/res/drawable-hdpi/baseball_guy_front_45_left_walk1.png has changed
30.1 Binary file GCA-BCS/res/drawable-hdpi/baseball_guy_front_45_right.png has changed
31.1 Binary file GCA-BCS/res/drawable-hdpi/baseball_guy_front_45_right_throw.png has changed
32.1 Binary file GCA-BCS/res/drawable-hdpi/baseball_guy_front_45_right_walk1.png has changed
33.1 Binary file GCA-BCS/res/drawable-hdpi/baseball_guy_front_45_right_walk2.png has changed
34.1 Binary file GCA-BCS/res/drawable-hdpi/baseball_guy_front_left_walk2.png has changed
35.1 Binary file GCA-BCS/res/drawable-hdpi/baseball_guy_front_throw.png has changed
36.1 Binary file GCA-BCS/res/drawable-hdpi/baseball_guy_front_walk1.png has changed
37.1 Binary file GCA-BCS/res/drawable-hdpi/baseball_guy_front_walk2.png has changed
38.1 Binary file GCA-BCS/res/drawable-hdpi/baseball_guy_left.png has changed
39.1 Binary file GCA-BCS/res/drawable-hdpi/baseball_guy_left_throw.png has changed
40.1 Binary file GCA-BCS/res/drawable-hdpi/baseball_guy_left_walk.png has changed
41.1 Binary file GCA-BCS/res/drawable-hdpi/baseball_guy_right.png has changed
42.1 Binary file GCA-BCS/res/drawable-hdpi/baseball_guy_right_throw.png has changed
43.1 Binary file GCA-BCS/res/drawable-hdpi/baseball_guy_right_walk.png has changed
44.1 Binary file GCA-BCS/res/drawable-hdpi/basketball_court.png has changed
45.1 Binary file GCA-BCS/res/drawable-hdpi/football_guy_back.png has changed
46.1 Binary file GCA-BCS/res/drawable-hdpi/football_guy_back_punch.png has changed
47.1 Binary file GCA-BCS/res/drawable-hdpi/football_guy_back_walk1.PNG has changed
48.1 Binary file GCA-BCS/res/drawable-hdpi/football_guy_back_walk2.PNG has changed
49.1 Binary file GCA-BCS/res/drawable-hdpi/football_guy_dead1.png has changed
50.1 Binary file GCA-BCS/res/drawable-hdpi/football_guy_dead2.png has changed
51.1 Binary file GCA-BCS/res/drawable-hdpi/football_guy_front.png has changed
52.1 Binary file GCA-BCS/res/drawable-hdpi/football_guy_front_punch.png has changed
53.1 Binary file GCA-BCS/res/drawable-hdpi/football_guy_front_walk1.png has changed
54.1 Binary file GCA-BCS/res/drawable-hdpi/football_guy_front_walk2.png has changed
55.1 Binary file GCA-BCS/res/drawable-hdpi/football_guy_left.png has changed
56.1 Binary file GCA-BCS/res/drawable-hdpi/football_guy_left_45_back.png has changed
57.1 Binary file GCA-BCS/res/drawable-hdpi/football_guy_left_45_back_punch.png has changed
58.1 Binary file GCA-BCS/res/drawable-hdpi/football_guy_left_45_back_walk1.png has changed
59.1 Binary file GCA-BCS/res/drawable-hdpi/football_guy_left_45_back_walk2.png has changed
60.1 Binary file GCA-BCS/res/drawable-hdpi/football_guy_left_45_front.png has changed
61.1 Binary file GCA-BCS/res/drawable-hdpi/football_guy_left_45_front_punch.png has changed
62.1 Binary file GCA-BCS/res/drawable-hdpi/football_guy_left_45_front_walk1.png has changed
63.1 Binary file GCA-BCS/res/drawable-hdpi/football_guy_left_45_front_walk2.png has changed
64.1 Binary file GCA-BCS/res/drawable-hdpi/football_guy_left_punch.png has changed
65.1 Binary file GCA-BCS/res/drawable-hdpi/football_guy_left_walk1.png has changed
66.1 Binary file GCA-BCS/res/drawable-hdpi/football_guy_left_walk2.png has changed
67.1 Binary file GCA-BCS/res/drawable-hdpi/football_guy_right.png has changed
68.1 Binary file GCA-BCS/res/drawable-hdpi/football_guy_right_45_back.png has changed
69.1 Binary file GCA-BCS/res/drawable-hdpi/football_guy_right_45_back_punch.png has changed
70.1 Binary file GCA-BCS/res/drawable-hdpi/football_guy_right_45_back_walk1.png has changed
71.1 Binary file GCA-BCS/res/drawable-hdpi/football_guy_right_45_back_walk2.png has changed
72.1 Binary file GCA-BCS/res/drawable-hdpi/football_guy_right_45_front.png has changed
73.1 Binary file GCA-BCS/res/drawable-hdpi/football_guy_right_45_front_punch.png has changed
74.1 Binary file GCA-BCS/res/drawable-hdpi/football_guy_right_45_front_walk1.png has changed
75.1 Binary file GCA-BCS/res/drawable-hdpi/football_guy_right_45_front_walk2.png has changed
76.1 Binary file GCA-BCS/res/drawable-hdpi/football_guy_right_punch.png has changed
77.1 Binary file GCA-BCS/res/drawable-hdpi/football_guy_right_walk1.png has changed
78.1 Binary file GCA-BCS/res/drawable-hdpi/football_guy_right_walk2.png has changed
79.1 Binary file GCA-BCS/res/drawable-hdpi/hockey_guy_back.png has changed
80.1 Binary file GCA-BCS/res/drawable-hdpi/hockey_guy_back_stick.png has changed
81.1 Binary file GCA-BCS/res/drawable-hdpi/hockey_guy_back_walk1.png has changed
82.1 Binary file GCA-BCS/res/drawable-hdpi/hockey_guy_back_walk2.png has changed
83.1 Binary file GCA-BCS/res/drawable-hdpi/hockey_guy_dead1.png has changed
84.1 Binary file GCA-BCS/res/drawable-hdpi/hockey_guy_dead2.png has changed
85.1 Binary file GCA-BCS/res/drawable-hdpi/hockey_guy_front.png has changed
86.1 Binary file GCA-BCS/res/drawable-hdpi/hockey_guy_front_stick.png has changed
87.1 Binary file GCA-BCS/res/drawable-hdpi/hockey_guy_front_walk1.png has changed
88.1 Binary file GCA-BCS/res/drawable-hdpi/hockey_guy_front_walk2.png has changed
89.1 Binary file GCA-BCS/res/drawable-hdpi/hockey_guy_left.png has changed
90.1 Binary file GCA-BCS/res/drawable-hdpi/hockey_guy_left_45_back.png has changed
91.1 Binary file GCA-BCS/res/drawable-hdpi/hockey_guy_left_45_back_stick.png has changed
92.1 Binary file GCA-BCS/res/drawable-hdpi/hockey_guy_left_45_back_walk.png has changed
93.1 Binary file GCA-BCS/res/drawable-hdpi/hockey_guy_left_45_front.png has changed
94.1 Binary file GCA-BCS/res/drawable-hdpi/hockey_guy_left_45_front_stick.png has changed
95.1 Binary file GCA-BCS/res/drawable-hdpi/hockey_guy_left_45_front_walk.png has changed
96.1 Binary file GCA-BCS/res/drawable-hdpi/hockey_guy_left_stick.png has changed
97.1 Binary file GCA-BCS/res/drawable-hdpi/hockey_guy_left_walk1.png has changed
98.1 Binary file GCA-BCS/res/drawable-hdpi/hockey_guy_left_walk2.png has changed
99.1 Binary file GCA-BCS/res/drawable-hdpi/hockey_guy_right.png has changed
100.1 Binary file GCA-BCS/res/drawable-hdpi/hockey_guy_right_45_back.png has changed
101.1 Binary file GCA-BCS/res/drawable-hdpi/hockey_guy_right_45_back_stick.png has changed
102.1 Binary file GCA-BCS/res/drawable-hdpi/hockey_guy_right_45_back_walk.png has changed
103.1 Binary file GCA-BCS/res/drawable-hdpi/hockey_guy_right_45_front.png has changed
104.1 Binary file GCA-BCS/res/drawable-hdpi/hockey_guy_right_45_front_stick.png has changed
105.1 Binary file GCA-BCS/res/drawable-hdpi/hockey_guy_right_45_front_walk.png has changed
106.1 Binary file GCA-BCS/res/drawable-hdpi/hockey_guy_right_stick.png has changed
107.1 Binary file GCA-BCS/res/drawable-hdpi/hockey_guy_right_walk1.png has changed
108.1 Binary file GCA-BCS/res/drawable-hdpi/hockey_guy_right_walk2.png has changed
109.1 Binary file GCA-BCS/res/drawable-hdpi/icon.png has changed
110.1 Binary file GCA-BCS/res/drawable-hdpi/menu_background.png has changed
111.1 Binary file GCA-BCS/res/drawable-hdpi/ninja_back.png has changed
112.1 Binary file GCA-BCS/res/drawable-hdpi/ninja_back_walk1.png has changed
113.1 Binary file GCA-BCS/res/drawable-hdpi/ninja_back_walk2.png has changed
114.1 Binary file GCA-BCS/res/drawable-hdpi/ninja_front.png has changed
115.1 Binary file GCA-BCS/res/drawable-hdpi/ninja_front_walk1.png has changed
116.1 Binary file GCA-BCS/res/drawable-hdpi/ninja_front_walk2.png has changed
117.1 Binary file GCA-BCS/res/drawable-hdpi/ninja_left.png has changed
118.1 Binary file GCA-BCS/res/drawable-hdpi/ninja_left_walk1.png has changed
119.1 Binary file GCA-BCS/res/drawable-hdpi/ninja_left_walk2.png has changed
120.1 Binary file GCA-BCS/res/drawable-hdpi/ninja_right.png has changed
121.1 Binary file GCA-BCS/res/drawable-hdpi/ninja_right_walk1.png has changed
122.1 Binary file GCA-BCS/res/drawable-hdpi/ninja_right_walk2.png has changed
123.1 Binary file GCA-BCS/res/drawable-hdpi/pirate_back.png has changed
124.1 Binary file GCA-BCS/res/drawable-hdpi/pirate_back_walk1.png has changed
125.1 Binary file GCA-BCS/res/drawable-hdpi/pirate_back_walk2.png has changed
126.1 Binary file GCA-BCS/res/drawable-hdpi/pirate_front.png has changed
127.1 Binary file GCA-BCS/res/drawable-hdpi/pirate_front_walk1.png has changed
128.1 Binary file GCA-BCS/res/drawable-hdpi/pirate_front_walk2.png has changed
129.1 Binary file GCA-BCS/res/drawable-hdpi/pirate_left.png has changed
130.1 Binary file GCA-BCS/res/drawable-hdpi/pirate_left_walk1.png has changed
131.1 Binary file GCA-BCS/res/drawable-hdpi/pirate_left_walk2.png has changed
132.1 Binary file GCA-BCS/res/drawable-hdpi/pirate_right.png has changed
133.1 Binary file GCA-BCS/res/drawable-hdpi/pirate_right_walk1.png has changed
134.1 Binary file GCA-BCS/res/drawable-hdpi/pirate_right_walk2.png has changed
135.1 Binary file GCA-BCS/res/drawable-hdpi/robot_back.png has changed
136.1 Binary file GCA-BCS/res/drawable-hdpi/robot_back_walk1.png has changed
137.1 Binary file GCA-BCS/res/drawable-hdpi/robot_back_walk2.png has changed
138.1 Binary file GCA-BCS/res/drawable-hdpi/robot_front.png has changed
139.1 Binary file GCA-BCS/res/drawable-hdpi/robot_front_walk1.png has changed
140.1 Binary file GCA-BCS/res/drawable-hdpi/robot_front_walk2.png has changed
141.1 Binary file GCA-BCS/res/drawable-hdpi/robot_left.png has changed
142.1 Binary file GCA-BCS/res/drawable-hdpi/robot_left_walk1.png has changed
143.1 Binary file GCA-BCS/res/drawable-hdpi/robot_left_walk2.png has changed
144.1 Binary file GCA-BCS/res/drawable-hdpi/robot_right.png has changed
145.1 Binary file GCA-BCS/res/drawable-hdpi/robot_right_walk1.png has changed
146.1 Binary file GCA-BCS/res/drawable-hdpi/robot_right_walk2.png has changed
147.1 Binary file GCA-BCS/res/drawable-hdpi/smoke1.png has changed
148.1 Binary file GCA-BCS/res/drawable-hdpi/smoke2.png has changed
149.1 Binary file GCA-BCS/res/drawable-hdpi/smoke3.png has changed
150.1 Binary file GCA-BCS/res/drawable-hdpi/smoke4.png has changed
151.1 Binary file GCA-BCS/res/drawable-hdpi/smoke5.png has changed
152.1 Binary file GCA-BCS/res/drawable-hdpi/smoke6.png has changed
153.1 Binary file GCA-BCS/res/drawable-ldpi/icon.png has changed
154.1 Binary file GCA-BCS/res/drawable-mdpi/icon.png has changed
155.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
155.2 +++ b/GCA-BCS/res/layout/game_screen.xml Wed Oct 19 19:08:10 2011 -0400
155.3 @@ -0,0 +1,9 @@
155.4 +<?xml version="1.0" encoding="utf-8"?>
155.5 +<FrameLayout
155.6 + xmlns:android="http://schemas.android.com/apk/res/android"
155.7 + android:orientation="vertical"
155.8 + android:layout_width="match_parent"
155.9 + android:layout_height="match_parent" android:id="@+id/frame">
155.10 + <com.blackcloverstudios.appathon.GameView android:id="@+id/game_view" android:layout_width="800px" android:layout_height="480px" android:layout_gravity="center"></com.blackcloverstudios.appathon.GameView>
155.11 +
155.12 +</FrameLayout>
156.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
156.2 +++ b/GCA-BCS/res/layout/instruction_screen.xml Wed Oct 19 19:08:10 2011 -0400
156.3 @@ -0,0 +1,9 @@
156.4 +<?xml version="1.0" encoding="utf-8"?>
156.5 +<TextView
156.6 + xmlns:android="http://schemas.android.com/apk/res/android"
156.7 + android:orientation="vertical"
156.8 + android:layout_width="match_parent"
156.9 + android:layout_height="match_parent"
156.10 + android:text="@string/instructionText" android:id="@+id/instructionsView">
156.11 +
156.12 +</TextView>
157.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
157.2 +++ b/GCA-BCS/res/layout/main.xml Wed Oct 19 19:08:10 2011 -0400
157.3 @@ -0,0 +1,12 @@
157.4 +<?xml version="1.0" encoding="utf-8"?>
157.5 +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
157.6 + android:orientation="vertical"
157.7 + android:layout_width="fill_parent"
157.8 + android:layout_height="fill_parent"
157.9 + >
157.10 +<TextView
157.11 + android:layout_width="fill_parent"
157.12 + android:layout_height="wrap_content"
157.13 + android:text="@string/hello"
157.14 + />
157.15 +</LinearLayout>
158.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
158.2 +++ b/GCA-BCS/res/layout/main_screen.xml Wed Oct 19 19:08:10 2011 -0400
158.3 @@ -0,0 +1,15 @@
158.4 +<?xml version="1.0" encoding="utf-8"?>
158.5 +<FrameLayout
158.6 + xmlns:android="http://schemas.android.com/apk/res/android"
158.7 + android:layout_width="match_parent"
158.8 + android:layout_height="match_parent" android:id="@+id/frame" android:background="@drawable/menu_background">
158.9 + <LinearLayout android:layout_height="wrap_content" android:layout_width="match_parent" android:id="@+id/linearLayout1">
158.10 + <View android:layout_height="wrap_content" android:layout_width="15dp" android:id="@+id/left_margin"></View>
158.11 + <LinearLayout android:orientation="vertical" android:layout_width="match_parent" android:gravity="center" android:layout_height="match_parent" android:id="@+id/layout" android:layout_weight="1">
158.12 + <Button android:layout_height="wrap_content" android:text="@string/start" android:layout_width="match_parent" android:id="@+id/start_button" android:layout_gravity="center"></Button>
158.13 + <Button android:layout_height="wrap_content" android:text="@string/instructions" android:layout_width="match_parent" android:id="@+id/instructions_button"></Button>
158.14 + <Button android:layout_height="wrap_content" android:text="@string/quit" android:layout_width="match_parent" android:id="@+id/quit_button"></Button>
158.15 + </LinearLayout>
158.16 + <View android:layout_height="wrap_content" android:layout_width="15dp" android:id="@+id/right_margin"></View>
158.17 + </LinearLayout>
158.18 +</FrameLayout>
159.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
159.2 +++ b/GCA-BCS/res/values/colours.xml Wed Oct 19 19:08:10 2011 -0400
159.3 @@ -0,0 +1,5 @@
159.4 +<?xml version="1.0" encoding="utf-8"?>
159.5 +<resources>
159.6 + <color name="black">#000000</color>
159.7 +
159.8 +</resources>
160.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
160.2 +++ b/GCA-BCS/res/values/strings.xml Wed Oct 19 19:08:10 2011 -0400
160.3 @@ -0,0 +1,10 @@
160.4 +<?xml version="1.0" encoding="utf-8"?>
160.5 +<resources>
160.6 + <string name="hello">Hello World, StartActivity!</string>
160.7 + <string name="app_name">GCA-BCS</string>
160.8 + <string name="start">Start</string>
160.9 + <string name="instructions">Instructions</string>
160.10 + <string name="options">Options</string>
160.11 + <string name="quit">Quit</string>
160.12 + <string name="instructionText"></string>
160.13 +</resources>
161.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
161.2 +++ b/GCA-BCS/src/com/blackcloverstudios/appathon/BaseballPlayer.java Wed Oct 19 19:08:10 2011 -0400
161.3 @@ -0,0 +1,144 @@
161.4 +/**
161.5 + * Main class for the baseball player
161.6 + */
161.7 +
161.8 +package com.blackcloverstudios.appathon;
161.9 +
161.10 +import java.util.Vector;
161.11 +
161.12 +import android.content.Context;
161.13 +import android.graphics.drawable.Drawable;
161.14 +
161.15 +public class BaseballPlayer extends PlayerCharacter {
161.16 +
161.17 + public BaseballPlayer(Vector<GameObject> o, Context context, Vector2D pos){
161.18 + super(o,context);
161.19 + //set up attributes
161.20 + speed = 0.1225f;
161.21 + attackDelay = 250; //time in ms before you can attack again
161.22 + damage = 10; //damage done by on attack
161.23 + healthRegenDelay = 500; //time in ms to gain one health
161.24 + healthRegenAmount = 12;
161.25 + maxHealth = 125; //maximum health
161.26 + health = maxHealth;
161.27 +
161.28 + position.set(pos);
161.29 +
161.30 + // set up the sprites hashmap
161.31 +// sprites = new HashMap<Integer, Drawable[][]>();
161.32 + Drawable tempSprite[][];
161.33 +
161.34 + tempSprite = new Drawable[1][1];
161.35 + tempSprite[0][0] = context.getResources().getDrawable(R.drawable.baseball_guy_dead2);
161.36 + sprites.put(ACTION_DIE, tempSprite);
161.37 +
161.38 + tempSprite = new Drawable[1][3];
161.39 + tempSprite[0][0] = context.getResources().getDrawable(R.drawable.baseball_guy_dead1);
161.40 + tempSprite[0][1] = context.getResources().getDrawable(R.drawable.baseball_guy_dead1);
161.41 + tempSprite[0][1] = context.getResources().getDrawable(R.drawable.baseball_guy_dead2);
161.42 + sprites.put(ACTION_DYING, tempSprite);
161.43 +
161.44 + // idle sprites
161.45 + tempSprite = new Drawable[8][1];
161.46 + tempSprite[0][0] = context.getResources().getDrawable(R.drawable.baseball_guy_right);
161.47 + tempSprite[7][0] = context.getResources().getDrawable(R.drawable.baseball_guy_back_45_right);
161.48 + tempSprite[6][0] = context.getResources().getDrawable(R.drawable.baseball_guy_back);
161.49 + tempSprite[5][0] = context.getResources().getDrawable(R.drawable.baseball_guy_back_45_left);
161.50 + tempSprite[4][0] = context.getResources().getDrawable(R.drawable.baseball_guy_left);
161.51 + tempSprite[3][0] = context.getResources().getDrawable(R.drawable.baseball_guy_front_45_left);
161.52 + tempSprite[2][0] = context.getResources().getDrawable(R.drawable.baseball_guy_front);
161.53 + tempSprite[1][0] = context.getResources().getDrawable(R.drawable.baseball_guy_front_45_right);
161.54 +// sprites.put(ACTION_DIE, tempSprite);
161.55 + sprites.put(ACTION_IDLE, tempSprite);
161.56 +
161.57 + tempSprite = new Drawable[8][4];
161.58 + tempSprite[0][0] = context.getResources().getDrawable(R.drawable.baseball_guy_right_throw);
161.59 + tempSprite[0][1] = context.getResources().getDrawable(R.drawable.baseball_guy_right_throw);
161.60 + tempSprite[0][2] = context.getResources().getDrawable(R.drawable.baseball_guy_right);
161.61 + tempSprite[0][3] = context.getResources().getDrawable(R.drawable.baseball_guy_right);
161.62 +
161.63 + tempSprite[7][0] = context.getResources().getDrawable(R.drawable.baseball_guy_back_45_right_throw);
161.64 + tempSprite[7][1] = context.getResources().getDrawable(R.drawable.baseball_guy_back_45_right_throw);
161.65 + tempSprite[7][2] = context.getResources().getDrawable(R.drawable.baseball_guy_back_45_right);
161.66 + tempSprite[7][3] = context.getResources().getDrawable(R.drawable.baseball_guy_back_45_right);
161.67 +
161.68 + tempSprite[6][0] = context.getResources().getDrawable(R.drawable.baseball_guy_back_throw);
161.69 + tempSprite[6][1] = context.getResources().getDrawable(R.drawable.baseball_guy_back_throw);
161.70 + tempSprite[6][2] = context.getResources().getDrawable(R.drawable.baseball_guy_back);
161.71 + tempSprite[6][3] = context.getResources().getDrawable(R.drawable.baseball_guy_back);
161.72 +
161.73 + tempSprite[5][0] = context.getResources().getDrawable(R.drawable.baseball_guy_back_45_left_throw);
161.74 + tempSprite[5][1] = context.getResources().getDrawable(R.drawable.baseball_guy_back_45_left_throw);
161.75 + tempSprite[5][2] = context.getResources().getDrawable(R.drawable.baseball_guy_back_45_left);
161.76 + tempSprite[5][3] = context.getResources().getDrawable(R.drawable.baseball_guy_back_45_left);
161.77 +
161.78 + tempSprite[4][0] = context.getResources().getDrawable(R.drawable.baseball_guy_left_throw);
161.79 + tempSprite[4][1] = context.getResources().getDrawable(R.drawable.baseball_guy_left_throw);
161.80 + tempSprite[4][2] = context.getResources().getDrawable(R.drawable.baseball_guy_left);
161.81 + tempSprite[4][3] = context.getResources().getDrawable(R.drawable.baseball_guy_left);
161.82 +
161.83 + tempSprite[3][0] = context.getResources().getDrawable(R.drawable.baseball_guy_front_45_left_throw);
161.84 + tempSprite[3][1] = context.getResources().getDrawable(R.drawable.baseball_guy_front_45_left_throw);
161.85 + tempSprite[3][2] = context.getResources().getDrawable(R.drawable.baseball_guy_front_45_left);
161.86 + tempSprite[3][3] = context.getResources().getDrawable(R.drawable.baseball_guy_front_45_left);
161.87 +
161.88 + tempSprite[2][0] = context.getResources().getDrawable(R.drawable.baseball_guy_front_throw);
161.89 + tempSprite[2][1] = context.getResources().getDrawable(R.drawable.baseball_guy_front_throw);
161.90 + tempSprite[2][2] = context.getResources().getDrawable(R.drawable.baseball_guy_front);
161.91 + tempSprite[2][3] = context.getResources().getDrawable(R.drawable.baseball_guy_front);
161.92 +
161.93 + tempSprite[1][0] = context.getResources().getDrawable(R.drawable.baseball_guy_front_45_right_throw);
161.94 + tempSprite[1][1] = context.getResources().getDrawable(R.drawable.baseball_guy_front_45_right_throw);
161.95 + tempSprite[1][2] = context.getResources().getDrawable(R.drawable.baseball_guy_front_45_right);
161.96 + tempSprite[1][3] = context.getResources().getDrawable(R.drawable.baseball_guy_front_45_right);
161.97 + sprites.put(ACTION_ATTACKING, tempSprite);
161.98 +
161.99 + // moving sprites
161.100 + tempSprite = new Drawable[8][4];
161.101 + tempSprite[0][0] = context.getResources().getDrawable(R.drawable.baseball_guy_right);
161.102 + tempSprite[0][1] = context.getResources().getDrawable(R.drawable.baseball_guy_right_walk);
161.103 + tempSprite[0][2] = context.getResources().getDrawable(R.drawable.baseball_guy_right);
161.104 + tempSprite[0][3] = context.getResources().getDrawable(R.drawable.baseball_guy_right_walk);
161.105 +
161.106 + tempSprite[7][0] = context.getResources().getDrawable(R.drawable.baseball_guy_back_45_right);
161.107 + tempSprite[7][1] = context.getResources().getDrawable(R.drawable.baseball_guy_back_45_right_walk1);
161.108 + tempSprite[7][2] = context.getResources().getDrawable(R.drawable.baseball_guy_back_45_right);
161.109 + tempSprite[7][3] = context.getResources().getDrawable(R.drawable.baseball_guy_back_45_right_walk2);
161.110 +
161.111 + tempSprite[6][0] = context.getResources().getDrawable(R.drawable.baseball_guy_back);
161.112 + tempSprite[6][1] = context.getResources().getDrawable(R.drawable.baseball_guy_back_walk1);
161.113 + tempSprite[6][2] = context.getResources().getDrawable(R.drawable.baseball_guy_back);
161.114 + tempSprite[6][3] = context.getResources().getDrawable(R.drawable.baseball_guy_back_walk2);
161.115 +
161.116 + tempSprite[5][0] = context.getResources().getDrawable(R.drawable.baseball_guy_back_45_left);
161.117 + tempSprite[5][1] = context.getResources().getDrawable(R.drawable.baseball_guy_back_45_left_walk1);
161.118 + tempSprite[5][2] = context.getResources().getDrawable(R.drawable.baseball_guy_back_45_left);
161.119 + tempSprite[5][3] = context.getResources().getDrawable(R.drawable.baseball_guy_back_45_left_walk2);
161.120 +
161.121 + tempSprite[4][0] = context.getResources().getDrawable(R.drawable.baseball_guy_left);
161.122 + tempSprite[4][1] = context.getResources().getDrawable(R.drawable.baseball_guy_left_walk);
161.123 + tempSprite[4][2] = context.getResources().getDrawable(R.drawable.baseball_guy_left);
161.124 + tempSprite[4][3] = context.getResources().getDrawable(R.drawable.baseball_guy_left_walk);
161.125 +
161.126 + tempSprite[3][0] = context.getResources().getDrawable(R.drawable.baseball_guy_front_45_left);
161.127 + tempSprite[3][1] = context.getResources().getDrawable(R.drawable.baseball_guy_front_45_left_walk1);
161.128 + tempSprite[3][2] = context.getResources().getDrawable(R.drawable.baseball_guy_front_45_left);
161.129 + tempSprite[3][3] = context.getResources().getDrawable(R.drawable.baseball_guy_front_45_left_walk1);
161.130 +
161.131 + tempSprite[2][0] = context.getResources().getDrawable(R.drawable.baseball_guy_front);
161.132 + tempSprite[2][1] = context.getResources().getDrawable(R.drawable.baseball_guy_front_walk1);
161.133 + tempSprite[2][2] = context.getResources().getDrawable(R.drawable.baseball_guy_front);
161.134 + tempSprite[2][3] = context.getResources().getDrawable(R.drawable.baseball_guy_front_walk2);
161.135 +
161.136 + tempSprite[1][0] = context.getResources().getDrawable(R.drawable.baseball_guy_front_45_right);
161.137 + tempSprite[1][1] = context.getResources().getDrawable(R.drawable.baseball_guy_front_45_right_walk1);
161.138 + tempSprite[1][2] = context.getResources().getDrawable(R.drawable.baseball_guy_front_45_right);
161.139 + tempSprite[1][3] = context.getResources().getDrawable(R.drawable.baseball_guy_front_45_right_walk2);
161.140 +
161.141 + sprites.put(ACTION_MOVING, tempSprite);
161.142 + sprites.put(ACTION_CHARGING, tempSprite);
161.143 + sprites.put(ACTION_POSITIONING, tempSprite);
161.144 +
161.145 + }
161.146 +
161.147 +}
162.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
162.2 +++ b/GCA-BCS/src/com/blackcloverstudios/appathon/CPUCharacter.java Wed Oct 19 19:08:10 2011 -0400
162.3 @@ -0,0 +1,39 @@
162.4 +/**
162.5 + * This abstract class represents a "CPU character", or a character that is
162.6 + * not controlled by the player
162.7 + */
162.8 +package com.blackcloverstudios.appathon;
162.9 +
162.10 +import java.util.Random;
162.11 +import java.util.Vector;
162.12 +
162.13 +import android.content.Context;
162.14 +import android.graphics.Canvas;
162.15 +import android.graphics.Rect;
162.16 +
162.17 +public abstract class CPUCharacter extends Character {
162.18 +
162.19 + CPUCharacter(Vector<GameObject> o, Context c){
162.20 + super(o,c);
162.21 + imageRect = new Rect(-48, -80, 48, 16);
162.22 + touchRect = new Rect(imageRect);
162.23 +
162.24 + position = new Vector2D(800, 480);
162.25 + desiredPosition = null;
162.26 + setState(ACTION_IDLE);
162.27 + radius = 16;
162.28 + }
162.29 +
162.30 + protected void think(long time) {
162.31 + if(!isStateEnabled(STATE_MOVING) && isAlive())
162.32 + {
162.33 + Random rand = new Random();
162.34 + moveTo(rand.nextFloat() * 800, rand.nextFloat() * 480);
162.35 + }
162.36 + }
162.37 +
162.38 + @Override
162.39 + public void render(Canvas canvas) {
162.40 + super.render(canvas);
162.41 + }
162.42 +}
163.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
163.2 +++ b/GCA-BCS/src/com/blackcloverstudios/appathon/Character.java Wed Oct 19 19:08:10 2011 -0400
163.3 @@ -0,0 +1,297 @@
163.4 +/**
163.5 + * A character is a GameObject that represents an entity with AI (like a human,
163.6 + * zombie, pirate, ninja, etc.). It has a set amount of health and a lifespan.
163.7 + * It can set other GameObjects as "targets". You can give it a "command".
163.8 + * It has different "character states".
163.9 + */
163.10 +
163.11 +package com.blackcloverstudios.appathon;
163.12 +
163.13 +import java.util.HashMap;
163.14 +import java.util.Vector;
163.15 +
163.16 +import android.content.Context;
163.17 +import android.graphics.Canvas;
163.18 +import android.graphics.Paint;
163.19 +import android.graphics.Rect;
163.20 +import android.graphics.RectF;
163.21 +import android.graphics.drawable.Drawable;
163.22 +
163.23 +public abstract class Character extends GameObject {
163.24 +
163.25 + final public static int STATE_DEAD;
163.26 + final public static int STATE_DYING;
163.27 + final public static int STATE_ALIVE;
163.28 + final public static int STATE_MOVING;
163.29 + final public static int STATE_MELLEE_ATTACKING;
163.30 + final public static int STATE_RANGE_ATTACKING;
163.31 + static {
163.32 + int i;
163.33 + STATE_DEAD = (i = 1);
163.34 + STATE_DYING = (i *= 2);
163.35 + STATE_ALIVE = (i *= 2);
163.36 + STATE_MOVING = (i *= 2);
163.37 + STATE_MELLEE_ATTACKING = (i *= 2);
163.38 + STATE_RANGE_ATTACKING = (i *= 2);
163.39 + }
163.40 +
163.41 + final public static int ACTION_DIE = STATE_DEAD;
163.42 + final public static int ACTION_DYING = STATE_DYING;
163.43 + final public static int ACTION_IDLE = STATE_ALIVE;
163.44 + final public static int ACTION_MOVING = STATE_ALIVE | STATE_MOVING;
163.45 + final public static int ACTION_ATTACKING = STATE_ALIVE | STATE_MELLEE_ATTACKING;
163.46 + final public static int ACTION_SHOOTING = STATE_ALIVE | STATE_RANGE_ATTACKING;
163.47 + final public static int ACTION_CHARGING = ACTION_ATTACKING | STATE_MOVING;
163.48 + final public static int ACTION_POSITIONING = ACTION_SHOOTING | STATE_MOVING;
163.49 + final public static int FRAMETIME = 200;
163.50 +
163.51 + final public static RectF HEALTH_BAR = new RectF(-32, -90, 32, -80);
163.52 + private static final Paint RED_PAINT = new Paint();
163.53 + private static final Paint GREEN_PAINT = new Paint();
163.54 + static {
163.55 + RED_PAINT.setARGB(255, 255, 0, 0);
163.56 + GREEN_PAINT.setARGB(255, 0, 255, 0);
163.57 + }
163.58 +
163.59 + //attrs
163.60 + protected float speed = 0.2f;
163.61 + protected int attackDelay = 250; //time in ms before you can attack again
163.62 + protected int damage = 30; //damage done by on attack
163.63 + protected int healthRegenDelay = 500; //time in ms to gain one health
163.64 + protected int healthRegenAmount = 5;
163.65 + protected int maxHealth = 100; //maximum health
163.66 + //timers
163.67 + protected int attackTimer = 0;
163.68 + protected int healthRegenTimer = 0;
163.69 + protected long startAnimationTime = 0;
163.70 +
163.71 + protected HashMap<Integer, Drawable[][]> sprites;
163.72 +
163.73 + protected int health;
163.74 + protected int state;
163.75 + protected GameObject target;
163.76 + protected Vector2D desiredPosition = null;
163.77 +
163.78 + protected Vector<GameObject> objects;
163.79 +
163.80 + Character(Vector<GameObject> o, Context c){
163.81 + objects = o;
163.82 + health = maxHealth;
163.83 +
163.84 + sprites = new HashMap<Integer, Drawable[][]>();
163.85 +
163.86 + // add "dying animation"
163.87 + Drawable dyingSmoke[][] = new Drawable[1][6];
163.88 + dyingSmoke[0][0] = c.getResources().getDrawable(R.drawable.smoke1);
163.89 + dyingSmoke[0][1] = c.getResources().getDrawable(R.drawable.smoke2);
163.90 + dyingSmoke[0][2] = c.getResources().getDrawable(R.drawable.smoke3);
163.91 + dyingSmoke[0][3] = c.getResources().getDrawable(R.drawable.smoke4);
163.92 + dyingSmoke[0][4] = c.getResources().getDrawable(R.drawable.smoke5);
163.93 + dyingSmoke[0][5] = c.getResources().getDrawable(R.drawable.smoke6);
163.94 + sprites.put(ACTION_DIE, dyingSmoke);
163.95 + sprites.put(ACTION_DYING, dyingSmoke);
163.96 +
163.97 + }
163.98 +
163.99 + public int getHealth(){ return health; }
163.100 + public void addHealth(int aHealth){
163.101 + health += aHealth;
163.102 + if(health < 0)
163.103 + health = 0;
163.104 + else if(health > maxHealth)
163.105 + health = maxHealth;
163.106 + if(health == 0)
163.107 + state = ACTION_DYING;
163.108 + }
163.109 + public void subtractHealth(int aHealth){ addHealth(-aHealth); }
163.110 + public void setHealth(int aHealth){ health = aHealth; }
163.111 +
163.112 + public float getSpeed(){ return speed; }
163.113 +
163.114 + public GameObject getTarget(){ return target; }
163.115 + public void setTarget(GameObject aTarget){ target = aTarget; setState(ACTION_CHARGING); }
163.116 + public void setRangeTarget(GameObject aTarget){ target = aTarget; setState(ACTION_POSITIONING); }
163.117 + public void follow(GameObject aTarget){ desiredPosition = null; target = aTarget; setState(ACTION_MOVING); }
163.118 + public void moveTo(Vector2D aTarget){ desiredPosition = aTarget; target = null; setState(ACTION_MOVING); }
163.119 + public void moveTo(float x, float y){ desiredPosition = new Vector2D(x, y); target = null; setState(ACTION_MOVING); }
163.120 + public void idle() { desiredPosition = null; target = null; setState(ACTION_IDLE); }
163.121 +
163.122 + public void enableState(int aState){ state |= aState; }
163.123 + public void disableState(int aState){ state &= ~aState; }
163.124 + public void setState(int aState){ state = aState; startAnimationTime = aliveTime; }
163.125 + public int getState(){ return state; }
163.126 + public boolean isAlive() { return isStateEnabled(STATE_ALIVE); }
163.127 + public boolean isDead() { return isStateEnabled(STATE_DEAD); }
163.128 + public boolean isDying() { return isStateEnabled(STATE_DYING); }
163.129 +
163.130 + /**
163.131 + * This function returns true if the state passed in is enabled. Otherwise it returns false
163.132 + * @param aState the state to test
163.133 + * @return
163.134 + */
163.135 + public boolean isStateEnabled(int aState){
163.136 + if( (state & aState) == aState)
163.137 + return true;
163.138 + else
163.139 + return false;
163.140 + }
163.141 +
163.142 + protected abstract void think(long time);
163.143 +
163.144 + protected void move(long time)
163.145 + {
163.146 + Vector2D oldPos = new Vector2D(position);
163.147 + if(target != null && desiredPosition == null)
163.148 + {
163.149 + desiredPosition = target.position;
163.150 + }
163.151 + if(desiredPosition != null && !position.equals(desiredPosition))
163.152 + {
163.153 + orientation = position.angleTo(desiredPosition);
163.154 + if(Math.pow(speed*time, 2) > position.distanceSquared(desiredPosition))
163.155 + {
163.156 + position.set(desiredPosition);
163.157 + desiredPosition = null;
163.158 + disableState(STATE_MOVING);
163.159 + }
163.160 + else
163.161 + {
163.162 + Vector2D vel = new Vector2D((float)(speed*time * Math.cos(orientation)), (float)(speed*time * Math.sin(orientation)));
163.163 + position.add(vel);
163.164 + }
163.165 + }
163.166 + else if(desiredPosition != null)
163.167 + {
163.168 + desiredPosition = null;
163.169 + disableState(STATE_MOVING);
163.170 + }
163.171 +
163.172 + float tryDir = 0;
163.173 + for(GameObject obj : objects)
163.174 + if(obj != this && collidesWith(obj))
163.175 + {
163.176 + //if hitting object blocking movement location then finish move
163.177 + if(desiredPosition != null && (obj.position.distanceSquared(desiredPosition) < obj.radius * obj.radius))
163.178 + {
163.179 + desiredPosition = null;
163.180 + disableState(STATE_MOVING);
163.181 + position.set(oldPos);
163.182 + return;
163.183 + }
163.184 + position.set(oldPos);
163.185 + tryDir += orientation - position.angleTo(obj.position);
163.186 + }
163.187 + if(tryDir == 0) tryDir = 1;
163.188 + for(int i = -1; i < 2 && position.equals(oldPos); i += 2)
163.189 + {
163.190 + Vector2D vel = new Vector2D((float)(speed*time * Math.cos(orientation - Math.signum(tryDir) * 90 * i)), (float)(speed*time * Math.sin(orientation - Math.signum(tryDir) * 90 * i)));
163.191 + position.add(vel);
163.192 + for(GameObject obj : objects)
163.193 + if(obj != this && collidesWith(obj))
163.194 + {
163.195 + position.set(oldPos);
163.196 + break;
163.197 + }
163.198 + }
163.199 +
163.200 + }
163.201 +
163.202 + protected void attack(long time)
163.203 + {
163.204 + if(target == null)
163.205 + {
163.206 + if(animationFrame() + 1 == numberOfAnimationFrames())
163.207 + disableState(STATE_MELLEE_ATTACKING);
163.208 + }
163.209 + else if(target instanceof Character && ((Character) target).getHealth() <= 0)
163.210 + {
163.211 + moveTo(target.getPosition());
163.212 + }
163.213 + else if(position.distanceSquared(target.position) > (radius+target.radius+4)*(radius+target.radius+4))
163.214 + enableState(STATE_MOVING);
163.215 + else if(target instanceof Character)
163.216 + {
163.217 + while(attackTimer > attackDelay){
163.218 + ((Character) target).subtractHealth(damage);
163.219 + attackTimer -= attackDelay;
163.220 + }
163.221 + }
163.222 + }
163.223 +
163.224 + void step(long time) {
163.225 + super.step(time);
163.226 + if(isAlive())
163.227 + {
163.228 + think(time);
163.229 + healthRegenTimer += time;
163.230 + while(healthRegenTimer > healthRegenDelay)
163.231 + {
163.232 + addHealth(healthRegenAmount);
163.233 + healthRegenTimer -= healthRegenDelay;
163.234 + }
163.235 + attackTimer += time;
163.236 + if(isStateEnabled(STATE_MOVING))
163.237 + move(time);
163.238 + if(isStateEnabled(STATE_MELLEE_ATTACKING))
163.239 + attack(time);
163.240 + attackTimer = Math.min(attackTimer, attackDelay);
163.241 + }
163.242 + else
163.243 + {
163.244 + if(animationFrame() + 1 == numberOfAnimationFrames())
163.245 + {
163.246 + setState(ACTION_DIE);
163.247 + }
163.248 + }
163.249 + }
163.250 +
163.251 + protected int numberOfAnimationFrames() {
163.252 + return sprites.get(state)[0].length;
163.253 + }
163.254 +
163.255 + protected long animationFrame() {
163.256 + return ((aliveTime - startAnimationTime) /FRAMETIME) % numberOfAnimationFrames();
163.257 + }
163.258 +
163.259 + @Override
163.260 + boolean collidesWith(GameObject o){
163.261 + if(!isAlive() || o instanceof Character && !((Character)o).isAlive()) return false;
163.262 + return super.collidesWith(o);
163.263 + }
163.264 +
163.265 + @Override
163.266 + public void render(Canvas aCanvas) {
163.267 + //aCanvas.drawBitmap(footballPlayerImage, null, new RectF(200.0f,200.0f,400.0f,400.0f), null);
163.268 + aCanvas.save();
163.269 +
163.270 + Drawable[][] spriteset = null;
163.271 +
163.272 + spriteset = sprites.get(state);
163.273 + int numOfOrientations = spriteset.length;
163.274 + int orientationIndex = (int)(Math.round((orientation*numOfOrientations)/(2*Math.PI)) % numOfOrientations);
163.275 + if(orientationIndex < 0)
163.276 + orientationIndex += numOfOrientations;
163.277 +
163.278 + int animationFrame = (int)((aliveTime - startAnimationTime) /FRAMETIME) % spriteset[orientationIndex].length;
163.279 + Drawable frame = spriteset[orientationIndex][animationFrame];
163.280 +
163.281 + // calculate the position of the sprite on the screen
163.282 + Rect bounds = new Rect(imageRect);
163.283 + bounds.offset((int)position.x, (int)position.y);
163.284 +
163.285 + frame.setBounds(bounds);
163.286 + frame.draw(aCanvas);
163.287 +
163.288 + //health bar
163.289 + RectF health_back = new RectF(HEALTH_BAR);
163.290 + RectF health_green = new RectF(HEALTH_BAR);
163.291 + health_back.offset(position.x, position.y);
163.292 + health_green.right = health_green.left + 64 * (float)health/(float)maxHealth;
163.293 + health_green.offset(position.x, position.y);
163.294 + aCanvas.drawRect(health_back, RED_PAINT);
163.295 + aCanvas.drawRect(health_green, GREEN_PAINT);
163.296 +
163.297 + aCanvas.restore();
163.298 + }
163.299 +
163.300 +}
164.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
164.2 +++ b/GCA-BCS/src/com/blackcloverstudios/appathon/FootballPlayer.java Wed Oct 19 19:08:10 2011 -0400
164.3 @@ -0,0 +1,143 @@
164.4 +/**
164.5 + * Main class for the football player
164.6 + */
164.7 +
164.8 +package com.blackcloverstudios.appathon;
164.9 +
164.10 +import java.util.Vector;
164.11 +
164.12 +import android.content.Context;
164.13 +import android.graphics.drawable.Drawable;
164.14 +
164.15 +public class FootballPlayer extends PlayerCharacter {
164.16 +
164.17 + public FootballPlayer(Vector<GameObject> o, Context context, Vector2D pos){
164.18 + super(o,context);
164.19 + //set up attributes
164.20 + speed = 0.0725f;
164.21 + attackDelay = 1000; //time in ms before you can attack again
164.22 + damage = 30; //damage done by on attack
164.23 + healthRegenDelay = 500; //time in ms to gain one health
164.24 + healthRegenAmount = 5;
164.25 + maxHealth = 200; //maximum health
164.26 + health = maxHealth;
164.27 +
164.28 + position.set(pos);
164.29 +
164.30 + // set up the sprites hashmap
164.31 +// sprites = new HashMap<Integer, Drawable[][]>();
164.32 + Drawable tempSprite[][];
164.33 +
164.34 + tempSprite = new Drawable[1][1];
164.35 + tempSprite[0][0] = context.getResources().getDrawable(R.drawable.football_guy_dead2);
164.36 + sprites.put(ACTION_DIE, tempSprite);
164.37 +
164.38 + tempSprite = new Drawable[1][3];
164.39 + tempSprite[0][0] = context.getResources().getDrawable(R.drawable.football_guy_dead1);
164.40 + tempSprite[0][1] = context.getResources().getDrawable(R.drawable.football_guy_dead1);
164.41 + tempSprite[0][1] = context.getResources().getDrawable(R.drawable.football_guy_dead2);
164.42 + sprites.put(ACTION_DYING, tempSprite);
164.43 +
164.44 + // idle sprites
164.45 + tempSprite = new Drawable[8][1];
164.46 + tempSprite[0][0] = context.getResources().getDrawable(R.drawable.football_guy_right);
164.47 + tempSprite[7][0] = context.getResources().getDrawable(R.drawable.football_guy_right_45_back);
164.48 + tempSprite[6][0] = context.getResources().getDrawable(R.drawable.football_guy_back);
164.49 + tempSprite[5][0] = context.getResources().getDrawable(R.drawable.football_guy_left_45_back);
164.50 + tempSprite[4][0] = context.getResources().getDrawable(R.drawable.football_guy_left);
164.51 + tempSprite[3][0] = context.getResources().getDrawable(R.drawable.football_guy_left_45_front);
164.52 + tempSprite[2][0] = context.getResources().getDrawable(R.drawable.football_guy_front);
164.53 + tempSprite[1][0] = context.getResources().getDrawable(R.drawable.football_guy_right_45_front);
164.54 + sprites.put(ACTION_IDLE, tempSprite);
164.55 +
164.56 + tempSprite = new Drawable[8][4];
164.57 + tempSprite[0][0] = context.getResources().getDrawable(R.drawable.football_guy_right_punch);
164.58 + tempSprite[0][1] = context.getResources().getDrawable(R.drawable.football_guy_right_punch);
164.59 + tempSprite[0][2] = context.getResources().getDrawable(R.drawable.football_guy_right);
164.60 + tempSprite[0][3] = context.getResources().getDrawable(R.drawable.football_guy_right);
164.61 +
164.62 + tempSprite[7][0] = context.getResources().getDrawable(R.drawable.football_guy_right_45_back_punch);
164.63 + tempSprite[7][1] = context.getResources().getDrawable(R.drawable.football_guy_right_45_back_punch);
164.64 + tempSprite[7][2] = context.getResources().getDrawable(R.drawable.football_guy_right_45_back);
164.65 + tempSprite[7][3] = context.getResources().getDrawable(R.drawable.football_guy_right_45_back);
164.66 +
164.67 + tempSprite[6][0] = context.getResources().getDrawable(R.drawable.football_guy_back_punch);
164.68 + tempSprite[6][1] = context.getResources().getDrawable(R.drawable.football_guy_back_punch);
164.69 + tempSprite[6][2] = context.getResources().getDrawable(R.drawable.football_guy_back);
164.70 + tempSprite[6][3] = context.getResources().getDrawable(R.drawable.football_guy_back);
164.71 +
164.72 + tempSprite[5][0] = context.getResources().getDrawable(R.drawable.football_guy_left_45_back_punch);
164.73 + tempSprite[5][1] = context.getResources().getDrawable(R.drawable.football_guy_left_45_back_punch);
164.74 + tempSprite[5][2] = context.getResources().getDrawable(R.drawable.football_guy_left_45_back);
164.75 + tempSprite[5][3] = context.getResources().getDrawable(R.drawable.football_guy_left_45_back);
164.76 +
164.77 + tempSprite[4][0] = context.getResources().getDrawable(R.drawable.football_guy_left_punch);
164.78 + tempSprite[4][1] = context.getResources().getDrawable(R.drawable.football_guy_left_punch);
164.79 + tempSprite[4][2] = context.getResources().getDrawable(R.drawable.football_guy_left);
164.80 + tempSprite[4][3] = context.getResources().getDrawable(R.drawable.football_guy_left);
164.81 +
164.82 + tempSprite[3][0] = context.getResources().getDrawable(R.drawable.football_guy_left_45_front_punch);
164.83 + tempSprite[3][1] = context.getResources().getDrawable(R.drawable.football_guy_left_45_front_punch);
164.84 + tempSprite[3][2] = context.getResources().getDrawable(R.drawable.football_guy_left_45_front);
164.85 + tempSprite[3][3] = context.getResources().getDrawable(R.drawable.football_guy_left_45_front);
164.86 +
164.87 + tempSprite[2][0] = context.getResources().getDrawable(R.drawable.football_guy_front_punch);
164.88 + tempSprite[2][1] = context.getResources().getDrawable(R.drawable.football_guy_front_punch);
164.89 + tempSprite[2][2] = context.getResources().getDrawable(R.drawable.football_guy_front);
164.90 + tempSprite[2][3] = context.getResources().getDrawable(R.drawable.football_guy_front);
164.91 +
164.92 + tempSprite[1][0] = context.getResources().getDrawable(R.drawable.football_guy_right_45_front_punch);
164.93 + tempSprite[1][1] = context.getResources().getDrawable(R.drawable.football_guy_right_45_front_punch);
164.94 + tempSprite[1][2] = context.getResources().getDrawable(R.drawable.football_guy_right_45_front);
164.95 + tempSprite[1][3] = context.getResources().getDrawable(R.drawable.football_guy_right_45_front);
164.96 + sprites.put(ACTION_ATTACKING, tempSprite);
164.97 +
164.98 + // moving sprites
164.99 + tempSprite = new Drawable[8][4];
164.100 + tempSprite[0][0] = context.getResources().getDrawable(R.drawable.football_guy_right);
164.101 + tempSprite[0][1] = context.getResources().getDrawable(R.drawable.football_guy_right_walk1);
164.102 + tempSprite[0][2] = context.getResources().getDrawable(R.drawable.football_guy_right);
164.103 + tempSprite[0][3] = context.getResources().getDrawable(R.drawable.football_guy_right_walk2);
164.104 +
164.105 + tempSprite[7][0] = context.getResources().getDrawable(R.drawable.football_guy_right_45_back);
164.106 + tempSprite[7][1] = context.getResources().getDrawable(R.drawable.football_guy_right_45_back_walk1);
164.107 + tempSprite[7][2] = context.getResources().getDrawable(R.drawable.football_guy_right_45_back);
164.108 + tempSprite[7][3] = context.getResources().getDrawable(R.drawable.football_guy_right_45_back_walk2);
164.109 +
164.110 + tempSprite[6][0] = context.getResources().getDrawable(R.drawable.football_guy_back);
164.111 + tempSprite[6][1] = context.getResources().getDrawable(R.drawable.football_guy_back_walk1);
164.112 + tempSprite[6][2] = context.getResources().getDrawable(R.drawable.football_guy_back);
164.113 + tempSprite[6][3] = context.getResources().getDrawable(R.drawable.football_guy_back_walk2);
164.114 +
164.115 + tempSprite[5][0] = context.getResources().getDrawable(R.drawable.football_guy_left_45_back);
164.116 + tempSprite[5][1] = context.getResources().getDrawable(R.drawable.football_guy_left_45_back_walk1);
164.117 + tempSprite[5][2] = context.getResources().getDrawable(R.drawable.football_guy_left_45_back);
164.118 + tempSprite[5][3] = context.getResources().getDrawable(R.drawable.football_guy_left_45_back_walk2);
164.119 +
164.120 + tempSprite[4][0] = context.getResources().getDrawable(R.drawable.football_guy_left);
164.121 + tempSprite[4][1] = context.getResources().getDrawable(R.drawable.football_guy_left_walk1);
164.122 + tempSprite[4][2] = context.getResources().getDrawable(R.drawable.football_guy_left);
164.123 + tempSprite[4][3] = context.getResources().getDrawable(R.drawable.football_guy_left_walk2);
164.124 +
164.125 + tempSprite[3][0] = context.getResources().getDrawable(R.drawable.football_guy_left_45_front);
164.126 + tempSprite[3][1] = context.getResources().getDrawable(R.drawable.football_guy_left_45_front_walk1);
164.127 + tempSprite[3][2] = context.getResources().getDrawable(R.drawable.football_guy_left_45_front);
164.128 + tempSprite[3][3] = context.getResources().getDrawable(R.drawable.football_guy_left_45_front_walk2);
164.129 +
164.130 + tempSprite[2][0] = context.getResources().getDrawable(R.drawable.football_guy_front);
164.131 + tempSprite[2][1] = context.getResources().getDrawable(R.drawable.football_guy_front_walk1);
164.132 + tempSprite[2][2] = context.getResources().getDrawable(R.drawable.football_guy_front);
164.133 + tempSprite[2][3] = context.getResources().getDrawable(R.drawable.football_guy_front_walk2);
164.134 +
164.135 + tempSprite[1][0] = context.getResources().getDrawable(R.drawable.football_guy_right_45_front);
164.136 + tempSprite[1][1] = context.getResources().getDrawable(R.drawable.football_guy_right_45_front_walk1);
164.137 + tempSprite[1][2] = context.getResources().getDrawable(R.drawable.football_guy_right_45_front);
164.138 + tempSprite[1][3] = context.getResources().getDrawable(R.drawable.football_guy_right_45_front_walk2);
164.139 +
164.140 + sprites.put(ACTION_MOVING, tempSprite);
164.141 + sprites.put(ACTION_CHARGING, tempSprite);
164.142 + sprites.put(ACTION_POSITIONING, tempSprite);
164.143 +
164.144 + }
164.145 +
164.146 +}
165.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
165.2 +++ b/GCA-BCS/src/com/blackcloverstudios/appathon/GameActivity.java Wed Oct 19 19:08:10 2011 -0400
165.3 @@ -0,0 +1,489 @@
165.4 +/**
165.5 + *
165.6 + */
165.7 +package com.blackcloverstudios.appathon;
165.8 +
165.9 +import java.util.Collections;
165.10 +import java.util.Iterator;
165.11 +import java.util.Random;
165.12 +import java.util.Vector;
165.13 +
165.14 +import android.app.Activity;
165.15 +import android.os.Bundle;
165.16 +import android.os.Handler;
165.17 +import android.os.SystemClock;
165.18 +import android.view.Menu;
165.19 +import android.view.MotionEvent;
165.20 +import android.view.View;
165.21 +import android.view.View.OnClickListener;
165.22 +import android.view.View.OnLongClickListener;
165.23 +import android.view.View.OnTouchListener;
165.24 +import android.view.Window;
165.25 +import android.view.WindowManager;
165.26 +import android.view.MenuItem;
165.27 +
165.28 +/**
165.29 + * @author Dan
165.30 + *
165.31 + */
165.32 +public class GameActivity extends Activity implements OnClickListener, OnTouchListener, OnLongClickListener {
165.33 +
165.34 + public static final long GAME_UPDATE_PERIOD = 30;
165.35 +
165.36 + private static final int MAX_OBJECTS = 256;
165.37 +
165.38 + private static final long INITIAL_SPAWN_DELAY = 2500;
165.39 + private static final long STAGE_ONE_SPAWN_TIME = 13000;
165.40 + private static final long STAGE_TWO_SPAWN_TIME = 10000;
165.41 + private static final long STAGE_THREE_SPAWN_TIME = 8000;
165.42 + private static final long STAGE_FOUR_SPAWN_TIME = 13000;
165.43 + private static final long STAGE_FIVE_SPAWN_TIME = 10000;
165.44 + private static final long STAGE_SIX_SPAWN_TIME = 13000;
165.45 + private static final long STAGE_SEVEN_SPAWN_TIME = 10000;
165.46 +
165.47 + private static final long STAGE_ONE_WAVES = 5;
165.48 + private static final long STAGE_TWO_WAVES = 5;
165.49 + private static final long STAGE_THREE_WAVES = 5;
165.50 + private static final long STAGE_FOUR_WAVES = 8;
165.51 + private static final long STAGE_FIVE_WAVES = 14;
165.52 + private static final long STAGE_SIX_WAVES = 20;
165.53 +
165.54 + private static final long STAGE_ONE = INITIAL_SPAWN_DELAY + STAGE_ONE_SPAWN_TIME;
165.55 + private static final long STAGE_TWO = STAGE_ONE + STAGE_ONE_SPAWN_TIME * STAGE_ONE_WAVES + STAGE_TWO_SPAWN_TIME;
165.56 + private static final long STAGE_THREE = STAGE_TWO + STAGE_TWO_SPAWN_TIME * STAGE_TWO_WAVES + STAGE_THREE_SPAWN_TIME;
165.57 + private static final long STAGE_FOUR = STAGE_THREE + STAGE_THREE_SPAWN_TIME * STAGE_THREE_WAVES + STAGE_FOUR_SPAWN_TIME;
165.58 + private static final long STAGE_FIVE = STAGE_FOUR + STAGE_FOUR_SPAWN_TIME * STAGE_FOUR_WAVES + STAGE_FIVE_SPAWN_TIME;
165.59 + private static final long STAGE_SIX = STAGE_FIVE + STAGE_FIVE_SPAWN_TIME * STAGE_FIVE_WAVES + STAGE_SIX_SPAWN_TIME;
165.60 + private static final long STAGE_SEVEN = STAGE_SIX + STAGE_SIX_SPAWN_TIME * STAGE_SIX_WAVES + STAGE_SEVEN_SPAWN_TIME;
165.61 +
165.62 +
165.63 + Vector<GameObject> objects;
165.64 + Vector<PlayerCharacter> playerCharacters;
165.65 + GameView gameView;
165.66 + Handler gameLoopHandler;
165.67 +
165.68 + private GameLoop gameLoop;
165.69 +
165.70 + private MotionEvent lastEvent;
165.71 +
165.72 + private boolean attachedToWindow = false;
165.73 +
165.74 + private boolean started = false;
165.75 +
165.76 + private Vector<Vector2D> spawns;
165.77 +
165.78 + private long gameTime;
165.79 + private long nextSpawn = 0;
165.80 +
165.81 + //Stores the score. Score equals number of enemies killed
165.82 + int score;
165.83 +
165.84 + private boolean reopenMenu = false;
165.85 +
165.86 + /* menu strings */
165.87 + final public static String DESELECT_STRING = "Deselect All";
165.88 + final public static String FOOTBALL_STRING = "Football Guy";
165.89 + final public static String HOCKEY_STRING = "Hockey Guy";
165.90 + final public static String BASEBALL_STRING = "Baseball Guy";
165.91 + final public static String SELECT_STRING = "Select All";
165.92 + final public static String SELECTED_STRING = " (#)";
165.93 + final public static String UNSELECTED_STRING = " ( )";
165.94 + final public static int DESELECT_ID = 0;
165.95 + final public static int FOOTBALL_ID = 1;
165.96 + final public static int HOCKEY_ID = 2;
165.97 + final public static int BASEBALL_ID = 3;
165.98 + final public static int SELECT_ID = 4;
165.99 +
165.100 + public long getGameTime() { return gameTime; }
165.101 + public int getScore() { return score; }
165.102 +
165.103 + @Override
165.104 + public void onCreate(Bundle savedInstanceState) {
165.105 + super.onCreate(savedInstanceState);
165.106 +
165.107 + requestWindowFeature(Window.FEATURE_NO_TITLE);
165.108 +
165.109 + setContentView(R.layout.game_screen);
165.110 + gameView = (GameView) findViewById(R.id.game_view);
165.111 + gameView.setOnClickListener(this);
165.112 + gameView.setOnTouchListener(this);
165.113 + gameView.setOnLongClickListener(this);
165.114 +
165.115 + getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
165.116 +
165.117 + objects = new Vector<GameObject>(MAX_OBJECTS);
165.118 + playerCharacters = new Vector<PlayerCharacter>();
165.119 + gameLoop = new GameLoop();
165.120 + gameLoopHandler = new Handler();
165.121 +
165.122 + initGame();
165.123 + }
165.124 +
165.125 + @Override
165.126 + public void onStart()
165.127 + {
165.128 + super.onStart();
165.129 + started = true;
165.130 + if(attachedToWindow && started)
165.131 + startGame();
165.132 + }
165.133 +
165.134 + @Override
165.135 + public void onAttachedToWindow()
165.136 + {
165.137 + super.onAttachedToWindow();
165.138 + attachedToWindow = true;
165.139 + if(attachedToWindow && started)
165.140 + startGame();
165.141 + }
165.142 +
165.143 + @Override
165.144 + public void onDetachedFromWindow()
165.145 + {
165.146 + super.onDetachedFromWindow();
165.147 + attachedToWindow = false;
165.148 + pauseGame();
165.149 + }
165.150 +
165.151 + @Override
165.152 + public void onStop()
165.153 + {
165.154 + super.onStart();
165.155 + started = false;
165.156 + gameView.startRendering(objects);
165.157 + }
165.158 +
165.159 + private void initGame() {
165.160 + spawns = new Vector<Vector2D>();
165.161 + spawns.add(new Vector2D(-32,160));
165.162 + spawns.add(new Vector2D(-32,320));
165.163 + spawns.add(new Vector2D(160,-32));
165.164 + spawns.add(new Vector2D(160,512));
165.165 + score = 0;
165.166 + objects.add(new FootballPlayer(objects, this, new Vector2D(700, 120)));
165.167 + playerCharacters.add((PlayerCharacter) objects.lastElement());
165.168 + objects.add(new BaseballPlayer(objects, this, new Vector2D(700, 240)));
165.169 + playerCharacters.add((PlayerCharacter) objects.lastElement());
165.170 + objects.add(new HockeyPlayer(objects, this, new Vector2D(700, 360)));
165.171 + playerCharacters.add((PlayerCharacter) objects.lastElement());
165.172 + nextSpawn = INITIAL_SPAWN_DELAY;
165.173 + }
165.174 +
165.175 + private void startGame() {
165.176 + gameView.startRendering(objects);
165.177 + gameLoopHandler.removeCallbacks(gameLoop);
165.178 + gameLoop.setTime();
165.179 + gameLoopHandler.post(gameLoop);
165.180 + }
165.181 +
165.182 + private void pauseGame() {
165.183 + gameLoopHandler.removeCallbacks(gameLoop);
165.184 + gameView.stopRendering();
165.185 + }
165.186 +
165.187 + private void spawnEnemy(int spawn){
165.188 + CPUCharacter enemy = null;
165.189 + Random random = new Random();
165.190 + final int types = 3;
165.191 +
165.192 + int type = random.nextInt(types);
165.193 + switch(type){
165.194 + case 0:
165.195 + enemy = new NinjaCPU(objects, this, spawns.get(spawn));
165.196 + break;
165.197 + case 1:
165.198 + enemy = new PirateCPU(objects, this, spawns.get(spawn));
165.199 + break;
165.200 + case 2:
165.201 + enemy = new RobotCPU(objects, this, spawns.get(spawn));
165.202 + break;
165.203 + }
165.204 + objects.add(enemy);
165.205 + enemy.moveTo(new Vector2D(Math.max(enemy.getPosition().x, 0),
165.206 + Math.min(Math.max(enemy.getPosition().y, 0), 480)));
165.207 + }
165.208 +
165.209 + private void stepGame(long time) {
165.210 + gameTime += time;
165.211 + if(objects.size() > 23)
165.212 + nextSpawn += time;
165.213 + else if(gameTime >= nextSpawn)
165.214 + {
165.215 +
165.216 + if(gameTime < STAGE_ONE) //initial spawn
165.217 + {
165.218 + for (int i=0; i<4; i++){
165.219 + spawnEnemy(i);
165.220 + }
165.221 + nextSpawn += STAGE_ONE_SPAWN_TIME;
165.222 + }
165.223 + else if(gameTime < STAGE_TWO) //stage 1
165.224 + {
165.225 + spawnEnemy(new Random().nextInt(2));
165.226 + nextSpawn += STAGE_ONE_SPAWN_TIME;
165.227 + }
165.228 + else if(gameTime < STAGE_THREE) //stage 2
165.229 + {
165.230 + spawnEnemy(new Random().nextInt(2));
165.231 + nextSpawn += STAGE_TWO_SPAWN_TIME;
165.232 + }
165.233 + else if(gameTime < STAGE_FOUR) //stage 3
165.234 + {
165.235 + spawnEnemy(new Random().nextInt(4));
165.236 + nextSpawn += STAGE_THREE_SPAWN_TIME;
165.237 + }
165.238 + else if(gameTime < STAGE_FIVE) //stage 4
165.239 + {
165.240 + int s1 = new Random().nextInt(4);
165.241 + int s2 = (s1 + new Random().nextInt(3) + 1) % 4;
165.242 + spawnEnemy(s1);
165.243 + spawnEnemy(s2);
165.244 + nextSpawn += STAGE_FOUR_SPAWN_TIME;
165.245 + }
165.246 + else if(gameTime < STAGE_SIX) //stage 5
165.247 + {
165.248 + int s1 = new Random().nextInt(4);
165.249 + int s2 = (s1 + new Random().nextInt(3) + 1) % 4;
165.250 + spawnEnemy(s1);
165.251 + spawnEnemy(s2);
165.252 + nextSpawn += STAGE_FIVE_SPAWN_TIME;
165.253 + }
165.254 + else if(gameTime < STAGE_SEVEN) //stage 6
165.255 + {
165.256 + int sNot = new Random().nextInt(4);
165.257 + for(int i = 0; i < 4; i++)
165.258 + if(i != sNot)
165.259 + spawnEnemy(i);
165.260 + nextSpawn += STAGE_SIX_SPAWN_TIME;
165.261 + }
165.262 + else //stage 7
165.263 + {
165.264 + int sNot = new Random().nextInt(4);
165.265 + for(int i = 0; i < 4; i++)
165.266 + if(i != sNot)
165.267 + spawnEnemy(i);
165.268 + nextSpawn += STAGE_SEVEN_SPAWN_TIME;
165.269 + }
165.270 + }
165.271 + Iterator<GameObject> i = objects.iterator();
165.272 + if(i.hasNext())
165.273 + {
165.274 + for(GameObject object = i.next(); object != null; object = i.hasNext() ? i.next() : null)
165.275 + {
165.276 + object.step(time);
165.277 + if(object instanceof CPUCharacter && ((CPUCharacter) object).isDead()){
165.278 + i.remove();
165.279 + score++;
165.280 + }
165.281 + }
165.282 + }
165.283 + boolean playerAlive = false;
165.284 + for(PlayerCharacter player : playerCharacters)
165.285 + if(player.isAlive())
165.286 + {
165.287 + playerAlive = true;
165.288 + break;
165.289 + }
165.290 + if(!playerAlive)
165.291 + endGame();
165.292 + }
165.293 +
165.294 + private void endGame() {
165.295 + gameLoopHandler.postDelayed(new Runnable(){
165.296 + public void run() { finish(); }
165.297 + },
165.298 + 2000);
165.299 + }
165.300 +
165.301 + private GameObject getLastObjectTouched() {
165.302 + Vector2D pos = new Vector2D(lastEvent.getX(), lastEvent.getY());
165.303 + Collections.sort(objects);
165.304 + for(int i = objects.size() - 1; i >= 0; i--)
165.305 + if(objects.get(i).isTouching((int)pos.x, (int)pos.y) &&
165.306 + (!(objects.get(i) instanceof Character) || ((Character)objects.get(i)).isStateEnabled(Character.STATE_ALIVE)))
165.307 + return objects.get(i);
165.308 + return null;
165.309 + }
165.310 +
165.311 + public boolean onTouch(View v, MotionEvent event) {
165.312 + if(v == gameView)
165.313 + {
165.314 + //DO NOT handle, just record event don't handle, we have other callbacks for that
165.315 + lastEvent = event;
165.316 + }
165.317 + return false;
165.318 + }
165.319 +
165.320 + public void onClick(View v) {
165.321 + if(v == gameView)
165.322 + {
165.323 + GameObject object = getLastObjectTouched();
165.324 + if(object == null) //if click back ground move selected characters to point on map
165.325 + for(PlayerCharacter character : selectedCharacters()) {
165.326 + character.moveTo(lastEvent.getX(), lastEvent.getY());
165.327 + }
165.328 + else {
165.329 + if(object instanceof PlayerCharacter) { //if click a player character toggle select
165.330 + ((PlayerCharacter) object).setSelected(!((PlayerCharacter) object).isSelected());
165.331 + }
165.332 + else if(object instanceof Character) { //if select an enemy character, selected characters attack
165.333 + for(PlayerCharacter character : selectedCharacters()) {
165.334 + character.setTarget(object);
165.335 + }
165.336 + }
165.337 + }
165.338 + }
165.339 + }
165.340 +
165.341 + private Vector<PlayerCharacter> selectedCharacters() {
165.342 + Vector<PlayerCharacter> selectedCharacters = new Vector<PlayerCharacter>();
165.343 + for(PlayerCharacter c : playerCharacters)
165.344 + if(c.isSelected())
165.345 + selectedCharacters.add(c);
165.346 + return selectedCharacters;
165.347 + }
165.348 +
165.349 + public boolean onLongClick(View v) {
165.350 + if(v == gameView)
165.351 + {
165.352 + GameObject object = getLastObjectTouched();
165.353 + if(object == null); //handle touch on screen
165.354 + else; //handle touch on object
165.355 + }
165.356 + return false;
165.357 + }
165.358 +
165.359 + public boolean onCreateOptionsMenu(Menu menu){
165.360 + int i = 0;
165.361 +
165.362 + // add deselect
165.363 + menu.add(Menu.NONE, DESELECT_ID,i,DESELECT_STRING );
165.364 + i++;
165.365 + // add the characters
165.366 + for(PlayerCharacter c: playerCharacters){
165.367 + String theString = "";
165.368 + int theId = FOOTBALL_ID; // intiialize to something default
165.369 + if(c.isDead() || c.isDying())
165.370 + continue;
165.371 + if(c instanceof FootballPlayer){
165.372 + theString = FOOTBALL_STRING;
165.373 + theId = FOOTBALL_ID;
165.374 + }else if(c instanceof HockeyPlayer){
165.375 + theString = HOCKEY_STRING;
165.376 + theId = HOCKEY_ID;
165.377 + }else if(c instanceof BaseballPlayer){
165.378 + theString = BASEBALL_STRING;
165.379 + theId = BASEBALL_ID;
165.380 + }
165.381 + if(c.isSelected()){
165.382 + theString = theString.concat(" " + SELECTED_STRING);
165.383 + }
165.384 + menu.add(Menu.NONE, theId, i, theString);
165.385 +
165.386 + i++;
165.387 + }
165.388 +
165.389 + // add select all
165.390 + menu.add(Menu.NONE, SELECT_ID, i, SELECT_STRING);
165.391 + return super.onCreateOptionsMenu(menu);
165.392 + }
165.393 +
165.394 + /**
165.395 + * Updates and Displays the menu
165.396 + */
165.397 + public boolean onPrepareOptionsMenu(Menu menu){
165.398 + for(PlayerCharacter c: playerCharacters){
165.399 + int id = FOOTBALL_ID; // by default, will be overwritten
165.400 + String playerString = "";
165.401 + if(c instanceof FootballPlayer){
165.402 + id = FOOTBALL_ID;
165.403 + playerString = FOOTBALL_STRING;
165.404 + }else if(c instanceof HockeyPlayer){
165.405 + id = HOCKEY_ID;
165.406 + playerString = HOCKEY_STRING;
165.407 + }else if(c instanceof BaseballPlayer){
165.408 + id = BASEBALL_ID;
165.409 + playerString = BASEBALL_STRING;
165.410 + }
165.411 + MenuItem item = menu.findItem(id);
165.412 + if(item != null){
165.413 + if(c.isSelected())
165.414 + item.setTitle(playerString + SELECTED_STRING);
165.415 + else
165.416 + item.setTitle(playerString + UNSELECTED_STRING);
165.417 +
165.418 + if(c.isDead() || c.isDying())
165.419 + item.setVisible(false);
165.420 + }
165.421 + }
165.422 +
165.423 + return super.onPrepareOptionsMenu(menu);
165.424 + }
165.425 +
165.426 + public boolean onOptionsItemSelected(MenuItem item){
165.427 + //CharSequence id = item.getId();
165.428 + int id = item.getItemId();
165.429 + String theString = (String) item.getTitle();
165.430 +
165.431 + if(id == DESELECT_ID){
165.432 + for(PlayerCharacter c: playerCharacters)
165.433 + c.setSelected(false);
165.434 + }else if(id == FOOTBALL_ID){
165.435 + boolean checkedState = theString.endsWith(SELECTED_STRING);
165.436 + for(PlayerCharacter c: playerCharacters){
165.437 + if(c instanceof FootballPlayer)
165.438 + c.setSelected(!checkedState);
165.439 + }
165.440 + }else if(id == HOCKEY_ID){
165.441 + boolean checkedState = theString.endsWith(SELECTED_STRING);
165.442 + for(PlayerCharacter c: playerCharacters){
165.443 + if(c instanceof HockeyPlayer)
165.444 + c.setSelected(!checkedState);
165.445 + }
165.446 + }else if(id == BASEBALL_ID){
165.447 + boolean checkedState = theString.endsWith(SELECTED_STRING);
165.448 + for(PlayerCharacter c: playerCharacters){
165.449 + if(c instanceof BaseballPlayer)
165.450 + c.setSelected(!checkedState);
165.451 + }
165.452 + }else if(id == SELECT_ID){
165.453 + for(PlayerCharacter c: playerCharacters){
165.454 + c.setSelected(true);
165.455 + }
165.456 + }
165.457 + reopenMenu = true;
165.458 + return super.onOptionsItemSelected(item);
165.459 + }
165.460 +
165.461 + @Override
165.462 + public void onOptionsMenuClosed(Menu menu) {
165.463 + super.onOptionsMenuClosed(menu);
165.464 + if(reopenMenu) {
165.465 + new Handler().post(new Runnable() {
165.466 +
165.467 + public void run() {
165.468 + openOptionsMenu();
165.469 + }
165.470 +
165.471 + });
165.472 + }
165.473 + reopenMenu = false;
165.474 + }
165.475 +
165.476 + class GameLoop implements Runnable
165.477 + {
165.478 + private long nextstep;
165.479 +
165.480 + public void setTime() {
165.481 + nextstep = SystemClock.uptimeMillis();
165.482 + }
165.483 +
165.484 + public void run() {
165.485 + stepGame(GAME_UPDATE_PERIOD);
165.486 + nextstep = Math.max(nextstep + GAME_UPDATE_PERIOD, SystemClock.uptimeMillis());
165.487 + gameLoopHandler.postAtTime(this, nextstep);
165.488 + }
165.489 + }
165.490 +
165.491 +
165.492 +}
166.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
166.2 +++ b/GCA-BCS/src/com/blackcloverstudios/appathon/GameObject.java Wed Oct 19 19:08:10 2011 -0400
166.3 @@ -0,0 +1,57 @@
166.4 +/**
166.5 + * This class is the "base class" that defines an dynamic
166.6 + * (not static, like a background) object in the game.
166.7 + */
166.8 +
166.9 +package com.blackcloverstudios.appathon;
166.10 +
166.11 +import android.graphics.Canvas;
166.12 +import android.graphics.Rect;
166.13 +
166.14 +public abstract class GameObject implements Comparable<GameObject> {
166.15 +
166.16 + protected Vector2D position;
166.17 + double orientation;
166.18 + protected Rect imageRect;
166.19 + protected Rect touchRect;
166.20 +
166.21 + /** The radius of the GameObject's circular hitbox */
166.22 + float radius;
166.23 +
166.24 + long aliveTime = 0;
166.25 +
166.26 + abstract void render(Canvas aCanvas);
166.27 +
166.28 + void step(long time){
166.29 + aliveTime += time;
166.30 + }
166.31 +
166.32 + boolean collidesWith(GameObject o){
166.33 + // quick check
166.34 + double r1r2 = (radius + o.radius);
166.35 + if((Math.abs(position.x - o.position.x) > r1r2) ||
166.36 + (Math.abs(position.y - o.position.y) > r1r2))
166.37 + return false;
166.38 +
166.39 + // slow check
166.40 + double dSquared = position.distanceSquared(o.position);
166.41 + if(dSquared <= (r1r2*r1r2))
166.42 + return true;
166.43 +
166.44 + return false;
166.45 + }
166.46 +
166.47 + boolean isTouching(int x, int y){
166.48 + Rect cont = new Rect(imageRect);
166.49 + cont.offset((int)position.x, (int)position.y);
166.50 + return cont.contains(x, y);
166.51 + }
166.52 +
166.53 + Vector2D getPosition(){ return position; }
166.54 + void setPosition(Vector2D aPosition){ position = aPosition; }
166.55 + double getOrientation() { return orientation; }
166.56 +
166.57 + public int compareTo(GameObject another) {
166.58 + return (int) Math.signum(position.y - another.position.y);
166.59 + }
166.60 +}
167.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
167.2 +++ b/GCA-BCS/src/com/blackcloverstudios/appathon/GameView.java Wed Oct 19 19:08:10 2011 -0400
167.3 @@ -0,0 +1,141 @@
167.4 +/**
167.5 + *
167.6 + */
167.7 +package com.blackcloverstudios.appathon;
167.8 +
167.9 +import java.util.Collections;
167.10 +import java.util.Vector;
167.11 +
167.12 +import android.content.Context;
167.13 +import android.graphics.Canvas;
167.14 +import android.graphics.Paint;
167.15 +import android.graphics.drawable.Drawable;
167.16 +import android.os.Handler;
167.17 +import android.util.AttributeSet;
167.18 +import android.view.SurfaceHolder;
167.19 +import android.view.SurfaceView;
167.20 +
167.21 +/**
167.22 + * @author Dan
167.23 + *
167.24 + */
167.25 +public class GameView extends SurfaceView {
167.26 + Thread viewThread;
167.27 + boolean running = false;
167.28 + boolean gameUpdated = false;
167.29 + Vector<GameObject> objects;
167.30 +
167.31 + /**
167.32 + * @param context
167.33 + */
167.34 + public GameView(Context context) {
167.35 + super(context);
167.36 + viewThread = new ViewThread(getHolder(), (GameActivity) getContext(), getHandler());
167.37 + }
167.38 +
167.39 + /**
167.40 + * @param context
167.41 + * @param attrs
167.42 + */
167.43 + public GameView(Context context, AttributeSet attrs) {
167.44 + super(context, attrs);
167.45 + viewThread = new ViewThread(getHolder(), (GameActivity) getContext(), getHandler());
167.46 + }
167.47 +
167.48 + /**
167.49 + * @param context
167.50 + * @param attrs
167.51 + * @param defStyle
167.52 + */
167.53 + public GameView(Context context, AttributeSet attrs, int defStyle) {
167.54 + super(context, attrs, defStyle);
167.55 + viewThread = new ViewThread(getHolder(), (GameActivity) getContext(), getHandler());
167.56 + }
167.57 +
167.58 + public void startRendering(Vector<GameObject> list)
167.59 + {
167.60 + objects = list;
167.61 + if(!running)
167.62 + {
167.63 + while(getHolder().isCreating());
167.64 + viewThread.start();
167.65 + running = true;
167.66 + }
167.67 + }
167.68 +
167.69 + public void stopRendering()
167.70 + {
167.71 + running = false;
167.72 + }
167.73 +
167.74 + class ViewThread extends Thread {
167.75 +
167.76 + @SuppressWarnings("unused")
167.77 + private Handler handler;
167.78 + private GameActivity context;
167.79 + private SurfaceHolder surfaceHolder;
167.80 + private Paint paint;
167.81 +
167.82 + public ViewThread(SurfaceHolder aSurfaceHolder, GameActivity aContext, Handler aHandler)
167.83 + {
167.84 + super();
167.85 + surfaceHolder = aSurfaceHolder;
167.86 + context = aContext;
167.87 + handler = aHandler;
167.88 + paint = new Paint();
167.89 + paint.setARGB(255, 255, 255, 255);
167.90 + }
167.91 +
167.92 + @Override
167.93 + public void run()
167.94 + {
167.95 + while(running)
167.96 + {
167.97 + Canvas c = null;
167.98 + gameUpdated = true;
167.99 + if(gameUpdated)
167.100 + {
167.101 + try {
167.102 + c = surfaceHolder.lockCanvas(null);
167.103 + if(c != null){
167.104 + synchronized (surfaceHolder) {
167.105 + drawCanvas(c);
167.106 + }
167.107 + }
167.108 + } finally {
167.109 + // do this in a finally so that if an exception is thrown
167.110 + // during the above, we don't leave the Surface in an
167.111 + // inconsistent state
167.112 + if (c != null) {
167.113 + surfaceHolder.unlockCanvasAndPost(c);
167.114 + }
167.115 + }// end finally block
167.116 +
167.117 + }
167.118 +
167.119 + }
167.120 + }
167.121 +
167.122 + public void drawCanvas(Canvas canvas)
167.123 + {
167.124 + canvas.drawARGB(255, 100, 198, 148);
167.125 +
167.126 + // draw background (basketball court)
167.127 + Drawable background = context.getResources().getDrawable(R.drawable.basketball_court);
167.128 + background.setBounds(0, 0, 800, 480);
167.129 + background.draw(canvas);
167.130 + synchronized(objects) {
167.131 + Collections.sort(objects);
167.132 + for(GameObject o: objects){
167.133 + synchronized(o){
167.134 + o.render(canvas);
167.135 + }
167.136 + }
167.137 + }
167.138 + canvas.drawText("Time: " + String.valueOf(((GameActivity)context).getGameTime()/1000), 20, 20, paint);
167.139 + canvas.drawText("Score: " + String.valueOf(((GameActivity)context).getScore()), 740, 20, paint);
167.140 + }
167.141 +
167.142 + }
167.143 +
167.144 +}
168.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
168.2 +++ b/GCA-BCS/src/com/blackcloverstudios/appathon/HockeyPlayer.java Wed Oct 19 19:08:10 2011 -0400
168.3 @@ -0,0 +1,146 @@
168.4 +/**
168.5 + * Class representing a Hockey Player (controlled by the user)
168.6 + */
168.7 +
168.8 +package com.blackcloverstudios.appathon;
168.9 +
168.10 +import java.util.Vector;
168.11 +
168.12 +import android.content.Context;
168.13 +import android.graphics.drawable.Drawable;
168.14 +
168.15 +public class HockeyPlayer extends PlayerCharacter {
168.16 + public HockeyPlayer(Vector<GameObject> o, Context context, Vector2D pos){
168.17 + super(o,context);
168.18 +
168.19 + // set up attributes
168.20 + //set up attributes
168.21 + speed = 0.1f;
168.22 + attackDelay = 500; //time in ms before you can attack again
168.23 + damage = 15; //damage done by on attack
168.24 + healthRegenDelay = 500; //time in ms to gain one health
168.25 + healthRegenAmount = 7;
168.26 + maxHealth = 175; //maximum health
168.27 + health = maxHealth;
168.28 +
168.29 + position.set(pos);
168.30 +
168.31 + // set up the sprites hashmap
168.32 +// sprites = new HashMap<Integer, Drawable[][]>();
168.33 + Drawable tempSprite[][];
168.34 +
168.35 + tempSprite = new Drawable[1][1];
168.36 + tempSprite[0][0] = context.getResources().getDrawable(R.drawable.hockey_guy_dead2);
168.37 + sprites.put(ACTION_DIE, tempSprite);
168.38 +
168.39 + tempSprite = new Drawable[1][3];
168.40 + tempSprite[0][0] = context.getResources().getDrawable(R.drawable.hockey_guy_dead1);
168.41 + tempSprite[0][1] = context.getResources().getDrawable(R.drawable.hockey_guy_dead1);
168.42 + tempSprite[0][1] = context.getResources().getDrawable(R.drawable.hockey_guy_dead2);
168.43 + sprites.put(ACTION_DYING, tempSprite);
168.44 +
168.45 + // idle sprites
168.46 + tempSprite = new Drawable[8][1];
168.47 + tempSprite[0][0] = context.getResources().getDrawable(R.drawable.hockey_guy_right);
168.48 + tempSprite[7][0] = context.getResources().getDrawable(R.drawable.hockey_guy_right_45_back);
168.49 + tempSprite[6][0] = context.getResources().getDrawable(R.drawable.hockey_guy_back);
168.50 + tempSprite[5][0] = context.getResources().getDrawable(R.drawable.hockey_guy_left_45_back);
168.51 + tempSprite[4][0] = context.getResources().getDrawable(R.drawable.hockey_guy_left);
168.52 + tempSprite[3][0] = context.getResources().getDrawable(R.drawable.hockey_guy_left_45_front);
168.53 + tempSprite[2][0] = context.getResources().getDrawable(R.drawable.hockey_guy_front);
168.54 + tempSprite[1][0] = context.getResources().getDrawable(R.drawable.hockey_guy_right_45_front);
168.55 +
168.56 +// sprites.put(ACTION_DIE, tempSprite);
168.57 + sprites.put(ACTION_IDLE, tempSprite);
168.58 +
168.59 + tempSprite = new Drawable[8][4];
168.60 + tempSprite[0][0] = context.getResources().getDrawable(R.drawable.hockey_guy_right_stick);
168.61 + tempSprite[0][1] = context.getResources().getDrawable(R.drawable.hockey_guy_right_stick);
168.62 + tempSprite[0][2] = context.getResources().getDrawable(R.drawable.hockey_guy_right);
168.63 + tempSprite[0][3] = context.getResources().getDrawable(R.drawable.hockey_guy_right);
168.64 +
168.65 + tempSprite[7][0] = context.getResources().getDrawable(R.drawable.hockey_guy_right_45_back_stick);
168.66 + tempSprite[7][1] = context.getResources().getDrawable(R.drawable.hockey_guy_right_45_back_stick);
168.67 + tempSprite[7][2] = context.getResources().getDrawable(R.drawable.hockey_guy_right_45_back);
168.68 + tempSprite[7][3] = context.getResources().getDrawable(R.drawable.hockey_guy_right_45_back);
168.69 +
168.70 + tempSprite[6][0] = context.getResources().getDrawable(R.drawable.hockey_guy_back_stick);
168.71 + tempSprite[6][1] = context.getResources().getDrawable(R.drawable.hockey_guy_back_stick);
168.72 + tempSprite[6][2] = context.getResources().getDrawable(R.drawable.hockey_guy_back);
168.73 + tempSprite[6][3] = context.getResources().getDrawable(R.drawable.hockey_guy_back);
168.74 +
168.75 + tempSprite[5][0] = context.getResources().getDrawable(R.drawable.hockey_guy_left_45_back_stick);
168.76 + tempSprite[5][1] = context.getResources().getDrawable(R.drawable.hockey_guy_left_45_back_stick);
168.77 + tempSprite[5][2] = context.getResources().getDrawable(R.drawable.hockey_guy_left_45_back);
168.78 + tempSprite[5][3] = context.getResources().getDrawable(R.drawable.hockey_guy_left_45_back);
168.79 +
168.80 + tempSprite[4][0] = context.getResources().getDrawable(R.drawable.hockey_guy_left_stick);
168.81 + tempSprite[4][1] = context.getResources().getDrawable(R.drawable.hockey_guy_left_stick);
168.82 + tempSprite[4][2] = context.getResources().getDrawable(R.drawable.hockey_guy_left);
168.83 + tempSprite[4][3] = context.getResources().getDrawable(R.drawable.hockey_guy_left);
168.84 +
168.85 + tempSprite[3][0] = context.getResources().getDrawable(R.drawable.hockey_guy_left_45_front_stick);
168.86 + tempSprite[3][1] = context.getResources().getDrawable(R.drawable.hockey_guy_left_45_front_stick);
168.87 + tempSprite[3][2] = context.getResources().getDrawable(R.drawable.hockey_guy_left_45_front);
168.88 + tempSprite[3][3] = context.getResources().getDrawable(R.drawable.hockey_guy_left_45_front);
168.89 +
168.90 + tempSprite[2][0] = context.getResources().getDrawable(R.drawable.hockey_guy_front_stick);
168.91 + tempSprite[2][1] = context.getResources().getDrawable(R.drawable.hockey_guy_front_stick);
168.92 + tempSprite[2][2] = context.getResources().getDrawable(R.drawable.hockey_guy_front);
168.93 + tempSprite[2][3] = context.getResources().getDrawable(R.drawable.hockey_guy_front);
168.94 +
168.95 + tempSprite[1][0] = context.getResources().getDrawable(R.drawable.hockey_guy_right_45_front_stick);
168.96 + tempSprite[1][1] = context.getResources().getDrawable(R.drawable.hockey_guy_right_45_front_stick);
168.97 + tempSprite[1][2] = context.getResources().getDrawable(R.drawable.hockey_guy_right_45_front);
168.98 + tempSprite[1][3] = context.getResources().getDrawable(R.drawable.hockey_guy_right_45_front);
168.99 + sprites.put(ACTION_ATTACKING, tempSprite);
168.100 +
168.101 + // moving sprites
168.102 + tempSprite = new Drawable[8][4];
168.103 + tempSprite[0][0] = context.getResources().getDrawable(R.drawable.hockey_guy_right);
168.104 + tempSprite[0][1] = context.getResources().getDrawable(R.drawable.hockey_guy_right_walk1);
168.105 + tempSprite[0][2] = context.getResources().getDrawable(R.drawable.hockey_guy_right);
168.106 + tempSprite[0][3] = context.getResources().getDrawable(R.drawable.hockey_guy_right_walk2);
168.107 +
168.108 + tempSprite[7][0] = context.getResources().getDrawable(R.drawable.hockey_guy_right_45_back);
168.109 + tempSprite[7][1] = context.getResources().getDrawable(R.drawable.hockey_guy_right_45_back_walk);
168.110 + tempSprite[7][2] = context.getResources().getDrawable(R.drawable.hockey_guy_right_45_back);
168.111 + tempSprite[7][3] = context.getResources().getDrawable(R.drawable.hockey_guy_right_45_back_walk);
168.112 +
168.113 + tempSprite[6][0] = context.getResources().getDrawable(R.drawable.hockey_guy_back);
168.114 + tempSprite[6][1] = context.getResources().getDrawable(R.drawable.hockey_guy_back_walk1);
168.115 + tempSprite[6][2] = context.getResources().getDrawable(R.drawable.hockey_guy_back);
168.116 + tempSprite[6][3] = context.getResources().getDrawable(R.drawable.hockey_guy_back_walk2);
168.117 +
168.118 + tempSprite[5][0] = context.getResources().getDrawable(R.drawable.hockey_guy_left_45_back);
168.119 + tempSprite[5][1] = context.getResources().getDrawable(R.drawable.hockey_guy_left_45_back_walk);
168.120 + tempSprite[5][2] = context.getResources().getDrawable(R.drawable.hockey_guy_left_45_back);
168.121 + tempSprite[5][3] = context.getResources().getDrawable(R.drawable.hockey_guy_left_45_back_walk);
168.122 +
168.123 + tempSprite[4][0] = context.getResources().getDrawable(R.drawable.hockey_guy_left);
168.124 + tempSprite[4][1] = context.getResources().getDrawable(R.drawable.hockey_guy_left_walk1);
168.125 + tempSprite[4][2] = context.getResources().getDrawable(R.drawable.hockey_guy_left);
168.126 + tempSprite[4][3] = context.getResources().getDrawable(R.drawable.hockey_guy_left_walk2);
168.127 +
168.128 + tempSprite[3][0] = context.getResources().getDrawable(R.drawable.hockey_guy_left_45_front);
168.129 + tempSprite[3][1] = context.getResources().getDrawable(R.drawable.hockey_guy_left_45_front_walk);
168.130 + tempSprite[3][2] = context.getResources().getDrawable(R.drawable.hockey_guy_left_45_front);
168.131 + tempSprite[3][3] = context.getResources().getDrawable(R.drawable.hockey_guy_left_45_front_walk);
168.132 +
168.133 + tempSprite[2][0] = context.getResources().getDrawable(R.drawable.hockey_guy_front);
168.134 + tempSprite[2][1] = context.getResources().getDrawable(R.drawable.hockey_guy_front_walk1);
168.135 + tempSprite[2][2] = context.getResources().getDrawable(R.drawable.hockey_guy_front);
168.136 + tempSprite[2][3] = context.getResources().getDrawable(R.drawable.hockey_guy_front_walk2);
168.137 +
168.138 + tempSprite[1][0] = context.getResources().getDrawable(R.drawable.hockey_guy_right_45_front);
168.139 + tempSprite[1][1] = context.getResources().getDrawable(R.drawable.hockey_guy_right_45_front_walk);
168.140 + tempSprite[1][2] = context.getResources().getDrawable(R.drawable.hockey_guy_right_45_front);
168.141 + tempSprite[1][3] = context.getResources().getDrawable(R.drawable.hockey_guy_right_45_front_walk);
168.142 +
168.143 + sprites.put(ACTION_MOVING, tempSprite);
168.144 + sprites.put(ACTION_CHARGING, tempSprite);
168.145 + sprites.put(ACTION_POSITIONING, tempSprite);
168.146 +
168.147 +
168.148 + }
168.149 +}
169.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
169.2 +++ b/GCA-BCS/src/com/blackcloverstudios/appathon/InstrActivity.java Wed Oct 19 19:08:10 2011 -0400
169.3 @@ -0,0 +1,38 @@
169.4 +
169.5 +package com.blackcloverstudios.appathon;
169.6 +
169.7 +import android.app.Activity;
169.8 +import android.os.Bundle;
169.9 +import android.view.View;
169.10 +import android.view.View.OnClickListener;
169.11 +import android.widget.Button;
169.12 +import android.widget.TextView;
169.13 +
169.14 +public class InstrActivity extends Activity implements OnClickListener{
169.15 + Button backButton;
169.16 +
169.17 + String instructions =
169.18 + "Welcome to the wold of High School Showdown: Athletes vs. Ninjas Pirates & Robots!\n\n" +
169.19 + "It's the end of the world! The Ninjas have teamed up with the Pirates, causing a cataclysm of internet trolls and memes. To make matters worse, Robots have joined forces with the two former enemies\n\n" +
169.20 + "Now it's just three athletes from a local high school standing firm against the onslaught of Ninjas Pirates and Robots! Stand your ground, survive!\n\n" +
169.21 + "Controls:\n\n" +
169.22 + "Select Character - Touch character image or push the Menu Button to bring up the Selection Menu.\n\n" +
169.23 + "Move Character - With character(s) selected, touch a point on-screen\n\n"+
169.24 + "Attack Enemy - With character(s) selected, touch an enemy on-screen.\n";
169.25 +
169.26 +
169.27 +
169.28 + public void onCreate(Bundle savedInstanceState) {
169.29 + super.onCreate(savedInstanceState);
169.30 + setContentView(R.layout.instruction_screen);
169.31 + TextView view = (TextView) findViewById(R.id.instructionsView);
169.32 + view.setText(instructions);
169.33 + }
169.34 +
169.35 + public void onClick(View view){
169.36 + if(view == backButton)
169.37 + {
169.38 + //...
169.39 + }
169.40 + }
169.41 +}
170.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
170.2 +++ b/GCA-BCS/src/com/blackcloverstudios/appathon/Mascot.java Wed Oct 19 19:08:10 2011 -0400
170.3 @@ -0,0 +1,64 @@
170.4 +package com.blackcloverstudios.appathon;
170.5 +
170.6 +import java.util.HashMap;
170.7 +import java.util.Vector;
170.8 +
170.9 +import android.content.Context;
170.10 +import android.graphics.drawable.Drawable;
170.11 +
170.12 +public class Mascot extends Character {
170.13 +
170.14 + Vector<GameObject> objects;
170.15 +
170.16 + Mascot(Vector<GameObject> o, Context context, Vector2D pos) {
170.17 + super(o,context);
170.18 + //set up attributes
170.19 + speed = 0.2f;
170.20 + position.set(pos);
170.21 +
170.22 + // set up the sprites hashmap
170.23 + sprites = new HashMap<Integer, Drawable[][]>();
170.24 + Drawable tempSprite[][];
170.25 +
170.26 + // idle sprites
170.27 + tempSprite = new Drawable[4][1];
170.28 + tempSprite[0][0] = context.getResources().getDrawable(R.drawable.football_guy_right);
170.29 + tempSprite[1][0] = context.getResources().getDrawable(R.drawable.football_guy_front);
170.30 + tempSprite[2][0] = context.getResources().getDrawable(R.drawable.football_guy_left);
170.31 + tempSprite[3][0] = context.getResources().getDrawable(R.drawable.football_guy_back);
170.32 +
170.33 + sprites.put(ACTION_IDLE, tempSprite);
170.34 + sprites.put(ACTION_ATTACKING, tempSprite);
170.35 +
170.36 + // moving sprites
170.37 + tempSprite = new Drawable[4][4];
170.38 + tempSprite[0][0] = context.getResources().getDrawable(R.drawable.football_guy_right);
170.39 + tempSprite[0][1] = context.getResources().getDrawable(R.drawable.football_guy_right_walk1);
170.40 + tempSprite[0][2] = context.getResources().getDrawable(R.drawable.football_guy_right);
170.41 + tempSprite[0][3] = context.getResources().getDrawable(R.drawable.football_guy_right_walk2);
170.42 +
170.43 + tempSprite[1][0] = context.getResources().getDrawable(R.drawable.football_guy_front);
170.44 + tempSprite[1][1] = context.getResources().getDrawable(R.drawable.football_guy_front_walk1);
170.45 + tempSprite[1][2] = context.getResources().getDrawable(R.drawable.football_guy_front);
170.46 + tempSprite[1][3] = context.getResources().getDrawable(R.drawable.football_guy_front_walk2);
170.47 +
170.48 + tempSprite[2][0] = context.getResources().getDrawable(R.drawable.football_guy_left);
170.49 + tempSprite[2][1] = context.getResources().getDrawable(R.drawable.football_guy_left_walk1);
170.50 + tempSprite[2][2] = context.getResources().getDrawable(R.drawable.football_guy_left);
170.51 + tempSprite[2][3] = context.getResources().getDrawable(R.drawable.football_guy_left_walk2);
170.52 +
170.53 + tempSprite[3][0] = context.getResources().getDrawable(R.drawable.football_guy_back);
170.54 + tempSprite[3][1] = context.getResources().getDrawable(R.drawable.football_guy_back_walk1);
170.55 + tempSprite[3][2] = context.getResources().getDrawable(R.drawable.football_guy_back);
170.56 + tempSprite[3][3] = context.getResources().getDrawable(R.drawable.football_guy_back_walk2);
170.57 +
170.58 + sprites.put(ACTION_MOVING, tempSprite);
170.59 + sprites.put(ACTION_CHARGING, tempSprite);
170.60 + sprites.put(ACTION_POSITIONING, tempSprite);
170.61 + }
170.62 +
170.63 + protected void think(long time) {
170.64 + // TODO Auto-generated method stub
170.65 + }
170.66 +
170.67 +}
171.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
171.2 +++ b/GCA-BCS/src/com/blackcloverstudios/appathon/NinjaCPU.java Wed Oct 19 19:08:10 2011 -0400
171.3 @@ -0,0 +1,90 @@
171.4 +
171.5 +package com.blackcloverstudios.appathon;
171.6 +
171.7 +import java.util.Random;
171.8 +import java.util.Vector;
171.9 +import android.content.Context;
171.10 +import android.graphics.drawable.Drawable;
171.11 +
171.12 +public class NinjaCPU extends CPUCharacter {
171.13 +
171.14 + NinjaCPU(Vector<GameObject> o, Context context, Vector2D pos){
171.15 + super(o,context);
171.16 + //set up attributes
171.17 + speed = 0.15f;
171.18 + attackDelay = 1500; //time in ms before you can attack again
171.19 + damage = 40; //damage done by on attack
171.20 + healthRegenDelay = 250; //time in ms to gain one health
171.21 + healthRegenAmount = 1;
171.22 + maxHealth = 50; //maximum health
171.23 + health = maxHealth;
171.24 +
171.25 + position.set(pos);
171.26 +
171.27 + // set up the sprites hashmap
171.28 +// sprites = new HashMap<Integer, Drawable[][]>();
171.29 + Drawable tempSprite[][];
171.30 +
171.31 + // idle sprites
171.32 + tempSprite = new Drawable[4][1];
171.33 + tempSprite[0][0] = context.getResources().getDrawable(R.drawable.ninja_right);
171.34 + tempSprite[1][0] = context.getResources().getDrawable(R.drawable.ninja_front);
171.35 + tempSprite[2][0] = context.getResources().getDrawable(R.drawable.ninja_left);
171.36 + tempSprite[3][0] = context.getResources().getDrawable(R.drawable.ninja_back);
171.37 +
171.38 + sprites.put(ACTION_IDLE, tempSprite);
171.39 + sprites.put(ACTION_ATTACKING, tempSprite);
171.40 +
171.41 + // moving sprites
171.42 + tempSprite = new Drawable[4][4];
171.43 + tempSprite[0][0] = context.getResources().getDrawable(R.drawable.ninja_right);
171.44 + tempSprite[0][1] = context.getResources().getDrawable(R.drawable.ninja_right_walk1);
171.45 + tempSprite[0][2] = context.getResources().getDrawable(R.drawable.ninja_right);
171.46 + tempSprite[0][3] = context.getResources().getDrawable(R.drawable.ninja_right_walk2);
171.47 +
171.48 + tempSprite[1][0] = context.getResources().getDrawable(R.drawable.ninja_front);
171.49 + tempSprite[1][1] = context.getResources().getDrawable(R.drawable.ninja_front_walk1);
171.50 + tempSprite[1][2] = context.getResources().getDrawable(R.drawable.ninja_front);
171.51 + tempSprite[1][3] = context.getResources().getDrawable(R.drawable.ninja_front_walk2);
171.52 +
171.53 + tempSprite[2][0] = context.getResources().getDrawable(R.drawable.ninja_left);
171.54 + tempSprite[2][1] = context.getResources().getDrawable(R.drawable.ninja_left_walk1);
171.55 + tempSprite[2][2] = context.getResources().getDrawable(R.drawable.ninja_left);
171.56 + tempSprite[2][3] = context.getResources().getDrawable(R.drawable.ninja_left_walk2);
171.57 +
171.58 + tempSprite[3][0] = context.getResources().getDrawable(R.drawable.ninja_back);
171.59 + tempSprite[3][1] = context.getResources().getDrawable(R.drawable.ninja_back_walk1);
171.60 + tempSprite[3][2] = context.getResources().getDrawable(R.drawable.ninja_back);
171.61 + tempSprite[3][3] = context.getResources().getDrawable(R.drawable.ninja_back_walk2);
171.62 +
171.63 + sprites.put(ACTION_MOVING, tempSprite);
171.64 + sprites.put(ACTION_CHARGING, tempSprite);
171.65 + sprites.put(ACTION_POSITIONING, tempSprite);
171.66 + }
171.67 +
171.68 + @Override
171.69 + public void think(long time) {
171.70 + //attack close players if you can then run around
171.71 + if(isStateEnabled(STATE_MELLEE_ATTACKING))
171.72 + {
171.73 + if(attackTimer < attackDelay || target != null && position.distance(target.position) > 100)
171.74 + setState(ACTION_IDLE);
171.75 + }
171.76 + else if(attackTimer >= attackDelay && isAlive())
171.77 + {
171.78 + for(GameObject object : objects)
171.79 + {
171.80 + if(object instanceof PlayerCharacter && ((PlayerCharacter)object).isAlive() &&
171.81 + position.x - object.position.x <= 200 && position.y - object.position.y <= 200 && position.distanceSquared(object.position) <= 40000)
171.82 + if(target == null || position.distanceSquared(target.position) > position.distanceSquared(object.position))
171.83 + setTarget(object);
171.84 + }
171.85 + }
171.86 + if(!isStateEnabled(STATE_MOVING) && isAlive())
171.87 + {
171.88 + Random rand = new Random();
171.89 + moveTo(rand.nextFloat() * 800, rand.nextFloat() * 480);
171.90 + }
171.91 + }
171.92 +
171.93 +}
172.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
172.2 +++ b/GCA-BCS/src/com/blackcloverstudios/appathon/PirateCPU.java Wed Oct 19 19:08:10 2011 -0400
172.3 @@ -0,0 +1,86 @@
172.4 +package com.blackcloverstudios.appathon;
172.5 +
172.6 +import java.util.Random;
172.7 +import java.util.Vector;
172.8 +
172.9 +import android.content.Context;
172.10 +import android.graphics.drawable.Drawable;
172.11 +
172.12 +public class PirateCPU extends CPUCharacter {
172.13 +
172.14 + public PirateCPU(Vector<GameObject> o, Context c, Vector2D pos){
172.15 + super(o, c);
172.16 +
172.17 + // set up attributes
172.18 + speed = 0.1f;
172.19 + attackDelay = 500;
172.20 + damage = 20;
172.21 + healthRegenDelay = 250;
172.22 + healthRegenAmount = 1;
172.23 + maxHealth = 100;
172.24 + health = maxHealth;;
172.25 +
172.26 + position.set(pos);
172.27 +
172.28 + // set up the sprites hashmap
172.29 + Drawable tempSprite[][];
172.30 +
172.31 + // idle sprites
172.32 + // idle sprites
172.33 + tempSprite = new Drawable[4][1];
172.34 + tempSprite[0][0] = c.getResources().getDrawable(R.drawable.pirate_right);
172.35 + tempSprite[1][0] = c.getResources().getDrawable(R.drawable.pirate_front);
172.36 + tempSprite[2][0] = c.getResources().getDrawable(R.drawable.pirate_left);
172.37 + tempSprite[3][0] = c.getResources().getDrawable(R.drawable.pirate_back);
172.38 +
172.39 + sprites.put(ACTION_IDLE, tempSprite);
172.40 + sprites.put(ACTION_ATTACKING, tempSprite);
172.41 +
172.42 + // moving sprites
172.43 + tempSprite = new Drawable[4][4];
172.44 + tempSprite[0][0] = c.getResources().getDrawable(R.drawable.pirate_right);
172.45 + tempSprite[0][1] = c.getResources().getDrawable(R.drawable.pirate_right_walk1);
172.46 + tempSprite[0][2] = c.getResources().getDrawable(R.drawable.pirate_right);
172.47 + tempSprite[0][3] = c.getResources().getDrawable(R.drawable.pirate_right_walk2);
172.48 +
172.49 + tempSprite[1][0] = c.getResources().getDrawable(R.drawable.pirate_front);
172.50 + tempSprite[1][1] = c.getResources().getDrawable(R.drawable.pirate_front_walk1);
172.51 + tempSprite[1][2] = c.getResources().getDrawable(R.drawable.pirate_front);
172.52 + tempSprite[1][3] = c.getResources().getDrawable(R.drawable.pirate_front_walk2);
172.53 +
172.54 + tempSprite[2][0] = c.getResources().getDrawable(R.drawable.pirate_left);
172.55 + tempSprite[2][1] = c.getResources().getDrawable(R.drawable.pirate_left_walk1);
172.56 + tempSprite[2][2] = c.getResources().getDrawable(R.drawable.pirate_left);
172.57 + tempSprite[2][3] = c.getResources().getDrawable(R.drawable.pirate_left_walk2);
172.58 +
172.59 + tempSprite[3][0] = c.getResources().getDrawable(R.drawable.pirate_back);
172.60 + tempSprite[3][1] = c.getResources().getDrawable(R.drawable.pirate_back_walk1);
172.61 + tempSprite[3][2] = c.getResources().getDrawable(R.drawable.pirate_back);
172.62 + tempSprite[3][3] = c.getResources().getDrawable(R.drawable.pirate_back_walk2);
172.63 +
172.64 + sprites.put(ACTION_MOVING, tempSprite);
172.65 + sprites.put(ACTION_CHARGING, tempSprite);
172.66 + sprites.put(ACTION_POSITIONING, tempSprite);
172.67 +
172.68 + }
172.69 +
172.70 + @Override
172.71 + public void think(long time){
172.72 + //charge closest player
172.73 + if(isAlive())
172.74 + {
172.75 + for(GameObject object : objects)
172.76 + {
172.77 + if(object instanceof PlayerCharacter && ((PlayerCharacter)object).isAlive())
172.78 + if(target == null || position.distanceSquared(target.position) > position.distanceSquared(object.position))
172.79 + setTarget(object);
172.80 + }
172.81 + }
172.82 + if(!isStateEnabled(STATE_MOVING) && !isStateEnabled(STATE_MELLEE_ATTACKING) && isAlive())
172.83 + {
172.84 + Random rand = new Random();
172.85 + moveTo(rand.nextFloat() * 800, rand.nextFloat() * 480);
172.86 + }
172.87 + }
172.88 +
172.89 +}
173.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
173.2 +++ b/GCA-BCS/src/com/blackcloverstudios/appathon/PlayerCharacter.java Wed Oct 19 19:08:10 2011 -0400
173.3 @@ -0,0 +1,56 @@
173.4 +/**
173.5 + * This abstract class represents a "Player Character". A player character
173.6 + * is a character that can be interacted with by the user (i.e. the player
173.7 + * controls it).
173.8 + */
173.9 +
173.10 +package com.blackcloverstudios.appathon;
173.11 +
173.12 +import java.util.Vector;
173.13 +
173.14 +import android.content.Context;
173.15 +import android.graphics.Canvas;
173.16 +import android.graphics.Paint;
173.17 +import android.graphics.Rect;
173.18 +import android.graphics.RectF;
173.19 +
173.20 +public abstract class PlayerCharacter extends Character {
173.21 +
173.22 + /** If this is true, then the character is "selected" and should respond to commands*/
173.23 + private boolean selected;
173.24 + protected RectF selectOval;
173.25 + protected Paint selectedPaint;
173.26 +
173.27 + public PlayerCharacter(Vector<GameObject> o, Context c) {
173.28 + super(o,c);
173.29 + imageRect = new Rect(-48, -80, 48, 16);
173.30 + touchRect = new Rect(imageRect);
173.31 + selectOval = new RectF(-36, -24, 36, 24);
173.32 + selectedPaint = new Paint();
173.33 + selectedPaint.setARGB(127, 0, 255, 0);
173.34 +
173.35 + position = new Vector2D(800, 480);
173.36 + desiredPosition = null;
173.37 + setState(ACTION_IDLE);
173.38 + radius = 16;
173.39 + }
173.40 +
173.41 + public boolean isSelected(){ return selected = selected && isAlive(); }
173.42 + public void setSelected(boolean select){ selected = select && isAlive(); }
173.43 +
173.44 + protected void think(long time) {
173.45 + }
173.46 +
173.47 + @Override
173.48 + public void render(Canvas canvas)
173.49 + {
173.50 + if(isSelected())
173.51 + {
173.52 + RectF select = new RectF(selectOval);
173.53 + select.offset(position.x, position.y);
173.54 + canvas.drawOval(select, selectedPaint);
173.55 + }
173.56 + super.render(canvas);
173.57 + }
173.58 +
173.59 +}
174.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
174.2 +++ b/GCA-BCS/src/com/blackcloverstudios/appathon/RobotCPU.java Wed Oct 19 19:08:10 2011 -0400
174.3 @@ -0,0 +1,86 @@
174.4 +package com.blackcloverstudios.appathon;
174.5 +
174.6 +import java.util.Random;
174.7 +import java.util.Vector;
174.8 +
174.9 +import android.content.Context;
174.10 +import android.graphics.drawable.Drawable;
174.11 +
174.12 +public class RobotCPU extends CPUCharacter {
174.13 +
174.14 + public RobotCPU(Vector<GameObject> o, Context c, Vector2D pos){
174.15 + super(o, c);
174.16 +
174.17 + // set up attributes
174.18 + speed = 0.05f;
174.19 + attackDelay = 1500;
174.20 + damage = 20;
174.21 + healthRegenDelay = 100;
174.22 + healthRegenAmount = 1;
174.23 + maxHealth = 250;
174.24 + health = maxHealth;
174.25 +
174.26 + position.set(pos);
174.27 +
174.28 + // set up the sprites hashmap
174.29 + Drawable tempSprite[][];
174.30 +
174.31 + // idle sprites
174.32 + // idle sprites
174.33 + tempSprite = new Drawable[4][1];
174.34 + tempSprite[0][0] = c.getResources().getDrawable(R.drawable.robot_right);
174.35 + tempSprite[1][0] = c.getResources().getDrawable(R.drawable.robot_front);
174.36 + tempSprite[2][0] = c.getResources().getDrawable(R.drawable.robot_left);
174.37 + tempSprite[3][0] = c.getResources().getDrawable(R.drawable.robot_back);
174.38 +
174.39 + sprites.put(ACTION_IDLE, tempSprite);
174.40 + sprites.put(ACTION_ATTACKING, tempSprite);
174.41 +
174.42 + // moving sprites
174.43 + tempSprite = new Drawable[4][4];
174.44 + tempSprite[0][0] = c.getResources().getDrawable(R.drawable.robot_right);
174.45 + tempSprite[0][1] = c.getResources().getDrawable(R.drawable.robot_right_walk1);
174.46 + tempSprite[0][2] = c.getResources().getDrawable(R.drawable.robot_right);
174.47 + tempSprite[0][3] = c.getResources().getDrawable(R.drawable.robot_right_walk2);
174.48 +
174.49 + tempSprite[1][0] = c.getResources().getDrawable(R.drawable.robot_front);
174.50 + tempSprite[1][1] = c.getResources().getDrawable(R.drawable.robot_front_walk1);
174.51 + tempSprite[1][2] = c.getResources().getDrawable(R.drawable.robot_front);
174.52 + tempSprite[1][3] = c.getResources().getDrawable(R.drawable.robot_front_walk2);
174.53 +
174.54 + tempSprite[2][0] = c.getResources().getDrawable(R.drawable.robot_left);
174.55 + tempSprite[2][1] = c.getResources().getDrawable(R.drawable.robot_left_walk1);
174.56 + tempSprite[2][2] = c.getResources().getDrawable(R.drawable.robot_left);
174.57 + tempSprite[2][3] = c.getResources().getDrawable(R.drawable.robot_left_walk2);
174.58 +
174.59 + tempSprite[3][0] = c.getResources().getDrawable(R.drawable.robot_back);
174.60 + tempSprite[3][1] = c.getResources().getDrawable(R.drawable.robot_back_walk1);
174.61 + tempSprite[3][2] = c.getResources().getDrawable(R.drawable.robot_back);
174.62 + tempSprite[3][3] = c.getResources().getDrawable(R.drawable.robot_back_walk2);
174.63 +
174.64 + sprites.put(ACTION_MOVING, tempSprite);
174.65 + sprites.put(ACTION_CHARGING, tempSprite);
174.66 + sprites.put(ACTION_POSITIONING, tempSprite);
174.67 +
174.68 + }
174.69 +
174.70 + @Override
174.71 + public void think(long time){
174.72 + //charge closest player
174.73 + if(isAlive())
174.74 + {
174.75 + for(GameObject object : objects)
174.76 + {
174.77 + if(object instanceof PlayerCharacter && ((PlayerCharacter)object).isAlive())
174.78 + if(target == null || position.distanceSquared(target.position) > position.distanceSquared(object.position))
174.79 + setTarget(object);
174.80 + }
174.81 + }
174.82 + if(!isStateEnabled(STATE_MOVING) && !isStateEnabled(STATE_MELLEE_ATTACKING) && isAlive())
174.83 + {
174.84 + Random rand = new Random();
174.85 + moveTo(rand.nextFloat() * 800, rand.nextFloat() * 480);
174.86 + }
174.87 + }
174.88 +
174.89 +}
175.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
175.2 +++ b/GCA-BCS/src/com/blackcloverstudios/appathon/StartActivity.java Wed Oct 19 19:08:10 2011 -0400
175.3 @@ -0,0 +1,60 @@
175.4 +package com.blackcloverstudios.appathon;
175.5 +
175.6 +import android.app.Activity;
175.7 +import android.content.Intent;
175.8 +import android.os.Bundle;
175.9 +import android.view.View;
175.10 +import android.view.Window;
175.11 +import android.view.View.OnClickListener;
175.12 +import android.widget.Button;
175.13 +
175.14 +public class StartActivity extends Activity implements OnClickListener {
175.15 + Button startButton;
175.16 + Button instButton;
175.17 + Button optionsButton;
175.18 + Button quitButton;
175.19 +
175.20 +
175.21 + /** Called when the activity (main menu) is first created. */
175.22 + @Override
175.23 + public void onCreate(Bundle savedInstanceState) {
175.24 + super.onCreate(savedInstanceState);
175.25 +
175.26 + requestWindowFeature(Window.FEATURE_NO_TITLE);
175.27 +
175.28 + setContentView(R.layout.main_screen);
175.29 + startButton = (Button) findViewById(R.id.start_button);
175.30 + startButton.setOnClickListener(this);
175.31 +
175.32 + instButton = (Button) findViewById(R.id.instructions_button);
175.33 + instButton.setOnClickListener(this);
175.34 + /*
175.35 + optionsButton = (Button) findViewById(R.id.options_button);
175.36 + optionsButton.setOnClickListener(this);
175.37 + */
175.38 +
175.39 + quitButton = (Button) findViewById(R.id.quit_button);
175.40 + quitButton.setOnClickListener(this);
175.41 +
175.42 + }
175.43 +
175.44 + public void onClick(View view){
175.45 + if(view == startButton)
175.46 + {
175.47 + this.startActivity(new Intent(this.getApplicationContext(), GameActivity.class));
175.48 + }
175.49 + if(view == instButton)
175.50 + {
175.51 + this.startActivity(new Intent(this.getApplicationContext(), InstrActivity.class));
175.52 + }
175.53 + /*
175.54 + if(view == optionsButton)
175.55 + {
175.56 + //add options menu
175.57 + }*/
175.58 + if(view == quitButton)
175.59 + {
175.60 + finish();
175.61 + }
175.62 + }
175.63 +}
175.64 \ No newline at end of file
176.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
176.2 +++ b/GCA-BCS/src/com/blackcloverstudios/appathon/Vector2D.java Wed Oct 19 19:08:10 2011 -0400
176.3 @@ -0,0 +1,52 @@
176.4 +/**
176.5 + * This class represents a 2D vector representing x and y as doubles
176.6 + * It also contains useful functions to help with calculations
176.7 + */
176.8 +
176.9 +package com.blackcloverstudios.appathon;
176.10 +
176.11 +import android.graphics.Point;
176.12 +import android.graphics.PointF;
176.13 +
176.14 +public class Vector2D extends PointF {
176.15 +
176.16 + public Vector2D() { super(); }
176.17 +
176.18 + public Vector2D(float x, float y) { super(x, y); }
176.19 +
176.20 + public Vector2D(Point p) { super(p); }
176.21 +
176.22 + // copy constructor
176.23 + public Vector2D(Vector2D anotherVector){
176.24 + super(anotherVector.x, anotherVector.y);
176.25 + }
176.26 +
176.27 + public void add(Vector2D anotherVector){
176.28 + x += anotherVector.x;
176.29 + y += anotherVector.y;
176.30 + }
176.31 +
176.32 + public void subtract(Vector2D anotherVector){
176.33 + x -= anotherVector.x;
176.34 + y -= anotherVector.y;
176.35 + }
176.36 +
176.37 + public double distanceSquared(Vector2D anotherVector){
176.38 + return Math.pow(x - anotherVector.x, 2) + Math.pow(y - anotherVector.y, 2);
176.39 + }
176.40 +
176.41 + public double distance(Vector2D anotherVector){
176.42 + return Math.sqrt(distanceSquared(anotherVector));
176.43 + }
176.44 +
176.45 + public double angleTo(Vector2D anotherVector){
176.46 + return Math.atan2( anotherVector.y - y, anotherVector.x - x );
176.47 + }
176.48 +
176.49 + public boolean equals(Object o){
176.50 + if(o == null || !(o instanceof PointF))
176.51 + return false;
176.52 + return ((PointF)o).x == x && ((PointF)o).y == y;
176.53 + }
176.54 +
176.55 +}