• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM [Question] How to: detect the end a "view sequence" | Change "view speed" on the fly?

S

SamuelBush

Guest
Hi Folks,
I am pretty damn new to this GM stuff so please forgive me if I might ask something what is fairly easy or if a thread like this already exists... i probably didn't notice that.

So I watched a few tutorials and tried to adapt it and use it with other things. Made my first useless programs/games and until now... it mostly worked fine.

But I am out of Ideas how to solve my actual problem and I really need some help.

I want to make a Room where the Camera (View) starts at the bottom right and slowly moves to the player position.
This step works fine... but if I "play" the "game" now and move the object i have the problem that the "camera speed" is still slow (about 4 or 5 pxl).




_______
I searched the web for a few hours and tried to solve this issue on my own, looked into the forums and the help menu and searched for everything with "view" and stuff... but nothing worked.


At least I've found 2 things i consider quite helpful.
  • if !view_enabled
    {
    view_visible[0] = true;
    view_enabled = true;
    }
and
  • room_set_view(ind, vind, vis, xview, yview, wview, hview, xport, yport, wport, hport, hborder, vborder, hspeed, vspeed, obj);
  • room_set_view_enabled( ind, val );


When i used and edited "room_set_view(ind, ...)" for example, the program ignored these settings and used those of the "view tab".

I tried to work with "if" stuff but I was always missing something that detected the end of the "view-squence".
I thought about creating a countdown for the time the "intro" needs to get to the object and switch to "View 2". Also thought about creating 2 Rooms which are the same. The first Room uses the Camera from bottom right and moves to the Player and Room 2 would use the "normal" camera that follows the player. Sadly that wouldn't get rid of the problem... might even cause more problems in the long run. So i got rid of those ideas pretty fast.

Sadly I got frustrated after 4h+ of nothing but failure... also got hungry, lost a game in lol and last but not least I didn't write down any of the stuff i tried before I save and exit the Program. I feel like I forgot 90% of the Stuff i already tried and maybe one of those tries would have been something where I just messed 1 little thing up and if that didn't happen everything would be perfectly fine. I kinda doubt that... but I will probably never know :(
One of my thoughts:

I wanted to use this:
-
if !view_enabled
{
view_visible[0] = true;
view_enabled = true;
}
-
... and add an "intro += 1;"
Once that finished i wanted to do exactly the same. But in that case i wanted to start view one. The second step only happened of the sign of intro was positive. If it was positive i wanted the use view 1, which would be the camera that follows the player.​

And all of my Ideas were something like
  1. start Camera A!
  2. Check if it's done or still running
  3. start Camera B!
or
  1. start Camera A!
  2. Check if it's done or still running / wait until it's finished
  3. Set camera Speed to something else

How do I manage to set the camera speed to "-1"?
How can detect if a "view-sequence" is finished ?
How do i make an other one start when the first one is finished?
Is there maybe an easier way? Am i completely wrong?
Or should I even use something else than "View"... I'm not sure if there is anything else tho.


I am out of Ideas how i could solve this on my own and slightly annoyed because i didn't figured it out yet.
I really hope that someone here can help me sorting this out. I also hope that i didn't miss a post like this... that would be kinda daft :/

Sorry if I don't reply quickly... its already past 4am and i think I will fall asleep soon
 
S

SamuelBush

Guest
Code:
view_hspeed[view_current] = -1;
view_vspeed[view_current] = -1;
will make it instantly follow the object
Hi, thanks for the quick reply.
In order to use it like I want to i have still have to figure out how to make the game recognise the end of an sequence.
Do you have any idea how to achieve this?
Will work a bit with "view_hspeed[view_current] = -1" and ofc "vspeed".
I'll update this post in case i figure it out myself.

Thanks
 

Yal

šŸ§ *penguin noises*
GMC Elder
You could always check whether the center of the view is sufficiently close to an end point.
Code:
view_centerx = view_xview + view_wview*0.5; view_centery = view_yview + view_hview*0.5;
view_goalx = obj_player.x; view_goaly = obj_player.y;

if(point_distance(view_centerx,view_centery,view_goalx,view_goaly) <= point_distance(0,0,view_hspeed,view_vspeed)){
  //Put code that switches to the next 'sequence' here
}

(I left out putting [view_current] after every view variable... if you only use view 0, the array indexing is optional)
 
S

SamuelBush

Guest
You could always check whether the center of the view is sufficiently close to an end point.
Code:
view_centerx = view_xview + view_wview*0.5; view_centery = view_yview + view_hview*0.5;
view_goalx = obj_player.x; view_goaly = obj_player.y;

if(point_distance(view_centerx,view_centery,view_goalx,view_goaly) <= point_distance(0,0,view_hspeed,view_vspeed)){
  //Put code that switches to the next 'sequence' here
}

(I left out putting [view_current] after every view variable... if you only use view 0, the array indexing is optional)
Thank you
Hopefully i can test it this evening.
Seems promising
 

TheouAegis

Member
I would just check if the absolute value of the difference between the center of the view and the player's position is less than the speed of The View. The only issue I can see that might come up is if the view extends to the edge of the room and you have the view automatically clip within the room boundaries. That will throw off any equations you use.

Edit: My voice-to-text blows.
 
Last edited:
Top