Adventure Game Studio

AGS Support => Modules, Plugins & Tools => Topic started by: eri0o on Mon 07/10/2019 03:26:58

Title: MODULE: rellax 0.4.0
Post by: eri0o on Mon 07/10/2019 03:26:58
rellax version 0.4.0

Get Latest Release rellax.scm (https://github.com/ericoporto/rellax/releases/download/0.4.0/rellax.scm) | GitHub Repo (https://github.com/ericoporto/rellax) | Demo Windows (https://github.com/ericoporto/rellax/releases/download/0.4.0/rellax_demo_windows.zip) | Demo Linux (https://github.com/ericoporto/rellax/releases/download/0.4.0/rellax_demo_linux.tar.gz) | Download project .zip  (https://github.com/ericoporto/rellax/archive/master.zip)

Rellax while the camera tracks with cool parallax

(https://raw.githubusercontent.com/ericoporto/rellax/master/rellax_demo.gif) (https://imgur.com/nJGnylM)

This module uses the camera and Viewport API from Adventure Game Studio 3.5.0.

Demo game uses keyboard arrows control, up arrow jumps. WASD should also work.


Usage
Before starting, you must create the following Custom Properties in AGS Editor, for usage with Objects.
Just click on Properties [...] and on the Edit Custom Properties screen, click on Edit Schema ... button, and add the two properties below:

PxPos:

PyPos:

The number defined on Px or Py will be divided by 100 and used to increase the scrolling.
An object with Px and Py 0 is scrolled normally, an object with Px and Py 100 will be fixed on the screen despite camera movement.
Objects with negative Px and Py are usually at the front, and positive values are usually at the back.


Script API

static attribute Character* TargetCharacter
The character being tracked by the Game.Camera.

static attribute bool EnableParallax
Gets/sets whether Parallax is on or off.

static attribute bool EnableSmoothCam
Gets/sets whether Smooth Camera tracking is on or off.

static attribute bool AutomaticallySetupOnRoomLoad
Gets/sets whether to automatically setup on room load. It defaults to yes (true).
Leave as this unless you really need it.

static void SetupRoomManually()
You should not call this, unless AutomaticallySetupOnRoomLoad is false.
Then call this at the end of your room_Load, after you are done setting things up.

static attribute bool AdjustCameraOnRoomLoad
Gets/sets whether to instantly adjust camera to target on room before fade in, when Smooth Camera is on. Default is true.

static attribute RellaxTweenEasingType EasingType
gets/sets the camera tween type to use when the character is stopped.

static attribute float TweenDuration
gets/sets the camera tween duration once the character is stopped.

static attribute int CameraOffsetX
Gets/sets the camera horizontal offset. It's applied without smoothing.

static attribute int CameraOffsetY
Gets/sets the camera vertical offset. It's applied without smoothing.

static attribute int CameraLookAheadX
Gets/sets the camera horizontal lookahead offset. This is an additional offset that is added in the direction the target character is facing (only 4 direction support now).

static attribute int CameraLookAheadY
Gets/sets the camera vertical lookahead offset. This is an additional offset that is added in the direction the target character is facing (only 4 direction support now).

static attribute int CameraLerpFactorX
Gets/sets the factor the camera should use when interpolating in the X axis.

static attribute int CameraLerpFactorY
Gets/sets the factor the camera should use when interpolating in the Y axis.

static attribute int CameraWindowWidth
Gets/sets the camera window width that is centered on the target lookahead point, when the target is outside of the window, the camera moves to keep it inside.

static attribute int CameraWindowHeight
Gets/sets the camera window height that is centered on the target lookahead point, when the target is outside of the window, the camera moves to keep it inside.


License
This module is created by eri0o is provided with MIT License, see LICENSE (https://github.com/ericoporto/rellax/blob/master/LICENSE) for more details.
The code on this module is based on the code of Smooth Scrolling + Parallax Module from Alasdair Beckett, which bases on code from Steve McCrea.
It uses easing code based on Edmundo Ruiz and Robert Penner's, works, which are MIT and BSD licensed, respectively (and included in the module script).
The demo game uses CC0 (Public Domain) art provided by jetrel (https://opengameart.org/users/jetrel).
Title: Re: MODULE: rellax 0.1.0
Post by: Mehrdad on Mon 07/10/2019 15:29:42
Hi  @eri0o

It's so fantastic!!!  8-0. FPS is great too. Is it possible to add some features like Grab ledge and so on?
Title: Re: MODULE: rellax 0.1.0
Post by: eri0o on Mon 07/10/2019 16:52:09
The module is just for parallax and smooth camera, the platformer was just for fun to test it under quick movement situations :)

The game project is on GitHub, you can also  download it as zip (https://github.com/ericoporto/rellax/archive/master.zip), if you want to play with the code, the platformer bits are all on room1.asc, and it's just around 100 lines of code (if I remember it correctly). It requires the latest 3.5.0 release available!

Erh, maybe the take here is figuring out a new module that would provide some facility for 2D platfomer, but I don't have anything figured out for this for now (except further developing AgsBox2D to support the full Box2D api, but still, details like grab ledge would be onto who is using it :/)
Title: Re: MODULE: rellax 0.1.0
Post by: Olleh19 on Wed 09/10/2019 20:26:02
Thanks eri0o, that module will probably come in handy once i start exporting various art groups separated from Photoshop! :) I've always wanted to see how a "plattformer" is made in AGS also, i know there's another plattformer done by abstauber. It didn't work in Ags 4.3.1 tho :-\ parallax scrolling is really cool too indeed.  (nod). Looks like i have to get the latest AGS, will do! 8-)
Title: Re: MODULE: rellax 0.1.2
Post by: eri0o on Sat 09/11/2019 18:11:25
@Olleh19 the platformer here was just a small thing so it was faster to see the parallax effects happening than by just clicking to interact, so a really dedicated person can make a platformer with a much nicer code :]

Just adding minor bug fix that prevented actually turning the smooth scroll off before.

Edit: Small fix so that the parallax still happens even when smoothing is disabled.
Title: Re: MODULE: rellax 0.1.2
Post by: Julius Dangerous on Tue 31/12/2019 23:23:58
Wow Beautiful!
Title: Re: MODULE: rellax 0.1.2
Post by: eri0o on Wed 01/01/2020 13:14:11
Thanks!

I have a small update to add in and need to throw a little explanation on how to mod it.

Also I discovered there's no way a character that walks really fast and have movement linked to animation can have a smooth scroll on the background AND not have the character blurred, so if anyone plans to use this, I recommend adding a check that if the level has a big scroll to change the movement type of the character (again, this is only a problem if the character walks really fast). Other alternative is a old-school Zelda like scrolling - just lerp rounding for camera sized grid.
Title: Re: MODULE: rellax 0.1.2
Post by: Monsieur OUXX on Mon 03/02/2020 12:36:46
Can you describe how your module differs from the SmoothScrolling module, which offered smooth scrolling & Parallax (by Ali) (https://www.adventuregamestudio.co.uk/forums/index.php?topic=33142) and foreground+background parallax too?
Title: Re: MODULE: rellax 0.1.2
Post by: eri0o on Mon 03/02/2020 13:46:50
Basic changes are:

- use of AGS 3.5.0 Camera API, even though a single camera.
- parallax on y axis
- fractional parallax, instead of pre-defined values


Additionally, but totally subjective:
- algorithm works better for the specific demoed case of a character that jumps in a platform.
- code is simpler and easier to understand and modify (like, zone based scrolling like NES Zelda is easy to mod to achieve it)

"Bug" still present:
- character with movement linked to animation moving fast will produce "ghosting" when scrolling as the previous module did. I tried a ton of things and decided is just best to not have movement linked to animation with large scrolling areas and fast characters.

Known issue:

I need to close an issue opened on GitHub and release a new version of this.
Title: Re: MODULE: rellax 0.1.2
Post by: Monsieur OUXX on Mon 03/02/2020 14:19:56
Quote from: eri0o on Mon 03/02/2020 13:46:50
Basic changes are:

Love it!
Title: Re: MODULE: rellax 0.1.2
Post by: Ali on Mon 03/02/2020 16:16:04
Great stuff, my module is getting pretty old. I've put a link to this one on the first post.
Title: Re: MODULE: rellax 0.1.2
Post by: Monsieur OUXX on Mon 03/02/2020 17:07:31
Quote from: Ali on Mon 03/02/2020 16:16:04
Great stuff, my module is getting pretty old. I've put a link to this one on the first post.

Your module was awesome, but it's nice to have a module made for 3.5 natively.
Title: Re: MODULE: rellax 0.1.2
Post by: eri0o on Tue 04/02/2020 00:13:18
Thank you Ali! You are awesome! I used your module for so much for so long! And you make cool games, and you are fun and have beautiful hair :]

---

Edit:

Pushed a minor bug fix update:
Title: Re: MODULE: rellax 0.1.3
Post by: ld-airgrafix on Thu 20/02/2020 07:23:07
Thank you so much for this, it works so well and smooth
Title: Re: MODULE: rellax 0.1.4
Post by: eri0o on Wed 01/07/2020 14:35:25
Small update, adding some attributes to the module API!


Now, I really liked having a very tiny API but I recently needed to do some more things with it in a game and decided it was best to add to the module itself. If someone has needs here when using it, please write and we try to figure out a solution.
Title: Re: MODULE: rellax 0.1.4
Post by: Snarky on Thu 30/07/2020 12:28:33
Quote from: eri0o on Mon 03/02/2020 13:46:50
- character with movement linked to animation moving fast will produce "ghosting" when scrolling as the previous module did. I tried a ton of things and decided is just best to not have movement linked to animation with large scrolling areas and fast characters.

Something that just occurred to me is that it might be possible to have movement linked to animation that is automatically disabled (and movement speeds adjusted accordingly) only when the background is scrolling. That way you avoid gliding whenever the background is static, but get smooth scrolling without character "ghosting" or jittering when it scrolls. (The trade-off is of course that the character will glide whenever the room is scrolling, but my hypothesis is that this will be less noticeable.)
Title: Re: MODULE: rellax 0.1.4
Post by: eri0o on Thu 30/07/2020 13:07:10
I think it would be something that needs to run before the function that tells the character to go to place "x", so what could be done theoretically is a function that guesses from a x,y point if the target character moving to that spot would require the room to scroll. This is a guess from looking how the pathfinding is fed to the characters in ags.

To do this, we need to know the path the character will take and see if any step on it will cause the room to scroll.

I think the easiest way is to use a dummy character and make it walk instantly and then "break" when there's a scroll and feed this info to do the change before the Process Click / walk to is ran, and leave the handling of this to the developer.

In my game I do a simpler thing than this which is: rooms that scroll are always the "gliding type" and rooms that don't make the player character use the other type of movement. In rooms that scroll I try to minimize regions that don't scroll by either giving large black border (if interior) or having carefully placed obstacle (in exterior areas).
Title: Re: MODULE: rellax 0.1.4
Post by: Snarky on Thu 30/07/2020 13:16:39
Quote from: eri0o on Thu 30/07/2020 13:07:10
I think it would be something that needs to run before the function that tells the character to go to place "x"

I was hoping Character.MovementLinkedToAnimation could be switched on the fly while walking. It would also require some sort of IsCurrentlyScrolling module state, at least internally.
Title: Re: MODULE: rellax 0.1.4
Post by: eri0o on Thu 30/07/2020 13:26:58
That state is easy to provide. I can give a try to this tonight and also check if the movement linked to animation can be set while walking - I really don't know.

I was also looking into adding more functions that would be used by the lerp, like those in the tween module, but have not yet figured the right way to do, but the idea would be so you could have a "spring" camera or other fun equations.
Title: Re: MODULE: rellax 0.1.4
Post by: Flugeldufel on Fri 04/09/2020 21:12:20
Hi eri0o, first of all thank you for this awesome module. But now I noticed something - no big issue, but a little bit annoying. When the player walks in a scrollable room from one edge to the other, the background ends a few pixels too soon. When he walks back again, the same happens to the other side (as shown in the picture). So after one walk to the other edge and back, both edges of the background are cut off.  ???

(https://i.imgur.com/jwdhu0B.jpg)

The Game's resolution is 320x180, the rooms are of different width, but it happens in every scrollable room.
I'm using the latest AGS Version (3.5.0 Patch 4) and no other modules (except 'Tween' of course)

Thanks and sorry if I missed the answer somewhere...
Title: Re: MODULE: rellax 0.1.4
Post by: eri0o on Fri 04/09/2020 23:56:14
@Flugeldufel Thanks, I had never noticed that issue.

It happens if you get to a lower than 12 distance between Current Camera Position and the Wanted Camera Position apparently.

For now you can replace the rellax.asc file with the content below.

rellax.asc (https://gist.githubusercontent.com/ericoporto/5269ca344027c6538bca2a20d1cae559/raw/aa386bb9c93feda26002eb8497e9947d24b3a4a8/rellax.asc)

Spoiler
Code (ags) Select
// Rellax
// 0.1.5~
// A module to provide smooth scrolling and parallax!
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
// Before starting, you must create the following Custom Properties
// in AGS Editor, for usage with Objects.
// Just click on Properties [...] and on the Edit Custom Properties screen,
// click on Edit Schema ... button, and add the two properties below:
//
// PxPos:
//    Name: PxPos
//    Description: Object's horizontal parallax
//    Type: Number
//    Default Value: 0
//
// PyPos:
//    Name: PyPos
//    Description: Object's vertical parallax
//    Type: Number
//    Default Value: 0
//
//  The number defined on Px or Py will be divided by 100 and used to increase
// the scrolling. An object with Px and Py 0 is scrolled normally, an object
// with Px and Py 100 will be fixed on the screen despite camera movement.
//
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//
// based on Smooth Scrolling + Parallax Module
// by Alasdair Beckett, based on code by Steve McCrea.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
// restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.

#define MAX_PARALLAX_OBJS 39

Character *_TargetCharacter;

Object *_pxo[MAX_PARALLAX_OBJS];
int _pxoRoomStartX[MAX_PARALLAX_OBJS];
int _pxoRoomStartY[MAX_PARALLAX_OBJS];
int _pxoOriginX[MAX_PARALLAX_OBJS];
int _pxoOriginY[MAX_PARALLAX_OBJS];
int _pxo_count;

int _cam_window_w, _cam_window_h;
float _scroll_x,  _scroll_y;
int _next_cam_x, _next_cam_y;
int _prev_c_x, _prev_c_y;
int _off_x, _off_y;
int _look_ahead_x = 48;
int _look_ahead_y = 16;

int _partial_c_height;
int _count_still_ticks;

bool _is_doRoomSetup;
bool _SmoothCamEnabled = true;
bool _ParallaxEnabled = true;

float _Abs(float v) {
  if(v<0.0) return -v;
  return v;
}

int _Lerp(float from, float to, float t) {
  return FloatToInt(from + (to - from) * t, eRoundNearest);
}

int _ClampInt(int value, int min, int max) {
  if (value > max) return max;
  else if (value < min) return min;
  return value;
}

void doObjectParallax(){
  int camx = _next_cam_x;
  int camy = _next_cam_y;

  for(int i=0; i<_pxo_count; i++){
    if(_pxo[i].GetProperty("PxPos") !=0 || _pxo[i].GetProperty("PyPos") != 0) {
      float parallax_x = IntToFloat(_pxo[i].GetProperty("PxPos"))/100.0;
      float parallax_y = IntToFloat(_pxo[i].GetProperty("PyPos"))/100.0;

      _pxo[i].X=_pxoOriginX[i]+FloatToInt(IntToFloat(camx)*parallax_x);
      _pxo[i].Y=_pxoOriginY[i]+FloatToInt(IntToFloat(camy)*parallax_y);
    }
  }
}

void _enable_parallax(bool enable) {
  _ParallaxEnabled = enable;
}

void _enable_smoothcam(bool enable) {
  if(enable == true){
    doObjectParallax();
  }

  _SmoothCamEnabled = enable; 
}

void _set_targetcharacter(Character* target) {
  _TargetCharacter = target;
}

// ---- Rellax API ------------------------------------------------------------

void set_TargetCharacter(this Rellax*, Character* target)
{
  _set_targetcharacter(target);
}

Character* get_TargetCharacter(this Rellax*)
{
  return  _TargetCharacter;
}

void set_EnableParallax(this Rellax*, bool enable)
{
  _enable_parallax(enable);
}

bool get_EnableParallax(this Rellax*)
{
  return _ParallaxEnabled;
}

void set_EnableSmoothCam(this Rellax*, bool enable)
{
  _enable_smoothcam(enable);
}

bool get_EnableSmoothCam(this Rellax*)
{
  return _SmoothCamEnabled;
}

void set_CameraOffsetX(this Rellax*, int offset_x)
{
  _off_x = offset_x;
}

int get_CameraOffsetX(this Rellax*)
{
  return _off_x;
}

void set_CameraOffsetY(this Rellax*, int offset_y)
{
  _off_y = offset_y;
}

int get_CameraOffsetY(this Rellax*)
{
  return _off_y;
}

void set_CameraLookAheadX(this Rellax*, int look_ahead_x)
{
  _look_ahead_x = look_ahead_x;
}

int get_CameraLookAheadX(this Rellax*)
{
  return _look_ahead_x;
}

void set_CameraLookAheadY(this Rellax*, int look_ahead_y)
{
  _look_ahead_y = look_ahead_y;
}

int get_CameraLookAheadY(this Rellax*)
{
  return _look_ahead_y;
}

// ----------------------------------------------------------------------------

void doSetOrigins (){
  _pxo_count=0; // Reset the total number of parallax objects to zero
  float cam_w = IntToFloat(Game.Camera.Width);
  float cam_h = IntToFloat(Game.Camera.Height);
  float room_w = IntToFloat(Room.Width);
  float room_h = IntToFloat(Room.Height);

  for(int i=0; i<Room.ObjectCount; i++){
    if (object[i].GetProperty("PxPos")!=0) {
_pxo[_pxo_count]=object[i];
      float parallax_x = IntToFloat(object[i].GetProperty("PxPos"))/100.0;
      float parallax_y = IntToFloat(object[i].GetProperty("PyPos"))/100.0;

      float obj_x = IntToFloat(object[i].X);
      float obj_y = IntToFloat(object[i].Y);

      // initial positions for reset
      _pxoRoomStartX[_pxo_count]= object[i].X;
      _pxoRoomStartY[_pxo_count]= object[i].Y;

      //Set origin for object:
      _pxoOriginX[_pxo_count] = object[i].X -FloatToInt(
        parallax_x*obj_x*(room_w-cam_w) / room_w );

      _pxoOriginY[_pxo_count] = object[i].Y -FloatToInt(
        parallax_y*obj_y*(room_h-cam_h) / room_h );

if(_pxo_count<MAX_PARALLAX_OBJS) _pxo_count++;
}
   }
  doObjectParallax();
}

void doRoomSetup(){
  Game.Camera.X = _ClampInt(_TargetCharacter.x-Game.Camera.Width/2,
    0, Room.Width-Game.Camera.Width);

  Game.Camera.Y = _ClampInt(_TargetCharacter.y-Game.Camera.Height/2,
    0, Room.Height-Game.Camera.Height);

  _next_cam_x = Game.Camera.X;
  _next_cam_y = Game.Camera.Y;
  doSetOrigins();

  ViewFrame* c_vf = Game.GetViewFrame(_TargetCharacter.NormalView, 0, 0);
  float scaling = IntToFloat(GetScalingAt(_TargetCharacter.x, _TargetCharacter.y))/100.00;
  _partial_c_height = FloatToInt((IntToFloat(Game.SpriteHeight[c_vf.Graphic])*scaling)/3.0);

  if (_ParallaxEnabled) _enable_parallax(true);
  else _enable_parallax(false);
  _is_doRoomSetup = true;
}

void doSmoothCameraTracking(){
  if(_prev_c_x == _TargetCharacter.x && _prev_c_y == _TargetCharacter.y)
    _count_still_ticks++;
  else
    _count_still_ticks = 0;

  if(_TargetCharacter.x-Game.Camera.Width/2-Game.Camera.X<=-_cam_window_w/2 ||
     _TargetCharacter.x-Game.Camera.Width/2-Game.Camera.X>_cam_window_w/2 ||
     _TargetCharacter.y-Game.Camera.Height/2-Game.Camera.Y<=-_cam_window_h/2 ||
     _TargetCharacter.y-Game.Camera.Height/2-Game.Camera.Y>_cam_window_h/2 ||
     _count_still_ticks > 5){

    int x_focus=0,y_focus=0;
    if(_TargetCharacter.Loop == 2) x_focus = _look_ahead_x; // right
    else if(_TargetCharacter.Loop == 1) x_focus = -_look_ahead_x; // left
    else if(_TargetCharacter.Loop == 0) y_focus = _look_ahead_y; // down
    else if(_TargetCharacter.Loop == 3) y_focus = -_look_ahead_y; // up

    float y_multiplier;
    if(_count_still_ticks<=30) y_multiplier = IntToFloat(_count_still_ticks)*0.138 ;
    if(_count_still_ticks>30) y_multiplier = 5.0;

    float target_cam_x = IntToFloat(_ClampInt(_TargetCharacter.x + _off_x + x_focus - Game.Camera.Width/2,   0, Room.Width-Game.Camera.Width));
    float target_cam_y = IntToFloat(_ClampInt(_TargetCharacter.y + _off_y + y_focus - _partial_c_height - Game.Camera.Height/2,   0, Room.Height-Game.Camera.Height));
    float current_cam_x =  IntToFloat(Game.Camera.X);
    float current_cam_y =  IntToFloat(Game.Camera.Y);
    float lerp_factor_x = 0.04;
    float cam_distance_x = _Abs(target_cam_x - current_cam_x);
   
    if( cam_distance_x < 32.0 && cam_distance_x >= 1.0) {
      lerp_factor_x  = 0.913*Maths.RaiseToPower(cam_distance_x, -0.7268);
    }   

    _next_cam_x = _Lerp( current_cam_x, target_cam_x, lerp_factor_x );
    _next_cam_y = _Lerp( current_cam_y, target_cam_y, 0.01*y_multiplier);
  }

  _prev_c_x = _TargetCharacter.x;
  _prev_c_y = _TargetCharacter.y;
}

// --- callbacks --------------------------------------------------------------

function on_event (EventType event, int data){
  // player exits any room
  if (event==eEventLeaveRoom){
    for(int i=0; i<_pxo_count; i++){
      _pxo[i].X=_pxoRoomStartX[i];
      _pxo[i].Y=_pxoRoomStartY[i];
    }
    _is_doRoomSetup = false;
  }

  // player enters a room that's different from current
if (event==eEventEnterRoomBeforeFadein){
    if(!_is_doRoomSetup){
      doRoomSetup();
    }
  }
}

function game_start(){
 
  System.VSync = true;
  _cam_window_w = 40;
  _cam_window_h = 40;
  _set_targetcharacter(player);
  _enable_parallax(true);
  _enable_smoothcam(true);
}

function late_repeatedly_execute_always(){
  if(_SmoothCamEnabled) doSmoothCameraTracking();
  if(_ParallaxEnabled) doObjectParallax();
  if(_SmoothCamEnabled) Game.Camera.SetAt(_next_cam_x, _next_cam_y);
  else {
    _next_cam_x = Game.Camera.X;
    _next_cam_y = Game.Camera.Y;
  }
}

function repeatedly_execute_always(){
  if(!_is_doRoomSetup) doRoomSetup();
}
[close]

This should fix for now, but I am not completely satisfied with the resulting camera movement, kinda wanted to be a bit smoother, so I need to think a little bit more. Please confirm that the above code temporarily solves for you.
Title: Re: MODULE: rellax 0.1.4
Post by: Flugeldufel on Sat 05/09/2020 07:10:22
Oh thank you for your quick response  :)
I‘m currently on the phone, but I will test it within the next hours, as soon as I‘m at home.
Title: Re: MODULE: rellax 0.1.4
Post by: Flugeldufel on Sat 05/09/2020 09:39:29
Yeah, it works. You're right, the movement isn't as smooth as before, but for a low-res old school game it's not that crucial...
So, no hurry - I just wanted to know if there's something wrong with the module or I'm just stupid  ;)

And thanks again for your fast help!
Title: Re: MODULE: rellax 0.1.4
Post by: Olleh19 on Sun 13/09/2020 18:45:18
Hey eri0o!

Just tried it in my upcoming game, and some issues occured.. And here is what happens if you try to use this module in a game sorta like Day of the Tentacle or Thimbleweed Park where you have different playable characters. The Parallax does not seem to recognise the character change, so the parallax effect gets stuck. Maybe it's just me, that don't understand how to do it, but just maybe you could do some kind of check for what player character is active, so the parallax follows that specific player.

Obviously since i've played Thimbleweed Park lately i was excited to try parallax scrolling, however when running in the Thumbleweed Template, the player gets transported back in the picture when running to the sides, so it looks funny. (laugh). Also the Parallax scrolling is stuttery looking, maybe that could be solved if i understood how to change the speed of the parallax, i'm not sure (Not using any objects, just followed the intro post's posy, posx in properties).

Btw, is there a manual of it somewhere? The syntax you wrote in the intro post, i just don't get how to use those in the scripts, it's way over my head, so examples would be great. I've tried several ways that i thought might would work, but to no success. However i did follow the instructions

Thanks, and i hope you deicide to keep working on this, tho it is a really cool feature for usage in AGS games  :)

Title: Re: MODULE: rellax 0.1.4
Post by: eri0o on Tue 15/09/2020 00:11:18
Hey Olleh19, I still need to figure out Flugerdufel problem. I use this module in my game, like my main use case is myself, which means if the problem doesn't affect me I tend to postpone solving - most from simply lack of time.

So you need to set the target character, basically the variable player points to a character, say cBob, when you assign player as target character, Rellax.TargetCharacter = player, you are actually assigning Rellax.TargetCharacter = cBob. Let's say now you change the player to cAlice, cAlice.SetAsPlayer(), NOW the player pointer will point to cAlice. But you have previously assigned the TargetCharacter as cBob. So you need to actually do something like this when changing player character:

Code (ags) Select
cAlice.SetAsPlayer();
Rellax.TargetCharacter = player;


About parallax scrolling being stuttery it will depend on many things so I can't comment. I recommending using SetGameSpeed(60). Basically the parallax is an illusion and the math is made simple, the object posx/posy (X position, Y position) is increased/decreased (divided by 100, this way I mentally think in percentages) an additional amount when the camera scrolls. The code is simple enough to be posted below, I find it easy to follow. The pxo are the room objects, the variable naming is stolen from Ali's module.

Code (ags) Select
void doObjectParallax(){
  int camx = _final_cam_x;
  int camy = _final_cam_y;

  for(int i=0; i<_pxo_count; i++){
    float parallax_x = IntToFloat(_pxo[i].GetProperty("PxPos"))/100.0;
    float parallax_y = IntToFloat(_pxo[i].GetProperty("PyPos"))/100.0;

    _pxo[i].X=_pxoOriginX[i]+FloatToInt(IntToFloat(camx)*parallax_x);
    _pxo[i].Y=_pxoOriginY[i]+FloatToInt(IntToFloat(camy)*parallax_y);
  }
}


So you set the room objects custom properties, and then you basically only use Rellax.EnableParallax = true on Room Load and you are done.
Title: Re: MODULE: rellax 0.1.4
Post by: Olleh19 on Tue 15/09/2020 22:07:20
Quote from: eri0o on Tue 15/09/2020 00:11:18
Hey Olleh19, I still need to figure out Flugerdufel problem. I use this module in my game, like my main use case is myself, which means if the problem doesn't affect me I tend to postpone solving - most from simply lack of time.

So you need to set the target character, basically the variable player points to a character, say cBob, when you assign player as target character, Rellax.TargetCharacter = player, you are actually assigning Rellax.TargetCharacter = cBob. Let's say now you change the player to cAlice, cAlice.SetAsPlayer(), NOW the player pointer will point to cAlice. But you have previously assigned the TargetCharacter as cBob. So you need to actually do something like this when changing player character:

Code (ags) Select
cAlice.SetAsPlayer();
Rellax.TargetCharacter = player;


About parallax scrolling being stuttery it will depend on many things so I can't comment. I recommending using SetGameSpeed(60). Basically the parallax is an illusion and the math is made simple, the object posx/posy (X position, Y position) is increased/decreased (divided by 100, this way I mentally think in percentages) an additional amount when the camera scrolls. The code is simple enough to be posted below, I find it easy to follow. The pxo are the room objects, the variable naming is stolen from Ali's module.

Code (ags) Select
void doObjectParallax(){
  int camx = _final_cam_x;
  int camy = _final_cam_y;

  for(int i=0; i<_pxo_count; i++){
    float parallax_x = IntToFloat(_pxo[i].GetProperty("PxPos"))/100.0;
    float parallax_y = IntToFloat(_pxo[i].GetProperty("PyPos"))/100.0;

    _pxo[i].X=_pxoOriginX[i]+FloatToInt(IntToFloat(camx)*parallax_x);
    _pxo[i].Y=_pxoOriginY[i]+FloatToInt(IntToFloat(camy)*parallax_y);
  }
}


So you set the room objects custom properties, and then you basically only use Rellax.EnableParallax = true on Room Load and you are done.

Thanks for your reply! I've used setplayer a lot of course, can't believe i didn't try that one! (doh!!). (laugh)
I'll play around with gamespeed aswell, thanks and once again keep working on it. I think it could be really cool if in the future it was inside the thumbleweed template. Since it's missing the parall feature.  :)

Edit: Rellax was it, now i'm making it look way better turns out all i needed was CameraLookaheadX and a minus value!

Title: Re: MODULE: rellax 0.1.4
Post by: TheVolumeRemote on Sat 06/03/2021 21:53:20
Love Rellax (Thank you!). I have a question, I have one scene which for comedic timing requires very fast cuts, immediate back and fourth between two players trading off as SetAsPlayer. It works w the default/stock AGS settings but with Rellax it’s so smooth, the comedic timing is lost.

Is there a way to disable Rellax during a function/midway in a rooms script? It tried
Code (ags) Select
Rellax.EnableSmoothCam = false;
But it doesn’t then use default AGS camera movement so it no longer targets/tracks the set player.

I also tried
Code (ags) Select
Rellax.CameraLookAheadX = 100;
With various numerical values, the idea was to move it so fast to the newly set player that it would look like a quick cut. No luck though.

Finally I tried making a duplicate/identical room just for the part I need quick cuts and even with enablesmoothcam off at room load, AGS’s default camera movement isn’t kicking in.

So long short, is there a way, even if it’s with default/stock AGS camera commands, to have Rellax working in a room and then for one segment, have it “off” for quick camera cuts? Alternatively, instead of turning it off and using AGS commands, perhaps Rellax can do quick cuts with a setting?

Thank you for any tips!
Title: Re: MODULE: rellax 0.1.4
Post by: eri0o on Mon 08/03/2021 15:53:09
I think you are mixing what the module does and what ags cameras do.

AGS Cameras have a property called AutoTracking which will make them follow whoever is the player.

https://adventuregamestudio.github.io/ags-manual/Camera.html#cameraautotracking

If you move the camera in other ways, like directly setting a camera position, it will disable this tracking, which is necessary for the module.

https://adventuregamestudio.github.io/ags-manual/Camera.html#camerasetat

Your default game camera can be accessed under Game.Camera property. When you disable the rellax camera, if you want it to return the default following you can just set AutoTracking to true.

I usually do my Camera movement that is not through rellax using the Tween module - because I usually want the smoothness - but it's interesting that you have a use case without smoothness.

There's a constant inside rellax that sets the smoothness, perhaps I could expose it too in case people want to tweak it.
Title: Re: MODULE: rellax 0.1.4
Post by: Tarnos12 on Mon 12/07/2021 19:11:23
Hey,

What happened to the module?
All links are broken, github repo is no longer available.
Is there a way to get this module?

Thanks ;]
Title: Re: MODULE: rellax 0.1.4
Post by: Snarky on Wed 14/07/2021 09:47:37
It's back now.  :)
Title: Re: MODULE: rellax 0.1.4
Post by: Tarnos12 on Thu 15/07/2021 00:09:38
Thanks  :-D
Title: MODULE: rellax 0.1.4
Post by: Hobbes on Sun 29/08/2021 04:04:46
Hi Eri0o, recently gave the rellax module a go and it's phenomenal! The smooth scrolling of the camera is an amazing addition to my game.

