Giter VIP home page Giter VIP logo

Comments (4)

ironfroggy avatar ironfroggy commented on August 27, 2024

Here are suggestions for making this a natural step after static sprites. Maybe these are separate issues later?

  1. If you already have a sprite.png adding number postfixed images in the same location (sprite-2.png, etc.) will create an animation automatically, at the base FPS
  2. If the numbers are consecutive (1, 2, 3, 4...) the animation frames run at a consistent rate. If a frame number is skipped, it indicates a pause (1, 2, 10, 11)
  3. Sprite classes have an optional "Sprite FPS" attribute that customizes the frame rate of the animation associated with that sprite. For example, if the game is running at 60 FPS and the Sprite FPS is 12, each image holds for 5 game frames. Maybe there could be a game-wide default you can adjust? Dunno.

from pursuedpybear.

AstraLuma avatar AstraLuma commented on August 27, 2024

I wrote an AnimationSprite in mutant games, although this is more like a particle effect.

from pursuedpybear.

jamesBrosnahan avatar jamesBrosnahan commented on August 27, 2024

OpenGL uses texture coordinates to map multiple textures to a single image file. The top left of the image is index 0,0 and the bottom right is 1,1. If you have a sprite sheet like this: fire animation sprite-sheet the texture coordinates for the first frame in the animation are [(0,0), (0,0.125), (0.125, 0.125), (0.125, 0)] note: the coordinates are counterclockwise this is explained in this link why-should-i-create-vertices-counter-clockwise-and-not-clockwise as allowing back face culling to be used. In the example sprite-sheet the frames are in a 2d left-to-right array this configuration and the alternative top-down listing of frames are special cases that deserve to be programmed as presets for an animated-sprite-sheet class.

For implementing sprite animations; I recommend creating a dataclass that holds the texture coordinates, and frame number; then using a generator class to represent the animation how-to-write-a-generator-class
def animation-generator(sprite-sheet, frame-number): //check if frame exists as an entry into the dictionary of frames if not dictionary-of-computed-frames[frame-number]: list-of-computed-frames[] = (compute-texture-coordinate-using-callback-function) return dictionary-of-computed-frames[frame-number]

explanation of texture coordinates for uv mapping on stackoverflow: how do opengl texture coordinates work

from pursuedpybear.

AstraLuma avatar AstraLuma commented on August 27, 2024

Implemented in #230.

from pursuedpybear.

Related Issues (20)

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.