Please login or register.

Login with username, password and session length
Advanced search  

News:

IRC channel - server: waelisch.de  channel: #wme (read more)

Pages: [1] 2  All

Author Topic: The illusion of vehicle movement across the scene (on the X-axis)  (Read 24792 times)

0 Members and 1 Guest are viewing this topic.

Indra Anagram

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 74
  • Periodical returnee
    • View Profile

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!

Logged
Owls are not what they seem...

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: The illusion of vehicle movement across the scene (on the X-axis)
« Reply #1 on: November 25, 2017, 01:05:55 PM »

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.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Indra Anagram

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 74
  • Periodical returnee
    • View Profile
Re: The illusion of vehicle movement across the scene (on the X-axis)
« Reply #2 on: November 25, 2017, 07:35:44 PM »

Hey Mnemonic!

The van is basically staying in the same place (moving a little to the left and right)

1. Do you mean something like this?



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.

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
  1. if(X>1200)
  2. {
  3.   tree.SkipTo(X, Y);
  4. }

Or do I understand you correctly at all?

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.

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!
« Last Edit: November 25, 2017, 10:47:46 PM by Indra Anagram »
Logged
Owls are not what they seem...

Indra Anagram

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 74
  • Periodical returnee
    • View Profile
Re: The illusion of vehicle movement across the scene (on the X-axis)
« Reply #3 on: November 29, 2017, 04:59:47 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.

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
  1. while(treebg1.X>=1200)
  2. {
  3.  
  4. }

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!
Logged
Owls are not what they seem...

eborr

  • Regular poster
  • ***
  • Karma: 4
  • Offline Offline
  • Posts: 196
    • View Profile
Re: The illusion of vehicle movement across the scene (on the X-axis)
« Reply #4 on: December 02, 2017, 11:48:51 PM »

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

Indra Anagram

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 74
  • Periodical returnee
    • View Profile
Re: The illusion of vehicle movement across the scene (on the X-axis)
« Reply #5 on: December 03, 2017, 02:00:40 PM »

Hi eborr!

Not wishing to sound harsh but all you do is to reset the x,y coordinnates for each object within a loop.

You don't sound harsh, not at all - maybe a bit sophisticated  :), but that's the question of your experience in scripting compared to mine.

I added this piece of code to scene_init.script:

Code: WME Script
  1. treebg1.X=0;
  2. while (treebg1.X<800+512)
  3.   {
  4.     treebg1.X = treebg1.X+1;
  5.     Sleep(1000);
  6.   }

However nothing really changed - the treebg1 entity isn't moving anywhere.

Guess the problem is I misunderstand following things:

1. Should background trees be one big entity sprite or separate entities?
2. How exactly do I move the tree entities along the x-axis? What method or command should be used?

You set this up as a script you can call, and invokr it for the duration.

3. I am sorry, could you please provide more details?

If you want to see this in action look at the cars in the background in the K'NOSSOS tutorial.

4. Where could I read or download the tutorial to see the cars in the background?

THANK YOU, eborr!
« Last Edit: December 03, 2017, 02:02:24 PM by Indra Anagram »
Logged
Owls are not what they seem...

eborr

  • Regular poster
  • ***
  • Karma: 4
  • Offline Offline
  • Posts: 196
    • View Profile
Re: The illusion of vehicle movement across the scene (on the X-axis)
« Reply #6 on: December 03, 2017, 02:41:01 PM »

you need to set the sleep to between 5 and 10 otherwise it will take ages to cross the screen

to get the KNOSSOS demo

www.svarunentertainment.com

also on itchio and gog - but I don't have the links
Logged

Indra Anagram

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 74
  • Periodical returnee
    • View Profile
Re: The illusion of vehicle movement across the scene (on the X-axis)
« Reply #7 on: December 03, 2017, 04:31:05 PM »

you need to set the sleep to between 5 and 10 otherwise it will take ages to cross the screen

Hey eborr, you did this! The tree runs across the scene behind the car sprite  ;D

However, I had to disable car entity animation (that imitated its movement) in this line

Code: WME Script
  1. car.PlayAnim("entities\car\sprites\move.sprite"); //Set the car in motion

because otherwise your code wouldn't cause the tree entity move.

1. Is that possible to keep both the car entity animation and your script running?
2. Also the tree entity only moved to the right once. How do we cause it return to the initial position and repeat its path across the scene? How do we stop this behavior at a given moment?

to get the KNOSSOS demo

www.svarunentertainment.com

I will download and try the demo, eborr.

THANK YOU for your kind attention and help!
Logged
Owls are not what they seem...

Indra Anagram

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 74
  • Periodical returnee
    • View Profile
Re: The illusion of vehicle movement across the scene (on the X-axis)
« Reply #8 on: December 03, 2017, 05:05:11 PM »

you need to set the sleep to between 5 and 10 otherwise it will take ages to cross the screen

eborr, I am sorry for asking you about the car entity animation. Have just solved this by setting move.sprite in car.entity by default  :) .

Anyway I don't know how it is possible to make the tree entity appear at its initial position over and over again once your script has run (like in this screen)



and how to make this stop at a given moment. Should the script be modified? Or is it another script?

THANK YOU, eborr!
Logged
Owls are not what they seem...

Indra Anagram

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 74
  • Periodical returnee
    • View Profile
Re: The illusion of vehicle movement across the scene (on the X-axis)
« Reply #9 on: December 08, 2017, 12:59:35 PM »

Dear Muties! Still need your help with the scene. eborr's code works fine, yet I tried to set it to repeat numerous times and... nothing.

How is it possible to make an entity (such as treebg1) move across the scene over and over again?

THANK YOU for your attention and help!
Logged
Owls are not what they seem...

anarchist

  • Regular poster
  • ***
  • Karma: 5
  • Offline Offline
  • Gender: Male
  • Posts: 212
    • View Profile
Re: The illusion of vehicle movement across the scene (on the X-axis)
« Reply #10 on: December 08, 2017, 03:24:30 PM »

You have a loop (while) which moves the tree a little every few milliseconds. At some point, the tree moves way over the limits of the screen. If you leave it, it will continue to move indefinitely.

What you need to do is have an if() statement inside the while loop, which will check whether the tree has moved too much, and reset its X position to 0.
Logged

Indra Anagram

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 74
  • Periodical returnee
    • View Profile
Re: The illusion of vehicle movement across the scene (on the X-axis)
« Reply #11 on: December 09, 2017, 12:34:33 AM »

Hi anarchist,

Please kindly view these questions:

What you need to do is have an if() statement inside the while loop, which will check whether the tree has moved too much, and reset its X position to 0.

1. Does this script express your point?

Code: WME Script
  1. treebg1.X=0;
  2. while (treebg1.X<800+512)
  3.   {
  4.     treebg1.X = treebg1.X+1;
  5.     Sleep(2);
  6.         if(treebg1.X == 1200)
  7.         {
  8.           treebg1.X=0;
  9.         }
  10.   }

I tried it and it worked! The tree entity (treebg1) started racing across the screen repeatedly. However I have some doubts, if it is okey from your point of view.

2. I tried to think how this script could be applied to other tree entities and a house entity. Will the following approach be correct?

Code: WME Script
  1. treebg1.X=0;
  2. treebg2.X=100;
  3. while (treebg1.X<800+512 + treebg2.X<800+336)
  4.   {
  5.   treebg1.X = treebg1.X+1;
  6.   Sleep(2);
  7.         if(treebg1.X == 1200)
  8.         {
  9.           treebg1.X=0;
  10.         }
  11.  
  12.   treebg2.X = treebg2.X+1;
  13.     Sleep(0);
  14.         if(treebg2.X == 2000)
  15.         {
  16.           treebg2.X=100;
  17.         }
  18.   }

3. The code from the previous question seems to work, yet entity sprites behave oddly - they sometimes appear from the left edge of screen as if right from the air, from nowhere (not from behind the left edge). And sometimes first tree joins second tree on the run like the engine doesn't manage to "draw" it in time :D Well, of course, WME is not the reason, and I blame my imperfect math knowledge. Is there a way to improve this scenario somehow to make the entities  emerge more naturally?

4. In terms of question 3 I thought maybe if there was a way to only display a central area of the scene background, then the tree entities had enough time and space to appear at their initial positions while we don't see them, move across the visible scene area and then reach the limit positions in the second area that we don't see. Does that make sense? If yes, how do we display the central part of 2400 X 600 background? What can I make in SceneEdit or in scene_init.script?

Hope this screen will illustrate what I mean: 



THANK YOU, anarchist! The scene starts getting closer and closer to what it was thought to be, yet there are some things I can't resolve without help from the community.
Logged
Owls are not what they seem...

anarchist

  • Regular poster
  • ***
  • Karma: 5
  • Offline Offline
  • Gender: Male
  • Posts: 212
    • View Profile
Re: The illusion of vehicle movement across the scene (on the X-axis)
« Reply #12 on: December 16, 2017, 10:43:07 PM »

Code: WME Script
  1. if(treebg2.X == 2000)
  2. {
  3.    treebg2.X=100;
  4. }
  5.  

This approach is not correct. What you want is the entities to start on the start position, move right and then, when they have reached a predefined position on the right they appear on the left. Something like this:

Code: WME Script
  1. if(treebg2.X == 1200)
  2. {
  3.    treebg2.X=0;
  4. }
  5.  

This is also problematic:

Code: WME Script
  1. while (treebg1.X<800+512 + treebg2.X<800+336)
  2.  

First of all, the + sign here 512 + treebg2.X is incorrect. You probably meant to use the "and" symbol, which for Wintermute and a lot of programming languages is this &&. I would also rethink what to use in the while() statement. You probably want this script to run for a specific duration of time, so you could probably use a counter variable. There is also no need to use a lot of Sleep() commands in the loop, just once in the end, after you have moved all the entities.
Logged

Indra Anagram

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 74
  • Periodical returnee
    • View Profile
Re: The illusion of vehicle movement across the scene (on the X-axis)
« Reply #13 on: December 18, 2017, 08:36:44 PM »

Hi anarchist!

This approach is not correct. What you want is the entities to start on the start position, move right and then, when they have reached a predefined position on the right they appear on the left.

Do you mean ALL tree entities in the scene must have X=0 as their starting point? In that case how do we prevent them from overlapping each other (set a space/time delay between them)?

I would also rethink what to use in the while() statement. You probably want this script to run for a specific duration of time, so you could probably use a counter variable.

The reason for me placing the x-axis coordinates in the while() statement is that I misunderstand how this script could work for multiple tree entities, not just one. Or should there be a separate loop for each entity?

4. In terms of question 3 I thought maybe if there was a way to only display a central area of the scene background, then the tree entities had enough time and space to appear at their initial positions while we don't see them, move across the visible scene area and then reach the limit positions in the second area that we don't see. Does that make sense? If yes, how do we display the central part of 2400 X 600 background? What can I make in SceneEdit or in scene_init.script?

Hope this screen will illustrate what I mean: 



I still don't know the way to only display a central part of the long background image so that the starting and end destinations of tree entities were invisible. Any advice?

THANK YOU for your attention, time and friendly help!
Logged
Owls are not what they seem...

Indra Anagram

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 74
  • Periodical returnee
    • View Profile
Re: The illusion of vehicle movement across the scene (on the X-axis)
« Reply #14 on: December 22, 2017, 09:41:35 PM »

Hey Muties!

Finding the answers to these questions is a good way to overcome the background width limitation for everyone who would like to create a scene with "movement illusion". Let's come up with a template.

Please kindly view my questions about the script and scene setting in previous messages here. Any ideas on how the script could be customized for smooth "movement" of multiple entities?

This may seem as something obvious for a person proficient in scripting, but, honestly, to me this is not that easy.

Thank you for your attention, patience and advice, guys! 
Logged
Owls are not what they seem...
Pages: [1] 2  All
 

Page created in 0.053 seconds with 21 queries.