I was curious though, is there a way to temporarily disable rellax? Certain cutscenes in my game would play better without, so if there was a rellax.disable() command or something similar, that would be great. Not sure if I'm looking in the right place for it! Any help you can give would be most appreciated. Thanks for creating this module in the first place!
Title: Re: MODULE: rellax 0.1.4
Post by: eri0o on Sun 29/08/2021 06:15:45
Hobbes, try Rellax.EnableSmoothCam = false; , there's also a separate one for disabling parallax scrolling - you may want to disable camera smoothing but keep parallax scrolling going if you are controlling the camera with a Tween for example.
Title: MODULE: rellax 0.1.4
Post by: Hobbes on Sun 29/08/2021 09:54:12
That did the trick - thank you!
Title: Re: MODULE: rellax 0.1.4
Post by: Icey on Mon 03/01/2022 11:44:21
Hey again, eri0o!  :grin:

I wanted to try to get the smooth scrolling module up that Ali made up and running and I found my way here after having some weird kind of problem with it.
I figured I'd give your module a go, and lo and behold, I'm having similar problem with AGS getting confused over some type of property issue?
(I see there is two other after it as well, but that "PxPos" one was a problem in both modules.

(https://i.imgur.com/2tDrKfy.png)
Title: Re: MODULE: rellax 0.1.4
Post by: Crimson Wizard on Mon 03/01/2022 12:24:05
@Icey, you need to read the description given in the first post (under the spoiler), it explains how to setup "PxPos" custom properties.

Custom properties are the way to add new values to game objects. Topic covering custom properties may be found in the manual: https://adventuregamestudio.github.io/ags-manual/CustomProperties.html
Title: Re: MODULE: rellax 0.1.4
Post by: eri0o on Mon 03/01/2022 13:12:10
@Icey, what CW said, the how-to, it's in the first page!

An important thing from that page that could be useful to you:

an object with Px and Py 100 will be fixed on the screen despite camera movement.

This is about your other question in the other topic.
Title: Re: MODULE: rellax 0.1.4
Post by: Icey on Mon 03/01/2022 23:36:37
That's interesting! I remember using this previously (if I'm correct) I was able to do load in the module and it would just work. So I wasn't sure if I could if was because of a new version of AGS or something else on my end.

I'll make sure to refer to that guide, and also thanks for the tip about Pxy 100. I was most likely going to lead to another question haha.
Title: Re: MODULE: rellax 0.1.4
Post by: Laura Hunt on Sat 15/01/2022 08:46:20
Hi eri0o,

I'm trying out your module only for the smooth camera tracking functionality (I don't need parallax for now, so I switched it off), but the behaviour is kind of weird. As you can see, the camera is not tracking the character as it walks, but only when it stops walking, resulting in a very jittery movement, rather than the smooth continuous scroll I was hoping for:

(https://i.imgur.com/LIGQefh.gif)

Any idea what could be happening here? I have tried adding some camera lookahead on the Y axis (since the room only scrolls vertically), but it makes no difference. I'm using AGS 3.5.1 (patch 4).
Title: Re: MODULE: rellax 0.1.4
Post by: eri0o on Sat 15/01/2022 09:51:05
It's probably the lerp factor here

https://github.com/ericoporto/rellax/blob/a6d532a4d938833709cd5c618216b049461f4593/rellax.asc#L272

I will come up with a way to expose this as a property.

I need to check since when I made this module for my problem with faster walkspeed in mind - like the platformer in the demo. This is the same problem previously reported but linked above.

Relax works like this (from memory), there's a 40x40px box at the center of the screen, when the character is outside of this box things happen to attempt to put it back in the box. I think for lower speeds I need to also expose this property to reduce this window size, this is made so it's easier to do precision jumps in a platformer or other precise movements without the window scrolling, but 40px window may be too big depending on game resolution - hence the need to expose it.

Ah it can also be the still ticks. Can you make your game 60fps instead of 40fps? It should take half a second on a 60fps game, I can also expose the still ticks, these were made for when a character falls it falls downwards, it only matters if the movement is done without leaving the box borders.

Edit:

Later today I will do a new release that should ease understanding, tuning the camera and fixing issues.
Title: Re: MODULE: rellax 0.1.4
Post by: Laura Hunt on Sat 15/01/2022 09:58:08
I see, thanks for replying!

Could I alter these values manually in the module code, or will I break something? From what I gather, I might need to change the 0.04 value in line 272, as well as the 40x40 box in lines 307 and 308:

Code (ags) Select
  _cam_window_w = 40;
  _cam_window_h = 40;


Is this correct? Anything else I might want to tweak? :)

Quote from: eri0o on Sat 15/01/2022 09:51:05
Ah it can also be the still ticks. Can you make your game 60fps instead of 40fps? It should take half a second on a 60fps game, I can also expose the still ticks, these were made for when a character falls it falls downwards, it only matters if the movement is done without leaving the box borders.

The game is already set to 60 (it might look like it has a lower fps because the gif is captured at 33 fps).
Title: Re: MODULE: rellax 0.1.4
Post by: Laura Hunt on Sat 15/01/2022 12:32:20
So I managed to find a workaround by commenting out these lines in order to set the still ticks to a fixed value of 30:

Code (ags) Select
void doSmoothCameraTracking(){
  //if(_prev_c_x == _TargetCharacter.x && _prev_c_y == _TargetCharacter.y)
    //_count_still_ticks++;
  //else
    _count_still_ticks = 30;


By doing this, now the camera follows the character as soon as it moves, instead of waiting until it stands still, so yay I guess :-D (disclaimer: as mentioned above, the game runs at 60 fps but the gif was captured at 33 fps, so it doesn't look as smooth here as it does in-game).

(https://i.imgur.com/afsGqjx.gif)

I've tried with different values below 30 and also with 31 (as from what I can see, all values greater than 30 yield the same result) and 30 seems to be the smoothest. However, although the camera scroll in itself is smooth, the character's movement still looks a little bit jerky. Is there any other parameter I could tweak further in order to improve this?

Title: Re: MODULE: rellax 0.1.4
Post by: eri0o on Sat 15/01/2022 13:04:20
The only way I found to truly unjerk the movement is to not use movement linked with animation. In my games I only use it in rooms where the camera doesn't move, and every other rooms I don't. The usage of still ticks and the box alleviates it but only works if the character still moves reasonably fast.

Set your playable Character MovementLinkedToAnimation (https://adventuregamestudio.github.io/ags-manual/Character.html#charactermovementlinkedtoanimation) (anti-glide) to off and see how well it works. If the room has lots of scrolling the gliding is not very perceptible.

You can of course edit the code of the module, I want to update it so it's possible to change these values without doing so, because then it should be easier to everyone. :)
Title: Re: MODULE: rellax 0.1.4
Post by: Laura Hunt on Sun 16/01/2022 08:18:03
Quote from: eri0o on Sat 15/01/2022 13:04:20
Set your playable Character MovementLinkedToAnimation (https://adventuregamestudio.github.io/ags-manual/Character.html#charactermovementlinkedtoanimation) (anti-glide) to off and see how well it works. If the room has lots of scrolling the gliding is not very perceptible.

It does look better! The only issue is that unlinking movement and animation means I don't quite have the same fine degree of control over the character's movement speed, but for now it's a good solution :)
Title: Re: MODULE: rellax 0.1.4
Post by: Tarnos12 on Mon 21/02/2022 21:03:27
Hello,

I have a question regarding this module.

Is there a way to snap camera to the player x/y position on room load?(before fade in)
It looks weird when the camera moves when entering new area.
I would like the camera to be at the center(including offset) when entering new room.

Can this be achieved?

Thanks
Title: Re: MODULE: rellax 0.1.4
Post by: shaun9991 on Mon 21/02/2022 21:17:44
I've just seen this module, it looks great!!!

I've basically made an entire game, with lots of parallax, using ABK's Smooth Scrolling + Parallax module. Do you think it's possible to sort of "upgrade" to rellax from this or best to stick to the ABK module (I'm worried it might cause chaos with the existing code!)? It would be amazing to get truly smooth scrolling, which this new module seems to be able to do.

Many thanks,
Shaun
Title: Re: MODULE: rellax 0.2.1
Post by: eri0o on Mon 02/05/2022 02:36:53
Updating to 0.2.0!

If someone would like to come up with a demo room that uses parallax and is a more traditional adventure game room, please hit me up, I did not have any ideas and also Adventure Game assets are hard to come by, so if you have an abandoned one, or have the art chops, send it my way.

I will at some point answer other things, I am still thinking about Laura's issue with traditional AGS walking characters that have MovementLinkedToAnimation, so far the only way I could come up is to have an additional character with anti glide off and move both at the same time, with the camera targeting the second... Unfortunately that is not very portable to put in a module...

Quote from: Tarnos12 on Mon 21/02/2022 21:03:27
Hello,

I have a question regarding this module.

Is there a way to snap camera to the player x/y position on room load?(before fade in)
It looks weird when the camera moves when entering new area.
I would like the camera to be at the center(including offset) when entering new room.

Can this be achieved?

Thanks

Updating to 0.2.1!

Not sure if I understood, made a new 0.2.1 release, added AdjustCameraOnRoomLoad property, default is true, it should quickly adjust the camera on room load, you can set it to false to keep the old behavior if you miss it! Please verify if this is enough.




I am currently investigating if there are better ways to provide smoothness as the current implementation may not be as smooth in some cases, like low resolution and slow characters... Finding lots (https://steamcommunity.com/app/311690/discussions/1/154644705028996486/?l=swedish) of interesting stuff in other places too.

I am also investigating a camera specific to following a character walking a path, if I can estimate the time it takes for the character to reach the destination and I know the destination, I can do something similar to a camera tween to that instead of directly tracking the player, and in this way I can ignore the stepped interval the character normally moves on screen.
Title: Re: MODULE: rellax 0.2.1
Post by: Tarnos12 on Mon 02/05/2022 22:50:42
Quote from: eri0o on Mon 02/05/2022 02:36:53
Not sure if I understood, made a new 0.2.1 release, added AdjustCameraOnRoomLoad property, default is true, it should quickly adjust the camera on room load, you can set it to false to keep the old behavior if you miss it! Please verify if this is enough.

Hey, I don't get any notifications on ags forums so I missed it, but I happened to update rellax today and used those extra variables, unfortunately that did not help.
The code is doing it's job, but there is another function that overrides that.
I have put an issue on github with a bit more specific information.

A way of "resetting" the camera would be great, I just don't want any movement when I change the room, the camera should be at the end position.
Title: Re: MODULE: rellax 0.2.2
Post by: eri0o on Tue 03/05/2022 00:44:58
Hey! Thanks for the well written GitHub issue! I was able to understand and track down the issue! I made a new 0.2.2 release, I think it's working now, please verify!

I am also working on a new implementation which will make the camera work slightly different when it's tracking a character that is following a path vs a character that is walking by some other way, the idea is the character following a path we can guess how long it will take for the character to get there, and loosely track the camera towards it, instead of following the character steps. The problem with this approach is that while the whole world looks non-jerky, the character itself is looking a bit weird so far, balance both is being a bit hard...

I also did not forgot shaun, I am thinking about if I should figure a compatibility mode for people coming from Ali's module, haven't figured that yet though...
Title: Re: MODULE: rellax 0.2.2
Post by: Tarnos12 on Tue 03/05/2022 02:47:36
Quote from: eri0o on Tue 03/05/2022 00:44:58
Hey! Thanks for the well written GitHub issue! I was able to understand and track down the issue! I made a new 0.2.2 release, I think it's working now, please verify!

I am also working on a new implementation which will make the camera work slightly different when it's tracking a character that is following a path vs a character that is walking by some other way, the idea is the character following a path we can guess how long it will take for the character to get there, and loosely track the camera towards it, instead of following the character steps. The problem with this approach is that while the whole world looks non-jerky, the character itself is looking a bit weird so far, balance both is being a bit hard...

I also did not forgot shaun, I am thinking about if I should figure a compatibility mode for people coming from Ali's module, haven't figured that yet though...

Thanks for the update, tested and it works great!
Title: Re: MODULE: rellax 0.2.2
Post by: eri0o on Mon 09/05/2022 00:25:28
Since 0.2.1 of rellax, I switched the camera position to use a float, and clamp to int positions when using it. I recently had an idea to move the viewport too along with the camera, with the residue of these positions!

Code (ags) Select
    Game.Camera.SetAt(FloatToInt(_next_cam_x), FloatToInt(_next_cam_y));
    Game.Camera.SetSize(320, 180);
 
    int residue_x = FloatToInt(_next_cam_x * 4.0, eRoundNearest) - FloatToInt(_next_cam_x) * 4;
    int residue_y = FloatToInt(_next_cam_y * 4.0, eRoundNearest) - FloatToInt(_next_cam_y) * 4;
   
    Screen.Viewport.SetPosition(-residue_x, -residue_y, Screen.Width, Screen.Height);


Above is an example of a game screen that is 1280x720, when the game camera is for a 320x180 game. This gives us an extra 0.25 times 4 positions we can move around

The effect looks like this: video_1.mp4 (https://user-images.githubusercontent.com/2244442/167321048-41277352-2d1e-4cf2-86f6-d79b15fd2c9a.mp4), video_2.mp4 (https://user-images.githubusercontent.com/2244442/167320427-63b04338-0e71-4eb0-871d-518245915ee5.mp4).

It needs some adjustments, but with this, the camera smoothness can be made much better for lower resolution games. This is not yet implemented in rellax, but I am looking into and just thought I would share it here - the experimental commit is here (https://github.com/ericoporto/rellax/commit/bcf87107e9dcc90c1e15d1d0c68acf606dcd6df0).

Of course, going this route you need to have all your GUIs scaled up to compensate, which is not trivial as we are now in AGS... But, this is interesting still.
Title: Re: MODULE: rellax 0.2.2
Post by: TheVolumeRemote on Sun 25/06/2023 20:16:18
Question! First, thank you @eri0o so much, Rellax has been invaluable to my dev and game:) Okay so Ive got a room that is taller than the rest of my rooms. One of my playable characters can float way up high, the other can only walk on the ground. When I switch from the floating way-up-high player, to the player on the ground, Rellax doesn't go all the way to the ground. It goes most of the way but cuts off at the walking players knees and anything below that isn't in sight.

What can I do to get Rellax to go to/return to the ground?

Rellax.CameraOffsetY = 50;
which I would think is what I need to do, doesn't seem to do anything, whereas
Rellax.CameraOffsetY = -50;does what's expected however that is in the wrong direction, this offsets the camera even higher up.

I've tried a lot of bad ideas like
Rellax.CameraOffsetY = cEgo1.y;but no luck. I have some plan B's I can employ but i'd rather understand what I doing wrong or how I could handle this correctly.

I hope this is coherent, thank you for your awesome module and for any help :)
Title: Re: MODULE: rellax 0.2.2
Post by: AndreasBlack on Sun 25/06/2023 22:30:14
@TheVolumeRemote
Did you forget to switch rellax to the current playable character? I know i did that mistake. It doesn't do that automatically! Rellax.TargetCharacter  ???

Question for @eri0o everytime i re-enter a room from a different spot the rellax jumps fast back to it's original position. How do i leave it from where it was when i left the room? I tried manually moving the object and such, but it doesn't do the trick, or disabling rellax and walking onto a region = enabling it still not really what i'm looking for, Thanks!
Title: Re: MODULE: rellax 0.2.2
Post by: eri0o on Sun 25/06/2023 22:48:55
@TheVolumeRemote Can you try this version here and see if it improves something for you?

rellax.zip (https://github.com/ericoporto/rellax/files/11860975/rellax.zip)

What I imagine can be a problem is if the difference in y distance is small, it may not give enough kick in the lerp, the version above should by default try to kickup in smaller distances - it also has an optional parameter so you can manually set the CameraLerpFactorX and CameraLerpFactorY, but lets try first the defaults and see what happens.

@AndreasBlack it sounds like the previous issue (forum comment (https://www.adventuregamestudio.co.uk/forums/modules-plugins-tools/module-rellax-0-2-2/msg636645902/#msg636645902), github link (https://github.com/ericoporto/rellax/issues/6)) from Tarnos that was fixed with the new AdjustCameraOnRoomLoad property, that defaults to true. Are you using the 0.2.2 version? Does using the above version changes anything for you?
Title: Re: MODULE: rellax 0.2.2
Post by: TheVolumeRemote on Sun 25/06/2023 22:49:32
@AndreasBlack thanks mate, but my problem happens upon switching to my other playable character, where it does target the newly selected character, it just doesn't bring the camera all the way back, or down enough :)

For your issue, perhaps call targetCharacter on room_load and/or on room_load try this
Rellax.AdjustCameraOnRoomLoad = true;
Title: Re: MODULE: rellax 0.2.2
Post by: TheVolumeRemote on Sun 25/06/2023 22:50:13
@eri0o what timing! Ok I will try this now and report back, thank you!!
Title: Re: MODULE: rellax 0.2.2
Post by: TheVolumeRemote on Sun 25/06/2023 23:07:28
@eri0o Unfortunately this didn't work but you are right about the small margins, I'd guess the returning camera is only off by about 50-60 pixels to where it should be returning to.

Let me know if a video would help, and any advice on what to perhaps set Lerp (or anything else) to, would be greatly appreciated :)
Title: Re: MODULE: rellax 0.2.2
Post by: eri0o on Mon 26/06/2023 02:34:11
@TheVolumeRemote Hey, sorry for taking a little while, the ideas I had didn't change much beyond that build I sent, can you give the x,y position of each character, the game resolution and the room size? Just so I can properly reproduce the issue.

The workaround idea I have is to temporarily disable the smoothcam, pan using Tween on the Camera, and then later turning it back on.
Title: Re: MODULE: rellax 0.2.2
Post by: TheVolumeRemote on Mon 26/06/2023 03:06:09
Hi @eri0o thank you, I am super grateful you've been giving it thought!
The game resolution is 320x200 the room size is 520 x 326 (first room in 83 rooms/the game that is not 200px in height). The character bound to the floor starts the room at 87X 318Y and his Y never changes (room to room, the game is Left to Right movement only). The floating character has a walkable that is essentially the entire room, beginning at 47X 316Y. The issue arises if I move the floating character up to say 47x 90Y and then target the character standing on the ground.

Here is a quick screengrab to help you help me, I worry I confuse things by explaining it so hopefully the video makes it clear. https://www.dropbox.com/s/h8wls0v4wx8e5fq/TPF_Rellax.mov?dl=0

thank you so so much for your help, the only 2 rooms I have that are taller than 200px are the second to last and last rooms in the game and the height is part of an exploration puzzle so I really appreciate your help with this, I've been a lot calmer and pleasant to be around since you took the case lol
Title: Re: MODULE: rellax 0.2.2
Post by: TheVolumeRemote on Mon 26/06/2023 03:22:05
@eri0o and for what it's worth, I can kind of click the camera down to where it should be which while a little strange, I thought might be helpful for you to know in thinking of a solution :)

here's what that looks like https://www.dropbox.com/s/hwtx6u42cbp4hql/TPF_Rellx_Clicks.mov?dl=0
Title: Re: MODULE: rellax 0.2.2
Post by: AndreasBlack on Mon 26/06/2023 19:22:28
I've solved it somewhat, it's good for now. I had already turned it to false since you can enter the room in various places. Somehow i had messed ut up, as always (laugh) Thanks for replying tho, and yes i use the latest (nod)
Title: Re: MODULE: rellax 0.2.2
Post by: AndreasBlack on Mon 26/06/2023 19:55:38
@TheVolumeRemote dumb question perhaps but have you tried resetting Game.Camera.SetAt(x, y); to where the character is positioned? Use this code on a debug button
Display(String.Format("CameraX: %d, CameraY: %d", Game.Camera.X, Game.Camera.Y));

and smoothcam off and then turn it on, i do that in the room i just asked about. It's the best solution i've found to not get that ehh none-jaggy movement or whatever you would call it. Game looks nice btw :)

Title: Re: MODULE: rellax 0.2.2
Post by: TheVolumeRemote on Mon 26/06/2023 20:57:57
@AndreasBlack thank you so much for the compliment and that's super kind of you to try to help! I appreciate the tip, on my end because the player can switch between 2 playable characters at any time, the solution I need has to work (afaik, i'm not great at this) in Repeatedly Execute, so something like this- is great advice- but I don't think it'll work in my case bc rep_exe :)

thanks again for your time and advice!!
Title: Re: MODULE: rellax 0.2.2
Post by: Dave Gilbert on Tue 25/07/2023 15:16:35
Nothing to add except that I just implemented this for Old Skies and it works SO WELL. Thanks!

edit: dang it I spoke to soon. I am noticing that the camera defaults to starting on the left side of the screen, regardless of where the player is placed on RoomLoad. After the room loads, the camera zips across the screen to center on the player like normal. I noticed earlier in the thread that someone else had this problem but an update fixed it. Sadly that doesn't seem to be the case for me. Any light shedding is appreciated!
Title: Re: MODULE: rellax 0.2.2
Post by: eri0o on Wed 27/09/2023 23:11:19
OK, I have been thinking about the issue of making the camera smooth and also make sure it slides in perfectly, without forgetting some pixels, and make sure the vertical axis also works correctly. I have looked into physics, how elastics work, planet gravity and gravity well and things didn't actually worked well. I think I came up with a really simple concept that appears to work well that is the following:


The results appear good so I need to make a pretty code for this that is self contained - I was using edmundito's module in my experiments. After this is adjusted - I think I will make it as an option for people that may want the old method for whatever reason. Then I will look into other bug fixes. Sorry for the long delay.
Title: Re: MODULE: rellax 0.2.2
Post by: Dave Gilbert on Thu 28/09/2023 11:58:34
Awesome!! Thanks so much. :)
Title: Re: MODULE: rellax 0.3.0
Post by: eri0o on Sun 01/10/2023 16:58:31
Release 0.3.0! Updated the first post with the links! Changes are the following

I will later looking into optimizing it more and making the code a little better. I stoled Edmundito's Tween math shamelessly, I will add a mention to this somewhere at some point. There is something in the vertical axis, that maybe isn't always right but I will look into this later, I have been rewriting too much code in this for a the last month. :/

@Dave Gilbert , what you are looking into is the AdjustCameraOnRoomLoad property, it defaults to true now, so it should not be a problem. If it turns out to be a problem still, let me know. There is an issue that a player.ChangeRoom in the same room doesn't trigger a eEventEnterRoomBeforeFadein, so if you find yourself in this edge case I will look into how to figure something for this.

@TheVolumeRemote I think this new version could fix the issue you had. If it doesn't, let me know. Sorry, I tried lots of things before, not sure if this really fix it though.

@AndreasBlack sorry, I can't figure it out if you have a problem or not, if there's, can you explain again? :)
Title: Re: MODULE: rellax 0.3.0
Post by: AndreasBlack on Sun 01/10/2023 17:49:03
Great a new version! :) Will have to try this asap! I think the issue i had before were solved, yes. Now i have other nightmares in front of me. The hotelstairs, but i'll come back and cry about that when i'm focusing on that area of the game! (laugh) Just take some well deserved rest now (nod)

Edit: Just tested it, yeah it feels better to me. I've used Rellax so much i've forgot how the normal AGS camera feels. This lagginess that you can feel sometimes when going up or down and sideways is that AGS or a Rellax issue? If so that could perhaps be bypassed somehow temporarely or is it too much of a hassle? Forexample when i walk up to a church and wants to look at it. It's laggy and i don't even have any parallax in that room going on, so i could just as easily turn it off completely. Perhaps i've already done that with  Rellax.EnableSmoothCam=false; and  Rellax.EnableParallax=false;. I'm not sure if that bypasses all the relax script? Remember i'm not a coder.

 

Title: Re: MODULE: rellax 0.3.2
Post by: eri0o on Sun 01/10/2023 19:07:12
There should not be lagginess. Is it possible to export this one room that you experience it and shove into a new game project that has said lag so I can test it? I only have my own stuff to test it. :/

Edit: Finally figured the character height bug!! I had a wrong sign in a place and this cause the vertical offset of the camera to be weird!!!!

Released new 0.3.1 release with the fix!

Edit2: quick 0.3.2 release with minor performance improvement by avoiding GetProperty repeatedly, instead we only read those once at room load now.
Title: Re: MODULE: rellax 0.3.2
Post by: AndreasBlack on Sun 01/10/2023 21:49:24
Will try it! Don't worry. It's pretty good for what it is, these minor lags that i feel here and there is just nitpicking, chill out! No biggie. It's great otherwise! In fact i was thinking about giving away one room as a "rellax demo room" but i'm not sure yet. My code is kinda messy, but it does use the rellax in a "realistic point & click setting" i would say!

Edit: I had no idea you had an "issue" with GetProperty, somehow i figured that is an issue. Look at what you had me doing! :-D
Btw, maybe i should mention that this room is the potential "demo room".

Now all "i" need is a setting for the rellax to "fall back" in a gradually smooth speed you'd like. Sorta like a tweening function, and since you are using it already. Can't you just shamelessly steal something again and make a function out of it? For the Parallax to move it's position smoothly for where the character is (look at the code in Spoiler to understand what i mean, hopefully).

Cause the parallax kinda flies back for lack of a better word. I can post a video if you want to see it? it's much better now then the jerky movement that was before. I think what is causing my little issue is the fact that i change from a character to a object doing the "custom animation", and the rellax doesn't track objects, so when you finally move the character in it's place rellax just immediately jumps to fit the characters placement on screen. Rellax needs a setting for that, so the rellax object fall back smoothly if that makes sense? I hope. Alltho i thought my do and while syntax should fix it, but nope it doesn't :-\

Spoiler
if (Used_Bed==true && Is_Ruslana_In_Bed==false)


{
 
 
     StartCutscene(eSkipAnyKey);
     Disable_Everything(); //Just gui, mouse, etc.
     cElita.Walk(254, 153, eBlock, eWalkableAreas); //rellax character that it's following
     oParallax_1.SetProperty("PxPos", 0); //this is the parallax front object, that looks a bit off..
      Rellax.EnableParallax=false; //without these off temporarely, it just "jumps" into place weirdly
     Rellax.EnableSmoothCam=false;
     SetWalkBehindBase(1, 151);
     oRuslana_Run.Transparency=0;
     cElita.Transparency=100;     
do
{
     oRuslana_Run.Animate(1, 1, eOnce, eBlock);
}

while (cElita.Move(144, 130,eBlock, eAnywhere)); //so if the rellax character is moving shouldnt it work
                                                 //but no, if i have parallax and smooth on='jumprellax'
}
     

     cElita.FaceDirection(eDirectionRight);
     oRuslana_Run.Animate(0, 1, eOnce, eBlock);   
     oRuslana_Run.Transparency=100;
     cElita.Baseline=140;
     cElita.Transparency=0;
         cElita.LockView(108);
          // oParallax_1.Move(12, 264, 2, eBlock, eAnywhere); //"Attempt to move parallax in it's place"
     cElita.Animate(0, 1, eOnce, eBlock);
     cElita.UnlockView();
     cElita.Walk(144, 126, eBlock, eWalkableAreas);
     oFloor_Get_Down_Right.Clickable=true;
     oFloor_Get_Down_Left.Clickable=true;
     Is_Ruslana_In_Bed=true;
         
           Enable_Everything();
 EndCutscene();
   return;
}


