Author Topic: MODULE: Smooth Scrolling & Parallax v1.7.1  (Read 67922 times)

Joe

  • Anywhere you think I am, I am
    • I can help with scripting
    • I can help with translating
    • I can help with web design
I get an error on this line:
Code: [Select]
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: [Select]
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

  • What will become of the baron?
    • Ali worked on one or more games that won an AGS Award!
    •  
    • Ali worked on one or more games that was nominated for an AGS Award!
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

  • Mittens Vassal
  • Cavefish
  • Mittens Half Initiate
    • I can help with proof reading
    • I can help with translating
    • I can help with voice acting
    • Monsieur OUXX worked on one or more games that won an AGS Award!
    •  
    • Monsieur OUXX worked on one or more games that was nominated for an AGS Award!
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

  • What will become of the baron?
    • Ali worked on one or more games that won an AGS Award!
    •  
    • Ali worked on one or more games that was nominated for an AGS Award!
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

  • Local Moderator
  • Rottwheelers
  • Pretty Badass
    • Dualnames worked on one or more games that won an AGS Award!
    •  
    • Dualnames worked on one or more games that was nominated for an AGS Award!
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.
No more military army stuff. I'm alive and back.

Joe

  • Anywhere you think I am, I am
    • I can help with scripting
    • I can help with translating
    • I can help with web design
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

  • What will become of the baron?
    • Ali worked on one or more games that won an AGS Award!
    •  
    • Ali worked on one or more games that was nominated for an AGS Award!
Thanks Joe!

Dualnames, once again you have blown my mind.

selmiak

  • ǝsıɔɹǝxǝ ʞɔǝu puɐ uıɐɹq
    • I can help with play testing
    • I can help with proof reading
    • I can help with translating
    • I can help with web design
    • selmiak worked on one or more games that won an AGS Award!
    •  
    • selmiak worked on one or more games that was nominated for an AGS Award!
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

  • What will become of the baron?
    • Ali worked on one or more games that won an AGS Award!
    •  
    • Ali worked on one or more games that was nominated for an AGS Award!
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

  • ǝsıɔɹǝxǝ ʞɔǝu puɐ uıɐɹq
    • I can help with play testing
    • I can help with proof reading
    • I can help with translating
    • I can help with web design
    • selmiak worked on one or more games that won an AGS Award!
    •  
    • selmiak worked on one or more games that was nominated for an AGS Award!
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

  • What will become of the baron?
    • Ali worked on one or more games that won an AGS Award!
    •  
    • Ali worked on one or more games that was nominated for an AGS Award!
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: Adventure Game Studio
  1.  
  2. bool cameraFollowing = true;// Global Variable
  3.  
  4. //In repeatedly execute:
  5.  
  6. if (Player.x < 1000 && cameraFollowing == true){
  7.     cCamera.x = cPlayer.x;
  8.     }
  9. else if (Player.x>=1000 && cameraFollowing == true){
  10.     cCamera.x = 1000;
  11. }

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!



« Last Edit: 30 Jul 2012, 02:12 by Ali »

selmiak

  • ǝsıɔɹǝxǝ ʞɔǝu puɐ uıɐɹq
    • I can help with play testing
    • I can help with proof reading
    • I can help with translating
    • I can help with web design
    • selmiak worked on one or more games that won an AGS Award!
    •  
    • selmiak worked on one or more games that was nominated for an AGS Award!
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

  • What will become of the baron?
    • Ali worked on one or more games that won an AGS Award!
    •  
    • Ali worked on one or more games that was nominated for an AGS Award!
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: Adventure Game Studio
  1. 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!
« Last Edit: 26 Aug 2012, 13:54 by Ali »

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: Adventure Game Studio
  1. 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

  • What will become of the baron?
    • Ali worked on one or more games that won an AGS Award!
    •  
    • Ali worked on one or more games that was nominated for an AGS Award!
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

  • What will become of the baron?
    • Ali worked on one or more games that won an AGS Award!
    •  
    • Ali worked on one or more games that was nominated for an AGS Award!
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
« Last Edit: 26 Aug 2012, 14:13 by Ali »

Luca

  • 2d is immortal
I just used your module and it's FAN-TAS-TIC!
Thank you!

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

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


Ali

  • What will become of the baron?
    • Ali worked on one or more games that won an AGS Award!
    •  
    • Ali worked on one or more games that was nominated for an AGS Award!
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
« Last Edit: 12 Nov 2013, 15:42 by Ali »