Skip to content

Releases: BtheDestroyer/SpriteTools

2.2 - Cameras and a User-Friendly Install

21 Mar 06:39
Compare
Choose a tag to compare

Icon SpriteTools 2.2

Ended up borrowing some code from the original SpriteTools to save time here.

Make sure you read the ReadME before asking questions. Many of them are answered there.

How to Use

Extract the Source listed below to an empty folder, then run the command make install to install the library and all of its dependencies. You may need sudo privileges to do so on Linux and macOS.

Attached is an example.2.2.zip file as an example of how to use the library.

New to SpriteTools and/or programming? Check out the Tutorial on the Wiki. It's designed for beginners so even if you have no experience, you should get by fine.

Showcase Video

Showcase Video

New Features

Compiling

It's finally here! You can now compile and install the library to your development environment. No more copy-pasting .c and .h files.

Easy-Install Dependencies

The Makefile can now download and install all needed dependencies on its own! That means you only need to worry about downloading Spritetools to get everything you need - no more repository searching.

Cameras

  • You can create and free cameras using ST_CameraCreate(double x, double y) (returns a pointer to a camera) and ST_CameraFree(st_camera *cam)

  • You can use the following functions to modify a camera by the given values: ST_CameraMoveBy(st_camera *cam, double x, double y), ST_CameraRotateBy(st_camera *cam, float rot), ST_CameraZoomBy(st_camera *cam, float zoom), ST_CameraColorChange(st_camera *cam, u8 r, u8 g, u8 b, u8 a)

  • You can use the following functions to set a camera's settings by the given values: ST_CameraMoveTo(st_camera *cam, double x, double y), ST_CameraRotateSet(st_camera *cam, float rot), ST_CameraZoomSet(st_camera *cam, float zoom), ST_CameraColorSet(st_camera *cam, u8 r, u8 g, u8 b, u8 a)

  • You can render with a camera using ST_RenderEntityCamera(st_entity *entity, st_camera *cam).

  • Alternatively, you can use ST_RenderEntityCameraNoSpriteRot(st_entity *entity, st_camera *cam) render without rotating sprites, just their positions.

Entity Following Cameras

  • You can tell a camera to follow an entity with ST_CameraSetFollowEntity(st_camera *cam, st_entity *ent)

  • Clear the camera's followed entity with ST_CameraClearFollowEntity(st_camera *cam)

  • You can set and modify a camera's offset from the entity it's following with ST_CameraMoveFollowOffsetBy(st_camera *cam, double x, double y) and ST_CameraMoveFollowOffsetTo(st_camera *cam, double x, double y) respectively.

  • Use ST_CameraMoveToFollow(st_camera *cam) to set a camera's position, rotation, and scale to match it's settings relative to the entity it's following. Has no effect if the camera is not following an entity.

  • Cameras now have the following "follow-flags":

Flag Description
CFF_ROTATE_WITH_ENTITY Sets the camera's rotation to the followed entity's rotation
CFF_OFFSET_WITH_ROTATION Modifies the camera's offset by rotating it around the entity by thier rotation value
CFF_INVERT_SCALE_WITH_ENTITY Sets the camera's scale to be the inverse of the followed entity's scale
CFF_OFFSET_WITH_SCALE Modifies the camera's offset by scaling it by the thier scale value
CFF_ALL For use when setting or toggling all flags
  • ST_CameraSetFollowFlag(st_camera *cam, CAMERA_FOLLOW_FLAGS flag, bool state) will set a camera's follow-flag to true or false based on the state given.

  • ST_CameraSetToggleFlag(st_camera *cam, CAMERA_FOLLOW_FLAGS flag, bool state) will toggle a camera's flag on and off.

  • You can use ST_CameraCheckFollowFlag(st_camera *cam, CAMERA_FOLLOW_FLAGS flag) to test if a camera's follow-flag is on.

Main Camera

It can sometimes make code shorter if there is a "Main Camera" in use. An example would be rendering from multiple cameras depending on the buttons being pressed. You can make give every option their own render function which may be more difficult to debug or harder to read, or you can use one "main" camera to render with all the time and have a few if statements switch which camera is the "main" one.

  • ST_MainCameraSet(st_camera *cam) will set the Main Camera to the given camera.

  • ST_MainCameraClear() will clear the Main Camera.

  • ST_MainCameraGet() will return the Main Camera.

Added sfillib Support

In response to #4.

If you have sfillib installed (it will be if you install SpriteTools using the provided Makefile), you can now use the following functions as you would in sfillib. They all return a st_spritesheet *.

  • ST_SpritesheetCreateSpritesheetPNG(const void *buffer)

  • ST_SpritesheetCreateSpritesheetBMP(const void *buffer)

  • ST_SpritesheetCreateSpritesheetJPEG(const void *buffer, unsigned long buffer_size)

