There is a new version of the forums ready for testing. Please post here if you're willing to help test! We could also use the help of coders!

Author Topic: MODULE: rellax 0.2.2  (Read 10210 times)

eri0o

MODULE: rellax 0.2.2
« on: 07 Oct 2019, 03:26 »
rellax version 0.2.2

Get Latest Release rellax.scm | GitHub Repo | Demo Windows | Demo Linux | Download project .zip

Rellax while the camera tracks with cool parallax



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:
  • 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.
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 AdjustCameraOnRoomLoad
Gets/sets whether to instantly adjust camera to target on room before fade in, when Smooth Camera is on.

static attribute int CameraOffsetX
Gets/sets the camera horizontal offset.

static attribute int CameraOffsetY
Gets/sets the camera vertical offset.

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 StandstillCameraDelayY
Gets/sets number of frames to wait before adjusting the Y axis quicker after the player is still. Set to 0 to disable it. This is more useful on platformers, or vertical rooms that have different pavements.

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 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.
The demo game uses CC0 (Public Domain) art provided by jetrel.
« Last Edit: 03 May 2022, 11:38 by eri0o »

Re: MODULE: rellax 0.1.0
« Reply #1 on: 07 Oct 2019, 15:29 »
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?
My official site: http://www.pershaland.ir/

eri0o

Re: MODULE: rellax 0.1.0
« Reply #2 on: 07 Oct 2019, 16:52 »
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, 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 :/)
« Last Edit: 07 Oct 2019, 17:01 by eri0o »

Olleh19

  • I'm an AGS n00b, please don't kill me
Re: MODULE: rellax 0.1.0
« Reply #3 on: 09 Oct 2019, 20:26 »
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-)

eri0o

Re: MODULE: rellax 0.1.2
« Reply #4 on: 09 Nov 2019, 18:11 »
@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.
« Last Edit: 16 Nov 2019, 23:43 by eri0o »

Re: MODULE: rellax 0.1.2
« Reply #5 on: 31 Dec 2019, 23:23 »
Wow Beautiful!
_______________________________________ ____________________

eri0o

Re: MODULE: rellax 0.1.2
« Reply #6 on: 01 Jan 2020, 13:14 »
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.

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!
Re: MODULE: rellax 0.1.2
« Reply #7 on: 03 Feb 2020, 12:36 »
Can you describe how your module differs from the SmoothScrolling module, which offered smooth scrolling & Parallax (by Ali) and foreground+background parallax too?
« Last Edit: 03 Feb 2020, 14:22 by Monsieur OUXX »
 

eri0o

Re: MODULE: rellax 0.1.2
« Reply #8 on: 03 Feb 2020, 13:46 »
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.

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!
Re: MODULE: rellax 0.1.2
« Reply #9 on: 03 Feb 2020, 14:19 »
Basic changes are:

Love it!
 

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!
Re: MODULE: rellax 0.1.2
« Reply #10 on: 03 Feb 2020, 16:16 »
Great stuff, my module is getting pretty old. I've put a link to this one on the first post.

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!
Re: MODULE: rellax 0.1.2
« Reply #11 on: 03 Feb 2020, 17:07 »
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.
 

eri0o

Re: MODULE: rellax 0.1.2
« Reply #12 on: 04 Feb 2020, 00:13 »
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:
  • Prevents wrong position updates by moving calculations to late repeatedly execute always.
  • Fix crash by wrong player loop when loading a new room.
« Last Edit: 10 Feb 2020, 22:55 by eri0o »

Re: MODULE: rellax 0.1.3
« Reply #13 on: 20 Feb 2020, 07:23 »
Thank you so much for this, it works so well and smooth
« Last Edit: 20 Feb 2020, 09:07 by ld-airgrafix »

eri0o

Re: MODULE: rellax 0.1.4
« Reply #14 on: 01 Jul 2020, 14:35 »
Small update, adding some attributes to the module API!

  • Adds CameraOffsetX and CameraOffsetY so you can easily add an offset on the camera, useful when you have a big room and want to set the camera offset differently between areas. Offset is not set instantaneously, the transition when changing offsets is smooth.
  • Adds CameraLookAheadX and CameraLookAheadY so you can set the lookahead offset to your liking (defaults are 48 and 16). These are offsets that are added or subtracted depending the direction your target character is facing - for now, only supports 4 direction movement.

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.

