SpriteTools 1.1.1 - SF2D Extension

Discussion in '3DS - Homebrew Development and Emulators' started by BtheDestroyer, Jul 28, 2016.

  1. BtheDestroyer
    OP

    BtheDestroyer Member

    Newcomer
    14
    15
    Apr 1, 2016
    United States
    Notice
    SpriteTools has been rewritten so this post is now outdated! Please check out this thread for new information: https://gbatemp.net/threads/spritetools-a-3ds-development-library-aimed-at-be.465146/

    What is SpriteTools?
    In short, SpriteTools is a C header that works on top of sf2d to add some powerful tools for rendering sprites on screen.
    As of 1.1.1, it adds:

    • Animations with spritesheets
    • Entities that can be rendered and controlled with one function
    • Cameras that can be used to modify how entities are rendered in various ways
    Here's a video showcasing what it can do with only 74 lines of code in v1.1:


    What's to come:
    • Rooms that store cameras and entities so you can store them together for easier switching
    • 3D rotation of entities utilizing zooming
    Most recent update:

    Where can I get it?

    Here's a link to the Github page.


    Here's a link to the releases page.

    Here's a link to the tutorial I wrote. It's geared at beginners, so you should be good to go even if you haven't programmed much in the past

    If you have curl, you can add this line to your makefile (or just run the command without the @) to automatically download the latest commit to your /include/ folder:

    Master branch (fully tested)
    Code:
    @curl https://raw.githubusercontent.com/BtheDestroyer/SpriteTools/master/spritetools.h  > include/spritetools.h
    Gold branch (Not yet tested, may contain some bugs)
    Code:
    @curl https://raw.githubusercontent.com/BtheDestroyer/SpriteTools/Gold/spritetools.h  > include/spritetools.h
     
    Last edited by BtheDestroyer, Mar 20, 2017
  2. NichyXD

    NichyXD GBAtemp Regular

    Member
    124
    63
    Feb 13, 2015
    Italy
    Really nice work. Bravo! ;)
     
  3. Goombi

    Goombi Meme crypto = my crypto

    Member
    143
    53
    Jun 1, 2014
    France
    RnVja1lvdU15RHVkZQ
    Well done, that's some nice stuff
     
  4. BtheDestroyer
    OP

    BtheDestroyer Member

    Newcomer
    14
    15
    Apr 1, 2016
    United States
    For the few wondering, this project is *not* dead, I was just taking a little break. I'm currently adding rooms which store entities (up to 1024), cameras (up to 16), and a background (animation) meaning you can create different rooms for each area (inside a town, floors of a building, rooms of a dungeon, etc.) and then switch the current room rather than switching everything separately and having to keep track.

    I've also added collision detection (not implemented in the movement function yet) and will probably add a structure for collision fields as well.

    Lastly, you will be able to set a room's default state, so that whenever the player leaves and reenters (or otherwise reloads the room) it will set all of its entities and cameras to the default setting rather than picking up where you left off. This is useful for something like a dungeon in Zelda, where all the enemies respawn when you exit and reenter a room.
     
  5. catlover007

    catlover007 GBAtemp Regular

    Member
    158
    178
    Oct 23, 2015
    Germany
    Isn't putting everything in a single header file is pretty stupid?

    Because when you include it into multiple source file every symbol gets duplicated and weird linker errors occur, because of functions defined more than one time
     
  6. BtheDestroyer
    OP

    BtheDestroyer Member

    Newcomer
    14
    15
    Apr 1, 2016
    United States
    I'm planning on splitting it up in the next update as well. Rather than just spritetools.h there will also be stanimations.h, stentities.h, stcameras.h, strooms.h, etc.

    EDIT: Also, does SF2D not do the same thing (only use one header)? I've never had an issue with including headers across multiple source files, so maybe your makefile has something wrong in it.
     
    Last edited by BtheDestroyer, Aug 10, 2016
  7. catlover007

    catlover007 GBAtemp Regular

    Member
    158
    178
    Oct 23, 2015
    Germany
    you are probably new to C?
     
  8. BtheDestroyer
    OP

    BtheDestroyer Member

    Newcomer
    14
    15
    Apr 1, 2016
    United States
    That I am.
     
  9. catlover007

    catlover007 GBAtemp Regular

    Member
    158
    178
    Oct 23, 2015
    Germany
    When you do an #include, the file gets actually embedded into the file, this gets done before everything else in the same step where all macros get resolved.
    In C you have to seperate your code in header and source files, where the source files contain the actual source code, while the header files contain predefinitons of functions(like so void testFunction(int arg1);). This is needed because the compiler doesn't know by itself about symbols from other source files, except when they get declared like above. Then in the next step, the linker resolves all referenced symbols by gathering the symbol files(.o) and the external linked files(when you use a library). Then the linker outputs the final binary.

    See here how to seperate your code correctly: http://stackoverflow.com/documentat...header-include-guards#t=201608102122073242157
     
    BtheDestroyer likes this.
  10. BtheDestroyer
    OP

    BtheDestroyer Member

    Newcomer
    14
    15
    Apr 1, 2016
    United States
    Last edited by BtheDestroyer, Aug 10, 2016