MODULE: Smooth Scrolling & Parallax v1.7.1

Started by Ali, Fri 07/12/2007 21:14:09

Previous topic - Next topic

Jackpumpkinhead

is it possible to use this along with the 9-verb MI style template
if so how
sorry for the n00b question
currently on an indefinite hold.

Ali

I'm not able to test it right now, but I see no reason why it shouldn't be. It's not 100% compatible with the verb coin template (because the screen scrolls slightly between the time when you click and the time when you choose an action), but there is a workaround for that.

Please try it and let me know if you run into problems!

Jackpumpkinhead

currently on an indefinite hold.

snaggletooth

Hi,

I'm having trouble figuring this out.
I have a very long background and I am using keyboard controls for movement.
Everytime my character gets towards the edge of the screen the screen will scroll but not fast enough.
Eventually the character outruns the screen.

How do I increase the scroll speed of the screen if there are no objects in the room?

Thanks in advance for any help

Ali

Try increasing the variable called targetScrollSpeedX and targetScrollSpeedY. You may also need to increase other variables (like slowDownRange) to get it to move smoothly.

snaggletooth

Thanks Ali,

That seems to have worked.

I'm having a few troubles now with the character moving a bit choppily.
Is there any way to avoid this?
Also what variable is used to detect how close to the edge the character is?
I would like the edge to be further from the screen so the character doe not have to be close to the edge.

Thanks for the help I really like the look of this module

Ali

Hi,

This module doesn't affect character movement. The choppy movement is probably to do with anti-glide mode which is less effective for larger character sprites / walkcycles with more frames.

To change the thresholds look for the comments reading "// Scroll towards the player when they are at the edge of the screen":

For the X Position:

Code: ags
        else if (ScrollingAllowedX && PlayerScreenX < (FloatToInt(0.30 * IntToFloat(ScreenWidth))) && PlayerVelocityX <= 0) TargetPointX = player.x; // Scroll towards the player when they are at the edge of the screen
        else if (ScrollingAllowedX && PlayerScreenX > (FloatToInt(0.70 * IntToFloat(ScreenWidth))) && PlayerVelocityX >= 0) TargetPointX = player.x; 
        else if (ScrollingAllowedX && PlayerScreenX < (FloatToInt(0.30 * IntToFloat(ScreenWidth))) && PlayerVelocityX > 0) TargetPointX = GetViewportX() + HalfScreenWidth - 6;  //Except if they change direction
        else if (ScrollingAllowedX && PlayerScreenX > (FloatToInt(0.70 * IntToFloat(ScreenWidth))) && PlayerVelocityX < 0) TargetPointX = GetViewportX() + HalfScreenWidth + 6;


And for Y:

Code: ags
        else if (ScrollingAllowedY && PlayerScreenY < (FloatToInt(0.30 * IntToFloat(ScreenHeight))) && PlayerVelocityY <= 0) TargetPointY = player.y; // Scroll towards the player when they are at the edge of the screen
        else if (ScrollingAllowedY && PlayerScreenY > (FloatToInt(0.70 * IntToFloat(ScreenHeight))) && PlayerVelocityY >= 0) TargetPointY = player.y; 
        else if (ScrollingAllowedY && PlayerScreenY < (FloatToInt(0.30 * IntToFloat(ScreenHeight))) && PlayerVelocityY > 0) TargetPointY = GetViewportY() + HalfScreenHeight - 6;  //Except if they change direction
        else if (ScrollingAllowedY && PlayerScreenY > (FloatToInt(0.70 * IntToFloat(ScreenHeight))) && PlayerVelocityY < 0) TargetPointY = GetViewportY() + HalfScreenHeight + 6;


The '30' and '70' mean that 30% of the screen on the left and right are the scrolling areas. To make the scrolling areas bigger try '40' and '60', to make them smaller try '20' and '80'.

In future releases I will try to make it this simpler to achieve, but I don't have time to work on the module now.

Grim

I've just started using it and I really like it!

I encountered a problem though... If the value of PxPos is below 3 an error comes up and game crashes. It seems that 3 and above displays fine, but it's really moving quite fast... I tweaked targetScrollSpeed because it was too slow and it's now 40... but I don't think that would affect anything, would it?

Also, the game is keyboard controlled in res 800:600.

EDIT: Same for - values.-1, -2 crash the game and -3 makes object practically follow character on the screen like a dog on the leash....

Ali

I've never had a crash like that at 800x600, perhaps it could be caused by keyboard control. Could you post the content of the error message to help me work out what the issue is?

0 is supposed to create static objects for objects a long way off, like the sun in the demo game. The negative numbers are possibly useful for a lens flare effect or similar, but most of the time only 0 and above would be useful. At this time in the morning, I can't think why the crash would happen for values under 3!

Grim


Kweepa

Did you add the PxView property to the schema for objects?
Make sure line 381 still says GetProperty("PxView") - you could have accidentally changed it.
Still waiting for Purity of the Surf II

Ali

Thanks Steve, as far as I can see that must be the problem.

Let me know if you keep having trouble!

Grim

Yeah, line 381 says just that. I haven't altered any of it.

But I think this isn't much of a problem- I'm happy just using setting for 3, 4 and 5. :)

I must also say I really love this module and it really adds a lot to the look of my project already!:) So, thanks!

Ali

Glad you're finding it useful. Please let me know if you've added the property PxView? If you haven't then there must be something wrong with the script.

Icey

hey i cant figure out why it gives me an error at 509 & 769. it comes up before the game even starts.

Ali

That sounds like you haven't added the required properties. See this section in the module information:

Code: ags

////////////////////////
//Required Properties://
////////////////////////
//
// Before starting, you must create the following properties 
// in AGS. 
//
// NOTE: You must do this even if you do not plan to use
//  the parallax effect. It doesn't take long, but I'm sorry 
//  all the same.
//
// PxPos:
//
//  Name: PxPos
//  Description: Stores an object's parallax position
//  Type: Number
//  Default Value: 0
//
// PxView:
//
//  Name: PxView
//  Description: Stores the pixel-adjustment view number
//  Type: Number
//  Default Value: 0
//
// PxLoop:
//
//  Name: PxLoop
//  Description: Stores the pixel-adjustment loop number
//  Type: Number
//  Default Value: 0

Icey


Ali

Look up the word 'properties' in the AGS manual index. All the information you need is there.

Icey

it works! but is there a way to keep the camera following my player until he stops?

Ali

If you mean you want the camera to stop moving the instant the player stops moving, then I'm afraid that's not possible. As it is the player stops, and then the camera takes a short while to come to a stop smoothly.

To make the camera and player stop simultaneously the module would have to anticipate when the player was going to stop and start to slow down. I don't know how I'd script that. Also I think the effect would be unnatural, in film a camera operator rarely stops panning the instant an actor stops moving.

SMF spam blocked by CleanTalk