β2.2.1 - Make Made Easy!

20 Mar 07:40
Compare
Choose a tag to compare
Pre-release

Icon SpriteTools Beta 2.2.1

NOTE: Forgot to update the splashscreen and don't really have the tools to do so right now. Expect it to be fixed by 2.2's release!

There's some major updates to the Makefile in this version. tl;dr: Install this to get all the dependencies

Make sure you read the ReadME before asking questions. Many of them are answered there.

How to Use

Extract the Source listed below to an empty folder, then run the command make install to install the library and all of its dependencies. You may need sudo privileges to do so on Linux and macOS.

Attached is an example.beta2.2.zip file as an example of how to use the library.

New to SpriteTools and/or programming? Check out the Tutorial on the Wiki. It's designed for beginners so even if you have no experience, you should get by fine. The tutorial for 2.2 will be released with the official release so if you need a tutorial, it's probably best to use an earlier official release rather than a beta.

New Features

Easy-Install Dependencies

The Makefile can now download and install all needed dependencies on its own! That means you only need to worry about downloading Spritetools to get everything you need - no more repository searching.

Entity Following Cameras

  • You can tell a camera to follow an entity with ST_CameraSetFollowEntity(st_camera *cam, st_entity *ent)

  • Clear the camera's followed entity with ST_CameraClearFollowEntity(st_camera *cam)

  • You can set and modify a camera's offset from the entity it's following with ST_CameraMoveFollowOffsetBy(st_camera *cam, double x, double y) and ST_CameraMoveFollowOffsetTo(st_camera *cam, double x, double y) respectively.

  • Use ST_CameraMoveToFollow(st_camera *cam) to set a camera's position, rotation, and scale to match it's settings relative to the entity it's following. Has no effect if the camera is not following an entity.

  • Cameras now have the following "follow-flags":

Flag Description
CFF_ROTATE_WITH_ENTITY Sets the camera's rotation to the followed entity's rotation
CFF_OFFSET_WITH_ROTATION Modifies the camera's offset by rotating it around the entity by thier rotation value
CFF_INVERT_SCALE_WITH_ENTITY Sets the camera's scale to be the inverse of the followed entity's scale
CFF_OFFSET_WITH_SCALE Modifies the camera's offset by scaling it by the thier scale value
CFF_ALL For use when setting or toggling all flags
  • ST_CameraSetFollowFlag(st_camera *cam, CAMERA_FOLLOW_FLAGS flag, bool state) will set a camera's follow-flag to true or false based on the state given.

  • ST_CameraSetToggleFlag(st_camera *cam, CAMERA_FOLLOW_FLAGS flag, bool state) will toggle a camera's flag on and off.

  • You can use ST_CameraCheckFollowFlag(st_camera *cam, CAMERA_FOLLOW_FLAGS flag) to test if a camera's follow-flag is on.

Main Camera

It can sometimes make code shorter if there is a "Main Camera" in use. An example would be rendering from multiple cameras depending on the buttons being pressed. You can make give every option their own render function which may be more difficult to debug or harder to read, or you can use one "main" camera to render with all the time and have a few if statements switch which camera is the "main" one.

  • ST_MainCameraSet(st_camera *cam) will set the Main Camera to the given camera.

  • ST_MainCameraClear() will clear the Main Camera.

  • ST_MainCameraGet() will return the Main Camera.

Added sfillib Support

In response to #4.

If you have sfillib installed (it will be if you install SpriteTools using the provided Makefile), you can now use the following functions as you would in sfillib. They all return a st_spritesheet *.

  • ST_SpritesheetCreateSpritesheetPNG(const void *buffer)

  • ST_SpritesheetCreateSpritesheetBMP(const void *buffer)

  • ST_SpritesheetCreateSpritesheetJPEG(const void *buffer, unsigned long buffer_size)

β2.2 - Smile for the Camera

17 Mar 00:56
Compare
Choose a tag to compare
Pre-release

Icon SpriteTools Beta 2.2

Ended up borrowing some code from the original SpriteTools to save time here.

Make sure you read the ReadME before asking questions. Many of them are answered there.

How to Use

NOTE: SpriteTools currently have the following dependencies that must be installed: ctrulib, citro3d, sf2d (sf2d will eventually not be needed, but for now it is)

Extract the Source listed below to an empty folder, then run the command make install to install the library just like you did for the dependencies above. You may need sudo privileges to do so on Linux and macOS.

Attached is an example.beta2.2.zip file as an example of how to use the library.

New to SpriteTools and/or programming? Check out the Tutorial on the Wiki. It's designed for beginners so even if you have no experience, you should get by fine. The tutorial for 2.2 will be released with the official release so if you need a tutorial, it's probably best to use an earlier official release rather than a beta.

