Background (sky) frozen during camera transpose

Started by Giacomo, Thu 13/10/2022 21:19:37

Previous topic - Next topic

Giacomo

Hello people of community,
I need your help.

I would like to:

-draw a big background
-split it into two camera scenes, scrolling left to right and viceversa in certain points of the screen
-I would like the sky to be frozen during the animation

Foreground is full of big objects drawn between it and sky, and I abandoned the idea of making
sky and foreground big objets because that would make everything harder. I wonder if there is
a way to use foreground as background, and sky as object put behind it. I hope you have better ideas.


Purple is for walking line.

Thank you all in advice,
Giacomo
https://ko-fi.com/giacomo97557 To support Falco's adventures

Crimson Wizard

#1
Use a big background object with a sky and move it along with a camera. This is generally how parallax is done in AGS.

If it makes it difficult to edit the room:
- set a small dummy sprite to that object in the editor;
- set a proper sprite in script, in room_Load event.

OR

- the modern editor allows you to hide certain objects in the room, by finding them in a topbar's drop list, and unticking "eye" icon.

Alternatively you may draw the sky upon the room's actual background, and redraw as camera moves, but that will make performance somewhat slower; thus I still recommend the object.
In case you are wondering, drawing is performed using DrawingSurface, which you may get for the room background:
https://adventuregamestudio.github.io/ags-manual/DrawingSurface.html
https://adventuregamestudio.github.io/ags-manual/Room.html#roomgetdrawingsurfaceforbackground


Khris

Hi Giacomo, to post pictures you need to use the URL, not the link to the imgur page. Right-click the image after uploading and select "Copy Image Link".


Giacomo

Thank you very much Crimson and Khris.

I will make the room as soon as possible
and apply your suggestions in script.
https://ko-fi.com/giacomo97557 To support Falco's adventures

Giacomo

I solved my problem, thank you all for your suggestions.

I did as following and it works fine, and I'm sure code
can be semplified:
Code: ags

bool goRight = true;
bool goLeft = false;

function region1_WalksOnto()
{
  
  if (goRight == true){   
  
      int i=0;
      player.Walk(360, 260);
      
      while ( i <40){   
        i++;
        Game.Camera.SetAt(Game.Camera.X + 8, Game.Camera.Y); //Same speed as sky
        oPianoIntermedio.X = oPianoIntermedio.X+4; //Half speed
        //foreground auto scrolls
        oCielo.X = oCielo.X+8;
        Wait(2);
      }     
      
      goRight = false;
      goLeft = true;
    }
  
  else if (goLeft == true){

    int i=0;
    player.Walk(260, 260);
    
    while ( i <40){
    
      i++;
      Game.Camera.SetAt(Game.Camera.X - 8, Game.Camera.Y);
      oPianoIntermedio.X = oPianoIntermedio.X-4; 
      oCielo.X = oCielo.X-8;
      Wait(2);
    }
    
    goRight = true;
    goLeft = false;
  }
    
}
    

Sorry I forgot that my variable names are in italian,
so oCielo is for sky, oPianoIntermedio is for middle ground.

In this way the objects scrolls in different speeds while also camera moves.
https://ko-fi.com/giacomo97557 To support Falco's adventures

SMF spam blocked by CleanTalk