Skip to content

Commit

Permalink
Add interfaces for framework
Browse files Browse the repository at this point in the history
  • Loading branch information
Syver Enstad committed Feb 16, 2012
1 parent af5769b commit fa3d513
Show file tree
Hide file tree
Showing 27 changed files with 487 additions and 0 deletions.
8 changes: 8 additions & 0 deletions GameFramework/.classpath
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>
33 changes: 33 additions & 0 deletions GameFramework/.project
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>GameFramework</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>
23 changes: 23 additions & 0 deletions GameFramework/AndroidManifest.xml
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.androidgames.framework"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk android:minSdkVersion="3" />

<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".GameFrameworkActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
40 changes: 40 additions & 0 deletions GameFramework/proguard.cfg
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,40 @@
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*

-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class com.android.vending.licensing.ILicensingService

-keepclasseswithmembernames class * {
native <methods>;
}

-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
}

-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}

-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}

-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}

-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
11 changes: 11 additions & 0 deletions GameFramework/project.properties
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,11 @@
# 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 use,
# "ant.properties", and override values to adapt the script to your
# project structure.

# Project target.
target=android-3
Binary file added GameFramework/res/drawable/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.
12 changes: 12 additions & 0 deletions GameFramework/res/layout/main.xml
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />

</LinearLayout>
7 changes: 7 additions & 0 deletions GameFramework/res/values/strings.xml
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<string name="hello">Hello World, GameFrameworkActivity!</string>
<string name="app_name">GameFramework</string>

</resources>
7 changes: 7 additions & 0 deletions GameFramework/src/com/androidgames/framework/Audio.java
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.androidgames.framework;

public interface Audio {
public Music newMusic(String filename);

public Sound newSound(String filename);
}
13 changes: 13 additions & 0 deletions GameFramework/src/com/androidgames/framework/FileIO.java
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.androidgames.framework;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

public interface FileIO {
public InputStream readAsset(String fileName) throws IOException;

public InputStream readFile(String fileName) throws IOException;

public OutputStream writeFile(String fileName) throws IOException;
}
17 changes: 17 additions & 0 deletions GameFramework/src/com/androidgames/framework/Game.java
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.androidgames.framework;

public interface Game {
public Input getInput();

public FileIO getFileIO();

public Graphics getGraphics();

public Audio getAudio();

public void setScreen(Screen screen);

public Screen getCurrentScreen();

public Screen getStartScreen();
}
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.androidgames.framework;

import android.app.Activity;
import android.os.Bundle;

public class GameFrameworkActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
26 changes: 26 additions & 0 deletions GameFramework/src/com/androidgames/framework/Graphics.java
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.androidgames.framework;

public interface Graphics {
public static enum PixmapFormat {
ARGB8888, ARGB4444, RGB565
}

public Pixmap newPixmap(String fileName, PixmapFormat format);

public void clear(int color);

public void drawPixel(int x, int y, int color);

public void drawLine(int x, int y, int x2, int y2, int color);

public void drawRect(int x, int y, int width, int height, int color);

public void drawPixmap(Pixmap pixmap, int x, int y, int srcX, int srcY,
int srcWidth, int srcHeight);

public void drawPixmap(Pixmap pixmap, int x, int y);

public int getWidth();

public int getHeight();
}
70 changes: 70 additions & 0 deletions GameFramework/src/com/androidgames/framework/Input.java
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,70 @@
package com.androidgames.framework;

import java.util.List;

public interface Input {
public static class KeyEvent {
public static final int KEY_DOWN = 0;
public static final int KEY_UP = 1;

public int type;
public int keyCode;
public char keyChar;

public String toString() {
StringBuilder builder = new StringBuilder();
if (type == KEY_DOWN)
builder.append("key down, ");
else
builder.append("key up, ");
builder.append(keyCode);
builder.append(",");
builder.append(keyChar);
return builder.toString();
}
}

public static class TouchEvent {
public static final int TOUCH_DOWN = 0;
public static final int TOUCH_UP = 1;
public static final int TOUCH_DRAGGED = 2;

public int type;
public int x, y;
public int pointer;

public String toString() {
StringBuilder builder = new StringBuilder();
if (type == TOUCH_DOWN)
builder.append("touch down, ");
else if (type == TOUCH_DRAGGED)
builder.append("touch dragged, ");
else
builder.append("touch up, ");
builder.append(pointer);
builder.append(",");
builder.append(x);
builder.append(",");
builder.append(y);
return builder.toString();
}
}

public boolean isKeyPressed(int keyCode);

public boolean isTouchDown(int pointer);

public int getTouchX(int pointer);

public int getTouchY(int pointer);

public float getAccelX();

public float getAccelY();

public float getAccelZ();

public List<KeyEvent> getKeyEvents();

public List<TouchEvent> getTouchEvents();
}
21 changes: 21 additions & 0 deletions GameFramework/src/com/androidgames/framework/Music.java
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.androidgames.framework;

public interface Music {
public void play();

public void stop();

public void pause();

public void setLooping(boolean looping);

public void setVolume(float volume);

public boolean isPlaying();

public boolean isStopped();

public boolean isLooping();

public void dispose();
}
13 changes: 13 additions & 0 deletions GameFramework/src/com/androidgames/framework/Pixmap.java
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.androidgames.framework;

import com.androidgames.framework.Graphics.PixmapFormat;

public interface Pixmap {
public int getWidth();

public int getHeight();

public PixmapFormat getFormat();

public void dispose();
}
19 changes: 19 additions & 0 deletions GameFramework/src/com/androidgames/framework/Screen.java
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.androidgames.framework;

public abstract class Screen {
protected final Game game;

public Screen(Game game) {
this.game = game;
}

public abstract void update(float deltaTime);

public abstract void present(float deltaTime);

public abstract void pause();

public abstract void resume();

public abstract void dispose();
}
7 changes: 7 additions & 0 deletions GameFramework/src/com/androidgames/framework/Sound.java
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.androidgames.framework;

public interface Sound {
public void play(float volume);

public void dispose();
}
15 changes: 15 additions & 0 deletions GameFramework/src/com/androidgames/framework/TouchHandler.java
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.androidgames.framework;

import java.util.List;

import com.androidgames.framework.Input.TouchEvent;

import android.view.View.OnTouchListener;

public interface TouchHandler extends OnTouchListener {
public boolean isTouchDown(int pointer);
public int getTouchX(int pointer);
public int getTouchY(int pointer);
public List<TouchEvent> getTouchEvents();

}
9 changes: 9 additions & 0 deletions GameFrameworkTest/.classpath
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry combineaccessrules="false" kind="src" path="/GameFramework"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>
Loading

0 comments on commit fa3d513

Please sign in to comment.