Skip to content

Commit

Permalink
First commit, com.kandl.ropgame-desktop.main is the desktop edition.
Browse files Browse the repository at this point in the history
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
Show file tree
Hide file tree
Showing 32 changed files with 367 additions and 0 deletions.
11 changes: 11 additions & 0 deletions rop-game-android/.classpath
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>
2 changes: 2 additions & 0 deletions rop-game-android/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/bin
*.class
33 changes: 33 additions & 0 deletions rop-game-android/.project
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>
4 changes: 4 additions & 0 deletions rop-game-android/.settings/org.eclipse.jdt.core.prefs
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
27 changes: 27 additions & 0 deletions rop-game-android/AndroidManifest.xml
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>
Binary file added rop-game-android/assets/data/libgdx.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions rop-game-android/gen/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/com
Binary file added rop-game-android/libs/android-support-v4.jar
Binary file not shown.
Binary file not shown.
Binary file added rop-game-android/libs/armeabi-v7a/libgdx.so
Binary file not shown.
Binary file added rop-game-android/libs/armeabi/libandroidgl20.so
Binary file not shown.
Binary file added rop-game-android/libs/armeabi/libgdx.so
Binary file not shown.
Binary file not shown.
Binary file added rop-game-android/libs/gdx-backend-android.jar
Binary file not shown.
40 changes: 40 additions & 0 deletions rop-game-android/proguard.cfg
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 *;
}
11 changes: 11 additions & 0 deletions rop-game-android/project.properties
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.
7 changes: 7 additions & 0 deletions rop-game-android/res/layout/main.xml
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>
4 changes: 4 additions & 0 deletions rop-game-android/res/values/strings.xml
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>
21 changes: 21 additions & 0 deletions rop-game-android/src/com/kandl/ropgame/MainActivity.java
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);
}
}
7 changes: 7 additions & 0 deletions rop-game/.classpath
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>
2 changes: 2 additions & 0 deletions rop-game/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/bin
*.class
17 changes: 17 additions & 0 deletions rop-game/.project
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>
11 changes: 11 additions & 0 deletions rop-game/.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
Binary file added rop-game/libs/gdx-sources.jar
Binary file not shown.
Binary file added rop-game/libs/gdx.jar
Binary file not shown.
5 changes: 5 additions & 0 deletions rop-game/src/RopGame.gwt.xml
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>
126 changes: 126 additions & 0 deletions rop-game/src/com/kandl/ropgame/GameScreen.java
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();
}

}
20 changes: 20 additions & 0 deletions rop-game/src/com/kandl/ropgame/RopGame.java
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();
}
}
18 changes: 18 additions & 0 deletions rop-game/src/com/kandl/ropgame/ui/UITable.java
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
}

}

0 comments on commit 6575788

Please sign in to comment.