-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 277a8a8
Showing
48 changed files
with
1,347 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# built application files | ||
*.apk | ||
*.ap_ | ||
|
||
# files for the dex VM | ||
*.dex | ||
|
||
# Java class files | ||
*.class | ||
|
||
# generated files | ||
bin/ | ||
gen/ | ||
|
||
# Local configuration file (sdk path, etc) | ||
local.properties | ||
|
||
# Eclipse | ||
*.pydevproject | ||
#.project | ||
.metadata | ||
bin/** | ||
tmp/** | ||
tmp/**/* | ||
*.tmp | ||
*.bak | ||
*.swp | ||
*~.nib | ||
local.properties | ||
.classpath | ||
#.settings/ | ||
.loadpath | ||
|
||
# External tool builders | ||
.externalToolBuilders/ | ||
|
||
# Locally stored "Eclipse launch configurations" | ||
*.launch | ||
|
||
# CDT-specific | ||
.cproject | ||
|
||
# PDT-specific | ||
.buildpath |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>AndroidBasics</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>com.android.ide.eclipse.adt.ApkBuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>com.android.ide.eclipse.adt.AndroidNature</nature> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
</natures> | ||
</projectDescription> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 | ||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve | ||
org.eclipse.jdt.core.compiler.compliance=1.6 | ||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate | ||
org.eclipse.jdt.core.compiler.debug.localVariable=generate | ||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate | ||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error | ||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error | ||
org.eclipse.jdt.core.compiler.source=1.6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.example.androidbasics" | ||
android:versionCode="1" | ||
android:versionName="1.0" | ||
android:installLocation="preferExternal" > | ||
|
||
<uses-sdk | ||
android:minSdkVersion="8" | ||
android:targetSdkVersion="17" /> | ||
|
||
<uses-permission | ||
android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> | ||
<uses-permission | ||
android:name="android.permission.WAKE_LOCK" /> | ||
|
||
<application | ||
android:allowBackup="false" | ||
android:icon="@drawable/ic_launcher" | ||
android:label="@string/app_name" | ||
android:theme="@style/AppTheme" | ||
android:debuggable="true" > | ||
<activity | ||
android:name=".AndroidBasicsStarter" | ||
android:label="@string/activity_android_basics_starter" | ||
android:screenOrientation="portrait" | ||
android:configChanges="keyboard|keyboardHidden|orientation" > | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
<activity | ||
android:name=".tests.LifeCycleTest" | ||
android:label="@string/activity_android_test_life_cycle" | ||
android:configChanges="keyboard|keyboardHidden|orientation" /> | ||
<activity | ||
android:name=".tests.SingleTouchTest" | ||
android:label="@string/activity_android_test_singletouch" | ||
android:configChanges="keyboard|keyboardHidden|orientation" /> | ||
<activity | ||
android:name=".tests.MultiTouchTest" | ||
android:label="@string/activity_android_test_multitouch" | ||
android:configChanges="keyboard|keyboardHidden|orientation" /> | ||
<activity | ||
android:name=".tests.KeyTest" | ||
android:label="@string/activity_android_test_key" | ||
android:configChanges="keyboard|keyboardHidden|orientation" /> | ||
<activity | ||
android:name=".tests.AccelerometerTest" | ||
android:label="@string/activity_android_test_accelerometer" | ||
android:configChanges="keyboard|keyboardHidden|orientation" /> | ||
<activity | ||
android:name=".tests.AssetsTest" | ||
android:label="@string/activity_android_test_assets" | ||
android:configChanges="keyboard|keyboardHidden|orientation" /> | ||
<activity | ||
android:name=".tests.ExternalStorageTest" | ||
android:label="@string/activity_android_test_external_storage" | ||
android:configChanges="keyboard|keyboardHidden|orientation" /> | ||
<activity | ||
android:name=".tests.SoundPoolTest" | ||
android:label="@string/activity_android_test_sound_pool" | ||
android:configChanges="keyboard|keyboardHidden|orientation" /> | ||
<activity | ||
android:name=".tests.MediaPlayerTest" | ||
android:label="@string/activity_android_test_media_player" | ||
android:configChanges="keyboard|keyboardHidden|orientation" /> | ||
<activity | ||
android:name=".tests.FullScreenTest" | ||
android:label="@string/activity_android_test_fullscreen" | ||
android:screenOrientation="portrait" | ||
android:configChanges="keyboard|keyboardHidden|orientation" /> | ||
<activity | ||
android:name=".tests.RenderViewTest" | ||
android:label="@string/activity_android_test_render_view" | ||
android:configChanges="keyboard|keyboardHidden|orientation" /> | ||
<activity | ||
android:name=".tests.ShapeTest" | ||
android:label="@string/activity_android_test_shape" | ||
android:configChanges="keyboard|keyboardHidden|orientation" /> | ||
<activity | ||
android:name=".tests.BitmapTest" | ||
android:label="@string/activity_android_test_bitmap" | ||
android:configChanges="keyboard|keyboardHidden|orientation" /> | ||
<activity | ||
android:name=".tests.FontTest" | ||
android:label="@string/activity_android_test_font" | ||
android:configChanges="keyboard|keyboardHidden|orientation" /> | ||
<activity | ||
android:name=".tests.SurfaceViewTest" | ||
android:label="@string/activity_android_test_surface_view" | ||
android:configChanges="keyboard|keyboardHidden|orientation" /> | ||
<activity | ||
android:name=".tests.SwipeTest" | ||
android:label="@string/activity_android_test_swipe" | ||
android:configChanges="keyboard|keyboardHidden|orientation" /> | ||
</application> | ||
|
||
</manifest> |
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
I’ve spent a few hours today and yesterday adding behaviour to the hero and monsters. The biggest challenge is keeping monsters apart, having them follow the hero and not tunnel through walls. | ||
|
||
For path finding i use a rather simple and unoptimized implementation of A* on a tile grid (though it’s generic enough to work on any graph really). Path finding is only used to guide the hero to the point on the map the user tapped on. | ||
|
||
For keeping monsters separated i give them a simple separation steering behaviours. To avoid walls, i implemented simplified obstacle avoidance which exploits the fact that the entities are moving on a tile grid. The monsters follow the hero by simple seeking. Those three steering behaviours (separate, wall avoidance, seeking) actually make for a passable overall experience. Each steering behaviour has a weight, so i can control the contribution of individual steering behaviours to the overall direction a monster takes. E.g. wall avoidance is weighted higher than seeking or separation. This (kinda) guarantees that monsters will prefer overlapping with each other more than tunneling through a wall. | ||
|
||
I tried doing A* for every individual monster, but wasn’t happy with the result. Steering behaviours can’t resolve deadlocks resulting from paths that overlap in space and time, which creates stalemates among monsters. There might still be a way to make this work, however, for the simple dungeon maps the seek behaviour should suffice. | ||
|
||
There’s a nice paper by Valve on how they solved similar problems in Left 4 Dead. It’s a bit overkill, but some principles i could apply to my scenario as well. Haven’t had time to look into it yet, reactive path following looks pretty much what i had before i killed A* path finding for monsters. Thanks to Dave (@redskyforge) for pointing me at the presentation. | ||
|
||
Here’s the obligatory screenshot, green lines show the velocity/direction, red lines show the steering force/acceleration. Blue tiles are the path nodes the hero follows. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<lint> | ||
</lint> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# To enable ProGuard in your project, edit project.properties | ||
# to define the proguard.config property as described in that file. | ||
# | ||
# Add project specific ProGuard rules here. | ||
# By default, the flags in this file are appended to flags specified | ||
# in ${sdk.dir}/tools/proguard/proguard-android.txt | ||
# You can edit the include path and order by changing the ProGuard | ||
# include property in project.properties. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# Add any project specific keep options here: | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# This file is automatically generated by Android Tools. | ||
# Do not modify this file -- YOUR CHANGES WILL BE ERASED! | ||
# | ||
# This file must be checked in Version Control Systems. | ||
# | ||
# To customize properties used by the Ant build system edit | ||
# "ant.properties", and override values to adapt the script to your | ||
# project structure. | ||
# | ||
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): | ||
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt | ||
|
||
# Project target. | ||
target=android-17 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<menu xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<item android:id="@+id/menu_settings" | ||
android:title="@string/menu_settings" | ||
android:orderInCategory="100" | ||
android:showAsAction="never" /> | ||
</menu> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<resources> | ||
|
||
<style name="AppTheme" parent="android:Theme.Holo.Light" /> | ||
|
||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<resources> | ||
|
||
<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar" /> | ||
|
||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<resources> | ||
|
||
<string name="app_name">AndroidBasics</string> | ||
<string name="menu_settings">Settings</string> | ||
<string name="activity_android_basics_starter">Android Basics Starter</string> | ||
<string name="activity_android_test_life_cycle">Life Cycle Test</string> | ||
<string name="activity_android_test_singletouch">Singletouch Test</string> | ||
<string name="activity_android_test_multitouch">Multitouch Test</string> | ||
<string name="activity_android_test_key">Key Test</string> | ||
<string name="activity_android_test_accelerometer">Accelerometer Test</string> | ||
<string name="activity_android_test_assets">Assets Test</string> | ||
<string name="activity_android_test_external_storage">External Storage Test</string> | ||
<string name="activity_android_test_sound_pool">Sound Pool Test</string> | ||
<string name="activity_android_test_media_player">Media Player Test</string> | ||
<string name="activity_android_test_fullscreen">Fullscreen Test</string> | ||
<string name="activity_android_test_render_view">Render View Test</string> | ||
<string name="activity_android_test_shape">Shape Test</string> | ||
<string name="activity_android_test_bitmap">Bitmap Test</string> | ||
<string name="activity_android_test_font">Font Test</string> | ||
<string name="activity_android_test_surface_view">Surface View Test</string> | ||
<string name="activity_android_test_swipe">Swipe Test</string> | ||
|
||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<resources> | ||
|
||
<style name="AppTheme" parent="android:Theme.Light" /> | ||
|
||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package com.example.androidbasics; | ||
|
||
import android.app.ListActivity; | ||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import android.view.Menu; | ||
import android.view.View; | ||
import android.widget.ArrayAdapter; | ||
import android.widget.ListView; | ||
|
||
public class AndroidBasicsStarter extends ListActivity { | ||
|
||
String tests[] = { "LifeCycleTest", | ||
"SingleTouchTest", | ||
"MultiTouchTest", | ||
"KeyTest", | ||
"AccelerometerTest", | ||
"AssetsTest", | ||
"ExternalStorageTest", | ||
"SoundPoolTest", | ||
"MediaPlayerTest", | ||
"FullScreenTest", | ||
"RenderViewTest", | ||
"ShapeTest", | ||
"BitmapTest", | ||
"FontTest", | ||
"SurfaceViewTest", | ||
"SwipeTest"}; | ||
|
||
@Override | ||
public void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setListAdapter( | ||
new ArrayAdapter<String>( | ||
this, | ||
android.R.layout.simple_list_item_1, | ||
tests)); | ||
} | ||
|
||
@Override | ||
public boolean onCreateOptionsMenu(Menu menu) { | ||
getMenuInflater().inflate(R.menu.activity_android_basics_starter, | ||
menu); | ||
return true; | ||
} | ||
|
||
@Override | ||
protected void onListItemClick(ListView list, | ||
View view, | ||
int position, | ||
long id) { | ||
super.onListItemClick(list, view, position, id); | ||
String testName = tests[position]; | ||
try { | ||
Class<?> clazz = Class.forName("com.example.androidbasics.tests." | ||
+ testName); | ||
Intent intent = new Intent(this, clazz); | ||
startActivity(intent); | ||
} | ||
catch (ClassNotFoundException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
} |
Oops, something went wrong.