GithubHelp home page GithubHelp logo

valkryst / v2dsprite Goto Github PK

View Code? Open in Web Editor NEW
9.0 3.0 0.0 103 KB

A Java2D library which allows for easy management, loading, and use of sprite sheets.

License: Apache License 2.0

Java 100.00%
java2d java2d-game-library sprite-animation sprite-sheet spritesheet sprite atlas texture-atlas sprite-atlas volatileimage

v2dsprite's Introduction

Java CI with Maven

I will eventually publish a sample project, which demonstrates the full use of this library.

Table of Contents

Installation

V2DSprite is hosted on the JitPack package repository which supports Gradle, Maven, and sbt.

Gradle Gradle

Add JitPack to your build.gradle at the end of repositories.

allprojects {
	repositories {
		...
		maven { url 'https://jitpack.io' }
	}
}

Add V2DSprite as a dependency.

dependencies {
	implementation 'com.github.Valkryst:V2DSprite:2023.02.24-break-fixed'
}

Maven Maven

Add JitPack as a repository.

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>

Add V2DSprite as a dependency.

<dependency>
    <groupId>com.github.Valkryst</groupId>
    <artifactId>V2DSprite</artifactId>
    <version>2023.02.24-break-fixed</version>
</dependency>

Scala SBT Scala SBT

Add JitPack as a resolver.

resolvers += "jitpack" at "https://jitpack.io"

Add V2DSprite as a dependency.

libraryDependencies += "com.github.Valkryst" % "V2DSprite" % "2023.02.24-break-fixed"

Terminology

Folder Structure

V2DSprite assumes that all of your data is located within the sprites folder, within your .jar file.

Each subfolder of the sprites folder must contain one sprite sheet, named image.extension and an animations folder.

The animations folder must contain all of the _collisionbox.tsv, _frame.tsv, and _hitbox.tsv files for each animation in the sprite sheet.

See the following heirarchy, as an example:

  • sprites
    • slime_green
      • image.png
      • animations
        • idle_collisionbox.tsv
        • idle_frame.tsv
        • idle_hitbox.tsv
        • walk_collisionbox.tsv
        • walk_frame.tsv
        • walk_hitbox.tsv
    • slime_purple
      • image.tiff
      • animations
        • idle_collisionbox.tsv
        • idle_frame.tsv
        • idle_hitbox.tsv
        • walk_collisionbox.tsv
        • walk_frame.tsv
        • walk_hitbox.tsv
    • skeleton
      • image.jpeg
      • animations
        • attack_collisionbox.tsv
        • attack_frame.tsv
        • attack_hitbox.tsv
        • idle_collisionbox.tsv
        • idle_frame.tsv
        • idle_hitbox.tsv
        • walk_collisionbox.tsv
        • walk_frame.tsv
        • walk_hitbox.tsv

File Structure

Each row of the .tsv files correspond with one another. So, the first row in _frame.tsv defines a Frame and the first row in _collisionbox.tsv defines the Collision Box for that Frame.

You are not required to use the _collisionbox.tsv or _hitbox.tsv files, but they are a useful feature for loading/working with that data in your projects.

Please remember that the values are seperated by tabs, not spaces.

frame.tsv

A Frame is defined by:

  • X-Axis offset, from the top-left pixel of the Sprite Sheet.
  • Y-Axis offset, from the top-left pixel of the Sprite Sheet.
  • Width of the Frame (sprite).
  • Height of the Frame (sprite).
  • Duration, in milliseconds, that the Frame should be displayed during an Animation.

e.g. xOffset yOffset width height duration

collisionbox.tsv

A Collision Box is defined by:

  • X-Axis offset, from the top-left pixel of the Frame.
  • Y-Axis offset, from the top-left pixel of the Frame.
  • Width of the Frame (sprite).
  • Height of the Frame (sprite).

e.g. xOffset yOffset width height

hitbox.tsv

A Hitbox is defined by:

  • X-Axis offset, from the top-left pixel of the Frame.
  • Y-Axis offset, from the top-left pixel of the Frame.
  • Width of the Frame (sprite).
  • Height of the Frame (sprite).

e.g. xOffset yOffset width height

Supported Image Formats

This library uses javax.imageio to load images, and it supports the following formats:

  • bmp
  • gif
  • jpeg/jpg
  • png
  • tiff/tif
  • wbmp

Credits & Inspiration

v2dsprite's People

Contributors

dependabot[bot] avatar valkryst avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

v2dsprite's Issues

Can't pull this repository with Maven.

I added this to the pom.xml, but it can't seem to be found:

...
    <repositories>
        <repository>
            <id>jitpack.io</id>
            <url>https://jitpack.io</url>
        </repository>
    </repositories>
...
    <dependencies>
        <dependency>
            <groupId>com.github.Valkryst</groupId>
            <artifactId>V2DSprite</artifactId>
            <version>2020.04.05-break</version>
        </dependency>
    </dependencies>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.