New Features

Compiling

It's finally here! You can now compile and install the library to your development environment. No more copy-pasting .c and .h files.

Cameras

  • You can create and free cameras using ST_CameraCreate(s32 x, s32 y) (returns a pointer to a camera) and ST_CameraFree(st_camera *cam)

  • You can use the following functions to modify a camera by the given values: ST_CameraMoveBy(st_camera *cam, s32 x, s32 y), ST_CameraRotateBy(st_camera *cam, float rot), ST_CameraZoomBy(st_camera *cam, float zoom), ST_CameraColorChange(st_camera *cam, u8 r, u8 g, u8 b, u8 a)

  • You can use the following functions to set a camera's settings by the given values: ST_CameraMoveTo(st_camera *cam, s32 x, s32 y), ST_CameraRotateSet(st_camera *cam, float rot), ST_CameraZoomSet(st_camera *cam, float zoom), ST_CameraColorSet(st_camera *cam, u8 r, u8 g, u8 b, u8 a)

  • You can render with a camera using ST_RenderEntityCamera(st_entity *entity, st_camera *cam).

  • Alternatively, you can use ST_RenderEntityCameraNoSpriteRot(st_entity *entity, st_camera *cam) render without rotating sprites, just their positions.

2.1 - Entities and Optimizations

08 Jan 06:59
Compare
Choose a tag to compare

Icon SpriteTools 2.1

The release of 2.1 is here and it brings with it entities which store animation and character data. There have also been some optimizations which should save a bit of memory.

Make sure you read the ReadME before asking questions. Many of them are answered there.

Trello

You can see our roadmap on this Trello page.

Twitter

Follow this twitter account for future information and updates as well as notices about when a developer is streaming programming.

How to Use

NOTE: SpriteTools currently have the following dependencies that must be installed: ctrulib, citro3d, sf2d (sf2d will eventually not be needed, but for now it is)

Extract the Source listed below, copy the source and include folders into your project, then you can start using any of the functions in this project in your own. You can then access all functions and features of the library in your project.

Attached is an example.2.1.zip file as an example of how to use the library.

New to SpriteTools and/or programming? Check out the Tutorial on the Wiki. It's designed for beginners so even if you have no experience, you should get by fine.

Already read the entire tutorial from 2.0? Here's the next entry: 6. Entities

List of All Features

Check out this page on the Wiki for a list of all features of the library.

β2.1 - From Frames come Animations and From Animations come Entities

06 Jan 00:52
Compare
Choose a tag to compare

Icon SpriteTools Beta 2.1

This is the addition that has caused me the most trouble both now and in the past: entities. Hopefully our efforts here will relieve those using SpriteTools!

Make sure you read the ReadME before asking questions. Many of them are answered there.

How to Use

NOTE: SpriteTools currently have the following dependencies that must be installed: ctrulib, citro3d, sf2d (sf2d will eventually not be needed, but for now it is)

Extract the Source listed below, copy the source and include folders into your project, then you can start using any of the functions in this project in your own. You can then access all functions and features of the library in your project.

Attached is an example.beta2.1.zip file as an example of how to use the library.

New to SpriteTools and/or programming? Check out the Tutorial on the Wiki. It's designed for beginners so even if you have no experience, you should get by fine. The tutorial for 2.1 will be released with the official release so if you need a tutorial, it's probably best to use an earlier official release rather than a beta.

New Features

Entities

  • You can create and free entities using ST_EntityCreateEntity(s64 x, s64 y, u8 animCount) (returns a pointer to an entity) and ST_EntityFreeEntity(st_entity *entity)
  • You can add an animation to an entity using ST_EntityAddAnimation(st_entity *entity, st_animation *anim, char *name)
  • You can set the attributes of entities using the following functions:
Function Description
ST_EntitySetXPosition(st_entity *entity, s64 x) Sets the entity's X position to the given value
ST_EntitySetYPosition(st_entity *entity, s64 y) Sets the entity's Y position to the given value
ST_EntitySetPosition(st_entity *entity, s64 x, s64 y) Sets the entity's position to the given values
ST_EntitySetScale(st_entity *entity, double scale) Sets the entity's scale to the given value
ST_EntitySetRotation(st_entity *entity, double rotation) Sets the entity's rotation to the given value
ST_EntitySetRed(st_entity *entity, u8 red) Sets the red of an entity's blending color
ST_EntitySetGreen(st_entity *entity, u8 green) Sets the green of an entity's blending color
ST_EntitySetBlue(st_entity *entity, u8 blue) Sets the blue of an entity's blending color
ST_EntitySetAlpha(st_entity *entity, u8 alpha) Sets the alpha of an entity's blending color
ST_EntitySetColor(st_entity *entity, u8 red, u8 green, u8 blue, u8 alpha) Sets the values of an entity's blending color
ST_EntitySetDirection(st_entity *entity, char *dir) Sets the entity's direction by name ie: "west", "south", "north east"
ST_EntitySetDirectionId(st_entity *entity, u8 dir) Sets the entity's direction by id ie: 0 for "east", 3 for "south west", 6 for "north"
ST_EntitySetAnimationName(st_entity *entity, char *name) Sets the entity's current animation by name (if the animation exists)
ST_EntitySetAnimationId(st_entity *entity, u8 id) Sets the entity's current animation by id (if the animation exists)
  • If you just want to modify the entity's values rather than setting them (ie: add 5 to the x position) you can use these functions:
