MODULE: rellax 0.4.0

Started by eri0o, Mon 07/10/2019 03:26:58

Previous topic - Next topic

AndreasBlack

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)

AndreasBlack

@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
Code: ags

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


TheVolumeRemote

#62
@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!!

Dave Gilbert

#63
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!

eri0o

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:

  • If the character is moving, LERP (default rellax implementation)
  • If the character is stopped, Tween the camera

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.

Dave Gilbert

Awesome!! Thanks so much. :)

eri0o

#66
Release 0.3.0! Updated the first post with the links! Changes are the following
  • Removes the standstill property, it's supposedly more useful for platforms, may add later if necessary.
  • The main change here is once the character stops, it will instead switch from plain Lerp to a Tween like behavior so that the camera slides in to whatever should be it's target. Additionally, now it defaults for `AdjustCameraOnRoomLoad` being true.
  • A lot of rewrites in the code

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? :)

AndreasBlack

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

 


eri0o

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

AndreasBlack

#69
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
Code: ags
 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.

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

[close]


eri0o

#70
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. I haven't merged this on rellax yet for the lack of people to test it.

AndreasBlack

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)

eri0o

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.

eri0o

Made a new 0.4.0 release! Get it on the first post!

  • Fixes issue where the game may error with a "SetObjectPosition: invalid object number" on room leave, stopping the game.
  • Notes with licenses of the recently include easing math.
  • Minor code/style refactors

Roadmap for the next thing: a way to pan the camera without turning off and on the smoothcam - leveraging the now added easing math.

Jelonertz

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!

eri0o

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.

AndreasBlack

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)

SMF spam blocked by CleanTalk