Camera move

Game Editor comments and discussion.

Camera move

Postby BogdansB » Fri Oct 28, 2011 10:05 am

Hi ,
I started to make a game like doodle jump. you know that the player goes up , so the camera needs to go up too. i tryed to make it but the player gets slower in the up so the camera needs to go slowly with the player. when i did it , the cam goes jumply. how can i make it flowly?
BogdansB
 
Posts: 94
Joined: Tue Oct 25, 2011 2:30 pm
Score: 0 Give a positive score

Re: Camera move

Postby skydereign » Fri Oct 28, 2011 10:14 am

You mean something like this?
player -> Draw Actor -> Script Editor
Code: Select all
if(yscreen<view.height/3 && yvelocity<0)
{
    ChangeParent("view", "Event Actor");
}
else
{
    ChangeParent("view", "(none)");
}
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Camera move

Postby BogdansB » Fri Oct 28, 2011 10:56 am

thank you
BogdansB
 
Posts: 94
Joined: Tue Oct 25, 2011 2:30 pm
Score: 0 Give a positive score

Re: Camera move

Postby skydereign » Fri Oct 28, 2011 11:20 am

Ok, that was just to get the idea, and perhaps to teach you some gE techniques. Really you can use this, and it doesn't have to use parenting (which is usually better).
player -> Draw Actor -> Script Editor
Code: Select all
view.y=min(view.y, y-view.height/3);
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Camera move

Postby BogdansB » Fri Oct 28, 2011 7:08 pm

ok thanks
BogdansB
 
Posts: 94
Joined: Tue Oct 25, 2011 2:30 pm
Score: 0 Give a positive score

Re: Camera move

Postby BogdansB » Sat Oct 29, 2011 1:53 pm

could you explain me that code?
BogdansB
 
Posts: 94
Joined: Tue Oct 25, 2011 2:30 pm
Score: 0 Give a positive score

Re: Camera move

Postby BogdansB » Sat Oct 29, 2011 2:03 pm

and how can i make the player create at the left side when he is out of vision in the right? like i doodle jump...
BogdansB
 
Posts: 94
Joined: Tue Oct 25, 2011 2:30 pm
Score: 0 Give a positive score

Re: Camera move

Postby skydereign » Sat Oct 29, 2011 11:37 pm

Okay, so min takes the lower of the two values you pass the function. Since you don't want the player to go above 1/3 of the screen, if the player's position is less than the 1/3 line (up is negative) set the view to the player's position -1/3 of the screen's height. But, if it isn't, you don't want to change the view's position. So, you use min(view.y, y-view.height/3). That will set the view's position properly in both cases.

For the other question, you can do this.
player -> Out of Vision -> Script Editor
Code: Select all
x+=((xscreen<0)-(xscreen>view.width))*view.width;

When the actor is out of vision, it uses the conditions to determine which side of the view it is, and increases (or decreases) the x position by the width of the view. If you are to the right of the screen, the condition returns a -1, but if you are to the left, it returns a 1. And if you happen to be out of the view from up or down, it doesn't do anything, since the condition results in a 0.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Camera move

Postby BogdansB » Sun Oct 30, 2011 9:15 am

thanks,but he "creates" unbuityful. how can i make him go flowly like in doodle jump?. how cn i make the score growing up when the player is going up?
BogdansB
 
Posts: 94
Joined: Tue Oct 25, 2011 2:30 pm
Score: 0 Give a positive score

Re: Camera move

Postby skydereign » Sun Oct 30, 2011 10:37 am

I've never played, nor actually seen doodle jump, so I'm not really sure what you mean flowy, but the code I gave was meant to get the idea across. The problem I think you are having is that it appears on screen, instead of coming back from off screen. To fix that, just add the view.width with the width of your actor. That should make it more "beautiful".
Code: Select all
x+=((xscreen<0)-(xscreen>view.width))*(view.width+width);
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Camera move

Postby BogdansB » Mon Oct 31, 2011 8:47 am

it works, thanks and whats about the score?
BogdansB
 
Posts: 94
Joined: Tue Oct 25, 2011 2:30 pm
Score: 0 Give a positive score

Re: Camera move

Postby skydereign » Mon Oct 31, 2011 9:00 am

Just make the score based off how high the player goes (you need a score variable). This assumes the starting position is 0, and also gives you a point per 10 pixels.
Code: Select all
score = -player.y/10;
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Camera move

Postby BogdansB » Mon Oct 31, 2011 9:17 am

and what do i need to do that the variable is shown? I have a text and hen i need to write :


Code: Select all
variable=score.textNumber;

?
BogdansB
 
Posts: 94
Joined: Tue Oct 25, 2011 2:30 pm
Score: 0 Give a positive score

Re: Camera move

Postby skydereign » Mon Oct 31, 2011 9:25 am

No, that could would try to set variable equal to the score actor's textNumber (something you should avoid). I'd put the code into the score display actor's draw event.
score -> Draw Actor -> Script Editor
Code: Select all
textNumber=score_var;

Since it seems your text actor is named score, you can't have an actor and a variable share the same name, so in the above I just changed the score variable to be score_var.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Camera move

Postby BogdansB » Tue Nov 01, 2011 9:28 am

now I want to make the score just add the -y and not the +y. how to do it?

and how to stop the score adding the y of the player after the player destroys?
BogdansB
 
Posts: 94
Joined: Tue Oct 25, 2011 2:30 pm
Score: 0 Give a positive score

Next

Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest