Skip to content

Commit

Permalink
First commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
tiberiomoliveira committed Dec 31, 2012
0 parents commit 277a8a8
Show file tree
Hide file tree
Showing 48 changed files with 1,347 additions and 0 deletions.
44 changes: 44 additions & 0 deletions .gitignore
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
33 changes: 33 additions & 0 deletions .project
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>
11 changes: 11 additions & 0 deletions .settings/org.eclipse.jdt.core.prefs
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
100 changes: 100 additions & 0 deletions AndroidManifest.xml
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 added assets/fonts/font.ttf
Binary file not shown.
Binary file added assets/pics/bobargb8888.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/pics/bobrgb888.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/pics/down.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/pics/left.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/pics/right.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/pics/up.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/sounds/explosion.ogg
Binary file not shown.
Binary file added assets/sounds/music.ogg
Binary file not shown.
11 changes: 11 additions & 0 deletions assets/texts/text_file.txt
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.
Binary file added ic_launcher-web.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added libs/android-support-v4.jar
Binary file not shown.
3 changes: 3 additions & 0 deletions lint.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<lint>
</lint>
20 changes: 20 additions & 0 deletions proguard-project.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# To enable ProGuard in your project, edit project.properties
# to define the proguard.config property as described in that file.
#
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in ${sdk.dir}/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the ProGuard
# include property in project.properties.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
14 changes: 14 additions & 0 deletions project.properties
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
Binary file added res/drawable-hdpi/ic_action_search.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-hdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-ldpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-mdpi/ic_action_search.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-mdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-xhdpi/ic_action_search.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-xhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions res/menu/activity_android_basics_starter.xml
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>
5 changes: 5 additions & 0 deletions res/values-v11/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<resources>

<style name="AppTheme" parent="android:Theme.Holo.Light" />

</resources>
5 changes: 5 additions & 0 deletions res/values-v14/styles.xml
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>
23 changes: 23 additions & 0 deletions res/values/strings.xml
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>
5 changes: 5 additions & 0 deletions res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<resources>

<style name="AppTheme" parent="android:Theme.Light" />

</resources>
64 changes: 64 additions & 0 deletions src/com/example/androidbasics/AndroidBasicsStarter.java
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();
}
}
}
Loading

0 comments on commit 277a8a8

Please sign in to comment.