We are working now on adding sprite flipping features to
CPCtelera (http://lronaldo.github.io/cpctelera) 1.4. and this is a first mini demo:
* Direct link to video (Youtube). (https://www.youtube.com/watch?v=hCtLluBWhGQ)
* Source Code (http://bit.ly/cpct-sprite-flip)
* DSK and CDT files (http://fremos.cheesetea.com/download/cpctelera-sprite-flipping-demo/#)
Features planned for
CPCtelera (http://lronaldo.github.io/cpctelera) 1.4. include:
- Sprite direct flipping (flipping an sprite data array)
- Sprite flipped drawing (draw a sprite flipped, without flipping it previously in data array)
- Sprite flipped drawing with Interlaced Mask and/or mask table
- Both horizontal and vertical flipping
- Every function will have compact and fast versions
Use of special sort of sprites (like half-pre-flipped) will not be supported in this release, but is planned for future ones.
Enjoy! :D
Demo Credits:
- Spirit image based on Little Candele Monsters (http://opengameart.org/content/little-candle-monsters) by C-TOY (http://c-toy.blogspot.com.es/). Thanks to C-TOY (http://c-toy.blogspot.com.es/) for sharing it.
- Music theme from Super Cauldron Game by Christian Lier
Nice. Look forward to that, will save loads of RAM. Will you also be adding sprite scaling too?
Yes, it's planed. However, it will probably be for future releases (say 1.5 or 2.0). There are many features to add and we are trying to order them starting from those we think will have greater use.
Will you use expansion RAM for things like Sprite scaling, flipping etc.?
Probably not in first place. We are considering giving direct support to CPC Expansions in the future, but that's still to be designed. First priority is giving nice support for standard CPC architecture.
Well, it's a lot of hard work. And you really archived something never seen before for CPC. :)
Another Little video, showing
Mode 1 Sprite Flipping. This example is
fully coded in assembler, for those who want to learn and use
CPCtelera (https://lronaldo.github.io/cpctelera) in ASM:
(Video URL: http://www.youtube.com/watch?v=4cJPMTr8y9s (http://www.youtube.com/watch?v=4cJPMTr8y9s))
- Source Code (Assembler) (http://bit.ly/cpct-sprite-flipm1)
- CDT & DSK (http://fremos.cheesetea.com/download/cpctelera-sprite-flipping-mode-1-demo/)
Enjoy :).
Very nice.
After your first example I though that perhaps you were drawing the sprite horizontally flipped on the fly, then I remembered how weirdly the CPC expects the pixel data to be arranged... and it wouldn't be possible to do it fast enough.
This technique is interesting, even if it requires a lot of flipping (eg, same sprite drawn several times facing opposite directions).
off-topic: I have an English teacher here that just said "astonishingly", re: "Astonishing fast Amstrad CPC game engine for C developers" ;)
Quote from: reidrac on 17:10, 06 April 16
After your first example I though that perhaps you were drawing the sprite horizontally flipped on the fly, then I remembered how weirdly the CPC expects the pixel data to be arranged... and it wouldn't be possible to do it fast enough.
It's actually quite easy to do if you go via a 256 byte lookup table. And with a little cunning you can use the same trick for doing things like flashing a sprite when it is hit just by using a different lookup.
@reidrac (http://www.cpcwiki.eu/forum/index.php?action=profile;u=1504): There are planned functions for drawing flipped sprites on the fly (and I've already implemented one of them, but it is still pending revision and documenting). Rearranging bits is "slow" but not so slow as not to be done on-the-fly, even without a look-up table. If you have a look at the implementation of these functions, the time/space requirements are measured and documented. You may check them as a guide to know if this kind of techniques suite your needs or not.
I assume that fast/slow constraints will mostly depend on the sort of game you wanted to do. Sometimes your sprites are most of the time facing the same direction (so you only want to flip them ocassionaly) and other times you need to flip them many times. Sometimes you have enough space for a 256-bytes look-up table, sometimes you don't.
The idea is giving the user alternatives for different needs. These examples are for functions not requiring look up table and flipping the sprite then drawing. It will take time, but I hope to provide variety to cover different needs :).
Also, thank you for the english tip :).
Quote from: reidrac on 17:10, 06 April 16
After your first example I though that perhaps you were drawing the sprite horizontally flipped on the fly, then I remembered how weirdly the CPC expects the pixel data to be arranged... and it wouldn't be possible to do it fast enough.
Renegade and Gryzor do it on the fly. ;)
It is possible.
And there you another example. This time, a complete Mode 2 animation is flipped on every keypress. Enjoy :).
(Video URL: http://www.youtube.com/watch?v=wIfO2q8wu34 (http://www.youtube.com/watch?v=wIfO2q8wu34))
- Source Code (http://bit.ly/cpct-sprite-flipm2)
- CDT & DSK (http://fremos.cheesetea.com/download/cpctelera-animation-flip-mode-2-demo/)
Hi ronaldo,
Have you thought to include compiled sprites support in CPCtelera?
The inclusion of this tech in your engine may standardize this tech on CPC and do it more popular.
It is true that usually compiled sprites require more memory than other ways, but what you gain in speed can be useful in many cases.
And the same for compiled tiles.
Regards,
@Rhino (http://www.cpcwiki.eu/forum/index.php?action=profile;u=174): Yes, indeed :) . Compiled sprites are in the tasklist, like other types of sprites (zig-zagged, reversed, 50% flipped, etc). Altough they are not tagged high priority at the momment, they are in the list.
It will take a great amount of time having many techs in the library, due to the way we are developing it. Everything is developed slowly to include as much documentation and information as possible. The idea is developing slowly but delivering great quality.
However, CPCtelera (http://lronaldo.github.io/cpctelera) is open for everyone to contribute. You can have a look at its sources to get an idea of how it is organized and the way functions are coded, then send pull requests with your own code proposals for discussion and inclusion in the library. I'd personally be much more than happy to receive contributions if you want/have time to :D . Many people is already contributing by testing, reporting and sending proposals and that's always awesome, even when contributions are small :D .
I tried flipping sprites on the fly with a 256 bytes table and it looks like it could be fast enough, and the memory saving is noticeable.
@ronaldo (http://www.cpcwiki.eu/forum/index.php?action=profile;u=1227): I didn't think about this until you started this thread, so thanks a lot!
Quote from: ronaldo on 22:02, 08 April 16
@Rhino (http://www.cpcwiki.eu/forum/index.php?action=profile;u=174): Yes, indeed :) . Compiled sprites are in the tasklist, like other types of sprites (zig-zagged, reversed, 50% flipped, etc). Altough they are not tagged high priority at the momment, they are in the list.
It will take a great amount of time having many techs in the library, due to the way we are developing it. Everything is developed slowly to include as much documentation and information as possible. The idea is developing slowly but delivering great quality.
However, CPCtelera (http://lronaldo.github.io/cpctelera) is open for everyone to contribute. You can have a look at its sources to get an idea of how it is organized and the way functions are coded, then send pull requests with your own code proposals for discussion and inclusion in the library. I'd personally be much more than happy to receive contributions if you want/have time to :D . Many people is already contributing by testing, reporting and sending proposals and that's always awesome, even when contributions are small :D .
Great !, I hope to find time to take a look.
If the format for compiled sprites is specified, I would gladly include it in Img2CPC ;)
Quote from: AugustoRuiz on 21:10, 24 April 16
If the format for compiled sprites is specified, I would gladly include it in Img2CPC ;)
Thanks!
As you say, the first step is to specify a standard format.
When I have some time, I will do a proposal in the "compiled sprites" thread, so that it can be discussed here.