Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Author
Message
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 7th May 2012 22:33
Way back in March, Marl provided a great demo program for doing UV scrolling with a parallax type effect:
http://forum.thegamecreators.com/?m=forum_view&t=194972&b=41

I really liked the effect and decided to use it in my game.

For testing purposes, I borrowed one of his images to create a new one that was the same dimensions as the resolution I'm using for my game.

I crunched the code to remove what I didn't need and set it for a single scrolled area.

Constants, UDTs and globals:


Setup and scrolling functions:


'initialiseUVlayers()' is called after all images have been loaded up and 'doUVscroll()' is called once per sync cycle during game play.

It looks quite cool. And works great in Windows and on my iPad (iOS 5.1, 16GB, run from Xcode on my Mac Mini). Both continue to have the same fast FPS. However, when I run it on my iPod Touch (iOS 5.1, 32GB), the FPS slows to a crawl, about 12.

I don't know why the UV Scrolling has this impact on only my iPod. I haven't tested on my Android, yet.

Without the scrolling, the iPod runs as fast as the iPad and Windows.

It's sad because the iPad is the primary target for my game. And I won't be able to do the very cool effect.

Oh well. Maybe I'll do seperate builds for the different platforms that support the UV scrolling effect.

Oh, and did anyone else spot the AppGameKit for Pascal showing up in thte TGC My Products page? Now I need to find a good Pascal compiler. It's been years since I was able to play in Pascal.

Cheers,
Ancient Lady
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 8th May 2012 00:49
Yes I noticed UVscrolling slowdown on the iphone 3gs too.

i only use uvscrolling for credits so its not very time critical for my needs
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 9th May 2012 02:04
I haven't tried since earlier versions of AppGameKit on a iphone of any type, but UV scrolling was bugged even then. Sprites simply refused to show on screen at all, no matter what the sprite dimensions were.

A parralax effect is quite easily achieved without the need for UV scrolling however. You can place 2 screen sized sprites next to each other scroll them across the screen, and when you reach the end of the second sprite, change the sprites images so that the first is now the second and the second one a 3rd image . Then reposition the sprites back at the original co-ords so it seamlessly scrolls onto the second sprite with the new image. Repeat the process with subsequent layers of sprites at a reduced speed/scrollrate and you have a parallax scroll.
You could obviously use tiles rather than huge screens as well, that just takes more finesse in the graphics design You also don't need full screen sized sprites, you can use strips to help keep speed issues down. For an effect like Choplifter on the arcades and master system (amongst many other versions), the strip method was used quite heavily and looked pretty good for the day.
There's probably several other ways to do it as well. I tend to use UV scrolling for simple things like menu effects as bjadams said above.

Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 9th May 2012 02:31
I'll give it a try. I really liked the visual effect and want to have a high 'cool' factor, if possible, in the game.

Thank you.

Cheers,
Ancient Lady
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 10th May 2012 05:46 Edited at: 10th May 2012 05:49
I used a slightly more complicated way for Obliterator, as it involves a 2 way scroll. I just used 3 sprites instead of 2. There's some videos of it in action in the showcase forum under shooter wip. I also added a little up and down movement for good measure. If used well, it can create some cool looking scroll effects. I haven't tried any more than 10 myself, and for Obliterator it was overkill and probably a bit too demanfding, but as long as the game is not too busy, you could have a fair amount of layers.
If you are struggling I can probably knock up an example

edit - The video choppiness is the screen capture software btw, the game runs at 60 fps np. Just in case you think it is choppy

MarcoBruti
13
Years of Service
User Offline
Joined: 20th Nov 2011
Location: Caput Mundi
Posted: 10th May 2012 15:55
For my app ReadMusic (on Google Play Market), I use the 3 sprites tecnique. It shows a scrolling stave.
Each sprite is a stripe with width equal to the screen width (and height about 1/3 of screen height).
- first I draw the sprites with the G or F clef at x=0, and 2 sprites with only the stave at world coordinate x=SCREEN_WIDTH and x=2*SCREEN_WIDTH
-I make the screen scroll to the left using setView.
- When left screen world cordinate becomes 2*SCREEN_WIDTH, I take the 2nd sprite and draw it at 3*SCREEN_WIDTH
- when left screen world cordinate becomes 3*SCREEN_WIDTH, I take the 3rd sprite and draw it at 3*SCREEN_WIDTH
- I continue swapping 2nd and 3rd sprite till the note sequence finished. (the notes are drawn at the beginning).
My doubt is about the maximum world coordinate that AppGameKit can manage.
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 10th May 2012 17:27
The videos of Obliterator are quite impressive.

Once I finish the next bit in the game, I'll revisit the scrolling (or jiggling as it would be in my case) using the suggested techniques.

Thank you.

Cheers,
Ancient Lady
Marl
13
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 10th May 2012 20:15
Quote: "My doubt is about the maximum world coordinate that AppGameKit can manage."

It can manage a lot, but you don't need to go that far.

Once you get to a certain point - say ten times your screen width - you could shift the whole lot back in one go and you will never have to worry about the limit.
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 10th May 2012 20:29
Marl, that is what I do every time you get to the end of the second screen dependant, on what I am doing. My description above may not been too clear, or you may not have read it The world co-ords never go beyond 2 screen widths. I'm sure if you wanted to go on without flipping back your x co-ords, you could effectively do so forever, in these modern times. It would take a pretty huge offset to hinder modern machines. I just tend to stick with old school methods, it's not hard to do and does save ( a tiny,tiny bit) of memory.

Login to post a reply

Server time is: 2024-11-23 10:49:36
Your offset time is: 2024-11-23 10:49:36