Function Description
ST_EntityModifyXPosition(st_entity *entity, s64 x) Adds the given value to the entity's x position
ST_EntityModifyYPosition(st_entity *entity, s64 y) Adds the given value to the entity's y position
ST_EntityModifyPosition(st_entity *entity, s64 x, s64 y) Adds the given values to the entity's position values
ST_EntityModifyScale(st_entity *entity, double scale) Adds the given value to the entity's scale
ST_EntityModifyRotation(st_entity *entity, double rotation) Adds the given value to the entity's rotation
ST_EntityModifyRotationNoWrap(st_entity *entity, double rotation) Same as above, but will not wrap past 0 or 2*pi
ST_EntityModifyRed(st_entity *entity, u8 red) Adds the given value to the red of an entity's blending color
ST_EntityModifyRedNoWrap(st_entity *entity, u8 red) Same as above, but will not wrap past 0 or 255
ST_EntityModifyGreen(st_entity *entity, u8 green) Adds the given value to the green of an entity's blending color
ST_EntityModifyGreenNoWrap(st_entity *entity, u8 green) Same as above, but will not wrap past 0 or 255
ST_EntityModifyBlue(st_entity *entity, u8 blue) Adds the given value to the blue of an entity's blending color
ST_EntityModifyBlueNoWrap(st_entity *entity, u8 blue) Same as above, but will not wrap past 0 or 255
ST_EntityModifyAlpha(st_entity *entity, u8 alpha) Adds the given value to the alpha of an entity's blending color
ST_EntityModifyAlphaNoWrap(st_entity *entity, u8 alpha) Same as above, but will not wrap past 0 or 255
ST_EntityModifyColor(st_entity *entity, u8 red, u8 green, u8 blue, u8 alpha) Adds the given values to the values of an entity's blending color
ST_EntityModifyColorNoWrap(st_entity *entity, u8 red, u8 green, u8 blue, u8 alpha) Same as above, but will not wrap past 0 or 255
ST_EntityModifyDirection(st_entity *entity, s8 dir) Modifies the entity's direction by the given value. Positive turns right, negative turns left
  • Entities can also hold up to 32 unnamed flags which can be turned on or off using the functions ST_EntityFlagOn(st_entity *entity, u8 flag), ST_EntityFlagOff(st_entity *entity, u8 flag), andST_EntityFlagToggle(st_entity *entity, u8 flag)`.
  • You can get these flags using the function ST_EntityFlagGet(st_entity *entity, u8 flag) which returns a 1 or a 0 if the flag is on (1) or off (0).
    • For example, you could use flag 0 as "walking"so if the entity's flag 0 is on, it will play the walking animation but if it is off, it will play the standing animation.
  • You can render entities using ST_RenderEntity(st_entity *entity) which will display the current animation as set by ST_EntitySetAnimationName(st_entity *entity, char *name) or ST_EntitySetAnimationId(st_entity *entity, u8 id).

Frames

  • There's a new function ST_AnimationCreateFrameOffset(st_spritesheet *spritesheet, unsigned int xleft, unsigned int ytop, unsigned int width, unsigned int height, unsigned int xoff, unsigned int yoff) which gives a frame an x and y offset when being rendered.
    • A positive x offset will render a frame to the left, while a negative x offset will render a frame to the right.
    • A positive y offset will render a frame higher, while a negative y offset will render a frame lower.

Debugger

  • The debugger used to create issues (error or crash) if scrolled past the added variables (in certain situations) and show a ton of VOID variables with no name that all pointed to NULL. The debugger will now show UNK variables in these slots and will not show a name or value. This should also fix those obscure errors and crashes.

2.0 - Revamped and Rereleased!

02 Jan 02:47
Compare
Choose a tag to compare

Icon SpriteTools 2.0

After much anticipation, SpriteTools Version 2.0 has been officially released!

Make sure you read the ReadME before asking questions. Many of them are answered there.

Trello

You can see our roadmap on this Trello page.

Twitter

Follow this twitter account for future information and updates as well as notices about when a developer is streaming programming.

How to Use

NOTE: SpriteTools currently have the following dependencies that must be installed: ctrulib, citro3d, sf2d (sf2d will eventually not be needed, but for now it is)

Extract the Source listed below, copy the source and include folders into your project, then you can start using any of the functions in this project in your own. You can then access all functions and features of the library in your project.

Attached is an example.zip file as an example of how to use the library.

New to SpriteTools and/or programming? Check out the Tutorial on the Wiki. It's designed for beginners so even if you have no experience, you should get by fine.

List of All Features

Check out this page on the Wiki for a list of all features of the library.

β2.0.3 - Final Cleanup

31 Dec 05:35
Compare
Choose a tag to compare
Pre-release

Icon SpriteTools Beta 2.0.3

Well that was fast! Speaking of fast, I'll be writing a full tutorial tomorrow which will mark the official release of SpriteTools 2.0.

Make sure you read the ReadME before asking questions. Many of them are answered there.

How to Use

Extract the Source, copy everything into your project's respective folders (include goes to include, source goes to source), then you can start using any of the functions in this project in your own.

NOTE: SpriteTools currently have the following dependencies that must be installed: ctrulib, citro3d, sf2d (sf2d will eventually not be needed, but for now it is)

Attached is an example.zip file as an example of how to use the debugging functions.

There will be a more detailed tutorial coming up in the future with an official release of 2.0 on the wiki.

New Features

General Use

  • You can now use ST_TimeRunning() to get the time in ms from program start (specifically, time since the module is initialized with either ST_Init() or ST_TimeInit())
  • You can also get the time since January 1st, 1990 in ms with ST_TimeOS()
  • You can get the time the program started (specifically, when the module was initialized) with ST_TimeStarted()
  • Functions either Initializing and Finishing modules or SpriteTools as a whole (ie with ST_Init() or ST_Fini()) will now return 1 on success and 0 on failure.

Debugger

  • You can now view memory usage and FPS in the standard debugger.
  • On that topic, you can now get the FPS using ST_RenderFPS()

Rendering

  • You can get the background color using ST_RenderGetBackground()
  • You can set the background color using ST_RenderSetBackground(u8 red, u8 green, u8 blue)
  • Displaying the splashscreen with ST_Splashscreen(u64 time) will now change the background color to black and then restore it after completion.

Rendering Animations

  • If an animation's speed (or fpf for "frames per frame") is negative, the animation will now go backwards when ST_RenderAnimationPlay(st_animation *animation, int x, int y) is used.
  • For advanced rendering options, there are now Advanced versions of all four animation rendering functions which also take a scalar multiplier, rotation value in radians, and red, green, blue, and alpha of a color to blend the sprite with.
    • ST_RenderAnimationCurrentAdvanced(st_animation *animation, int x, int y, double scale, double rotate, u8 red, u8 green, u8 blue, u8 alpha)
    • ST_RenderAnimationNextAdvanced(st_animation *animation, int x, int y, double scale, double rotate, u8 red, u8 green, u8 blue, u8 alpha)
    • ST_RenderAnimationPreviousAdvanced(st_animation *animation, int x, int y, double scale, double rotate, u8 red, u8 green, u8 blue, u8 alpha)
    • ST_RenderAnimationPlayAdvanced(st_animation *animation, int x, int y, double scale, double rotate, u8 red, u8 green, u8 blue, u8 alpha)

β2.0.2 - SpriteTools? More like AnimationTools!

31 Dec 02:49
Compare
Choose a tag to compare

Icon SpriteTools Beta 2.0.2

Time to animate those sprites we made in the last version!

Make sure you read the ReadME before asking questions. Many of them are answered there.

How to Use

Extract the Source, copy everything into your project's respective folders (include goes to include, source goes to source), then you can start using any of the functions in this project in your own.

NOTE: SpriteTools currently have the following dependencies that must be installed: ctrulib, citro3d, sf2d (sf2d will eventually not be needed, but for now it is)

Attached is an example.zip file as an example of how to use the debugging functions.

There will be a more detailed tutorial coming up in the future with an official release of 2.0 on the wiki.

New Features

Sprite Rendering

There was a thing or two we missed last time, so let's add them now:

  • ST_RenderSpriteAdvanced(st_frame *frame, int x, int y, double scale, double rotate, u8 red, u8 green, u8 blue, u8 alpha) adds all features of frame rendering.
  • ST_RenderCurrentScreen() will give you the current screen being rendered to

Splashscreen

  • You can use the function ST_Splashscreen(u64 time) to display a "Made with SpriteTools" splashscreen after ST_Init(). It's not a requirement, but we appreciate it when people give credit this way.

Splashscreen

Animation Frames

  • st_frame is a datatype that stores a frame of animation or sprite from a spritehseet.
  • You can use ST_AnimationCreateFrame(st_spritesheet *spritesheet, unsigned int xleft, unsigned int ytop, unsigned int width, unsigned int height) to get a pointer to an st_frame.
  • You can use ST_AnimationFreeFrame(st_frame *frame) to free an st_frame.

The following functions render frames:

Function Description
ST_RenderFramePosition(st_frame *frame, int x, int y) Draws a frame at a given position
ST_RenderFrameScale(st_frame *frame, int x, int y, double scale) Draws scaled frame at given position
ST_RenderFrameRotate(st_frame *frame, int x, int y, double rotate) Draws rotated frame at given position
ST_RenderFramePositionAdvanced(st_frame *frame, int x, int y, double scale, double rotate, u8 red, u8 green, u8 blue, u8 alpha) Draws scaled, rotated, and blended frame at given position

Animations

  • st_animation is a datatype that stores a list of frames as well as information about how they should be played.

  • You can use ST_AnimationCreateAnimation(u16 fpf, u16 loopFrame, u16 length, ...) to make a pointer to an st_animation. Make sure you free your animation and its frames with ST_AnimationFreeAnimation(st_animation *animation) ie:

    st_animation *link_o_walk_down = ST_AnimationCreateAnimation(3, 0, 10,
      ST_AnimationCreateFrame(link_overworld_s, 30, 2, 18, 24),
      ST_AnimationCreateFrame(link_overworld_s, 30, 2, 18, 24),
      ST_AnimationCreateFrame(link_overworld_s, 56, 1, 18, 25),
      ST_AnimationCreateFrame(link_overworld_s, 82, 0, 18, 26),
      ST_AnimationCreateFrame(link_overworld_s, 108, 0, 18, 26),
      ST_AnimationCreateFrame(link_overworld_s, 134, 1, 18, 25),
      ST_AnimationCreateFrame(link_overworld_s, 160, 2, 18, 24),
      ST_AnimationCreateFrame(link_overworld_s, 186, 1, 18, 25),
      ST_AnimationCreateFrame(link_overworld_s, 212, 0, 18, 26),
      ST_AnimationCreateFrame(link_overworld_s, 238, 0, 18, 26),
      ST_AnimationCreateFrame(link_overworld_s, 264, 1, 18, 25));
    /* -- CODE -- */
    ST_AnimationFreeAnimation(link_o_walk_down);
    

Rendering Animations

You can modify how animations play with the following functions:

Function Description
ST_AnimationSetFrame(st_animation *animation, u16 frame) Sets the current frame of an animation
ST_AnimationNextFrame(st_animation *animation) Adds 1 to the current frame of an animation. Wraps to 0 if needed
ST_AnimationPreviousFrame(st_animation *animation) Subtracts 1 from the current frame of an animation. Wraps to last frame if needed
ST_AnimationSetSpeed(st_animation *animation, s16 speed) Sets the playback speed of an animation

You can use the following functions to display animations:

Function Description
ST_RenderAnimationCurrent(st_animation *animation, int x, int y) Draws the current frame of an animation at the given position
ST_RenderAnimationNext(st_animation *animation, int x, int y) Draws the next frame of an animation at the given position
ST_RenderAnimationPrevious(st_animation *animation, int x, int y) Draws the previous frame of an animation at the given position
ST_RenderAnimationPlay(st_animation *animation, int x, int y) Plays an animation at the given position. This also accounts for the animation's speed.

β2.0.1 - Putting "Sprite" in "SpriteTools"

27 Dec 22:53
Compare
Choose a tag to compare

Icon SpriteTools Beta 2.0.1

Now for what we actually started this project for: sprites!

Make sure you read the ReadME before asking questions. Many of them are answered there.

How to Use

Extract the Source, copy everything into your project's respective folders (include goes to include, source goes to source), then you can start using any of the functions in this project in your own.

NOTE: SpriteTools currently have the following dependencies that must be installed: ctrulib, citro3d, sf2d (sf2d will eventually not be needed, but for now it is)

Attached is an example.zip file as an example of how to use the debugging functions.

There will be a more detailed tutorial coming up in the future with an official release of 2.0 on the wiki.

New Features

General Use

  • There are now the functions ST_Init() and ST_Fini() to initialize and finish every section of the library. Rather than initializing each section individually, just use this one function.
  • SPRITETOOLS_VERSION is a new define which can be used to get the current version as a const char *. ie: right now it is defined as `"Beta 2.0.1"

