Author Topic: Background image top-to-bottom smooth scrolling  (Read 491 times)

bx83

  • Get 'Er Doooooone
I want to move a large image (1024x7068) from top-to-bottom, on a 1024x768 room screen. This is for the credits.
Can I do it without flicker/jaggedness?
Can I do it *at all*, or should I find a module?

Slasher

  • slasher
    • I can help with AGS tutoring
    •  
    • Lifetime Achievement Award Winner
    •  
    • I can help with scripting
    •  
    • I can help with story design
    •  
    • Slasher worked on a game that was nominated for an AGS Award!
Re: Background image top-to-bottom smooth scrolling
« Reply #1 on: 09 Mar 2018, 12:25 »
You could check out the Tween Module... It's easy to use once you get the hang of it..

Re: Background image top-to-bottom smooth scrolling
« Reply #2 on: 09 Mar 2018, 13:18 »
Normally you would just move the viewport to accomplish this. Did you try if that results in flickering?

Khris

    • Lifetime Achievement Award Winner
    •  
    • I can help with play testing
    •  
    • I can help with scripting
    •  
    • I can help with translating
    •  
    • Khris worked on a game that was nominated for an AGS Award!
Re: Background image top-to-bottom smooth scrolling
« Reply #3 on: 09 Mar 2018, 13:23 »
In case you took the "if all you have is a hammer" route and let an invisible character walk down the room, that will result in choppy scrolling due to the fact that the character moves multiple pixels every few frames.

bx83

  • Get 'Er Doooooone
Re: Background image top-to-bottom smooth scrolling
« Reply #4 on: 09 Mar 2018, 21:59 »
Normally you would just move the viewport to accomplish this. Did you try if that results in flickering?

Sounds good, how to I do that? What function? Should I have the background as the tall credit's background and move the viewport down?

bx83

  • Get 'Er Doooooone
Re: Background image top-to-bottom smooth scrolling
« Reply #5 on: 09 Mar 2018, 22:04 »
You could check out the Tween Module... It's easy to use once you get the hang of it..

Which function in Tween should I use?

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: Background image top-to-bottom smooth scrolling
« Reply #6 on: 09 Mar 2018, 22:11 »
Normally you would just move the viewport to accomplish this. Did you try if that results in flickering?

Sounds good, how to I do that? What function? Should I have the background as the tall credit's background and move the viewport down?

You may put the image on the object and move the object up, or put the image on room background and move viewport down.
To change viewport position see function SetViewport(x, y) and ReleaseViewport (you would need to call latter if you return from credits screen to another room).

bx83

  • Get 'Er Doooooone
Re: Background image top-to-bottom smooth scrolling
« Reply #7 on: 12 Mar 2018, 04:54 »
Hey again
I'm, building my room with CW's last suggestion, no stutter :)

Just wondering, how do I get the room transition as instant, rather than fade out/fade in?
When I load this room, it fades in from black for about 500ms - how do I make it 0ms?

Checked setgameoption, no luck.

Gurok

  • Rottwheelers
  • When life hands you lemons, combine them with the mop
    • I can help with AGS tutoring
    •  
    • Best Innovation Award Winner 2016, for improving and extending the AGS scripting language
    •  
    • I can help with proof reading
    •  
    • I can help with scripting
    •  
    • Gurok worked on a game that was nominated for an AGS Award!
      Gurok worked on a game that won an AGS Award!
Re: Background image top-to-bottom smooth scrolling
« Reply #8 on: 12 Mar 2018, 05:44 »
In the editor, go to General settings -> Visual -> Default transition when changing rooms and set it to Instant

If you really want to use SetGameOption, you might try:

Code: Adventure Game Studio
  1. SetGameOption(19, 1);

19 is OPT_FADETYPE, but I don't think the editor defines it. The transition styles are:

FadeOutAndIn = 0
Instant = 1
Dissolve = 2
BlackBoxOut = 3
CrossFade = 4

Slasher

  • slasher
    • I can help with AGS tutoring
    •  
    • Lifetime Achievement Award Winner
    •  
    • I can help with scripting
    •  
    • I can help with story design
    •  
    • Slasher worked on a game that was nominated for an AGS Award!
