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.

AppGameKit Classic Chat / Multi-Split Screen, Parallax, Texture Scrolling Demo (project included)

Author
Message
Marl
12
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 6th Mar 2012 23:20
My main project needed a better background so I gave it a parallax scroll using texture scrolling.

Basically it scrolls the texture of several sprites with varying texture scales overlaid to form a background.

The scroll direction changes randomly at random intervals

The effect worked so well I thought I'd share it with you, so wrapped what was a few lines of code into a new project, wrapped it up in a few demo routines and commented the hell out of it.

You can change the number of layers, the number of splits and if you want, control one of the parallaxes with a virtual joystick.

It adjusts for rotation and should work at any size.

I've included a few textures to demo the effect.

Hope you find it useful.

Codes a bit longer than I planned so I split it up;
Initialisation

Main Loop

Resize function (used for orientation change)

Scroll function and supplementary bits;


@baxslash,

I know you are working on this very topic for your tutorials, feel free to use anything you find useful, though I can't see much of it being new to you.

Attachments

Login to view attachments
Marl
12
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 6th Mar 2012 23:24 Edited at: 6th Mar 2012 23:27
Screen for above 'cos I don't know how to attach two things

Though demonstrating parallax with a screenshot is not really that effective

Attachments

Login to view attachments
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 7th Mar 2012 10:20 Edited at: 7th Mar 2012 10:30
Quote: "I know you are working on this very topic for your tutorials, feel free to use anything you find useful, though I can't see much of it being new to you."

I am, I'll take a look now.

My method for multi-screen will use the new setScissor (providing it works as expected).

EDIT: I like it. Using UV scrolling to do parallax is a great idea The split screen effect I've started will give two views on the same world, currently you would have to fake this but using the "setScissor" command you should be able to set the view offset, render to one half of the buffer, set the view offset again then render to the other half of the buffer. Finally you swap the buffer to the screen.

bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 7th Mar 2012 11:54
Baxslash you are talking from the future!!!!
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 7th Mar 2012 12:19
Sorry, got to polish my delorean... I'll reply later (or is it sooner?)

Marl
12
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 8th Mar 2012 05:48
Is setScissor() in 107 ?

Sounds like it recreates and effect from the old Atari and Amiga days where they changed the buffer pointer half way down the screen.

If it had a corresponding setting for the zoom it would make maps a doddle - the map part of the screen could just be the whole play area zoomed out.

Is it a one split deal or can you do it multiple times?

Have you got any more of these future commands to share?
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 8th Mar 2012 08:01
They have been posted multiple times in the newsletter and on the forum. How the commands work is only going to vary slightly from what you can guess I would imagine. SetSpriteScissor for example is likely to crop a single sprite to an area of the screen making it a good candidate for your map idea

Trisect Development
21
Years of Service
User Offline
Joined: 8th Sep 2002
Location: Denmark
Posted: 14th Mar 2012 12:46
Could be me that just dont get it, but how do I use this with just one layer and one area?

I want to use this as a scrolling background on my menu screen.

iOS Apps from Trisect Development.
Click here.
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 14th Mar 2012 13:40
trisect use the SetSpriteUVOffset command, that's all you need
Trisect Development
21
Years of Service
User Offline
Joined: 8th Sep 2002
Location: Denmark
Posted: 14th Mar 2012 14:38
I trying but I can't seem to figure out how to use it.
Can you give me a simple example?

iOS Apps from Trisect Development.
Click here.
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 14th Mar 2012 18:59 Edited at: 14th Mar 2012 18:59
Here's a simpler version: DOWNLOAD

Attachments

Login to view attachments
Trisect Development
21
Years of Service
User Offline
Joined: 8th Sep 2002
Location: Denmark
Posted: 15th Mar 2012 01:09
Super thanks!

iOS Apps from Trisect Development.
Click here.
Trisect Development
21
Years of Service
User Offline
Joined: 8th Sep 2002
Location: Denmark
Posted: 15th Mar 2012 11:31 Edited at: 15th Mar 2012 11:31
If I play this on the iPad emulator I get a thick black line in the image.
This does not happen if I run from the AppGameKit Editor.

See picture.


iOS Apps from Trisect Development.
Click here.
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 15th Mar 2012 11:44
Not seen that before. Looks like a bug.

If that background is one sprite I would say you need to report it to the bug board.

Trisect Development
21
Years of Service
User Offline
Joined: 8th Sep 2002
Location: Denmark
Posted: 15th Mar 2012 11:50
Yes its a sprite with the size of 982x982

iOS Apps from Trisect Development.
Click here.
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 15th Mar 2012 11:56
Trisect ipad resolution is 1024 by 768. Make sure your app meets that resolution, else you will get some black border
Trisect Development
21
Years of Service
User Offline
Joined: 8th Sep 2002
Location: Denmark
Posted: 15th Mar 2012 12:06 Edited at: 15th Mar 2012 12:11
The App is set to 1024x768 resolution

If I try on my Android tablet with AGKPlayer I get the same result as on the iPad(compiled from Xcode)

This is what I do.


iOS Apps from Trisect Development.
Click here.
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 15th Mar 2012 14:01
Trisect, if you want your scrolling sprite to cover the whole background, the sprite has to be 1024 (or longer if you app is landscape) x 768 too!
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 15th Mar 2012 14:07
bjadams is right, here's why. The iPad is expanding the size of the image to a power of 2 (1024). Increase the size of your image to 1024x1024 and this should be fixed.

Trisect Development
21
Years of Service
User Offline
Joined: 8th Sep 2002
Location: Denmark
Posted: 15th Mar 2012 14:33 Edited at: 15th Mar 2012 14:41
Its working on the Andoid AGKPlayer now.
Next stop iPad.

And it working on the iPad.

Thanks guys! I love this forum...

iOS Apps from Trisect Development.
Click here.
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 15th Mar 2012 15:46
Quote: "Thanks guys! I love this forum..."

Me too...

Login to post a reply

Server time is: 2024-05-07 12:17:34
Your offset time is: 2024-05-07 12:17:34