Skip to content

Commit

Permalink
Part 2 of the tutorial series
Browse files Browse the repository at this point in the history
 * Changed the name from Nemo.kt to Game.kt
 * Added image asset (nemo_01.png)
 * Created Nemo data class
  • Loading branch information
Impaler committed Jan 28, 2016
1 parent a45a662 commit fdd86b2
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 10 deletions.
Binary file added android/assets/images/nemo_01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions android/src/net/obviam/nemo/android/AndroidLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

import com.badlogic.gdx.backends.android.AndroidApplication;
import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;
import net.obviam.nemo.Nemo;
import net.obviam.nemo.Game;

public class AndroidLauncher extends AndroidApplication {
@Override
protected void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
initialize(new Nemo(), config);
initialize(new Game(), config);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,30 @@ import com.badlogic.gdx.Gdx
import com.badlogic.gdx.graphics.GL20
import com.badlogic.gdx.graphics.Texture
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.badlogic.gdx.math.Vector2

class Nemo : ApplicationAdapter() {
class Game : ApplicationAdapter() {
internal lateinit var batch: SpriteBatch
internal lateinit var img: Texture
internal lateinit var nemo: Nemo

override fun create() {
batch = SpriteBatch()
img = Texture("badlogic.jpg")
// Load Nemo's texture
img = Texture("images/nemo_01.png")
nemo = Nemo()
}

override fun render() {
Gdx.gl.glClearColor(1f, 0f, 0f, 1f)
// render the screen black
Gdx.gl.glClearColor(0f, 0f, 0f, 1f)
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT)
batch.begin()
batch.draw(img, 0f, 0f)
// render the texture at Nemo's position
batch.draw(img, nemo.position.x, nemo.position.y)
batch.end()
}

/* Declare the Nemo data class */
data class Nemo(val position: Vector2 = Vector2(0f, 0f))
}
4 changes: 2 additions & 2 deletions desktop/src/net/obviam/nemo/desktop/DesktopLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
import net.obviam.nemo.Nemo;
import net.obviam.nemo.Game;

public class DesktopLauncher {
public static void main (String[] arg) {
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
new LwjglApplication(new Nemo(), config);
new LwjglApplication(new Game(), config);
}
}
3 changes: 1 addition & 2 deletions ios/src/net/obviam/nemo/IOSLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@

import com.badlogic.gdx.backends.iosrobovm.IOSApplication;
import com.badlogic.gdx.backends.iosrobovm.IOSApplicationConfiguration;
import net.obviam.nemo.Nemo;

public class IOSLauncher extends IOSApplication.Delegate {
@Override
protected IOSApplication createApplication() {
IOSApplicationConfiguration config = new IOSApplicationConfiguration();
return new IOSApplication(new Nemo(), config);
return new IOSApplication(new Game(), config);
}

public static void main(String[] argv) {
Expand Down

0 comments on commit fdd86b2

Please sign in to comment.