{"id":16214073,"url":"https://github.com/bitbrain/parallax","last_synced_at":"2026-03-02T14:33:07.931Z","repository":{"id":10968342,"uuid":"13283675","full_name":"bitbrain/parallax","owner":"bitbrain","description":"Library which provides parallax scrolling support for Java 2D libraries such as LibGDX and Slick2D.","archived":false,"fork":false,"pushed_at":"2014-02-11T08:19:47.000Z","size":2532,"stargazers_count":4,"open_issues_count":3,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-13T21:19:26.953Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bitbrain.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-10-02T21:41:13.000Z","updated_at":"2017-08-26T10:01:32.000Z","dependencies_parsed_at":"2022-08-29T15:40:53.031Z","dependency_job_id":null,"html_url":"https://github.com/bitbrain/parallax","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitbrain%2Fparallax","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitbrain%2Fparallax/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitbrain%2Fparallax/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitbrain%2Fparallax/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bitbrain","download_url":"https://codeload.github.com/bitbrain/parallax/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247721946,"owners_count":20985080,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-10T11:09:33.397Z","updated_at":"2026-03-02T14:33:02.898Z","avatar_url":"https://github.com/bitbrain.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"![parallax](parallax.png)\n\nLibrary which provides parallax scrolling support for Java 2D libraries such as LibGDX and Slick2D.\n\n## Features\n\nThis library is able to..\n\n* generate custom (pre-processed) textures on runtime\n* display parallax effects\n* customize your backgrounds with parallax patterns\n\n#Download\n\nYou can download the library [here](https://www.dropbox.com/s/wt8m9w53obixzbc/parallax.jar).\n\n## Getting started\n\nTo create a new parallax effect, you need a so called ```Viewport``` and ```ParallaxMapper```. The ```Viewport``` is an required interface implementation of your field of view (FOV). You can implement for instance the interface in your camera class:\n\n```java\npublic class MyCamera extends Camera implements Viewport {\n\n   @Override\n   public float getLeft() {\n      return getX();\n   }\n\n   @Override\n   public float getTop() {\n      return getY();\n   }\n\n   @Override\n   public float getRight() {\n      return getLeft() + getWidth();\n   }\n\n   @Override\n   public float getBottom() {\n      return getTop() + getHeight();\n   }\n}\n```\n\nAfterwards you are able to create your parallax mapper:\n\n```java\nMyCamera camera = new MyCamera();\nParallaxMapper mapper = new ParallaxMapper(camera);\n```\n\n### Slick2D remarks\n\nThe parallax system works only with matrix translation. Therefore you need to translate the matrix by the current camera position:\n\n```java\n// Code in the render method\ng.pushMatrix();\ng.translate(camera.getX(), camera.getY();\nmapper.render();\ng.popMatrix();\n```\n\n### LibGDX remarks\n\nIn order to use the parallax effect properly, you have to define a ```SpriteBatch``` instance. You need to wrap *begin* and *end* around the render method:\n\n```java\nbatch.begin();\nmapper.render();\nbatch.end();\n```\n\n## Adding layers\n\nTo add a layer, you need a layer configuration. This configuration requires a ```LayerTexture``` in order to draw the parallax effect properly. For [LibGDX](http://libgdx.badlogicgames.com/) and [Slick2D](http://slick.ninjacave.com/) exist already implementation of those textures.\n\n```java\nImage image = new Image(\"test.png\"); // Slick2D\nLayerTexture texture = new SlickTexture(image); // Slick2D\nLayerConfig config = new LayerConfig(texture);\nmapper.add(10.0f, config);\n```\n\nThat's all! You can define a so called *z index* in order to specify the distance of the layer. \n\n### Preprocessed Textures\n\nIt is also possible to create textures on your own on runtime! For instance you want to generate some kind of random star field without using a pre-defined image texture. You need to implement ```TextureProcessor``` due to generate a texture on your own:\n\n```\nTexturePreprocessor processor = new SlickTextureProcessor({\n\n   @Override\n   public void process(Graphics g) {\n      g.setColor(Color.red);\n      g.fillRect(0, 0, 10, 10);\n   }\n});\n\nLayerTexture customTexture = new PreprocessedTexture(64, 64, processor);\nconfig.setTexture(customTexture);\nmapper.add(20.0f, config); \n``` \n\nAs you can see it is pretty easy to extend your parallax effect by custom textures.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitbrain%2Fparallax","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbitbrain%2Fparallax","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitbrain%2Fparallax/lists"}