Добавил вторую главу занимательного программирования

This commit is contained in:
2025-12-15 00:36:33 +01:00
parent c1147629f7
commit 2878f1e34c
128 changed files with 6744 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
sourceSets.main.java.srcDirs = [ "src/" ]
eclipse.project.name = appName + "-core"

View File

@@ -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();
}
}