Coder Social home page Coder Social logo

ericoporto / rellax Goto Github PK

View Code? Open in Web Editor NEW
4.0 2.0 3.0 3.3 MB

Rellax camera tracks with parallax

Home Page: https://www.adventuregamestudio.co.uk/forums/index.php?topic=57489.0

License: MIT License

AGS Script 100.00%
parallax adventure-game-studio ags-script

rellax's Introduction

rellax

Rellax while the Camera tracks with cool parallax

rellax demo

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

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.

Scritp 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 Érico Porto and 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 his code on code from Steve McCrea.

The demo game uses CC0 (Public Domain) art provided by jetrel.

rellax's People

Contributors

ericoporto avatar ivan-mogilko avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

rellax's Issues

Test to force pressure increase in lerp factor

rellax.zip

There is a problem when the distance between two points is not very big and the character changes the camera may not move and correctly position.

The test above increases the lerp factor as the distance between the camera and the subject becomes smaller than 8 pixels to try to force it.

AdjustCameraOnRoomLoad doesn't seem to work as expected

In game_start I have:
Rellax.AdjustCameraOnRoomLoad = true;

When moving to a different room the camera moves on y axis a bit(from bottom to top)
I am not sure why, is there a way to make it snap to the "end position" on room load?

I am changing room like so:
player.ChangeRoom(1, 1000, 500);
player.ChangeRoom(2, 2000, 1500);

Once I go to the room 2, camera still moves upwards after fade in.
How would I force the camera to reach the end position on room load?

After all this, I tried adding these lines of code which did not help.

Rellax.CameraWindowHeight = 1080;
Rellax.CameraWindowWidth = 1920;
Rellax.CameraOffsetX = 0;
Rellax.CameraOffsetY = 0;
Rellax.CameraLookAheadX = 0;
Rellax.CameraLookAheadY = 0;

Remove hardcoded VSync

I need to remove this, I added because in 3.5.0 I had a bad tearing with direct draw.

only set camera when Smooth Camera is enabled

Remind to switch code for this

function late_repeatedly_execute_always(){
  if(_SmoothCamEnabled)  Game.Camera.SetAt(_next_cam_x, _next_cam_y);
}

Otherwise turning off the smooth camera doesn't enable tween or manually changing camera position.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.