Snarky

  • Global Moderator
  • Global Moderator
  • Mittens Lord
  • Private Insultant
    • Best Innovation Award Winner 2018, for his numerous additions to the AGS open source ecosystem including the new Awards Ceremony client and modules
    • Snarky worked on one or more games that won an AGS Award!
    •  
    • Snarky worked on one or more games that was nominated for an AGS Award!
Re: MODULE: rellax 0.1.4
« Reply #15 on: 30 Jul 2020, 12:28 »
- 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.)

eri0o

Re: MODULE: rellax 0.1.4
« Reply #16 on: 30 Jul 2020, 13:07 »
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).

Snarky

  • Global Moderator
  • Global Moderator
  • Mittens Lord
  • Private Insultant
    • Best Innovation Award Winner 2018, for his numerous additions to the AGS open source ecosystem including the new Awards Ceremony client and modules
    • Snarky worked on one or more games that won an AGS Award!
    •  
    • Snarky worked on one or more games that was nominated for an AGS Award!
Re: MODULE: rellax 0.1.4
« Reply #17 on: 30 Jul 2020, 13:16 »
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.

eri0o

Re: MODULE: rellax 0.1.4
« Reply #18 on: 30 Jul 2020, 13:26 »
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.

Flugeldufel

  • Gary G. Gerisson
    • Flugeldufel worked on one or more games that was nominated for an AGS Award!
Re: MODULE: rellax 0.1.4
« Reply #19 on: 04 Sep 2020, 21:12 »
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.  ???



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...

eri0o

Re: MODULE: rellax 0.1.4
« Reply #20 on: 04 Sep 2020, 23:56 »
@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

