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
Apress
committed
Oct 16, 2016
0 parents
commit 3363fe4
Showing
580 changed files
with
27,601 additions
and
0 deletions.
There are no files selected for viewing
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,27 @@ | ||
Freeware License, some rights reserved | ||
|
||
Copyright (c) 2011 Mario Zechner and Robert Green | ||
|
||
Permission is hereby granted, free of charge, to anyone obtaining a copy | ||
of this software and associated documentation files (the "Software"), | ||
to work with the Software within the limits of freeware distribution and fair use. | ||
This includes the rights to use, copy, and modify the Software for personal use. | ||
Users are also allowed and encouraged to submit corrections and modifications | ||
to the Software for the benefit of other users. | ||
|
||
It is not allowed to reuse, modify, or redistribute the Software for | ||
commercial use in any way, or for a user�s educational materials such as books | ||
or blog articles without prior permission from the copyright holder. | ||
|
||
The above copyright notice and this permission notice need to be included | ||
in all copies or substantial portions of the software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS OR APRESS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
|
||
|
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,15 @@ | ||
#Apress Source Code | ||
|
||
This repository accompanies [*Beginning Android 4 Games Development*](http://www.apress.com/9781430239871) by Mario Zechner and Robert Green (Apress, 2011). | ||
|
||
![Cover image](9781430239871.jpg) | ||
|
||
Download the files as a zip using the green button, or clone the repository to your machine using Git. | ||
|
||
##Releases | ||
|
||
Release v1.0 corresponds to the code in the published book, without corrections or updates. | ||
|
||
##Contributions | ||
|
||
See the file Contributing.md for more information on how you can contribute to this repository. |
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,7 @@ | ||
<?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="output" path="bin"/> | ||
</classpath> |
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>ch02-hello world</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,18 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.helloworld" | ||
android:versionCode="1" | ||
android:versionName="1.0"> | ||
<application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="true"> | ||
<activity android:name=".HelloWorldActivity" | ||
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> | ||
<uses-sdk android:minSdkVersion="3" /> | ||
|
||
</manifest> |
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 @@ | ||
# 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, | ||
# "build.properties", and override values to adapt the script to your | ||
# project structure. | ||
|
||
# Project target. | ||
target=android-12 |
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,12 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:orientation="vertical" | ||
android:layout_width="fill_parent" | ||
android:layout_height="fill_parent" | ||
> | ||
<TextView | ||
android:layout_width="fill_parent" | ||
android:layout_height="wrap_content" | ||
android:text="@string/hello" | ||
/> | ||
</LinearLayout> |
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 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<string name="hello">Hello World, HelloWorldActivity!</string> | ||
<string name="app_name">Hello World</string> | ||
</resources> |
26 changes: 26 additions & 0 deletions
26
ch02-hello world/src/com/helloworld/HelloWorldActivity.java
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,26 @@ | ||
package com.helloworld; | ||
|
||
import android.app.Activity; | ||
import android.os.Bundle; | ||
import android.view.View; | ||
import android.widget.Button; | ||
|
||
public class HelloWorldActivity extends Activity | ||
implements View.OnClickListener { | ||
Button button; | ||
int touchCount; | ||
|
||
@Override | ||
public void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
button = new Button(this); | ||
button.setText( "Touch me!" ); | ||
button.setOnClickListener(this); | ||
setContentView(button); | ||
} | ||
|
||
public void onClick(View v) { | ||
touchCount++; | ||
button.setText("Touched me "+touchCount+" time(s)"); | ||
} | ||
} |
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 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> | ||
<classpathentry kind="output" path="bin"/> | ||
</classpath> |
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,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>ch03-game-framework</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
</natures> | ||
</projectDescription> |
7 changes: 7 additions & 0 deletions
7
ch03-game-framework/src/com/badlogic/androidgames/framework/Audio.java
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,7 @@ | ||
package com.badlogic.androidgames.framework; | ||
|
||
public interface Audio { | ||
public Music newMusic(String filename); | ||
|
||
public Sound newSound(String filename); | ||
} |
13 changes: 13 additions & 0 deletions
13
ch03-game-framework/src/com/badlogic/androidgames/framework/FileIO.java
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,13 @@ | ||
package com.badlogic.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
17
ch03-game-framework/src/com/badlogic/androidgames/framework/Game.java
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,17 @@ | ||
package com.badlogic.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(); | ||
} |
26 changes: 26 additions & 0 deletions
26
ch03-game-framework/src/com/badlogic/androidgames/framework/Graphics.java
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,26 @@ | ||
package com.badlogic.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
70
ch03-game-framework/src/com/badlogic/androidgames/framework/Input.java
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,70 @@ | ||
package com.badlogic.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
21
ch03-game-framework/src/com/badlogic/androidgames/framework/Music.java
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,21 @@ | ||
package com.badlogic.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
13
ch03-game-framework/src/com/badlogic/androidgames/framework/Pixmap.java
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,13 @@ | ||
package com.badlogic.androidgames.framework; | ||
|
||
import com.badlogic.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
19
ch03-game-framework/src/com/badlogic/androidgames/framework/Screen.java
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,19 @@ | ||
package com.badlogic.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
7
ch03-game-framework/src/com/badlogic/androidgames/framework/Sound.java
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,7 @@ | ||
package com.badlogic.androidgames.framework; | ||
|
||
public interface Sound { | ||
public void play(float volume); | ||
|
||
public void dispose(); | ||
} |
Oops, something went wrong.