Page 1 of 2

Camera move

PostPosted: Fri Oct 28, 2011 10:05 am
by BogdansB
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?

Re: Camera move

PostPosted: Fri Oct 28, 2011 10:14 am
by skydereign
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)");
}

Re: Camera move

PostPosted: Fri Oct 28, 2011 10:56 am
by BogdansB
thank you

Re: Camera move

PostPosted: Fri Oct 28, 2011 11:20 am
by skydereign
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);

Re: Camera move

PostPosted: Fri Oct 28, 2011 7:08 pm
by BogdansB
ok thanks

Re: Camera move

PostPosted: Sat Oct 29, 2011 1:53 pm
by BogdansB
could you explain me that code?

Re: Camera move

PostPosted: Sat Oct 29, 2011 2:03 pm
by BogdansB
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...

Re: Camera move

PostPosted: Sat Oct 29, 2011 11:37 pm
by skydereign
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.

Re: Camera move

PostPosted: Sun Oct 30, 2011 9:15 am
by BogdansB
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?

Re: Camera move

PostPosted: Sun Oct 30, 2011 10:37 am
by skydereign
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);

Re: Camera move

PostPosted: Mon Oct 31, 2011 8:47 am
by BogdansB
it works, thanks and whats about the score?

Re: Camera move

PostPosted: Mon Oct 31, 2011 9:00 am
by skydereign
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;

Re: Camera move

PostPosted: Mon Oct 31, 2011 9:17 am
by BogdansB
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;

?

Re: Camera move

PostPosted: Mon Oct 31, 2011 9:25 am
by skydereign
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.

Re: Camera move

PostPosted: Tue Nov 01, 2011 9:28 am
by BogdansB
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?