Spoiler: ShowHide
Code: Adventure Game Studio
  1. // Rellax
  2. // 0.1.5~
  3. // A module to provide smooth scrolling and parallax!
  4. // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  5. // Before starting, you must create the following Custom Properties
  6. // in AGS Editor, for usage with Objects.
  7. // Just click on Properties [...] and on the Edit Custom Properties screen,
  8. // click on Edit Schema ... button, and add the two properties below:
  9. //
  10. // PxPos:
  11. //    Name: PxPos
  12. //    Description: Object's horizontal parallax
  13. //    Type: Number
  14. //    Default Value: 0
  15. //
  16. // PyPos:
  17. //    Name: PyPos
  18. //    Description: Object's vertical parallax
  19. //    Type: Number
  20. //    Default Value: 0
  21. //
  22. //  The number defined on Px or Py will be divided by 100 and used to increase
  23. // the scrolling. An object with Px and Py 0 is scrolled normally, an object
  24. // with Px and Py 100 will be fixed on the screen despite camera movement.
  25. //
  26. // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  27. //
  28. // based on Smooth Scrolling + Parallax Module
  29. // by Alasdair Beckett, based on code by Steve McCrea.
  30. //
  31. // Permission is hereby granted, free of charge, to any person
  32. // obtaining a copy of this software and associated documentation
  33. // files (the "Software"), to deal in the Software without
  34. // restriction, including without limitation the rights to use,
  35. // copy, modify, merge, publish, distribute, sublicense, and/or
  36. // sell copies of the Software, and to permit persons to whom the
  37. // Software is furnished to do so, subject to the following
  38. // conditions:
  39. //
  40. // The above copyright notice and this permission notice shall be
  41. // included in all copies or substantial portions of the Software.
  42. //
  43. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  44. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  45. // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  46. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  47. // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  48. // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  49. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  50. // OTHER DEALINGS IN THE SOFTWARE.
  51.  
  52. #define MAX_PARALLAX_OBJS 39
  53.  
  54. Character *_TargetCharacter;
  55.  
  56. Object *_pxo[MAX_PARALLAX_OBJS];
  57. int _pxoRoomStartX[MAX_PARALLAX_OBJS];
  58. int _pxoRoomStartY[MAX_PARALLAX_OBJS];
  59. int _pxoOriginX[MAX_PARALLAX_OBJS];
  60. int _pxoOriginY[MAX_PARALLAX_OBJS];
  61. int _pxo_count;
  62.  
  63. int _cam_window_w, _cam_window_h;
  64. float _scroll_x,  _scroll_y;
  65. int _next_cam_x, _next_cam_y;
  66. int _prev_c_x, _prev_c_y;
  67. int _off_x, _off_y;
  68. int _look_ahead_x = 48;
  69. int _look_ahead_y = 16;
  70.  
  71. int _partial_c_height;
  72. int _count_still_ticks;
  73.  
  74. bool _is_doRoomSetup;
  75. bool _SmoothCamEnabled = true;
  76. bool _ParallaxEnabled = true;
  77.  
  78. float _Abs(float v) {
  79.   if(v<0.0) return -v;
  80.   return v;
  81. }
  82.  
  83. int _Lerp(float from, float to, float t) {
  84.   return FloatToInt(from + (to - from) * t, eRoundNearest);
  85. }
  86.  
  87. int _ClampInt(int value, int min, int max) {
  88.   if (value > max) return max;
  89.   else if (value < min) return min;
  90.   return value;
  91. }
  92.  
  93. void doObjectParallax(){
  94.   int camx = _next_cam_x;
  95.   int camy = _next_cam_y;
  96.  
  97.   for(int i=0; i<_pxo_count; i++){
  98.     if(_pxo[i].GetProperty("PxPos") !=0 || _pxo[i].GetProperty("PyPos") != 0) {
  99.       float parallax_x = IntToFloat(_pxo[i].GetProperty("PxPos"))/100.0;
  100.       float parallax_y = IntToFloat(_pxo[i].GetProperty("PyPos"))/100.0;
  101.  
  102.       _pxo[i].X=_pxoOriginX[i]+FloatToInt(IntToFloat(camx)*parallax_x);
  103.       _pxo[i].Y=_pxoOriginY[i]+FloatToInt(IntToFloat(camy)*parallax_y);
  104.     }
  105.   }
  106. }
  107.  
  108. void _enable_parallax(bool enable) {
  109.   _ParallaxEnabled = enable;
  110. }
  111.  
  112. void _enable_smoothcam(bool enable) {
  113.   if(enable == true){
  114.     doObjectParallax();
  115.   }
  116.  
  117.   _SmoothCamEnabled = enable;  
  118. }
  119.  
  120. void _set_targetcharacter(Character* target) {
  121.   _TargetCharacter = target;
  122. }
  123.  
  124. // ---- Rellax API ------------------------------------------------------------
  125.  
  126. void set_TargetCharacter(this Rellax*, Character* target)
  127. {
  128.   _set_targetcharacter(target);
  129. }
  130.  
  131. Character* get_TargetCharacter(this Rellax*)
  132. {
  133.   return  _TargetCharacter;
  134. }
  135.  
  136. void set_EnableParallax(this Rellax*, bool enable)
  137. {
  138.   _enable_parallax(enable);
  139. }
  140.  
  141. bool get_EnableParallax(this Rellax*)
  142. {
  143.   return _ParallaxEnabled;
  144. }
  145.  
  146. void set_EnableSmoothCam(this Rellax*, bool enable)
  147. {
  148.   _enable_smoothcam(enable);
  149. }
  150.  
  151. bool get_EnableSmoothCam(this Rellax*)
  152. {
  153.   return _SmoothCamEnabled;
  154. }
  155.  
  156. void set_CameraOffsetX(this Rellax*, int offset_x)
  157. {
  158.   _off_x = offset_x;
  159. }
  160.  
  161. int get_CameraOffsetX(this Rellax*)
  162. {
  163.   return _off_x;
  164. }
  165.  
  166. void set_CameraOffsetY(this Rellax*, int offset_y)
  167. {
  168.   _off_y = offset_y;
  169. }
  170.  
  171. int get_CameraOffsetY(this Rellax*)
  172. {
  173.   return _off_y;
  174. }
  175.  
  176. void set_CameraLookAheadX(this Rellax*, int look_ahead_x)
  177. {
  178.   _look_ahead_x = look_ahead_x;
  179. }
  180.  
  181. int get_CameraLookAheadX(this Rellax*)
  182. {
  183.   return _look_ahead_x;
  184. }
  185.  
  186. void set_CameraLookAheadY(this Rellax*, int look_ahead_y)
  187. {
  188.   _look_ahead_y = look_ahead_y;
  189. }
  190.  
  191. int get_CameraLookAheadY(this Rellax*)
  192. {
  193.   return _look_ahead_y;
  194. }
  195.  
  196. // ----------------------------------------------------------------------------
  197.  
  198. void doSetOrigins (){
  199.   _pxo_count=0; // Reset the total number of parallax objects to zero
  200.   float cam_w = IntToFloat(Game.Camera.Width);
  201.   float cam_h = IntToFloat(Game.Camera.Height);
  202.   float room_w = IntToFloat(Room.Width);
  203.   float room_h = IntToFloat(Room.Height);
  204.  
  205.   for(int i=0; i<Room.ObjectCount; i++){
  206.     if (object[i].GetProperty("PxPos")!=0) {
  207.                         _pxo[_pxo_count]=object[i];
  208.       float parallax_x = IntToFloat(object[i].GetProperty("PxPos"))/100.0;
  209.       float parallax_y = IntToFloat(object[i].GetProperty("PyPos"))/100.0;
  210.  
  211.       float obj_x = IntToFloat(object[i].X);
  212.       float obj_y = IntToFloat(object[i].Y);
  213.  
  214.       // initial positions for reset
  215.       _pxoRoomStartX[_pxo_count]= object[i].X;
  216.       _pxoRoomStartY[_pxo_count]= object[i].Y;
  217.  
  218.       //Set origin for object:
  219.       _pxoOriginX[_pxo_count] = object[i].X -FloatToInt(
  220.         parallax_x*obj_x*(room_w-cam_w) / room_w );
  221.  
  222.       _pxoOriginY[_pxo_count] = object[i].Y -FloatToInt(
  223.         parallax_y*obj_y*(room_h-cam_h) / room_h );
  224.  
  225.                         if(_pxo_count<MAX_PARALLAX_OBJS) _pxo_count++;
  226.                 }
  227.    }
  228.   doObjectParallax();
  229. }
  230.  
  231. void doRoomSetup(){
  232.   Game.Camera.X = _ClampInt(_TargetCharacter.x-Game.Camera.Width/2,
  233.     0, Room.Width-Game.Camera.Width);
  234.  
  235.   Game.Camera.Y = _ClampInt(_TargetCharacter.y-Game.Camera.Height/2,
  236.     0, Room.Height-Game.Camera.Height);
  237.  
  238.   _next_cam_x = Game.Camera.X;
  239.   _next_cam_y = Game.Camera.Y;
  240.   doSetOrigins();
  241.  
  242.   ViewFrame* c_vf = Game.GetViewFrame(_TargetCharacter.NormalView, 0, 0);
  243.   float scaling = IntToFloat(GetScalingAt(_TargetCharacter.x, _TargetCharacter.y))/100.00;
  244.   _partial_c_height = FloatToInt((IntToFloat(Game.SpriteHeight[c_vf.Graphic])*scaling)/3.0);
  245.  
  246.   if (_ParallaxEnabled) _enable_parallax(true);
  247.   else _enable_parallax(false);
  248.   _is_doRoomSetup = true;
  249. }
  250.  
  251. void doSmoothCameraTracking(){
  252.   if(_prev_c_x == _TargetCharacter.x && _prev_c_y == _TargetCharacter.y)
  253.     _count_still_ticks++;
  254.   else
  255.     _count_still_ticks = 0;
  256.  
  257.   if(_TargetCharacter.x-Game.Camera.Width/2-Game.Camera.X<=-_cam_window_w/2 ||
  258.      _TargetCharacter.x-Game.Camera.Width/2-Game.Camera.X>_cam_window_w/2 ||
  259.      _TargetCharacter.y-Game.Camera.Height/2-Game.Camera.Y<=-_cam_window_h/2 ||
  260.      _TargetCharacter.y-Game.Camera.Height/2-Game.Camera.Y>_cam_window_h/2 ||
  261.      _count_still_ticks > 5){
  262.  
  263.     int x_focus=0,y_focus=0;
  264.     if(_TargetCharacter.Loop == 2) x_focus = _look_ahead_x; // right
  265.     else if(_TargetCharacter.Loop == 1) x_focus = -_look_ahead_x; // left
  266.     else if(_TargetCharacter.Loop == 0) y_focus = _look_ahead_y; // down
  267.     else if(_TargetCharacter.Loop == 3) y_focus = -_look_ahead_y; // up
  268.  
  269.     float y_multiplier;
  270.     if(_count_still_ticks<=30) y_multiplier = IntToFloat(_count_still_ticks)*0.138 ;
  271.     if(_count_still_ticks>30) y_multiplier = 5.0;
  272.  
  273.     float target_cam_x = IntToFloat(_ClampInt(_TargetCharacter.x + _off_x + x_focus - Game.Camera.Width/2,   0, Room.Width-Game.Camera.Width));
  274.     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));
  275.     float current_cam_x =  IntToFloat(Game.Camera.X);
  276.     float current_cam_y =  IntToFloat(Game.Camera.Y);
  277.     float lerp_factor_x = 0.04;
  278.     float cam_distance_x = _Abs(target_cam_x - current_cam_x);
  279.    
  280.     if( cam_distance_x < 32.0 && cam_distance_x >= 1.0) {
  281.       lerp_factor_x  = 0.913*Maths.RaiseToPower(cam_distance_x, -0.7268);
  282.     }    
  283.  
  284.     _next_cam_x = _Lerp( current_cam_x, target_cam_x, lerp_factor_x );
  285.     _next_cam_y = _Lerp( current_cam_y, target_cam_y, 0.01*y_multiplier);
  286.   }
  287.  
  288.   _prev_c_x = _TargetCharacter.x;
  289.   _prev_c_y = _TargetCharacter.y;
  290. }
  291.  
  292. // --- callbacks --------------------------------------------------------------
  293.  
  294. function on_event (EventType event, int data){
  295.   // player exits any room
  296.   if (event==eEventLeaveRoom){
  297.     for(int i=0; i<_pxo_count; i++){
  298.       _pxo[i].X=_pxoRoomStartX[i];
  299.       _pxo[i].Y=_pxoRoomStartY[i];
  300.     }
  301.     _is_doRoomSetup = false;
  302.   }
  303.  
  304.   // player enters a room that's different from current
  305.         if (event==eEventEnterRoomBeforeFadein){
  306.     if(!_is_doRoomSetup){
  307.       doRoomSetup();
  308.     }
  309.   }
  310. }
  311.  
  312. function game_start(){
  313.  
  314.   System.VSync = true;
  315.   _cam_window_w = 40;
  316.   _cam_window_h = 40;
  317.   _set_targetcharacter(player);
  318.   _enable_parallax(true);
  319.   _enable_smoothcam(true);
  320. }
  321.  
  322. function late_repeatedly_execute_always(){
  323.   if(_SmoothCamEnabled) doSmoothCameraTracking();
  324.   if(_ParallaxEnabled) doObjectParallax();
  325.   if(_SmoothCamEnabled) Game.Camera.SetAt(_next_cam_x, _next_cam_y);
  326.   else {
  327.     _next_cam_x = Game.Camera.X;
  328.     _next_cam_y = Game.Camera.Y;
  329.   }
  330. }
  331.  
  332. function repeatedly_execute_always(){
  333.   if(!_is_doRoomSetup) doRoomSetup();
  334. }
  335.  


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.

