Добавил вторую главу занимательного программирования
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
|
||||
|
||||
sourceSets.main.java.srcDirs = [ "src/" ]
|
||||
|
||||
eclipse.project.name = appName + "-core"
|
||||
@@ -0,0 +1,61 @@
|
||||
package net.caraus.multilayer;
|
||||
|
||||
import com.badlogic.gdx.ApplicationAdapter;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||
import com.badlogic.gdx.utils.ScreenUtils;
|
||||
|
||||
public class MultiLayer extends ApplicationAdapter {
|
||||
SpriteBatch batch;
|
||||
|
||||
Texture clouds;
|
||||
Texture ground;
|
||||
Texture tree;
|
||||
|
||||
float cloudsPosition = 512.0f;
|
||||
float groundPosition = 0.0f;
|
||||
float treePosition = 0.0f;
|
||||
|
||||
boolean reverseDirection = false;
|
||||
|
||||
@Override
|
||||
public void create () {
|
||||
batch = new SpriteBatch();
|
||||
|
||||
clouds = new Texture("clouds.jpg");
|
||||
ground = new Texture("ground.jpg");
|
||||
tree = new Texture("tree.png");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render () {
|
||||
ScreenUtils.clear(0, 0, 0, 1);
|
||||
batch.begin();
|
||||
batch.draw(ground, 0, groundPosition);
|
||||
batch.draw(clouds, 0, cloudsPosition);
|
||||
batch.draw(tree, 0, treePosition);
|
||||
batch.end();
|
||||
|
||||
if (reverseDirection) {
|
||||
groundPosition += 3.0f;
|
||||
cloudsPosition += 1.0f;
|
||||
treePosition += 4.0f;
|
||||
} else {
|
||||
groundPosition -= 3.0f;
|
||||
cloudsPosition -= 1.0f;
|
||||
treePosition -= 4.0f;
|
||||
}
|
||||
if (cloudsPosition < 360 || cloudsPosition > 512) {
|
||||
reverseDirection = !reverseDirection;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose () {
|
||||
batch.dispose();
|
||||
|
||||
ground.dispose();
|
||||
tree.dispose();
|
||||
clouds.dispose();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user