Jibble

Author Topic: MODULE: rellax 0.1.4  (Read 2426 times)

eri0o

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

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


  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: 01 Jul 2020, 14:32 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 »

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.