Flugeldufel

  • Gary G. Gerisson
    • Flugeldufel worked on one or more games that was nominated for an AGS Award!
Re: MODULE: rellax 0.1.4
« Reply #21 on: 05 Sep 2020, 07:10 »
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.

Flugeldufel

  • Gary G. Gerisson
    • Flugeldufel worked on one or more games that was nominated for an AGS Award!
Re: MODULE: rellax 0.1.4
« Reply #22 on: 05 Sep 2020, 09:39 »
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!

Olleh19

  • I'm an AGS n00b, please don't kill me
Re: MODULE: rellax 0.1.4
« Reply #23 on: 13 Sep 2020, 18:45 »
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  :)


eri0o

Re: MODULE: rellax 0.1.4
« Reply #24 on: 15 Sep 2020, 00:11 »
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: Adventure Game Studio
  1. cAlice.SetAsPlayer();
  2. 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: Adventure Game Studio
  1. void doObjectParallax(){
  2.   int camx = _final_cam_x;
  3.   int camy = _final_cam_y;
  4.  
  5.   for(int i=0; i<_pxo_count; i++){
  6.     float parallax_x = IntToFloat(_pxo[i].GetProperty("PxPos"))/100.0;
  7.     float parallax_y = IntToFloat(_pxo[i].GetProperty("PyPos"))/100.0;
  8.  
  9.     _pxo[i].X=_pxoOriginX[i]+FloatToInt(IntToFloat(camx)*parallax_x);
  10.     _pxo[i].Y=_pxoOriginY[i]+FloatToInt(IntToFloat(camy)*parallax_y);
  11.   }
  12. }

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

