News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_ronaldo

#CPCtelera Sprite Flipping Demo (WIP)

Started by ronaldo, 11:04, 31 March 16

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ronaldo

We are working now on adding sprite flipping features to CPCtelera 1.4. and this is a first mini demo:


*
Direct link to video (Youtube).
* Source Code
* DSK and CDT files

Features planned for 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:

EgoTrip

Nice. Look forward to that, will save loads of RAM. Will you also be adding sprite scaling too?

ronaldo

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.

TFM

Will you use expansion RAM for things like Sprite scaling, flipping etc.?
TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus

ronaldo

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.

TFM

Well, it's a lot of hard work. And you really archived something never seen before for CPC.  :)
TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus

ronaldo

#6
Another Little video, showing Mode 1 Sprite Flipping. This example is fully coded in assembler, for those who want to learn and use CPCtelera in ASM:


(Video URL:
http://www.youtube.com/watch?v=4cJPMTr8y9s)

Enjoy :).

reidrac

#7
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" ;)
Released The Return of Traxtor, Golden Tail, Magica, The Dawn of Kernel, Kitsune`s Curse, Brick Rick and Hyperdrive for the CPC.

If you like my games and want to show some appreciation, you can always buy me a coffee.

andycadley

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.

ronaldo

@reidrac: 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 :).

arnoldemu

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.
My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

ronaldo

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)

Rhino

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,

ronaldo

@Rhino: 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 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 .

reidrac

#14
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: I didn't think about this until you started this thread, so thanks a lot!
Released The Return of Traxtor, Golden Tail, Magica, The Dawn of Kernel, Kitsune`s Curse, Brick Rick and Hyperdrive for the CPC.

If you like my games and want to show some appreciation, you can always buy me a coffee.

Rhino

Quote from: ronaldo on 22:02, 08 April 16
@Rhino: 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 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.

AugustoRuiz

If the format for compiled sprites is specified, I would gladly include it in Img2CPC ;)

Rhino

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.

Powered by SMFPacks Menu Editor Mod