Sprites/Spritesheets

SpriteTools currently acts as an extension to SF2D by xerpi. This means that if you are familiar with his library, this will be fairly familiar to you. It also means that you will need it installed to use ST until we develop our own rendering system. While you can use SF2D functions with ST objects and vice versa, it is recommended that you only use one or the other when possible as this cross functionality may one day stop working.

  • You can load and free spritesheets to and from memory using ST_SpritesheetCreateSpritesheet(const unsigned char *pixel_data, unsigned int width, unsigned int height) (returns st_spritesheet *) and ST_SpritesheetFreeSpritesheet(st_spritesheet *spritesheet).

Rendering

  • ST_RenderInit() initializes the rendering engine while ST_RenderFini() cleans it up.
  • ST_RenderStartFrame(gfxScreen_t screen) will start a frame on the specified screen (GFX_TOP or GFX_BOTTOM)
  • ST_RenderEndRender() will display the rendered frame on both the top and bottom screens (swap buffers etc.)

Spritesheets

  • You can render spritesheets using ST_RenderSpritesheet(st_spritesheet *spritesheet).
  • You can also use ST_RenderSpritesheetPosition(st_spritesheet *spritesheet, int x, int y) to offset their position.

Sprites

  • You can use ST_RenderSpritePosition(st_spritesheet *spritesheet, unsigned int xleft, unsigned int ytop, unsigned int width, unsigned int height, int x, int y) to render a sprite in a spritesheet at a given position.
  • ST_RenderSprite(st_spritesheet *spritesheet, unsigned int xleft, unsigned int ytop, unsigned int width, unsigned int height) can also be used to just put it at 0,0.
  • The other variants also allow rotation and scaling of a given sprite: ST_RenderSpritePositionScale(st_spritesheet *spritesheet, unsigned int xleft, unsigned int ytop, unsigned int width, unsigned int height, int x, int y, double scale), ST_RenderSpritePositionRotate(st_spritesheet *spritesheet, unsigned int xleft, unsigned int ytop, unsigned int width, unsigned int height, int x, int y, double rotate), and ST_RenderSpritePositionScaleRotate(st_spritesheet *spritesheet, unsigned int xleft, unsigned int ytop, unsigned int width, unsigned int height, int x, int y, double scale, double rotate).