Olleh19

  • I'm an AGS n00b, please don't kill me
Re: MODULE: rellax 0.1.4
« Reply #25 on: 15 Sep 2020, 22:07 »
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: Adventure Game Studio
  1. cAlice.SetAsPlayer();
  2. 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: Adventure Game Studio
  1. void doObjectParallax(){
  2.   int camx = _final_cam_x;
  3.   int camy = _final_cam_y;
  4.  
  5.   for(int i=0; i<_pxo_count; i++){
  6.     float parallax_x = IntToFloat(_pxo[i].GetProperty("PxPos"))/100.0;
  7.     float parallax_y = IntToFloat(_pxo[i].GetProperty("PyPos"))/100.0;
  8.  
  9.     _pxo[i].X=_pxoOriginX[i]+FloatToInt(IntToFloat(camx)*parallax_x);
  10.     _pxo[i].Y=_pxoOriginY[i]+FloatToInt(IntToFloat(camy)*parallax_y);
  11.   }
  12. }

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!

« Last Edit: 15 Sep 2020, 22:26 by Olleh19 »

Re: MODULE: rellax 0.1.4
« Reply #26 on: 06 Mar 2021, 21:53 »
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: Adventure Game Studio
  1. 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: Adventure Game Studio
  1. 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!

eri0o

Re: MODULE: rellax 0.1.4
« Reply #27 on: 08 Mar 2021, 15:53 »
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.

Re: MODULE: rellax 0.1.4
« Reply #28 on: 12 Jul 2021, 19:11 »
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 ;]

Snarky

  • Global Moderator
  • Global Moderator
  • Mittens Lord
  • Private Insultant
    • Best Innovation Award Winner 2018, for his numerous additions to the AGS open source ecosystem including the new Awards Ceremony client and modules
    • Snarky worked on one or more games that won an AGS Award!
    •  
    • Snarky worked on one or more games that was nominated for an AGS Award!
Re: MODULE: rellax 0.1.4
« Reply #29 on: 14 Jul 2021, 09:47 »
It's back now.  :)

Re: MODULE: rellax 0.1.4
« Reply #30 on: 15 Jul 2021, 00:09 »
Thanks  :-D

Hobbes

  • Swashbuckler
MODULE: rellax 0.1.4
« Reply #31 on: 29 Aug 2021, 04:04 »
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!

eri0o

Re: MODULE: rellax 0.1.4
« Reply #32 on: 29 Aug 2021, 06:15 »
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.

Hobbes

  • Swashbuckler
MODULE: rellax 0.1.4
« Reply #33 on: 29 Aug 2021, 09:54 »
That did the trick - thank you!

Icey

  • It's the time of ICEY!!!
    • Icey worked on one or more games that was nominated for an AGS Award!
Re: MODULE: rellax 0.1.4
« Reply #34 on: 03 Jan 2022, 11:44 »
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.