Re: Background image top-to-bottom smooth scrolling
« Reply #9 on: 12 Mar 2018, 09:42 »
And if you want to change a Room's Transition to the next Room in script you can add this:

Code: Adventure Game Studio
  1. SetNextScreenTransition(eTransitionBoxout); // Or whatever you wish it to be.. Could also be SetNextScreenTransition(3);
  2. player.ChangeRoom(10);  // player that changes Room
  3.  

bx83

  • Get 'Er Doooooone
Re: Background image top-to-bottom smooth scrolling
« Reply #10 on: 12 Mar 2018, 10:47 »
Fabulous :)

And another thing...

I've come across a problem running this code:

Code: Adventure Game Studio
  1. function room_Load()
  2. {
  3.         cJulius.Transparency=100;
  4.         cJulius.x=2000;
  5.         cJulius.y=2000;
  6.         gIconbar.Clickable=false;
  7.         gIconbar.Visible=false;
  8.         mouse.Mode=5;
  9.         SetGameOption(OPT_CROSSFADEMUSIC, 0);           //set crossfade to 'no crossfade' for music_chan
  10.         music_chan=aTitleTheme_1_6_1.Play(eAudioPriorityNormal, eOnce);
  11. }
  12.  
  13. function room_RepExec()
  14. {
  15.         if (oCredits.Y>=850) {
  16.                 oCredits.Y-=1;
  17.         } else {
  18.                 if (music_chan.PlayingClip!=aTitleTheme_1_6_1) {
  19.                         SetTimer(TIMER_WAIT, GetGameSpeed()*2);
  20.                        
  21.                         if (IsTimerExpired(TIMER_WAIT)) {
  22.                                 FadeOut(5);
  23.                                 sounds_chan=aBlowing_out_a_match_2.Play(eAudioPriorityNormal, eOnce);
  24.                                 QuitGame(0);
  25.                         }
  26.                        
  27.                 }
  28.         }
  29. }

I set break points, but it's forever jumping between these 2 lines:

Code: Adventure Game Studio
  1. SetTimer(TIMER_WAIT, GetGameSpeed()*2);
  2.  
  3. if (IsTimerExpired(TIMER_WAIT)) {

It then never ends.

My original idea was to Wait() 2 seconds, then turn the game off, but the Wait icon appeared; I was trying to get the mouse pointer set to something else, but nothing worked within the Wait() loop, when it would be changed to the little watch-face anyway. Finally, I thought of setting a timer; but it just loops forever. :/

Khris

    • Lifetime Achievement Award Winner
    •  
    • I can help with play testing
    •  
    • I can help with scripting
    •  
    • I can help with translating
    •  
    • Khris worked on a game that was nominated for an AGS Award!
Re: Background image top-to-bottom smooth scrolling
« Reply #11 on: 12 Mar 2018, 11:00 »
The condition of the block that sets the timer doesn't change, so the timer gets set again and again and again (and therefore never expires).

bx83

  • Get 'Er Doooooone
Re: Background image top-to-bottom smooth scrolling
« Reply #12 on: 13 Mar 2018, 07:14 »
Here's the working code for anyone needing it:

Code: Adventure Game Studio
  1. function room_Load()
  2. {
  3.         gIconbar.Clickable=false;
  4.         gIconbar.Visible=false;
  5.         RunCreditsNow=true;
  6.         SetGameOption(OPT_CROSSFADEMUSIC, 0);           //set crossfade to 'no crossfade' for music_chan
  7.         music_chan=aSong.Play(eAudioPriorityNormal, eOnce);
  8. }
  9.  
  10. function room_RepExec()
  11. {
  12.         if (RunCreditsNow) {
  13.                 mouse.Mode=5;    //blank action
  14.                 if (oCredits.Y>=690) {
  15.                         oCredits.Y-=1;
  16.                         SetTimer(TIMER_WAIT_3SECONDS, GetGameSpeed()*3);
  17.                 } else {
  18.                         if (music_chan.PlayingClip!=aSong) {
  19.                                 if (IsTimerExpired(TIMER_WAIT)) {
  20.                                         FadeOut(10);
  21.                                         QuitGame(0);
  22.                                 }
  23.                         }
  24.                 }
  25.         }
  26. }