Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package io.github.supplied;
- import com.badlogic.gdx.Application;
- import com.badlogic.gdx.ApplicationAdapter;
- import com.badlogic.gdx.Gdx;
- import com.badlogic.gdx.Input;
- import com.badlogic.gdx.InputAdapter;
- import com.badlogic.gdx.assets.AssetManager;
- import com.badlogic.gdx.audio.Music;
- import com.badlogic.gdx.audio.Sound;
- import com.badlogic.gdx.graphics.Color;
- import com.badlogic.gdx.graphics.PerspectiveCamera;
- import com.badlogic.gdx.graphics.Texture;
- import com.badlogic.gdx.graphics.g2d.SpriteBatch;
- import com.badlogic.gdx.graphics.g3d.Environment;
- import com.badlogic.gdx.graphics.g3d.Material;
- import com.badlogic.gdx.graphics.g3d.Model;
- import com.badlogic.gdx.graphics.g3d.ModelBatch;
- import com.badlogic.gdx.graphics.g3d.ModelInstance;
- import com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute;
- import com.badlogic.gdx.graphics.g3d.environment.DirectionalLight;
- import com.badlogic.gdx.graphics.g3d.utils.ModelBuilder;
- import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
- import com.badlogic.gdx.math.Matrix4;
- import com.badlogic.gdx.math.Vector3;
- import com.badlogic.gdx.physics.bullet.Bullet;
- import com.badlogic.gdx.physics.bullet.collision.ContactCallbackEvent;
- import com.badlogic.gdx.physics.bullet.collision.btBoxShape;
- import com.badlogic.gdx.physics.bullet.collision.btCollisionConfiguration;
- import com.badlogic.gdx.physics.bullet.collision.btCollisionDispatcher;
- import com.badlogic.gdx.physics.bullet.collision.btCollisionShape;
- import com.badlogic.gdx.physics.bullet.collision.btDbvtBroadphase;
- import com.badlogic.gdx.physics.bullet.collision.btDefaultCollisionConfiguration;
- import com.badlogic.gdx.physics.bullet.collision.btDispatcher;
- import com.badlogic.gdx.physics.bullet.dynamics.btDiscreteDynamicsWorld;
- import com.badlogic.gdx.physics.bullet.dynamics.btRigidBody;
- import com.badlogic.gdx.physics.bullet.linearmath.btDefaultMotionState;
- import com.badlogic.gdx.physics.bullet.linearmath.btMotionState;
- import java.math.BigInteger;
- import java.nio.charset.StandardCharsets;
- import java.security.MessageDigest;
- import java.security.NoSuchAlgorithmException;
- import java.util.ArrayList;
- import java.util.List;
- import java.util.Random;
- /* loaded from: classes3.dex */
- public class Main extends ApplicationAdapter {
- private AssetManager assetManager;
- public ModelInstance backWallInstance;
- public Model backWallModel;
- private Music backgroundMusic;
- private btDbvtBroadphase broadphase;
- public PerspectiveCamera cam;
- private btCollisionConfiguration collisionConfig;
- private btDispatcher dispatcher;
- private btDiscreteDynamicsWorld dynamicsWorld;
- public Environment environment;
- public ModelInstance floorInstance;
- public Model floorModel;
- public ModelInstance frontWallInstance;
- public Model frontWallModel;
- public String hash;
- private Texture jumpscareImage;
- private Sound jumpscareSound;
- public ModelInstance leftWallInstance;
- public Model leftWallModel;
- public MessageDigest md;
- public ModelBatch modelBatch;
- private btRigidBody playerBody;
- public ModelInstance playerInstance;
- public Model playerModel;
- private btCollisionShape playerShape;
- public Vector3 position;
- public ModelInstance rightWallInstance;
- public Model rightWallModel;
- private Sound scareSound;
- private ShapeRenderer shapeRenderer;
- private SpriteBatch spriteBatch;
- public Model wallModel;
- Random rand = new Random();
- public int state = this.rand.nextInt() % 256;
- private float jumpscareTimer = 0.0f;
- public float JUMPSCARE_INTERVAL = (this.rand.nextFloat() * 10.0f) + 10.0f;
- public final float SCARE_INTERVAL = (this.rand.nextFloat() * 7.0f) + 3.0f;
- private boolean jumpscareTriggered = false;
- private boolean scareTriggered = false;
- private List<Model> Models = new ArrayList();
- public List<int[]> offsets = new ArrayList();
- public List<int[]> repeatedList = new ArrayList();
- public List<Vector3> positions = new ArrayList();
- private List<ModelInstance> ModelInstances = new ArrayList();
- private float movementSpeed = 900.0f;
- private List<btRigidBody> environmentBodies = new ArrayList();
- private List<ModelInstance> modelInstances = new ArrayList<>();
- private int selectedModelIndex = 0;
- @Override // com.badlogic.gdx.ApplicationAdapter, com.badlogic.gdx.ApplicationListener
- public void create() {
- Bullet.init();
- this.assetManager = new AssetManager();
- this.spriteBatch = new SpriteBatch();
- this.jumpscareImage = new Texture("jumpscare.jpeg");
- this.jumpscareSound = Gdx.audio.newSound(Gdx.files.internal("jumpscare.wav"));
- this.scareSound = Gdx.audio.newSound(Gdx.files.internal("jumpscare.mp3"));
- this.backgroundMusic = Gdx.audio.newMusic(Gdx.files.internal("background.wav"));
- this.backgroundMusic.setLooping(true);
- this.backgroundMusic.setVolume(0.5f);
- this.backgroundMusic.play();
- this.environment = new Environment();
- this.environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.1f, 0.1f, 0.15f, 1.0f));
- this.environment.add(new DirectionalLight().set(0.3f, 0.3f, 0.5f, -1.0f, -0.5f, -0.2f));
- // Set ambient light to white and brighter intensity
- this.environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 1.0f, 1.0f, 1.0f, 1.0f));
- Gdx.graphics.setFullscreenMode( Gdx.graphics.getDisplayMode() );
- // Add a white directional light
- this.environment.add(new DirectionalLight().set(1.0f, 1.0f, 1.0f, -1.0f, -0.5f, -0.2f));
- this.cam = new PerspectiveCamera(75.0f, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
- this.cam.position.set(0.0f, 5.0f, 0.0f);
- this.cam.far = 1000000.0f;
- this.cam.update();
- this.modelBatch = new ModelBatch();
- this.shapeRenderer = new ShapeRenderer();
- loadModels();
- setupPhysicsWorld();
- }
- private void loadModels() {
- for (char i = 0; i <= 187; i = (char) (i + 1)) {
- String modelName = Integer.toString(i) + ".g3db";
- this.assetManager.load(modelName, Model.class);
- }
- this.assetManager.finishLoading();
- float xOffset = 0.0f;
- for (char i2 = 0; i2 <= 187; i2 = (char) (i2 + 1)) {
- String modelName2 = Integer.toString(i2) + ".g3db";
- Model model = (Model) this.assetManager.get(modelName2, Model.class);
- ModelInstance instance = new ModelInstance(model);
- instance.transform.setToTranslation(xOffset, 0.0f, 0.0f);
- this.Models.add(model);
- this.ModelInstances.add(instance);
- xOffset += 100.0f;
- }
- this.ModelInstances.get(0).transform.setToTranslation(29455.0f, -800.0f, 44968.0f);
- this.ModelInstances.get(1).transform.setToTranslation(50415.0f, 350.0f, -27154.0f);
- this.ModelInstances.get(2).transform.setToTranslation(20321.0f, 380.0f, -23095.0f);
- this.ModelInstances.get(3).transform.setToTranslation(16609.0f, -810.0f, 14772.0f);
- this.ModelInstances.get(4).transform.setToTranslation(31910.0f, -910.0f, 25007.0f);
- this.ModelInstances.get(5).transform.setToTranslation(47547.0f, -940.0f, -31146.0f);
- this.ModelInstances.get(6).transform.setToTranslation(55754.0f, 470.0f, 27242.0f);
- this.ModelInstances.get(7).transform.setToTranslation(54879.0f, -770.0f, -778.0f);
- this.ModelInstances.get(8).transform.setToTranslation(29055.0f, -900.0f, 15768.0f);
- this.ModelInstances.get(9).transform.setToTranslation(51215.0f, 940.0f, -31654.0f);
- this.ModelInstances.get(10).transform.setToTranslation(23021.0f, -820.0f, 2905.0f);
- this.ModelInstances.get(11).transform.setToTranslation(14609.0f, -810.0f, 14842.0f);
- this.ModelInstances.get(12).transform.setToTranslation(33110.0f, -920.0f, 51927.0f);
- this.ModelInstances.get(13).transform.setToTranslation(48147.0f, -980.0f, -34146.0f);
- this.ModelInstances.get(14).transform.setToTranslation(56354.0f, 420.0f, 24742.0f);
- this.ModelInstances.get(15).transform.setToTranslation(56379.0f, -810.0f, 27942.0f);
- this.ModelInstances.get(16).transform.setToTranslation(29555.0f, 450.0f, 13768.0f);
- this.ModelInstances.get(17).transform.setToTranslation(50915.0f, -820.0f, -1744.0f);
- this.ModelInstances.get(18).transform.setToTranslation(31221.0f, -420.0f, -29595.0f);
- this.ModelInstances.get(19).transform.setToTranslation(18009.0f, -260.0f, -76928.0f);
- this.ModelInstances.get(20).transform.setToTranslation(36710.0f, 490.0f, 20507.0f);
- this.ModelInstances.get(21).transform.setToTranslation(47247.0f, -820.0f, -3696.0f);
- this.ModelInstances.get(22).transform.setToTranslation(61354.0f, 520.0f, 24742.0f);
- this.ModelInstances.get(23).transform.setToTranslation(65539.0f, -530.0f, -2278.0f);
- this.ModelInstances.get(24).transform.setToTranslation(36455.0f, -5220.0f, 15268.0f);
- this.ModelInstances.get(25).transform.setToTranslation(52915.0f, -820.0f, -1774.0f);
- this.ModelInstances.get(26).transform.setToTranslation(20021.0f, -810.0f, 2875.0f);
- this.ModelInstances.get(27).transform.setToTranslation(24109.0f, 60.0f, -14428.0f);
- this.ModelInstances.get(28).transform.setToTranslation(42810.0f, -480.0f, 23007.0f);
- this.ModelInstances.get(29).transform.setToTranslation(49647.0f, -500.0f, -32146.0f);
- this.ModelInstances.get(30).transform.setToTranslation(57854.0f, 510.0f, 27742.0f);
- this.ModelInstances.get(31).transform.setToTranslation(56979.0f, -520.0f, 722.0f);
- this.ModelInstances.get(32).transform.setToTranslation(28655.0f, -800.0f, 45238.0f);
- this.ModelInstances.get(33).transform.setToTranslation(52115.0f, -810.0f, -1694.0f);
- this.ModelInstances.get(34).transform.setToTranslation(23021.0f, 40.0f, -24095.0f);
- this.ModelInstances.get(35).transform.setToTranslation(15209.0f, -810.0f, 14992.0f);
- this.ModelInstances.get(36).transform.setToTranslation(34710.0f, -320.0f, 25507.0f);
- this.ModelInstances.get(37).transform.setToTranslation(50347.0f, 550.0f, -29646.0f);
- this.ModelInstances.get(38).transform.setToTranslation(58554.0f, 760.0f, 30242.0f);
- this.ModelInstances.get(39).transform.setToTranslation(55179.0f, -820.0f, 27892.0f);
- this.ModelInstances.get(40).transform.setToTranslation(30255.0f, -900.0f, 44968.0f);
- this.ModelInstances.get(41).transform.setToTranslation(52715.0f, -920.0f, -1704.0f);
- this.ModelInstances.get(42).transform.setToTranslation(24421.0f, -520.0f, -47295.0f);
- this.ModelInstances.get(74).transform.setToTranslation(17769.0f, 750.0f, 21182.0f);
- this.ModelInstances.get(75).transform.setToTranslation(25840.0f, 360.0f, 58877.0f);
- this.ModelInstances.get(76).transform.setToTranslation(52397.0f, -590.0f, 9384.0f);
- this.ModelInstances.get(77).transform.setToTranslation(63484.0f, -360.0f, 60702.0f);
- this.ModelInstances.get(78).transform.setToTranslation(59699.0f, -250.0f, 26372.0f);
- this.ModelInstances.get(79).transform.setToTranslation(36725.0f, -770.0f, 48498.0f);
- this.ModelInstances.get(80).transform.setToTranslation(56445.0f, -700.0f, 8486.0f);
- this.ModelInstances.get(81).transform.setToTranslation(25851.0f, -340.0f, 6035.0f);
- this.ModelInstances.get(82).transform.setToTranslation(19879.0f, -130.0f, 22612.0f);
- this.ModelInstances.get(83).transform.setToTranslation(29000.0f, 270.0f, 61247.0f);
- this.ModelInstances.get(84).transform.setToTranslation(55007.0f, 720.0f, 8804.0f);
- this.ModelInstances.get(85).transform.setToTranslation(54654.0f, 350.0f, 64882.0f);
- this.ModelInstances.get(86).transform.setToTranslation(56339.0f, -390.0f, 26172.0f);
- this.ModelInstances.get(87).transform.setToTranslation(31925.0f, -640.0f, 47858.0f);
- this.ModelInstances.get(88).transform.setToTranslation(59775.0f, 380.0f, 6.0f);
- this.ModelInstances.get(89).transform.setToTranslation(16791.0f, -110.0f, 13535.0f);
- this.ModelInstances.get(90).transform.setToTranslation(10899.0f, -560.0f, 15302.0f);
- this.ModelInstances.get(91).transform.setToTranslation(33950.0f, 680.0f, 64057.0f);
- this.ModelInstances.get(92).transform.setToTranslation(48887.0f, 340.0f, -1036.0f);
- this.ModelInstances.get(93).transform.setToTranslation(52644.0f, 180.0f, 61342.0f);
- this.ModelInstances.get(94).transform.setToTranslation(60249.0f, -70.0f, 38322.0f);
- this.ModelInstances.get(95).transform.setToTranslation(26225.0f, 680.0f, 49458.0f);
- this.ModelInstances.get(96).transform.setToTranslation(47255.0f, 710.0f, -2594.0f);
- this.ModelInstances.get(97).transform.setToTranslation(18851.0f, 330.0f, 10895.0f);
- this.ModelInstances.get(98).transform.setToTranslation(17039.0f, -710.0f, 20192.0f);
- this.ModelInstances.get(99).transform.setToTranslation(26290.0f, 230.0f, 57247.0f);
- this.ModelInstances.get(100).transform.setToTranslation(44167.0f, 760.0f, -476.0f);
- this.ModelInstances.get(101).transform.setToTranslation(56384.0f, -730.0f, 59502.0f);
- this.ModelInstances.get(102).transform.setToTranslation(57979.0f, 400.0f, 36182.0f);
- this.ModelInstances.get(Input.Keys.BUTTON_R1).transform.setToTranslation(31705.0f, -160.0f, 54168.0f);
- this.ModelInstances.get(Input.Keys.BUTTON_L2).transform.setToTranslation(49075.0f, 20.0f, 576.0f);
- this.ModelInstances.get(Input.Keys.BUTTON_R2).transform.setToTranslation(13881.0f, 120.0f, 14555.0f);
- this.ModelInstances.get(Input.Keys.BUTTON_THUMBL).transform.setToTranslation(18549.0f, 290.0f, 20112.0f);
- this.ModelInstances.get(Input.Keys.BUTTON_THUMBR).transform.setToTranslation(31250.0f, 700.0f, 57637.0f);
- this.ModelInstances.get(Input.Keys.BUTTON_START).transform.setToTranslation(41767.0f, 30.0f, 7454.0f);
- this.ModelInstances.get(Input.Keys.BUTTON_SELECT).transform.setToTranslation(62624.0f, -590.0f, 56312.0f);
- this.ModelInstances.get(Input.Keys.BUTTON_MODE).transform.setToTranslation(58099.0f, 70.0f, 40592.0f);
- this.ModelInstances.get(Input.Keys.ESCAPE).transform.setToTranslation(23575.0f, 670.0f, 55128.0f);
- this.ModelInstances.get(Input.Keys.FORWARD_DEL).transform.setToTranslation(50835.0f, -670.0f, -2204.0f);
- this.ModelInstances.get(113).transform.setToTranslation(15411.0f, 730.0f, 3255.0f);
- this.ModelInstances.get(114).transform.setToTranslation(15989.0f, -550.0f, 18582.0f);
- this.ModelInstances.get(Input.Keys.CAPS_LOCK).transform.setToTranslation(26420.0f, 140.0f, 59297.0f);
- this.ModelInstances.get(Input.Keys.SCROLL_LOCK).transform.setToTranslation(46217.0f, -30.0f, 5724.0f);
- this.ModelInstances.get(117).transform.setToTranslation(63254.0f, 200.0f, 55272.0f);
- this.ModelInstances.get(118).transform.setToTranslation(58809.0f, 110.0f, 39882.0f);
- this.ModelInstances.get(119).transform.setToTranslation(22075.0f, 170.0f, 43138.0f);
- this.ModelInstances.get(Input.Keys.PRINT_SCREEN).transform.setToTranslation(45675.0f, -370.0f, 7236.0f);
- this.ModelInstances.get(Input.Keys.PAUSE).transform.setToTranslation(27291.0f, -160.0f, 14635.0f);
- this.ModelInstances.get(122).transform.setToTranslation(22429.0f, -460.0f, 15162.0f);
- this.ModelInstances.get(Input.Keys.END).transform.setToTranslation(35030.0f, -540.0f, 55047.0f);
- this.ModelInstances.get(Input.Keys.INSERT).transform.setToTranslation(48847.0f, -100.0f, 8974.0f);
- this.ModelInstances.get(125).transform.setToTranslation(63684.0f, 530.0f, 63242.0f);
- this.ModelInstances.get(126).transform.setToTranslation(56619.0f, -60.0f, 32152.0f);
- this.ModelInstances.get(127).transform.setToTranslation(23975.0f, -350.0f, 56288.0f);
- this.ModelInstances.get(128).transform.setToTranslation(50575.0f, -430.0f, 5576.0f);
- this.ModelInstances.get(Input.Keys.CONTROL_LEFT).transform.setToTranslation(23201.0f, 100.0f, 9855.0f);
- this.ModelInstances.get(Input.Keys.CONTROL_RIGHT).transform.setToTranslation(12579.0f, -600.0f, 16042.0f);
- this.ModelInstances.get(Input.Keys.F1).transform.setToTranslation(30150.0f, -580.0f, 60817.0f);
- this.ModelInstances.get(Input.Keys.F2).transform.setToTranslation(49887.0f, 470.0f, -516.0f);
- this.ModelInstances.get(Input.Keys.F3).transform.setToTranslation(63194.0f, -610.0f, 66392.0f);
- this.ModelInstances.get(Input.Keys.F4).transform.setToTranslation(61929.0f, 760.0f, 29002.0f);
- this.ModelInstances.get(Input.Keys.F5).transform.setToTranslation(32925.0f, 360.0f, 45588.0f);
- this.ModelInstances.get(Input.Keys.F6).transform.setToTranslation(47295.0f, -540.0f, 4656.0f);
- this.ModelInstances.get(Input.Keys.F7).transform.setToTranslation(27601.0f, 240.0f, 4265.0f);
- this.ModelInstances.get(Input.Keys.F8).transform.setToTranslation(19399.0f, 410.0f, 19812.0f);
- this.ModelInstances.get(Input.Keys.F9).transform.setToTranslation(39730.0f, 550.0f, 56387.0f);
- this.ModelInstances.get(Input.Keys.F10).transform.setToTranslation(53687.0f, 120.0f, -1836.0f);
- this.ModelInstances.get(Input.Keys.F11).transform.setToTranslation(61034.0f, 300.0f, 67142.0f);
- this.ModelInstances.get(Input.Keys.F12).transform.setToTranslation(61519.0f, 460.0f, 38192.0f);
- this.ModelInstances.get(Input.Keys.NUM_LOCK).transform.setToTranslation(30465.0f, 740.0f, 58328.0f);
- this.ModelInstances.get(144).transform.setToTranslation(46585.0f, 300.0f, 1976.0f);
- this.ModelInstances.get(Input.Keys.NUMPAD_1).transform.setToTranslation(27521.0f, -580.0f, 13895.0f);
- this.ModelInstances.get(Input.Keys.NUMPAD_2).transform.setToTranslation(14199.0f, 660.0f, 12782.0f);
- this.ModelInstances.get(Input.Keys.NUMPAD_3).transform.setToTranslation(38590.0f, 80.0f, 61017.0f);
- this.ModelInstances.get(Input.Keys.NUMPAD_4).transform.setToTranslation(56637.0f, -600.0f, 7654.0f);
- this.ModelInstances.get(Input.Keys.NUMPAD_5).transform.setToTranslation(59704.0f, 770.0f, 68842.0f);
- this.ModelInstances.get(Input.Keys.NUMPAD_MULTIPLY).transform.setToTranslation(55349.0f, 0.0f, 36422.0f);
- this.ModelInstances.get(43).transform.setToTranslation(30825.0f, 320.0f, 106268.0f);
- this.ModelInstances.get(44).transform.setToTranslation(53375.0f, 410.0f, 18446.0f);
- this.ModelInstances.get(45).transform.setToTranslation(23801.0f, -300.0f, 71305.0f);
- this.ModelInstances.get(46).transform.setToTranslation(20489.0f, 540.0f, -47528.0f);
- this.ModelInstances.get(47).transform.setToTranslation(36020.0f, 350.0f, 63307.0f);
- this.ModelInstances.get(48).transform.setToTranslation(54657.0f, 500.0f, -8046.0f);
- this.ModelInstances.get(49).transform.setToTranslation(63044.0f, -320.0f, 134442.0f);
- this.ModelInstances.get(50).transform.setToTranslation(63409.0f, -450.0f, -14478.0f);
- this.ModelInstances.get(51).transform.setToTranslation(34945.0f, 770.0f, 114868.0f);
- this.ModelInstances.get(52).transform.setToTranslation(55595.0f, 50.0f, -28854.0f);
- this.ModelInstances.get(53).transform.setToTranslation(15981.0f, -20.0f, -36295.0f);
- this.ModelInstances.get(54).transform.setToTranslation(20329.0f, -400.0f, -11328.0f);
- this.ModelInstances.get(55).transform.setToTranslation(31000.0f, -650.0f, 110507.0f);
- this.ModelInstances.get(56).transform.setToTranslation(43507.0f, -160.0f, -56746.0f);
- this.ModelInstances.get(57).transform.setToTranslation(59404.0f, -30.0f, 37442.0f);
- this.ModelInstances.get(58).transform.setToTranslation(57529.0f, 10.0f, 75622.0f);
- this.ModelInstances.get(59).transform.setToTranslation(27335.0f, 130.0f, 129968.0f);
- this.ModelInstances.get(60).transform.setToTranslation(46965.0f, 540.0f, -27654.0f);
- this.ModelInstances.get(61).transform.setToTranslation(17021.0f, -350.0f, 53605.0f);
- this.ModelInstances.get(62).transform.setToTranslation(15009.0f, 100.0f, -26428.0f);
- this.ModelInstances.get(63).transform.setToTranslation(28140.0f, -50.0f, 53307.0f);
- this.ModelInstances.get(64).transform.setToTranslation(53667.0f, -640.0f, 70554.0f);
- this.ModelInstances.get(Input.Keys.NUMPAD_DIVIDE).transform.setToTranslation(56594.0f, 0.0f, 65842.0f);
- this.ModelInstances.get(65).transform.setToTranslation(50259.0f, -740.0f, 90322.0f);
- this.ModelInstances.get(66).transform.setToTranslation(23545.0f, 30.0f, -164232.0f);
- this.ModelInstances.get(67).transform.setToTranslation(57225.0f, -310.0f, 55046.0f);
- this.ModelInstances.get(68).transform.setToTranslation(22881.0f, -740.0f, -33895.0f);
- this.ModelInstances.get(69).transform.setToTranslation(19739.0f, -60.0f, 24172.0f);
- this.ModelInstances.get(70).transform.setToTranslation(28880.0f, 280.0f, -13493.0f);
- this.ModelInstances.get(71).transform.setToTranslation(51047.0f, -560.0f, -11546.0f);
- this.ModelInstances.get(72).transform.setToTranslation(50614.0f, 390.0f, 139742.0f);
- this.ModelInstances.get(73).transform.setToTranslation(57069.0f, 740.0f, 56022.0f);
- this.ModelInstances.get(Input.Keys.NUMPAD_DOT).transform.setToTranslation(800.0f, 0.0f, 830.0f);
- this.ModelInstances.get(Input.Keys.NUMPAD_COMMA).transform.setToTranslation(500.0f, 0.0f, 120.0f);
- this.ModelInstances.get(160).transform.setToTranslation(250.0f, 0.0f, 370.0f);
- this.ModelInstances.get(Input.Keys.NUMPAD_EQUALS).transform.setToTranslation(-480.0f, 0.0f, 720.0f);
- this.ModelInstances.get(Input.Keys.NUMPAD_LEFT_PAREN).transform.setToTranslation(360.0f, 0.0f, -440.0f);
- this.ModelInstances.get(Input.Keys.NUMPAD_ADD).transform.setToTranslation(560.0f, 0.0f, -690.0f);
- this.ModelInstances.get(Input.Keys.NUMPAD_RIGHT_PAREN).transform.setToTranslation(750.0f, 0.0f, 800.0f);
- this.ModelInstances.get(164).transform.setToTranslation(710.0f, 0.0f, -880.0f);
- this.ModelInstances.get(165).transform.setToTranslation(720.0f, 0.0f, -640.0f);
- this.ModelInstances.get(166).transform.setToTranslation(180.0f, 0.0f, -440.0f);
- this.ModelInstances.get(167).transform.setToTranslation(780.0f, 0.0f, -130.0f);
- this.ModelInstances.get(168).transform.setToTranslation(620.0f, 0.0f, 210.0f);
- this.ModelInstances.get(169).transform.setToTranslation(-740.0f, 0.0f, 230.0f);
- this.ModelInstances.get(170).transform.setToTranslation(-110.0f, 0.0f, -300.0f);
- this.ModelInstances.get(171).transform.setToTranslation(-300.0f, 0.0f, 820.0f);
- this.ModelInstances.get(172).transform.setToTranslation(740.0f, 0.0f, -630.0f);
- this.ModelInstances.get(173).transform.setToTranslation(810.0f, 0.0f, -850.0f);
- this.ModelInstances.get(174).transform.setToTranslation(510.0f, 0.0f, 820.0f);
- this.ModelInstances.get(175).transform.setToTranslation(590.0f, 0.0f, -90.0f);
- this.ModelInstances.get(ContactCallbackEvent.ON_PROCESSED_FILTERED_OBJECT_INCLUDEPOINT).transform.setToTranslation(-590.0f, 0.0f, -580.0f);
- this.ModelInstances.get(177).transform.setToTranslation(-230.0f, 0.0f, -400.0f);
- this.ModelInstances.get(178).transform.setToTranslation(750.0f, 0.0f, -50.0f);
- this.ModelInstances.get(179).transform.setToTranslation(-410.0f, 0.0f, 660.0f);
- this.ModelInstances.get(180).transform.setToTranslation(-780.0f, 0.0f, 210.0f);
- this.ModelInstances.get(Input.Keys.NUMPAD_SUBTRACT).transform.setToTranslation(320.0f, 0.0f, 350.0f);
- this.ModelInstances.get(181).transform.setToTranslation(-40.0f, 0.0f, 140.0f);
- this.ModelInstances.get(182).transform.setToTranslation(570.0f, 0.0f, 330.0f);
- this.ModelInstances.get(Input.Keys.F13).transform.setToTranslation(-210.0f, 0.0f, -520.0f);
- this.ModelInstances.get(Input.Keys.F14).transform.setToTranslation(370.0f, 0.0f, 500.0f);
- this.ModelInstances.get(Input.Keys.F15).transform.setToTranslation(-210.0f, 0.0f, -670.0f);
- this.ModelInstances.get(Input.Keys.F16).transform.setToTranslation(760.0f, 0.0f, -500.0f);
- this.ModelInstances.get(Input.Keys.F17).transform.setToTranslation(-190.0f, 0.0f, 460.0f);
- for (ModelInstance model2 : this.ModelInstances) {
- this.position = new Vector3();
- model2.transform.getTranslation(this.position);
- this.positions.add(this.position);
- }
- try {
- // shuffleFlagChars();
- } catch (Exception e) {
- System.out.println(e.getMessage());
- }
- }
- private void teleportToFlag() {
- // Assuming the flag is represented by the first ModelInstance
- if (this.ModelInstances.isEmpty()) return;
- ModelInstance flagInstance = this.ModelInstances.get(0); // Adjust index if needed
- Vector3 flagPosition = new Vector3();
- flagInstance.transform.getTranslation(flagPosition);
- // Teleport player to the flag's position
- this.playerBody.setWorldTransform(flagInstance.transform);
- this.cam.position.set(flagPosition.x, flagPosition.y + 5.0f, flagPosition.z); // Slight offset above the flag
- this.cam.update();
- System.out.println("Teleported to flag at: " + flagPosition);
- }
- private void shuffleFlagChars() {
- try {
- float xStart = 0.0f; // Starting position on the X-axis
- float yLevel = 900.0f; // Keep flags higher in the world
- float zStart = 0.0f; // Fixed Z position
- float spacing = 200.0f; // Much more spacing between characters
- float xPosition = xStart; // Initial X position for the first flag
- for (int i = 0; i < 187; i++) {
- ModelInstance model = this.ModelInstances.get(i);
- // Set each flag in a long row, spaced apart
- model.transform.setToTranslation(xPosition, yLevel, zStart);
- // Store updated position
- Vector3 newPosition = new Vector3();
- model.transform.getTranslation(newPosition);
- this.positions.set(i, newPosition);
- // Move the X position for the next flag
- xPosition += spacing;
- }
- } catch (Exception e) {
- System.out.println("Error arranging flag characters in row: " + e.getMessage());
- }
- }
- private void createUI() {
- // Create buttons or touch zones for each model.
- // For simplicity, let's just create a button that cycles through the model list.
- // Create an input listener for selecting models via touch
- Gdx.input.setInputProcessor(new InputAdapter() {
- @Override
- public boolean touchDown(int screenX, int screenY, int pointer, int button) {
- if (screenX > 100 && screenX < 200 && screenY > 100 && screenY < 200) {
- // Cycle through models on touch
- selectedModelIndex = (selectedModelIndex + 1) % modelInstances.size();
- return true;
- }
- return false;
- }
- });
- }
- public List<int[]> repeatList(List<int[]> offsets, int targetLength) {
- this.repeatedList = new ArrayList();
- while (this.repeatedList.size() < targetLength) {
- for (int[] offset : offsets) {
- if (this.repeatedList.size() < targetLength) {
- this.repeatedList.add(offset);
- }
- }
- }
- return this.repeatedList;
- }
- public List<int[]> generateOffsets(String hash) {
- List<int[]> offsets = new ArrayList<>();
- for (int i = 0; i < hash.length(); i += 8) {
- int xOffset = Integer.parseInt(hash.substring(i, i + 4), 16);
- int zOffset = Integer.parseInt(hash.substring(i + 4, i + 8), 16);
- offsets.add(new int[]{xOffset, zOffset});
- }
- return offsets;
- }
- public String toHexString(byte[] hash) {
- BigInteger number = new BigInteger(1, hash);
- StringBuilder hexString = new StringBuilder(number.toString(16));
- while (hexString.length() < 64) {
- hexString.insert(0, '0');
- }
- return hexString.toString();
- }
- private void setupPhysicsWorld() {
- this.collisionConfig = new btDefaultCollisionConfiguration();
- this.dispatcher = new btCollisionDispatcher(this.collisionConfig);
- this.broadphase = new btDbvtBroadphase();
- this.dynamicsWorld = new btDiscreteDynamicsWorld(this.dispatcher, this.broadphase, null, this.collisionConfig);
- this.dynamicsWorld.setGravity(new Vector3(0.0f, -50.0f, 0.0f));
- createEnvironmentBodies();
- createPlayerBody();
- }
- private void createEnvironmentBodies() {
- ModelBuilder modelBuilder = new ModelBuilder();
- this.floorModel = modelBuilder.createBox(2000.0f, 1.0f, 2000.0f, new Material(ColorAttribute.createDiffuse(Color.GRAY)), 9L);
- this.floorInstance = new ModelInstance(this.floorModel);
- this.floorInstance.transform.setToTranslation(0.0f, -0.5f, 0.0f);
- btCollisionShape floorShape = new btBoxShape(new Vector3(1000.0f, 0.5f, 1000.0f));
- btRigidBody floorBody = createStaticBody(floorShape, this.floorInstance.transform);
- this.environmentBodies.add(floorBody);
- this.frontWallModel = modelBuilder.createBox(2000.0f, 500.0f, 10.0f, new Material(ColorAttribute.createDiffuse(Color.valueOf("#e4e6a8"))), 9L);
- this.frontWallInstance = new ModelInstance(this.frontWallModel);
- this.frontWallInstance.transform.setToTranslation(0.0f, 250.0f, 1000.0f);
- btCollisionShape frontWallShape = new btBoxShape(new Vector3(1000.0f, 250.0f, 10.0f / 2.0f));
- btRigidBody frontWallBody = createStaticBody(frontWallShape, this.frontWallInstance.transform);
- this.environmentBodies.add(frontWallBody);
- this.backWallModel = modelBuilder.createBox(2000.0f, 500.0f, 10.0f, new Material(ColorAttribute.createDiffuse(Color.valueOf("#e4e6a8"))), 9L);
- this.backWallInstance = new ModelInstance(this.backWallModel);
- this.backWallInstance.transform.setToTranslation(0.0f, 250.0f, -1000.0f);
- btCollisionShape backWallShape = new btBoxShape(new Vector3(1000.0f, 250.0f, 10.0f / 2.0f));
- btRigidBody backWallBody = createStaticBody(backWallShape, this.backWallInstance.transform);
- this.environmentBodies.add(backWallBody);
- this.leftWallModel = modelBuilder.createBox(10.0f, 500.0f, 2000.0f, new Material(ColorAttribute.createDiffuse(Color.valueOf("#e4e6a8"))), 9L);
- this.leftWallInstance = new ModelInstance(this.leftWallModel);
- this.leftWallInstance.transform.setToTranslation(-1000.0f, 250.0f, 0.0f);
- btCollisionShape leftWallShape = new btBoxShape(new Vector3(10.0f / 2.0f, 250.0f, 1000.0f));
- btRigidBody leftWallBody = createStaticBody(leftWallShape, this.leftWallInstance.transform);
- this.environmentBodies.add(leftWallBody);
- this.rightWallModel = modelBuilder.createBox(10.0f, 500.0f, 2000.0f, new Material(ColorAttribute.createDiffuse(Color.valueOf("#e4e6a8"))), 9L);
- this.rightWallInstance = new ModelInstance(this.rightWallModel);
- this.rightWallInstance.transform.setToTranslation(1000.0f, 250.0f, 0.0f);
- btCollisionShape rightWallShape = new btBoxShape(new Vector3(10.0f / 2.0f, 250.0f, 1000.0f));
- btRigidBody rightWallBody = createStaticBody(rightWallShape, this.rightWallInstance.transform);
- this.environmentBodies.add(rightWallBody);
- }
- private void createPlayerBody() {
- ModelBuilder modelBuilder = new ModelBuilder();
- this.playerModel = modelBuilder.createBox(10.0f, 30.0f, 10.0f, new Material(ColorAttribute.createDiffuse(Color.BLUE)), 9L);
- this.playerInstance = new ModelInstance(this.playerModel);
- this.playerShape = new btBoxShape(new Vector3(5.0f, 15.0f, 5.0f));
- btDefaultMotionState motionState = new btDefaultMotionState(this.playerInstance.transform);
- btRigidBody.btRigidBodyConstructionInfo bodyInfo = new btRigidBody.btRigidBodyConstructionInfo(1.0f, motionState, this.playerShape, new Vector3(0.0f, 5.0f, 0.0f));
- this.playerBody = new btRigidBody(bodyInfo);
- this.playerBody.setAngularFactor(Vector3.Zero);
- this.playerBody.setActivationState(4);
- this.dynamicsWorld.addRigidBody(this.playerBody);
- this.playerBody.setAngularFactor(new Vector3(0.0f, 0.0f, 0.0f));
- this.playerBody.setActivationState(4);
- this.playerBody.setWorldTransform(this.playerInstance.transform);
- teleportToFlag();
- this.dynamicsWorld.addRigidBody(this.playerBody);
- }
- private void drawButtons() {
- shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);
- // Movement and camera buttons (existing buttons remain unchanged)
- shapeRenderer.setColor(Color.BLUE);
- shapeRenderer.rect(0, 200, 50, 50); // Rotate left
- shapeRenderer.rect(100, 200, 50, 50); // Rotate right
- shapeRenderer.setColor(Color.CYAN);
- shapeRenderer.rect(50, 250, 50, 50); // Look up
- shapeRenderer.rect(50, 150, 50, 50); // Look down
- shapeRenderer.setColor(Color.GREEN);
- shapeRenderer.rect(50, 200, 50, 50); // Forward
- shapeRenderer.rect(50, 100, 50, 50); // Backward
- shapeRenderer.setColor(Color.YELLOW);
- shapeRenderer.rect(0, 150, 50, 50); // Strafe left
- shapeRenderer.rect(100, 150, 50, 50); // Strafe right
- shapeRenderer.setColor(Color.MAGENTA);
- shapeRenderer.rect(200, 200, 50, 50); // Ascend
- shapeRenderer.rect(200, 150, 50, 50); // Descend
- // Freeze and teleport buttons
- shapeRenderer.setColor(Color.RED);
- shapeRenderer.rect(300, 200, 50, 50); // Freeze button
- shapeRenderer.setColor(Color.ORANGE);
- shapeRenderer.rect(300, 150, 50, 50); // Teleport button
- shapeRenderer.end();
- }
- private btRigidBody createStaticBody(btCollisionShape shape, Matrix4 transform) {
- btRigidBody.btRigidBodyConstructionInfo bodyConstructionInfo = new btRigidBody.btRigidBodyConstructionInfo(0.0f, (btMotionState) null, shape, Vector3.Zero);
- btRigidBody body = new btRigidBody(bodyConstructionInfo);
- body.setWorldTransform(transform);
- this.dynamicsWorld.addRigidBody(body);
- return body;
- }
- @Override // com.badlogic.gdx.ApplicationAdapter, com.badlogic.gdx.ApplicationListener
- public void render() {
- Gdx.gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
- Gdx.gl.glClear(16640);
- this.dynamicsWorld.stepSimulation(Gdx.graphics.getDeltaTime(), 5, 0.016666668f);
- Matrix4 playerTransform = new Matrix4();
- this.playerBody.getWorldTransform(playerTransform);
- this.playerInstance.transform.set(playerTransform);
- this.cam.position.set(this.playerBody.getCenterOfMassPosition().x, this.playerBody.getCenterOfMassPosition().y + 5.0f, this.playerBody.getCenterOfMassPosition().z);
- this.cam.update();
- handlePlayerMovement();
- this.modelBatch.begin(this.cam);
- this.modelBatch.render(this.floorInstance, this.environment);
- this.modelBatch.render(this.frontWallInstance, this.environment);
- this.modelBatch.render(this.backWallInstance, this.environment);
- this.modelBatch.render(this.leftWallInstance, this.environment);
- this.modelBatch.render(this.rightWallInstance, this.environment);
- this.modelBatch.render(this.playerInstance, this.environment);
- for (ModelInstance alphabetInstance : this.ModelInstances) {
- this.modelBatch.render(alphabetInstance, this.environment);
- }
- this.modelBatch.end();
- drawButtons();
- // this.jumpscareTimer += Gdx.graphics.getDeltaTime();
- if (this.jumpscareTimer >= this.JUMPSCARE_INTERVAL && !this.jumpscareTriggered) {
- try {
- triggerJumpscare();
- } catch (Exception e) {
- System.out.println(e.getMessage());
- }
- }
- if (this.jumpscareTimer >= this.SCARE_INTERVAL && !this.scareTriggered) {
- this.scareSound.play(0.5f);
- this.scareTriggered = true;
- }
- if (this.jumpscareTriggered) {
- this.spriteBatch.begin();
- this.spriteBatch.draw(this.jumpscareImage, 0.0f, 0.0f, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
- this.spriteBatch.end();
- if (this.jumpscareTimer >= this.JUMPSCARE_INTERVAL + 2.0f) {
- Gdx.app.exit();
- }
- }
- }
- public void triggerJumpscare() throws NoSuchAlgorithmException {
- this.jumpscareTriggered = true;
- this.jumpscareSound.play();
- }
- private void handlePlayerMovement() {
- Vector3 movement = new Vector3();
- // Touch-based input handling
- if (Gdx.input.isTouched()) {
- int screenX = Gdx.input.getX();
- int screenY = Gdx.graphics.getHeight() - Gdx.input.getY();
- // Toggle freeze
- if (screenX >= 300 && screenX <= 350 && screenY >= 200 && screenY <= 250) {
- this.playerBody.setLinearVelocity(Vector3.Zero);
- this.playerBody.setGravity(Vector3.Zero); // Disable gravity
- return; // Skip further movement when frozen
- }
- // Rotate camera horizontally (left/right)
- if (screenX >= 0 && screenX <= 50 && screenY >= 200 && screenY <= 250) {
- this.cam.rotate(Vector3.Y, 2.5f); // Rotate left
- this.cam.update();
- } else if (screenX >= 100 && screenX <= 150 && screenY >= 200 && screenY <= 250) {
- this.cam.rotate(Vector3.Y, -2.5f); // Rotate right
- this.cam.update();
- }
- // Rotate camera vertically (look up/down)
- else if (screenX >= 50 && screenX <= 100 && screenY >= 250 && screenY <= 300) {
- Vector3 right = new Vector3(this.cam.direction).crs(this.cam.up).nor(); // Camera's right vector
- this.cam.direction.rotate(right, 2.5f); // Look up
- this.cam.update();
- } else if (screenX >= 50 && screenX <= 100 && screenY >= 150 && screenY <= 200) {
- Vector3 right = new Vector3(this.cam.direction).crs(this.cam.up).nor(); // Camera's right vector
- this.cam.direction.rotate(right, -2.5f); // Look down
- this.cam.update();
- }
- // Move forward/backward
- else if (screenX >= 50 && screenX <= 100 && screenY >= 200 && screenY <= 250) {
- movement.set(this.cam.direction.x, 0.0f, this.cam.direction.z).nor().scl(this.movementSpeed); // Forward
- } else if (screenX >= 50 && screenX <= 100 && screenY >= 100 && screenY <= 150) {
- movement.set(this.cam.direction.x, 0.0f, this.cam.direction.z).nor().scl(-this.movementSpeed); // Backward
- }
- // Strafe left/right
- else if (screenX >= 0 && screenX <= 50 && screenY >= 150 && screenY <= 200) {
- Vector3 left = new Vector3(this.cam.direction).crs(this.cam.up).nor();
- movement.set(left.x, 0.0f, left.z).scl(-this.movementSpeed); // Strafe left
- } else if (screenX >= 100 && screenX <= 150 && screenY >= 150 && screenY <= 200) {
- Vector3 right = new Vector3(this.cam.direction).crs(this.cam.up).nor();
- movement.set(right.x, 0.0f, right.z).scl(this.movementSpeed); // Strafe right
- }
- // Move up/down
- else if (screenX >= 200 && screenX <= 250 && screenY >= 200 && screenY <= 250) {
- movement.set(0.0f, this.movementSpeed, 0.0f); // Ascend
- this.playerBody.setGravity(Vector3.Zero); // Temporarily disable gravity
- } else if (screenX >= 200 && screenX <= 250 && screenY >= 150 && screenY <= 200) {
- movement.set(0.0f, -this.movementSpeed, 0.0f); // Descend
- this.playerBody.setGravity(Vector3.Zero); // Temporarily disable gravity
- } else {
- this.playerBody.setGravity(new Vector3(0.0f, -50.0f, 0.0f)); // Restore gravity
- }
- }
- // Apply movement to the player body
- if (!movement.isZero()) {
- this.playerBody.applyCentralImpulse(movement);
- // Limit maximum velocity
- Vector3 velocity = this.playerBody.getLinearVelocity();
- if (velocity.len() > 2000.0f) {
- velocity.nor().scl(2000.0f);
- this.playerBody.setLinearVelocity(velocity);
- }
- }
- }
- @Override // com.badlogic.gdx.ApplicationAdapter, com.badlogic.gdx.ApplicationListener
- public void dispose() {
- for (btRigidBody body : this.environmentBodies) {
- body.dispose();
- }
- this.playerBody.dispose();
- this.playerShape.dispose();
- this.dynamicsWorld.dispose();
- this.dispatcher.dispose();
- this.broadphase.dispose();
- this.collisionConfig.dispose();
- this.dispatcher.dispose();
- this.collisionConfig.dispose();
- this.modelBatch.dispose();
- this.floorModel.dispose();
- this.wallModel.dispose();
- this.leftWallModel.dispose();
- this.rightWallModel.dispose();
- this.backWallModel.dispose();
- this.frontWallModel.dispose();
- for (Model model : this.Models) {
- model.dispose();
- }
- if (this.assetManager != null) {
- this.assetManager.dispose();
- }
- if (this.jumpscareImage != null) {
- this.jumpscareImage.dispose();
- }
- if (this.jumpscareSound != null) {
- this.jumpscareSound.dispose();
- }
- if (this.scareSound != null) {
- this.scareSound.dispose();
- }
- if (this.spriteBatch != null) {
- this.spriteBatch.dispose();
- }
- if (this.backgroundMusic != null) {
- this.backgroundMusic.dispose();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement