Unique View moving style

Talk about making games.

Unique View moving style

Postby arcreamer » Mon Jan 07, 2013 6:28 pm

Hey guys so heres what Im trying to do. I want to make it so that whenever my actor hits my moveview_right (or any other direction) instead of the view moving with the character, I want to make it so that the view moves, say, 20 feet to the right automatically and then stops, as to show what the next part of the level is instead of consistently moving with the player. The script I have now with the collision of the moveview_right and player is

Code: Select all
view.x+=10;
arcreamer
 
Posts: 398
Joined: Tue Jul 03, 2007 4:08 pm
Score: 9 Give a positive score

Re: Unique View moving style

Postby Hblade » Tue Jan 08, 2013 12:20 am

I know an interesting one. Try this (Of course, replace event.x with your player actor)

View Draw Actor:
Code: Select all
angle=direction(x, y, event.x, event.y);
directional_velocity=distance(x, y, event.x, event.y)/2;
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Unique View moving style

Postby arcreamer » Wed Jan 09, 2013 8:52 pm

I like how it adjusting the last digit can change the speed of the view following the actor, but for some reason when I hit play, the view drops to the bottom right and i can barely even see my charactor's feet on top left corner of the screen
arcreamer
 
Posts: 398
Joined: Tue Jul 03, 2007 4:08 pm
Score: 9 Give a positive score

Re: Unique View moving style

Postby skydereign » Wed Jan 09, 2013 8:56 pm

That's because the code is using the player's xy. The view actor's xy is based off of the top left of the view. You'd have to use (x+width/2, y+height/2, event.x, event.y), for the direction and distance functions, as that will put the player at the center.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Unique View moving style

Postby lcl » Wed Jan 09, 2013 9:02 pm

arcreamer wrote:I like how it adjusting the last digit can change the speed of the view following the actor, but for some reason when I hit play, the view drops to the bottom right and i can barely even see my charactor's feet on top left corner of the screen

That's because the code has an error. It should be:

Code: Select all
angle=direction(x, y, event.x - width * 0.5, event.y - height * 0.5);
directional_velocity=distance(x, y, event.x - width * 0.5, event.y - height * 0.5)/2;

Because view coordinates are its top left corner coordinates, not the center. :)
If we decrease half of the views size from the coordinates to move to, it goes to the right place.

I see that skydereign was faster, but I think my explanation could be useful too. =)
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: Unique View moving style

Postby arcreamer » Wed Jan 09, 2013 9:17 pm

I understand, thanks guys
arcreamer
 
Posts: 398
Joined: Tue Jul 03, 2007 4:08 pm
Score: 9 Give a positive score

Re: Unique View moving style

Postby RippeR7420 » Wed Jan 09, 2013 11:49 pm

Thank you! And I use the same code Hblade gave you in your topic "Unique View moving style". But the difference is, I gave the view a limit so it couldn't move any further up or down, just left or right.

and to do that, you simply type this code;

view-> draw actor-> script editor->
Code: Select all
x=min(max(x, -320), 5680); // This limits the the views "x" coordinates so they cant go any further left than -320, or no further right than 5680.

y=min(max(y, -240), -240); // This limits the views "y" coordinates so they cant go any further up than -240, or any lower than -240. So it locks it in place.


Just like Sky said, Always remember that the view center point isn't in the middle of the view, but the top - left corner.

I hope that helps!
CURRENT PROJECTS:

-Olo: The Sword Shaman http://game-editor.com/forum/viewtopic.php?f=4&t=12919

-The Wrath of Blob: (On the back burner)

-StickMcGee - Blast to the Future http://game-editor.com/forum/viewtopic.php?f=4&t=13660
User avatar
RippeR7420
 
Posts: 391
Joined: Mon Apr 27, 2009 4:16 pm
Location: Salt Lake City, Utah.
Score: 23 Give a positive score

Re: Unique View moving style

Postby RippeR7420 » Wed Jan 09, 2013 11:51 pm

I tried to message that to you arcreamer, but you have private messages disabled. :)
CURRENT PROJECTS:

-Olo: The Sword Shaman http://game-editor.com/forum/viewtopic.php?f=4&t=12919

-The Wrath of Blob: (On the back burner)

-StickMcGee - Blast to the Future http://game-editor.com/forum/viewtopic.php?f=4&t=13660
User avatar
RippeR7420
 
Posts: 391
Joined: Mon Apr 27, 2009 4:16 pm
Location: Salt Lake City, Utah.
Score: 23 Give a positive score


Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest