Wintermute Engine > Technical forum

The illusion of vehicle movement across the scene (on the X-axis)

(1/4) > >>

Indra Anagram:
Dear Muties!

Here I am again with another question. Like previous ones I think it is pretty much common for adventure games, so lots of people may be interested in the solution.

In "The Cat Lady" (this adventure game has recently become my huge inspiration) there is a cutscene/scripted scene with a van driving across the scene. I've made some screens and combined them in this GIF to illustrate what I mean:



What I am especially interested here is the van moving horizontally past trees and houses in the background.

1) I know there is a limitation for background resolution in WME. In the aforementioned scene the background seems to last and scroll forever. Yet since houses in the fog do repeat, I suspect the background is looped somehow. How is it possible to achieve such an effect in WME?

2) The van sprite itself is animated in a sly way: sometimes it seems not to move on the X-axis at all and other times it does actual motion from one edge of the scene to the other. Am I right?

3) The trees in the "foreground" have a kind of parallax effect. I know there is a chapter in WME tutorial about levels, yet here, like with the background, the trees seem to last forever)) How does one achieve this? Do these sprites load and unload constantly? What would the code look like? I'm afraid even to think about such code size and contents  :o

Guys, please help me to comprehend making of a complex scripted thing like this.

Thank you for your attention, thoughts, portions of wisdom and advice!

Mnemonic:
It's all smoke and mirrors :) Simply put, forget about scrolling. The van is basically staying in the same place (moving a little to the left and right) while everything else moves. For example, the trees would be "recyclable" entities, that move from right to left, and when they're off screen, they skip back all the way to the right and then move through the screen again. Same for the fog, houses etc.

Basically you'd need just one script, that would move it's owner entity by decreasing its X position, and if X is lower than some threshold, it would increase it again and repeat the process.
This trick is used by many games, both 2D and 3D. From recent memory, Life is Strange Before the Storm uses this when the main character drives a car through the countryside.

Indra Anagram:
Hey Mnemonic!


--- Quote from: Mnemonic on November 25, 2017, 01:05:55 PM ---The van is basically staying in the same place (moving a little to the left and right)

--- End quote ---

1. Do you mean something like this?




--- Quote from: Mnemonic on November 25, 2017, 01:05:55 PM ---Basically you'd need just one script, that would move it's owner entity by decreasing its X position, and if X is lower than some threshold, it would increase it again and repeat the process.

--- End quote ---

2. I want the vehicle to move left, like in the example gif from my original post. Will the code resemble something like:


--- Code: WME Script ---if(X>1200){  tree.SkipTo(X, Y);}
Or do I understand you correctly at all?


--- Quote from: Mnemonic on November 25, 2017, 01:05:55 PM ---while everything else moves. For example, the trees would be "recyclable" entities, that move from right to left, and when they're off screen, they skip back all the way to the right and then move through the screen again. Same for the fog, houses etc.

--- End quote ---

3. I am creating a simple replica of the scene. How many layers should be in the scene? 3 or 4? I mean for background, emerging and disappearing house and back trees, the car itself (with floor region), and foreground with trees. Should those foreground tree entities be recycled one by one or as one long sprite?

THANK YOU for your kind reply and inspiration!

Indra Anagram:

--- Quote from: Mnemonic on November 25, 2017, 01:05:55 PM ---For example, the trees would be "recyclable" entities, that move from right to left, and when they're off screen, they skip back all the way to the right and then move through the screen again. Same for the fog, houses etc.

Basically you'd need just one script, that would move it's owner entity by decreasing its X position, and if X is lower than some threshold, it would increase it again and repeat the process.

--- End quote ---

Dear Muties,

I've created a project called "Vehicle" and a scene called "Car" to achieve a rough replica of the scene from the original post here. All entities are loaded in the scene and the car entity has a simple animation of "movement" (smoke and mirrors, just like Mnemonic said  :)). Now I am stuck, because of several questions:

1. How should this scene be organized in terms of levels? In "Car" there are currently two layers: one for background2 (background image itself) and main for floor region and all entities. The idea is to mimic car movement by loading and moving trees and house in the background (behind the car) in the x-axis from left to right. I guess later the third level - for foreground trees - could be added, however the floor region can be only on the main layer. So, how do I organize the layers?

2. As you can see in the screen below, currently tree entities overlap the car entity, since all entities are loaded on the same layer. Is there a way to solve this and make the car entity overlap and cover everything that is "behind"?



3. I haven't found any info in the Documentation about scripting moving entities and the OldGuy entity in the demo project is pretty much static, so... How do I move tree and house entities in the x-axis? Looked through "Scene object" and "Entity object" sections in the Scripting reference, yet didn't come up with something like "GoTo" analog for entities. I am pretty bad at understanding scripts. Mnemonic replied me there should be basically one script. The problem is I seemingly understand the principle, yet cannot specify that with appropriate commands in the form of a working condition. My guess was something like this:


--- Code: WME Script ---while(treebg1.X>=1200){  }
but I don't know if this will be right and again, what method, command or parameter should I use to move entities?

I disabled actor as Game.MainObject and erased Molly's lines from game.script. Should I make the car entity Game.MainObject now?

So many questions and I've tried different approaches for 2 - 3 days. Please help me with this scene, guys! After all, such things are pretty common for adventure games, and I think others might need it too. We could add it to the free resources section when it's ready.

Here are links to the source files. I've had some issues with Dropbox recently, so I made both zip and rar archives of same scene:

https://www.dropbox.com/s/1ykixggujdcd5xv/Vehicle.rar?dl=0
https://www.dropbox.com/s/5sjcz5isg5kj40m/Vehicle.zip?dl=0

THANK YOU for your kind attention and friendly advice!

eborr:
Not wishing to sound harsh but all you do is to reset the x,y coordinnates for each object within a loop. I dont have access to a win box at the moment but the code goes something like this


Myobejct.X =0;
while (Myobject.X <Screensize+objectsize)
  {
    Myobject.X = Myobejct.X +1;
    SLEEP(<some int >);
  }

Obviously this ie not pure WME script but I hope you get the general idea. You set this up as a script you can call, and invokr it for the duration. If you want to see this in action look at the cars in the background in the K'NOSSOS tutorial.

Navigation

[0] Message Index

[#] Next page

Go to full version