MODULE: Smooth Scrolling & Parallax v1.7.1

Started by Ali, Fri 07/12/2007 21:14:09

Previous topic - Next topic

Joe

I get an error on this line:
Code: ags

PlayerSprite = Game.GetViewFrame(player.NormalView, player.Loop, 0); // Set it to their current Normal View


I guess it's because it's called when my player isn't using its normal view but other wiew with more loops than the normal view.
I modified that line for this one:

Code: ags

PlayerSprite = Game.GetViewFrame(player.View, player.Loop, 0); // Set it to their current Normal View


it works nice now, but I don't know if this is the true solution.
Thanks,
Joe.
Copinstar © Oficial Site

Ali

If you're not using normal views that seems like a good workaround. To be honest, I can't remember what that bit of code is for, or why I chose to use normal views. Let me know if there are any weird occurrences!

Monsieur OUXX

Hey Ali, have you considered adding the trick of "duplicating the sprites in 2 adjacent positions and blending them together with 50% alpha" to smoothen sub-pixel movement, as was suggested in another thread? That could help for very distant parallax, I guess.
Just an idea.
 

Ali

I have thought about it, but I'm not sure how I'd approach it. RawDraw? Or could I create a dynamic sprite and 'map' it to the object? It's not something I'd rule out, but it's not something I could work out quickly.

I'm less keen to achieve sub-pixel movement than I used to be when the engine moved objects in double-pixel jumps. Slow movement looks much better now, particularly at 800x600+ resolution.


Dualnames

Hey, Ali, have you realized that Cinderella's shoe slips off her foot, whilst when she tries them on they're EXACT size? Just an idea.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Joe

Quote from: Ali on Mon 12/12/2011 17:50:48
If you're not using normal views that seems like a good workaround. To be honest, I can't remember what that bit of code is for, or why I chose to use normal views. Let me know if there are any weird occurrences!

Ok, I will. Anyway I want to thank you for splitting the module. Thankyou very much. :)

Joe
Copinstar © Oficial Site

Ali

Thanks Joe!

Dualnames, once again you have blown my mind.

selmiak

is it possible to set a viewport or a range in which the smoothscrolling should happen? And also have a viewportchange happen with smooth scrolling.
For example you have a very long background but don't want the player to see a specific part of it through scrolling but make it seem like the room ends there. But when the player click on an object at the end of the room the visible screen should move over there as if the playercharacter is looking there. Just looking through moving the part of the background visible for the player and the playercharacter should not move there.

Ali

Not without modifying the script a little, but I think it would be possible.

You could create an invisible character called cCamera, and set it to player.x and y. Then replace 'player' with 'cCamera' wherever it appears in the module, so the viewport is following cCamera not the player.

Then make it so that in this particular room cCamera follows the player, but not beyond a certain point. Then when clicking the object, alter cCamera's x value and the viewport should pan over to follow it.

Does that make sense?

selmiak

makes perfect sense, how do I set a characters x+y to players x+y and stop it from moving beyond a certain point? all in global script?
By now I am so far as to have an invisible player character that only walks this and that far and have my normal character walk normally. This works too, but right now I'm at the point where I would have to swap inventory items, so your solution is better, just tell me please how to set this same xy and limit it. But then I would have to have this cCamera in all rooms that are scrolling, right?

Thanks for this great module btw :D
If you find some time, a LockScrollX and LockScrollRangeX parameter would also be cool (same for Y) :D
and a SmoothMoveViewport function maybe ;)

Ali

Yes, it would be more flexible if you could swap camera targets in-game, but I won't have time to add that kind of function for a while I'm afraid! It's definitely something I'd like to add.

I haven't tested it, but I'd do something like this (where 1000 is the centre-point you want the screen to stop at):

Code: AGS


bool cameraFollowing = true;// Global Variable

//In repeatedly execute:

if (Player.x < 1000 && cameraFollowing == true){
    cCamera.x = cPlayer.x;
    }
else if (Player.x>=1000 && cameraFollowing == true){
    cCamera.x = 1000;
}


And you could switch the boolean off to manually position cCamera.

I'm not sure if the effect will be perfect with the (relatively) new Lucas Arts style scrolling where scrolling only begins when the player gets near the edge of the screen... so please let me know how it works for you!




selmiak

It was quite late yesterday, so after posting my last post, shutting down and getting to sleep I figured I could just switch roles and limit my invisible player character and let the dummylookalike move around (make the player the camera) as I already coded some kind of crappy framework for this ;). This works now for me and did cost me some sleep as I was always tempted to reboot and implement this :D

Ali

New version for testing: http://ali.agser.me/smooth_scroll_1_7.zip
(Please let me know if you can host a mirror)

This version allows you to change who the camera is looking at with the following code:

Code: AGS
targetCharacter = cDummy;


You could use an invisible character to create camera movements and other effects. The camera has to be pointing at someone at all times. Setting targetCharacter to null should just revert to the player without crashing, but it's better not to try it.

Let me know if you find any bugs!

Sslaxx

Quote from: Ali on Fri 17/08/2012 22:01:44
New version for testing: http://www.gamefront.com/files/22143642/smooth_scroll_and_parallax_1_7.zip
(Please let me know if you can host a mirror)

This version allows you to change who the camera is looking at with the following code:

Code: AGS
targetCharacter = cDummy;


You could use an invisible character to create camera movements and other effects. The camera has to be pointing at someone at all times. Setting targetCharacter to null should just revert to the player without crashing, but it's better not to try it.

Let me know if you find any bugs!
What happens if you set the targetCharacter to a character not in the current room?
Stuart "Sslaxx" Moore.

Ali

It probably crashes. Probably definitely if that character is positioned outside the bounds of the current room.

Thanks for spotting that! I'll try to upload a fix soon.

Ali

I've uploaded a fix. In this version the target character should always me moved to the current room to avoid nastiness. Please let me know if you spot any more issues.

It's also now possible to adjust the customScrollSpeedX / Y from other scripts. However, you'll find that very slow speeds don't work, which I'm asking for help about here: http://www.adventuregamestudio.co.uk/forums/index.php?topic=46684.new#new

Luca

I just used your module and it's FAN-TAS-TIC!
Thank you!

The baker
Indiana Jones : Archeology = Big Lebowski : Communication Sciences

Crimson Wizard

Ali, can you please remove the restriction that disables smooth scrolling on Linux? I believe current ports should work right.


Ali

I have no idea what I meant by emulator either...

I've uploaded a revised version 1.7 with the Linux restriction gone: http://ali.agser.me/smooth_scroll_1_7.zip

SMF spam blocked by CleanTalk