package ru.samsung.gamestudiovtim2026; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.math.Rectangle; public class Player { private Texture texture; private Rectangle bounds; private int currentLine; // 0 - верхняя, 1 - средняя, 2 - нижняя private float[] linePositions = {400, 240, 80}; // Y-позиции линий private boolean isJumping; private float jumpTime; public Player() { texture = new Texture("smile.png"); // Игрок фиксирован по X (100px от левого края) bounds = new Rectangle(100, linePositions[1], 60, 60); currentLine = 1; // Начинаем со средней линии isJumping = false; } public void update(float deltaTime) { // Игрок НЕ движется по X, только плавно перемещается по Y между линиями // Плавное перемещение между линиями float targetY = linePositions[currentLine]; if (Math.abs(bounds.y - targetY) > 1) { bounds.y += (targetY - bounds.y) * 5 * deltaTime; } // Обработка прыжка if (isJumping) { jumpTime += deltaTime; if (jumpTime > 0.3f) { // Длительность прыжка isJumping = false; jumpTime = 0; } } } public void moveUp() { if (currentLine > 0) { currentLine--; } } public void moveDown() { if (currentLine < 2) { currentLine++; } } public void jump() { if (!isJumping) { isJumping = true; } } public void render(SpriteBatch batch) { float drawY = bounds.y; if (isJumping) { drawY += 50 * (float)Math.sin(jumpTime * 10); } batch.draw(texture, bounds.x, drawY, bounds.width, bounds.height); } public Rectangle getBounds() { return bounds; } public int getCurrentLine() { return currentLine; } public void dispose() { texture.dispose(); } }