and then in a region ID when i've come so far away from the object that it's not seen on the screen.

function region7_WalksOnto()
{
  oParallax_1.SetProperty("PxPos", -50); //Original setting when starting the room..
}

[close]

Title: Re: MODULE: rellax 0.3.3
Post by: eri0o on Sun 01/10/2023 22:33:16
Quick 0.3.3 update, added two new things to the top post, a function and a new attribute.

static attribute bool AutomaticallySetupOnRoomLoad
Gets/sets whether to automatically setup on room load. It defaults to yes (true).
Leave as this unless you really need it.

static void SetupRoomManually()
You should not call this, unless AutomaticallySetupOnRoomLoad is false.
Then call this at the end of your room_Load, after you are done setting things up.

Because there isn't an event that triggers after room_Load but before room_AfterFadeIn, if you need to setup things at your room_Load, use Rellax.AutomaticallySetupOnRoomLoad = false; before you call your player.ChangeRoom and then in the once in the room there, you should use Rellax.SetupRoomManually(), as the last function you call in your room_Load. If this is a one time thing, you can use Rellax.AutomaticallySetupOnRoomLoad = true; when you go to your other rooms.

@AndreasBlack I wouldn't mind an extra demo room! :D (or a character!)

Ah, there is a technique to make the camera smoother in pixel art games @AndreasBlack , the camera width/height would be the intended one (say 320x180) and then the game resolution would be either twice or four times (so either 640x360 or 1280x720) and then I would modify both the camera position and the viewport position to be smoother. Of course the price for this is that AGS has no way to scale GUIs, so their art and fonts would need to be manually scaled and redone - though this gives opportunity to use slightly more resolution for texts if desired. Result looks like the videos here (https://github.com/ericoporto/rellax/issues/7). I haven't merged this on rellax yet for the lack of people to test it.
Title: Re: MODULE: rellax 0.3.3
Post by: AndreasBlack on Sun 01/10/2023 23:20:11
I've updated my previous post. And yes, that's the thing! I have been thinking about doing that for a long while. In fact i don't know if you've seen my posts in beginners, but i have been doing upscaling on wheels forexample in my game to make them spin nicely without apparent anti-aliased effect/blurryness. In fact that would probably solve my little issue with the save files that i have aswell. not being in "high res" most likely since it's basing the screenshot of the game's average resolution. I tried to momentarily change the resolution of the game just before the saving part in the code, but i couldn't get it to work properly. I need practice in AGS coding so bad (laugh)
Title: Re: MODULE: rellax 0.3.3
Post by: eri0o on Sun 01/10/2023 23:44:02
Uhm, from looking just at the code I can't really tell how it should work... That SetProperty won't work in the new version if you do it after the room has been setup. :/ You would need to go the manual route for doing that (added in 0.3.3). Is it really necessary?

The other thing, is there is Rellax.TweenDuration and also there is a easing type property too, if the target character is stopped, it will use tween when moving the camera in position, and if the target character is moving, it will instead rely in the Rellax LERP factors properties.
Title: Re: MODULE: rellax 0.4.0
Post by: eri0o on Wed 04/10/2023 23:49:29
Made a new 0.4.0 release! Get it on the first post!


Roadmap for the next thing: a way to pan the camera without turning off and on the smoothcam - leveraging the now added easing math.
Title: Re: MODULE: rellax 0.4.0
Post by: Jelonertz on Sat 14/10/2023 15:25:38
Hi! Congrats for the module. I'm using latest version 0.4.0 and I have a couple of questions: 1) It looks RellaxTweenEasingType is not public anymore and 2) Do you have any brief tutorial about how to use parallax scroll?
Thank you!
Title: Re: MODULE: rellax 0.4.0
Post by: eri0o on Thu 19/10/2023 13:29:32
I don't know what 1 means, but I plan to have an update of this module released this weekend. I may try to cookup a video too.
Title: Re: MODULE: rellax 0.4.0
Post by: AndreasBlack on Mon 23/10/2023 12:20:55
I've been thinking about a 'hotel stairway' or what you call it. Where you can walk up to a 12th floor, as a demo room for rellax perhaps. Instead of the one i previously had in mind. Including both Y and X objects in the room. That could be a huge challenge for you to get right tho, but for us that wants to use rellax in various tricky ways it would show us "how" you'd use it "better". I still find myself struggling a lot. :-\
Looking forward to the not having to turn off smoothcam and still panning feature!

Anyways keep up the great work! (nod)
Title: Re: MODULE: rellax 0.4.0
Post by: blaholtzen on Sat 25/11/2023 18:45:49
First off, this module is absolutely phenomenal!
I initially tried it out as a solution for some flickering I got with the default camera behavior whenever I had two characters walking at the same time and getting out of sync, (my characters all use low frame rate animation and the MovementLinkedToAnimation turned on as a style choice) which this not only solved, but also made the experience of walking around in the game more pleasant general!

However, I seem to still be using 0.2.1 and when I tried upgrading I cant seem to achieve the same smoothness I have when using the old version.
Not sure if this is some setting I forgot to change or something that's different in the module itself. I would guess it might have to do with my characters using movement-linked-to-animation? Which is not something I want to change since like I mentioned its part of the style I'm going for.

I'm fine with sticking with the older version since it does what I need it to but I did want to ask if there is a way to move an object that is all the way back in the parallaxing background?
In my specific case I have a cloud that would ideally crawl across the sky while still being all the way at the back at PxPos 100 without needing a view with hundreds of frames, haha.

Is this possible? and if so is it possible in any version or only as of some later version?
It's not crucial at all but it would be neat if I could. :)
Title: Re: MODULE: rellax 0.4.0
Post by: eri0o on Sat 25/11/2023 21:56:05
I have not done anything for animated things and have no plans to add in near future - lots of plates to spin, sorry. What you could do maybe is having some hidden cloud with the px,py you want and have the cloud you want to move to have the position set by the cloud that is hidden plus a point that is moving, in this way it would have the resulting position.

About movement linkedtoanimation, I usually have it on in non-scrolling rooms and off in scrolling rooms in my games. Another middle ground approach is doubling the frames in a walk view with movement linkedtoanimation which would give some half frame for the smoothing.
Title: Re: MODULE: rellax 0.4.0
Post by: jarekkolar on Sun 18/02/2024 23:19:49
Thanks for this fantastic module together with the ongoing support of it!