β2.0 - Debugging for all

25 Dec 06:06
Compare
Choose a tag to compare
Pre-release

Icon SpriteTools Beta 2.0

A major issue I had last time was with debugging things. This time around, we've started by adding debugging features among other things that will all make future development easier for us and you.

Make sure you read the ReadME before asking questions. Many of them are answered there.

How to Use

Extract the Source, copy everything into your project's respective folders (include goes to include, source goes to source), then you can start using any of the functions in this project in your own.

Attached is a main.c file as an example of how to use the debugging functions.

There will be a more detailed tutorial coming up in the future with an official release of 2.0 on the wiki.

Debugging

tl;dr: You can use ST_DebugDisplay() to display a debugger with information like what buttons are being pressed and the values of currently tracked variables.

General Debugging

  • ST_DebugInit() should be placed when your program is starting up to ensure values are initialized correctly.

  • ST_DebugSetOn() and ST_DebugSetOff() can be used to turn this debugger (and other debug messages) on and off.

  • ST_DebugGet() retrieves the current debug state. You can use this in if statements to only run code if you're debugging. This is 0 (false) by default, so make sure you turn debugging on if you plan on using it!

  • ST_DebugPrint(char *str) will print any string its given, but only if you are currently debugging.

  • ST_DebugAddVar(char *name, void *varp, ST_PointerType datatype) will tell the debugger to start tracking a variable for use with ST_DebugPrintVar functions (see below). Example:

    int myvar = 3;
    ST_DebugAddVar("three", (void *) &myvar, INT);
    ST_DebugPrintVarName("three");
    
  • ST_DebugRemoveId(int id), ST_DebugRemoveName(char *name), and ST_DebugRemoveLast() all tell the debugger to stop tracking a variable. The first one takes the id of the variable being tracked (0 to 63), the second takes the name of the variable (in the debugger, not in the code meaning the above example would use "three" and not "myvar"), and the third will remove the last one in the list (if indexes 1, 2, 4, 7, and 9 are taken, it'll remove 9).

  • ST_DebugPrintVarId(int id) and ST_DebugPrintVarName(char *name) will both print a variable's type, name, and data on the screen (if debugging is on). The first takes the id of the variable to display and the second takes its name (in the debugger, not in the code meaning the above example would use "three" and not "myvar").

  • ST_DebugPrintVarIdPosition(int id, int x, int y) and ST_DebugPrintVarNamePosition(char *name, int x, int y) do the same as their counterparts, but also take an x and y position to be printed at.

There are a few more variable printing commands that a table will be useful for:

Function Description
ST_DebugPrintVarAll() Prints all variables being tracked
ST_DebugPrintVarAllPosition(int x, int y) Same as above, but also takes a position
ST_DebugPrintVarAllUntil(int max) Prints all variables being tracked from 0 until a given max
ST_DebugPrintVarAllUntilPosition(int max, int x, int y) Same as above, but also takes a position
ST_DebugPrintVarAllFrom(int start) Prints all variables being tracked from a given start onwards
ST_DebugPrintVarAllFromPosition(int start, int x, int y) Same as above, but also takes a position
ST_DebugPrintVarAllFromUntil(int start, int max) Prints variables being tracked from a given start until a given max
ST_DebugPrintVarAllFromUntilPosition(int start, int max, int x, int y) Same as above, but also takes a position
  • ST_DebugScrollUp(int scroll) and ST_DebugScrollDown(int scroll) can be used to alter an internal integer that can be retrieved with ST_DebugGetScroll(). This can be used for scrolling through the set of variables being printed.
  • ST_DebugDisplay() will take care of all the printing for you and will just print all the information you need. It also uses the scroll variable talked of above.
  • ST_DebugClear() is simple and just clears the entire console.

Button Debugging

  • ST_DebugButtonA(), ST_DebugButtonB(), ST_DebugButtonX(), etc. will display if the button is pressed or not by printing to the screen (if debugging is on) and returning 0 (not pressed), 1 (just pressed), or 2 (currently held). There are functions for A, B, X, Y, Start, Select, R, L, and Dpad directions (DUp, DRight, DDown, DLeft).
  • ST_DebugButtonFormatted() will print all of the buttons' statuses (if debug is on) in a 12 wide, 3 tall area.
  • ST_DebugButtonFormattedAtPosition(int x, int y) does the same as above but also takes a position.

Input

tl;dr: use ST_InputScan() to scan all input devices and then a few other functions to get critical information like buttons being pressed, held, and released, the touch screen's current touch position, or the gyroscope's rotation.

General Input

  • ST_InputInit() initializes the input system.
  • ST_InputScan() scans all inputs including buttons, touch screen, gyroscope, and accelerometer. All future input functions require this be run first
  • ST_InputButtonPressed(u32 key), ST_InputButtonDown(u32 key), and ST_InputButtonReleased(u32 key) all take a key (you can use ctrulib's macros like KEY_A for the A button) and return 1 (true) or 0 (false) depending on if the key was just pressed, is currently held, or was just released.

Touchscreen

  • ST_InputTouchX() and ST_InputTouchY() will return the X and Y positions of the current touch on the touch screen.
  • ST_InputTouchOriginX() and ST_InputTouchOriginY() will return the X and Y positions of where the current touch started.
  • ST_InputTouchDistanceX() and ST_InputTouchDistanceY() will return the X and Y distance from the origin of the current touch to the current touch's position.
  • ST_InputTouchDistance() will return the direct distance between the origin and currently touched point.
  • ST_InputTouchLength() will return the length in pixels that the current touch has drawn (ie: length of a curve that has been drawn).

Circle Pad

  • ST_InputCirclePadX() returns the X position of the circle pad.
  • ST_InputCirclePadY() returns the Y position of the circle pad.

Accelerometer

  • ST_InputAccel() returns the vector of the accelerometer as an accelVector.
  • ST_InputAccelX(), ST_InputAccelY(), and ST_InputAccelZ() return the x, y, and z of the accelerometer respectively.

Gyroscope

  • ST_InputGyro() returns the angular rate of the gyroscope as an angularRate.
  • ST_InputGyroRoll(), ST_InputGyroYaw(), and ST_InputGyroPitch() return the roll, yaw, and pitch of the gyroscope respectively.

Text Modifications

tl;dr: You can change the color of the console's text with functions like ST_TextRedFore(), the background with functions like ST_TextYellowBack(), and add effects with functions like ST_TextUnderline();

Colors

Color Foreground Background
Black ST_TextBlackFore() ST_TextBlackBack()
Red ST_TextRedFore() ST_TextRedBack()
Green ST_TextGreenFore() ST_TextGreenBack()
Yellow ST_TextYellowFore() ST_TextYellowBack()
Blue ST_TextBlueFore() ST_TextBlueBack()
Magenta ST_TextMagentaFore() ST_TextMagentaBack()
Cyan ST_TextCyanFore() ST_TextCyanBack()
White ST_TextWhiteFore() ST_TextWhiteBack()
Default ST_TextDefaultFore() ST_TextDefaultBack()

Effects

Function Effect
ST_TextBright() Sets foreground to a brighter shade
ST_TextDark() Sets foreground to a darker shade
ST_TextNoBright() Turns off the two above
ST_TextUnderline() Turns on underlining
ST_TextNoUnderline() Turns off underlining
`ST_TextNegative() Swaps the background and foreground colors
`ST_TextPositive() Turns off the above
ST_TextStrikethrough() Turns on strikethrough
ST_TextNoStrikethrough() Turns off strikethrough

Defaults

  • ST_TextDefault() can be used to restore all text defaults.