Re: MODULE: rellax 0.1.4
« Reply #35 on: 03 Jan 2022, 12:24 »
@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

eri0o

Re: MODULE: rellax 0.1.4
« Reply #36 on: 03 Jan 2022, 13:12 »
@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.

Icey

  • It's the time of ICEY!!!
    • Icey worked on one or more games that was nominated for an AGS Award!
Re: MODULE: rellax 0.1.4
« Reply #37 on: 03 Jan 2022, 23:36 »
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.

Re: MODULE: rellax 0.1.4
« Reply #38 on: 15 Jan 2022, 08:46 »
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:



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).

eri0o

Re: MODULE: rellax 0.1.4
« Reply #39 on: 15 Jan 2022, 09:51 »
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.
« Last Edit: 15 Jan 2022, 09:58 by eri0o »

Re: MODULE: rellax 0.1.4
« Reply #40 on: 15 Jan 2022, 09:58 »
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: Adventure Game Studio
  1.   _cam_window_w = 40;
  2.   _cam_window_h = 40;

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

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).
« Last Edit: 15 Jan 2022, 10:00 by Laura Hunt »

Re: MODULE: rellax 0.1.4
« Reply #41 on: 15 Jan 2022, 12:32 »
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: Adventure Game Studio
  1. void doSmoothCameraTracking(){
  2.   //if(_prev_c_x == _TargetCharacter.x && _prev_c_y == _TargetCharacter.y)
  3.     //_count_still_ticks++;
  4.   //else
  5.     _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).



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?

« Last Edit: 15 Jan 2022, 12:41 by Laura Hunt »

eri0o

Re: MODULE: rellax 0.1.4
« Reply #42 on: 15 Jan 2022, 13:04 »
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 (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. :)

Re: MODULE: rellax 0.1.4
« Reply #43 on: 16 Jan 2022, 08:18 »
Set your playable Character MovementLinkedToAnimation (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 :)

Re: MODULE: rellax 0.1.4
« Reply #44 on: 21 Feb 2022, 21:03 »
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

Re: MODULE: rellax 0.1.4
« Reply #45 on: 21 Feb 2022, 21:17 »
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
Support Cloak and Dagger Games on Patreon: https://www.patreon.com/user?u=460039

eri0o

Re: MODULE: rellax 0.2.1
« Reply #46 on: 02 May 2022, 02:36 »
Updating to 0.2.0!
  • additional StandstillCameraDelayY, CameraLerpFactorX, CameraLerpFactorY, CameraWindowWidth and CameraWindowHeight attributes;
  • defaults have changed, hopefully they are more useful for Adventure Games;
  • Camera interpolation now uses a float camera position and this position is synced occasionally to the Camera, this should fix the issue reported by Flugeldufel here...;
  • demo is now built using AGS 3.5.1.17;

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...

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 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.
« Last Edit: 02 May 2022, 18:24 by eri0o »

Re: MODULE: rellax 0.2.1
« Reply #47 on: 02 May 2022, 22:50 »
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.

eri0o

Re: MODULE: rellax 0.2.2
« Reply #48 on: 03 May 2022, 00:44 »
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...
« Last Edit: 03 May 2022, 00:51 by eri0o »

Re: MODULE: rellax 0.2.2
« Reply #49 on: 03 May 2022, 02:47 »
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!

eri0o

Re: MODULE: rellax 0.2.2
« Reply #50 on: 09 May 2022, 00:25 »
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: Adventure Game Studio
  1.     Game.Camera.SetAt(FloatToInt(_next_cam_x), FloatToInt(_next_cam_y));
  2.     Game.Camera.SetSize(320, 180);
  3.  
  4.     int residue_x = FloatToInt(_next_cam_x * 4.0, eRoundNearest) - FloatToInt(_next_cam_x) * 4;
  5.     int residue_y = FloatToInt(_next_cam_y * 4.0, eRoundNearest) - FloatToInt(_next_cam_y) * 4;
  6.    
  7.     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, video_2.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.

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.
« Last Edit: 09 May 2022, 01:06 by eri0o »