From 1953e95ba22aeb568992aeadd6b1e41ea9e97676 Mon Sep 17 00:00:00 2001 From: James <150948866+jameslaight@users.noreply.github.com> Date: Sun, 21 Apr 2024 16:47:31 +0100 Subject: [PATCH] adding fallingpip --- .../com/monjaro/gamejam/main/FallingPip.java | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 core/src/com/monjaro/gamejam/main/FallingPip.java diff --git a/core/src/com/monjaro/gamejam/main/FallingPip.java b/core/src/com/monjaro/gamejam/main/FallingPip.java new file mode 100644 index 0000000..2b4a8f2 --- /dev/null +++ b/core/src/com/monjaro/gamejam/main/FallingPip.java @@ -0,0 +1,34 @@ +package com.monjaro.gamejam.main; + +import com.badlogic.gdx.graphics.g2d.SpriteBatch; +import com.badlogic.gdx.math.Vector2; + +import java.util.Random; + +public class FallingPip extends Actor { + + private final Transform transform; + private final Vector2 velocity; + private final float rotationalVelocity; + + public FallingPip(Transform transform) { + Random random = new Random(); + + this.transform = transform; + velocity = new Vector2(-1 + random.nextFloat() * 2, random.nextFloat() * 2); + rotationalVelocity = 40 * (-0.5f + random.nextFloat()); + } + + @Override + public void tick() { + transform.x += velocity.x; + transform.y += velocity.y; + transform.rotation += rotationalVelocity; + } + + @Override + public void render(SpriteBatch batch) { + + } + +}