Comments (4)
Here are suggestions for making this a natural step after static sprites. Maybe these are separate issues later?
- 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 - 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)
- 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.
I wrote an AnimationSprite
in mutant games, although this is more like a particle effect.
from pursuedpybear.
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.
Implemented in #230.
from pursuedpybear.
Related Issues (20)
- Relatively Positioned Sprites
- Import warnings in ppb __init__.py HOT 1
- features subpackage doesn't have __init__.py HOT 3
- Update Getting Started HOT 5
- SDLmixererror when invoking ppb.run() HOT 4
- Crash on exit "Error calling SDL_DestroyWindow: Window data not set" HOT 3
- SdlMixerError error when running ppb HOT 2
- Wheels have version 0.0.0 HOT 1
- RectangleSprite objects create a Square image as default. HOT 1
- Design Proposal: Event extensions
- Update Trove classifier from stage "4 - Beta" to "5 - Production/Stable"
- mypy in a ppb project won't type the ppb module.
- Update function
- KeyBoardMovementSprite moves too quickly when moving diagonally HOT 3
- Default sprites are not in doecumentation
- Remove SDL installation step from getting started
- Fix outdated mention of "ship" class in getting started
- Remove mentions of Python 3.8 ahead of its impending end of life
- Updater system does not call `super().__init__`
- Add end-to-end briefcase testing HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pursuedpybear.