News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu

Parallax scrolling via palette rotation

Started by andycadley, 19:06, 01 January 17

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

andycadley

So, while working on my sprite engine, I've been watching a bunch of C64 shoot-em-up YouTube videos for "inspiration." And I have to admit being a bit jealous of that character based display, in particular the way it can pull off some nifty parallax effects with reasonably simple character rotation. Naturally I started to wonder if we could get something similar on the CPC, but obviously we don't have character mode and having to redraw the entire parallax area is rather too time consuming.

However, what we can do with relative ease is rotate palette colours and that should allow us to do something like the C64 effects with minimal overhead. So I spent a little time playing around to see how well it might work. With 8 colours reserved for two different sets of rotating groups of colours (4 inks in each) I managed to come up with:



Which I think works reasonably well. The entire screen is scrolling to the left by one Mode 0 pixel every 4 frames (using the SSCR) and all the variation in motion is purely down to palette cycling. It's a little limited in the kinds of patterns that work, although I suspect clever art work might do better, as might using a larger rotating palette selection but I'm not much of an artist.

Has this ever been done before in a CPC game? I'd have assumed somewhere it would be, but I couldn't think of a good example.

Ast

Fine. I really think it is the Best way to do it.
Another way Would be to use hardware sprites...Guru meditation ?
_____________________

Ast/iMP4CT. "By the power of Grayskull, i've the power"

http://amstradplus.forumforever.com/index.php
http://impdos.wikidot.com/
http://impdraw.wikidot.com/

All friends are welcome !

Carnivius

Cool.  I'm doing parallax a slightly different way using copies of the simple background tile graphic I want 'parallaxed' with each one shifted horizontally an increasing amount.

So with a 8 pixel wide Mode 0 tile it's sorta like this.
frame 1 - 01234567
frame 2 - 12345670
frame 3 - 23456701

and so on.  And obviously if going the other direction you just subtract the frame count rather than adding it.   I think this is what some 8 bit games did back in the day but I'm not sure.  It works nicely though (in theory since I've not attempted it on a true CPC, just my CPC-style projects I plan to put onto the machine itself with help from CPCWiki folks in future).  I wondered if it's how Teenage Mutant Hero Turtles does parallax.
Favorite CPC games: Count Duckula 3, Oh Mummy Returns, RoboCop Resurrection, Tankbusters Afterlife

andycadley


@Ast - I'm planning to use all the hardware sprites for actual sprites, so I was looking for something a bit more lightweight as a possible background effect


@Carnivius - Yes, pre-shifted tiles is the "normal" way of doing it (and I believe how TMNT did it), but since I'm aiming for a pure hardware scroll I don't really want to be re-drawing any part of the screen unless I actually have to. I want 50FPS to at least be theoretically doable with the engine and that means keeping redraws to the minimum required.

Carnivius

#4
ah cool. So that tile method does work then. I'll keep that in mind and continue using it.   :)

I wondering what ThunderCats uses.
Favorite CPC games: Count Duckula 3, Oh Mummy Returns, RoboCop Resurrection, Tankbusters Afterlife

Overflow

Quote from: andycadley on 19:06, 01 January 17Has this ever been done before in a CPC game? I'd have assumed somewhere it would be, but I couldn't think of a good example.
Same as you! I can't remember a good example. That said: if we add the feature smooth 1-pixel scrolling (that can be done on GX4000 only ;)), well: you did a première.  Sounds good for your upcoming game using this!

I'm not wrong? in your YouTube video, you use only 2 colors for foreground -> actually (considering what you wrote: 2*4 colors for background) 8 colors are available for foreground, aren't they? Adding some sprites (with another set of 15 colors): enough for a colorful game. :)

Possibly an enhancement? 2*4 colors for background = 2 kinds of animations/scroll. It looks like (?) there's no need for the 2 "groups of 4 colors" at the same time - I mean on the same scanline/character line. Which would mean: if you change the 4 colors from single group during the frame - thanks to scanline-interruption, there's no need for 2 "groups of 4 colors"? Am I wrong? If not: this would allow, either a group a 8 colors (for wider scroll/animation) or 8+4 colors for foreground. Just thinking about it a bit - I might miss something.



Unregistered from CPCwiki forum.

andycadley

Yes, there's are only a couple of colours used in the foreground there but you could certainly accomplish the same thing with just 4 reserved colours and some raster changes, which would give you more colours freed up for the foreground. And, of course, in a scrolling game you might only need parallax tricks in specific sections of the map, so those inks could be re-used for other objects during other portions of the map.

sigh

A great demonstration. Is this the same technique and advice you gave me for the scrolling on my football game?

How many frames per second is this example running at?
Also - is this using stock CPC features without the PLUS enhancements of the GX4000?
Is it coded in basic or assembly?

andycadley


It's a similar technique, I hadn't really considered the possibility of combining a palette shift based effect with a normal scroll when I suggested it to you, but that thread was probably where the first seeds of this idea came from.


The example is assembly language and running at 12.5fps, though that's just because I deliberately slowed it down because the effect looks better - if I removed the forced delay it can happily whizz along at 50fps. It's using the Plus pixel scrolling and extended palette, though neither of those is necessary for the basic principle, which could jut as easily work on a standard machine (I just happened to have a scroll routine written for the GX that it was easy to try it out on). You probably do need a hardware scroll for it to make sense too, since if you're doing a full scroll redraw in software you can probably just as easily get a similar parallax effect without some of the pattern limitations by just drawing different tile patterns.

Powered by SMFPacks Menu Editor Mod