-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First commit, com.kandl.ropgame-desktop.main is the desktop edition.
Currently in the very first stages, just getting used to libgdx. Planning on using scene2d for the most part, may extend the class to enable MVC if it's too slow just having everything act. Signed-off-by: Ken Hoover <[email protected]>
- Loading branch information
Ken Hoover
committed
Jun 7, 2013
0 parents
commit 6575788
Showing
32 changed files
with
367 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,11 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry kind="src" path="gen"/> | ||
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/rop-game"/> | ||
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/> | ||
<classpathentry exported="true" kind="lib" path="/rop-game/libs/gdx.jar" sourcepath="/rop-game/libs/gdx-sources.jar"/> | ||
<classpathentry exported="true" kind="lib" path="libs/gdx-backend-android.jar" sourcepath="libs/gdx-backend-android-sources.jar"/> | ||
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/> | ||
<classpathentry kind="output" path="bin/classes"/> | ||
</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,2 @@ | ||
/bin | ||
*.class |
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>rop-game-android</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,4 @@ | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 | ||
org.eclipse.jdt.core.compiler.compliance=1.6 | ||
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,27 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.kandl.ropgame" | ||
android:versionCode="1" | ||
android:versionName="1.0" > | ||
|
||
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17" /> | ||
<uses-permission android:name="android.permission.VIBRATE"/> | ||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> | ||
|
||
<application | ||
android:icon="@drawable/ic_launcher" | ||
android:label="@string/app_name" | ||
android:allowBackup="true"> | ||
<activity | ||
android:name=".MainActivity" | ||
android:label="@string/app_name" | ||
android:screenOrientation="landscape" | ||
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
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 @@ | ||
/com |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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,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 *; | ||
} |
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, | ||
# "ant.properties", and override values to adapt the script to your | ||
# project structure. | ||
|
||
# Project target. | ||
target=android-14 |
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,7 @@ | ||
<?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" > | ||
|
||
</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,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<string name="app_name">My LibGDX Game</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,21 @@ | ||
package com.kandl.ropgame; | ||
|
||
import android.os.Bundle; | ||
|
||
import com.badlogic.gdx.backends.android.AndroidApplication; | ||
import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration; | ||
|
||
public class MainActivity extends AndroidApplication { | ||
@Override | ||
public void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
|
||
AndroidApplicationConfiguration cfg = new AndroidApplicationConfiguration(); | ||
cfg.useAccelerometer = false; | ||
cfg.hideStatusBar = true; | ||
cfg.useCompass = false; | ||
cfg.useGL20 = false; | ||
|
||
initialize(new RopGame(), cfg); | ||
} | ||
} |
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="output" path="bin"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> | ||
<classpathentry kind="lib" exported="true" path="libs/gdx.jar" sourcepath="libs/gdx-sources.jar"/> | ||
</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,2 @@ | ||
/bin | ||
*.class |
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>rop-game</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> |
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 |
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,5 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit trunk//EN" "http://google-web-toolkit.googlecode.com/svn/trunk/distro-source/core/src/gwt-module.dtd"> | ||
<module> | ||
<source path="com/kandl/ropgame" /> | ||
</module> |
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,126 @@ | ||
package com.kandl.ropgame; | ||
|
||
/* | ||
* HOW libgdx VIEWPORTS WORK, AND HOW THE SCENE DOES THEM: | ||
* Ok, this is so I can remember what the hell I was doing in the future. | ||
* The Viewport is the "size" of any particular part of the stage being rendered, in terms of the stage. | ||
* - ie. if the viewport is 1x1, then the things created in the stage get a percentage of the final screen = size*100. | ||
* What the camera then does is it scales the whole thing to match the device. | ||
* So, how does this impact my UI? Welp, glad you asked. See, what I -WANT- to happen is this: | ||
* - If 1024x600 (native), then all's well, no scaling/stretching needed. | ||
* - If 1280x800 (10.1"), then the right column should scale, and the left column should scale THEN stretch. | ||
* - Only one actual IMAGE will have to stretch, and it'll be defined as .9, all good; the other is just in a location in a cell, | ||
* scale automagically and be reflowed. | ||
* Where's the problem? Don't want the right column to stretch, but I want the left column to. The problem, then, is this; how do I | ||
* define the viewport such that it takes up the full screen, BUT only one column fucks up when that happens. In essence, tell the UI "world" | ||
* to shrink when I upscale. (narrow). | ||
* | ||
* Possible solution: Viewport goes to either 1280x800 or 1024x600, depending on aspect ratio of resize; 1024/600 > 1.7, so, should be safe | ||
* to use 1.7 as the delimiter for 1.6 or not. What should happen, then, is the UI should tell it's table to reflow itself, using viewport | ||
* size (ie. table resize, validate(), I think), and all to-do is replace right column width with 280, instead of 210. Left is still fill, | ||
* so when reflow happens, it'll stretch to take up space. Similarly, bottom row...Oh. Well then...Ah, fuck it, just run with it for now. | ||
*/ | ||
|
||
import com.badlogic.gdx.Gdx; | ||
import com.badlogic.gdx.Screen; | ||
import com.badlogic.gdx.graphics.*; | ||
import com.badlogic.gdx.graphics.g2d.Sprite; | ||
import com.badlogic.gdx.scenes.scene2d.*; | ||
import com.badlogic.gdx.scenes.scene2d.ui.*; | ||
import com.badlogic.gdx.scenes.scene2d.utils.*; | ||
import com.badlogic.gdx.utils.Scaling; | ||
import com.kandl.ropgame.ui.UITable; | ||
|
||
public class GameScreen implements Screen{ | ||
private final Stage UILayer; | ||
private final UITable UItable; | ||
private final Stage GameLayer; | ||
private Image UIImage; | ||
|
||
/* NOTE: | ||
* Figure out how viewport should be set for UI layer (ie. scaling) | ||
* - Solved, have two Stages; one for UILayer, the other for game world. | ||
* Figure out how to swap between scenes | ||
* Formalize MVC within the context of the Actor framework (saves me time) | ||
*/ | ||
|
||
public GameScreen() { | ||
UILayer = new Stage(1024, 600, true); | ||
UItable = new UITable(); | ||
UILayer.addActor(UItable); | ||
GameLayer = new Stage(1024, 600, true, UILayer.getSpriteBatch()); | ||
Pixmap GameTest = new Pixmap(1024, 1024, Pixmap.Format.RGBA8888); | ||
GameTest.setColor(Color.RED); | ||
GameTest.fillRectangle(0, 212, 1024, 600); | ||
GameLayer.addActor(new Image(new SpriteDrawable(new Sprite(new Texture(GameTest), 0, 212, 1024, 600)), Scaling.fill)); | ||
GameTest.dispose(); | ||
} | ||
|
||
|
||
@Override | ||
public void render(float delta) { | ||
// TODO Auto-generated method stub | ||
GameLayer.act(delta); | ||
UILayer.act(delta); | ||
Gdx.gl.glClearColor(0, 0, 0, 1); | ||
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT); | ||
GameLayer.draw(); | ||
UILayer.draw(); | ||
} | ||
|
||
@Override | ||
public void resize(int width, int height) { | ||
// TODO Auto-generated method stub | ||
final int UIlength = (float) width / (float) height < 1.7 ? 1280 : 1024; | ||
final int UIheight = UIlength == 1280 ? 800 : 600; | ||
if (UIheight != UILayer.getHeight()) { | ||
UILayer.getRoot().removeActor(UIImage); | ||
Pixmap UItest = new Pixmap(2048, 2048, Pixmap.Format.RGBA8888); | ||
UItest.setColor(Color.WHITE); | ||
final int padX = (2048 - UIlength)/2; | ||
final int padY = (2048 - UIheight)/2; | ||
UItest.fillRectangle(padX, padY, UIlength, UIheight); | ||
UItest.setColor(Color.CLEAR); | ||
Pixmap.setBlending(Pixmap.Blending.None); | ||
UItest.fillRectangle(padX+100, padY+100, UIlength - 200, UIheight - 200); | ||
Pixmap.setBlending(Pixmap.Blending.SourceOver); | ||
UIImage = new Image(new SpriteDrawable(new Sprite(new Texture(UItest), padX, padY, UIlength, UIheight)), Scaling.fill); | ||
UItest.dispose(); | ||
UILayer.addActor(UIImage); | ||
} | ||
System.out.println("UI: " + UIlength); | ||
UILayer.setViewport(UIlength, UIheight, true); | ||
final int Gamelength = UIlength == 1280 ? 960 : 1024; | ||
GameLayer.setViewport(Gamelength, 600, true); | ||
} | ||
|
||
@Override | ||
public void show() { | ||
// TODO Auto-generated method stub | ||
|
||
} | ||
|
||
@Override | ||
public void hide() { | ||
// TODO Auto-generated method stub | ||
|
||
} | ||
|
||
@Override | ||
public void pause() { | ||
// TODO Gets called when this goes to background. So, what? | ||
} | ||
|
||
@Override | ||
public void resume() { | ||
// TODO add call to showPauseOverlay | ||
|
||
} | ||
|
||
@Override | ||
public void dispose() { | ||
GameLayer.dispose(); | ||
UILayer.dispose(); | ||
} | ||
|
||
} |
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 @@ | ||
package com.kandl.ropgame; | ||
|
||
import com.badlogic.gdx.Game; | ||
|
||
public class RopGame extends Game { | ||
private GameScreen gameScreen; | ||
public static final int WIDTH = 1024; | ||
public static final int HEIGHT = 600; | ||
|
||
@Override | ||
public void create() { | ||
gameScreen = new GameScreen(); | ||
setScreen(gameScreen); | ||
} | ||
|
||
@Override | ||
public void dispose() { | ||
gameScreen.dispose(); | ||
} | ||
} |
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 @@ | ||
package com.kandl.ropgame.ui; | ||
|
||
import com.badlogic.gdx.scenes.scene2d.ui.Skin; | ||
import com.badlogic.gdx.scenes.scene2d.ui.Table; | ||
|
||
public class UITable extends Table { | ||
|
||
public UITable() { | ||
// TODO Auto-generated constructor stub | ||
super(); | ||
} | ||
|
||
public UITable(Skin skin) { | ||
super(skin); | ||
// TODO Auto-generated constructor stub | ||
} | ||
|
||
} |