The Daily Click ::. Forums ::. Klik Coding Help ::. Camera Tricks
 

Post Reply  Post Oekaki 
 

Posted By Message

»xerus



Registered
  28/06/2002
Points
  675

You've Been Circy'd!Game of the Week Winner
13th July, 2007 at 14:12:21 -

In a lot of the better Click platformers, there are always some fancy camera tricks and I always wonder how they're done.

The main one I'm interested in is the blocking the camera until the player moves passed a certain point. For example if you had a hidden room behind a breakable wall or something, and you didnt want the camera to lead over to it until the player actually went passed that wall, how would you go about doing that?

And what about having the camera move between different targets smoothly? And I dont want to know about a bouncing ball movement way to do this, I'm thinking math related ways.

Thanks! ;D

 
n/a

DaVince

This fool just HAD to have a custom rating

Registered
  04/09/2004
Points
  7998

Game of the Week WinnerClickzine StaffHas Donated, Thank You!Cardboard BoxDos Rules!
13th July, 2007 at 15:57:56 -

Stop the camera:
If target has not been reached + character X > some value: set Camera X to some fixed value.

Smooth movement:
If character X < Camera X: add 1 to camera X
If character X < Camera X - 50: add 1 to camera X
Same for > and Y. The two different events will make the camera scroll to the character quicker if the camera's further away from the character. Add as many factors as you like.

About smooth movement: I'm sure there's a correct formula to do it REALLY smoothly, but I always seem to fail at these increment/decrement-a-value formulae.

 
Old member (~2004-2007).

»xerus



Registered
  28/06/2002
Points
  675

You've Been Circy'd!Game of the Week Winner
13th July, 2007 at 16:14:02 -

"If character X < Camera X: add 1 to camera X
If character X < Camera X - 50: add 1 to camera X"

Thats actually an interesting way to do it, and I never really thought about this. I always try to use one big long formula, and I can never figure out how to get smooth movement and have the camera slow down and stop where I want it to.

The stopping the camera thing isnt so clear to me, I guess. How would I do it without having to code it for every instance I wanted it to happen in the event editor? If I could somehow use marker objects in the levels that signified "The camera shouldn't show the player anything beyond this point until after the player crosses that point." but having multiple "Secret areas" in a level might be problematic...

I'm thinking about like A Game with a Kitty (I think.) where the camera wouldn't follow you at certain points until you reached the edge of the window.

 
n/a

DaVince

This fool just HAD to have a custom rating

Registered
  04/09/2004
Points
  7998

Game of the Week WinnerClickzine StaffHas Donated, Thank You!Cardboard BoxDos Rules!
13th July, 2007 at 16:29:08 -

Well, I was thinking this: if the character X gets higher than a certain value but you haven't done something yet, block the camera from going any further than a certain X position. This being done by fixing the camera at one X point once the person X gets too high & a certain other condition was not met

 
Old member (~2004-2007).

Del Duio

Born in a Bowling Alley

Registered
  29/07/2005
Points
  1078

GOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!Evil klikerHasslevania 2!The OutlawSanta Boot
13th July, 2007 at 19:28:33 -

It's probably not the "right" way of doing things, but most of the time when I want the camera not to see something all I do is make a black active square or whatever and just cover up the secret room. Then, once your guy goes inside just destroy the object and there you go. Or you could change the black active object's transparency to 128 while the player overlaps it (i.e. he's inside the room), and transparency to 0 when he's out of the room (the darkness becomes fully visible.)

 
--

"Del Duio has received 0 trophies. Click here to see them all."

"To be a true ninja you must first pick the most stealthy of our assorted combat suits. Might I suggest the bright neon orange?"

DXF Games, coming next: Hasslevania 2- This Space for Rent!

»xerus



Registered
  28/06/2002
Points
  675

You've Been Circy'd!Game of the Week Winner
13th July, 2007 at 19:34:00 -

Well, anything beyond a 320 x 240 game is probably not going to enjoy that huge active very much, and the problem is that it doesnt hide it.

If the player approaches a wall, and you want them to think its the edge of the frame, the camera stops and they walk to the side of the screen. There is no more frame beyond that point, so the camera cant follow them until they return to the center of the window.

If they approach that same wall, and the camera still follows them, then its an immediate tip that "Hey, theres some more frame area beyond this wall..." and they'll pick up on the secret.

 
n/a

viva/volt

Awesome Sauce

Registered
  26/08/2006
Points
  1694

Game of the Week WinnerSilverNova MemberKlikCast StarVIP Member
14th July, 2007 at 02:15:24 -

The underside does something like this, you'd need to tell the camera to "snap" to a certain point (maybe only vertical or horizontal) and only move again when you go past the edge.

That's a very interesting way indeed Vince!

EDIT: I can confirm Vince's idea works very nicely! My game looks great now

Image Edited by the Author.

 
Image
http://bfollington.tumblr.com

»xerus



Registered
  28/06/2002
Points
  675

You've Been Circy'd!Game of the Week Winner
16th July, 2007 at 19:03:57 -

I was hoping some more people would contribute to this thread with some more camera related goodies. So... do it =B

 
n/a

DaVince

This fool just HAD to have a custom rating

Registered
  04/09/2004
Points
  7998

Game of the Week WinnerClickzine StaffHas Donated, Thank You!Cardboard BoxDos Rules!
16th July, 2007 at 19:36:39 -

Earthquake effect:
Always:
- Set some alterable value somewhere to -somevalue + Random(somevalue*2)
- Center screen at fixed point (current point?) + alterable value
Simple and smooth. Can be enhanced by making somevalue an alterable value too (this can change it in such a way that earthquakes appear gradually! )


Quick and smooth scrolling to a certain area in the game - done like the smooth scrolling method, just make it scroll even faster at really high values.

Screen effects like explosion impact effects etc - just use the perspective object.

Um yeah, I don't need if you need any more, but those are some.

 
Old member (~2004-2007).

Liquixcat

Administrator
Lazy Coder

Registered
  08/12/2002
Points
  201

VIP MemberLikes TDCKitty
21st July, 2007 at 12:10:22 -

Create an object (call it Camera)
make it like 1x1 and invisible
Use a global value to store value (I use C)
Set C to a value, the lower the value the faster the camera scrolls
(I find 12 a good value)

In event editor:

//code
X position of ("Camera") < then X ("player")
> start loop camR for "(X("player")-X("Camera"))/Global Value C"

On loop CamR
> X( "Camera" ) - 1
//end code

Then repeat that event for each X or Y
Ie.

//code
X position of ("Camera") > then X ("player")
> start loop camL for "(X("player")-X("Camera"))/Global Value C"

On loop CamL
> X( "Camera" ) - 1
//end code


The Y axis will be just as easy. This will create a nice smooth camera. In situation you can use "player" as a variable and make the "camera" focus whatever you want. which includes keeping the camera still until all enemies are destroyed.

Hope this helps.

 
thinking is like pong, it's easy, but you miss sometimes.

Dr. James MD

Addict

Registered
  08/12/2003
Points
  11941

First GOTW AwardSecond GOTW AwardThird GOTW AwardPicture Me This -Round 26- Winner!
21st July, 2007 at 12:38:02 -

Now theres no code here, sorry about that. But a bit of talking n junk.

I use 3 objects. One is where the camera looks to, and 2 seperate 1x1 actives to represent the X and Y camera positions.

When the character is facing right I set it the camera look to object about 100px right of the player, and -100px for left. The X and Y camera objects always look towards the camera and the speed is set by the distance between the 2. So you get a lovely smooth transition if you need to move the camera to a different area.

Why use 2 cameras for X and Y? Fixed scrolling positions. I did this in Sam and it's used heavily in Tormishire. Creating actives or "zones" where the X or Y camera will stay (rather than looking at the camera-looks-to). You can isolate certain areas to only scroll in the X or Y dimensions. And you can also throw in a zone to fix both X and Y cameras so you can draw focus to just 1 area.

Might make an example actually...

 
Image
http://uk.youtube.com/watch?v=j--8iXVv2_U
On the sixth day God created Manchester
"You gotta get that sand out your vaj!" x13
www.bossbaddie.com

Liquixcat

Administrator
Lazy Coder

Registered
  08/12/2002
Points
  201

VIP MemberLikes TDCKitty
21st July, 2007 at 12:42:13 -

There isn't two camera's. Besides, I taught you how to use loops Jimmi, start using them!

 
thinking is like pong, it's easy, but you miss sometimes.

Dr. James MD

Addict

Registered
  08/12/2003
Points
  11941

First GOTW AwardSecond GOTW AwardThird GOTW AwardPicture Me This -Round 26- Winner!
21st July, 2007 at 12:49:02 -

Not 2 cameras sorry, but 2 representations. One for X and one for Y positions.

 
Image
http://uk.youtube.com/watch?v=j--8iXVv2_U
On the sixth day God created Manchester
"You gotta get that sand out your vaj!" x13
www.bossbaddie.com

»xerus



Registered
  28/06/2002
Points
  675

You've Been Circy'd!Game of the Week Winner
21st July, 2007 at 12:49:50 -

"Might make an example actually..."

Do do that! ;D

 
n/a

Dr. James MD

Addict

Registered
  08/12/2003
Points
  11941

First GOTW AwardSecond GOTW AwardThird GOTW AwardPicture Me This -Round 26- Winner!
21st July, 2007 at 13:35:28 -

http://satansam.co.uk/ftp/quickscroll.rar

It's a little bit rushed since I'm working at the moment. But it works!

Edit: forgot to mention. It's in MMF2 and uses the Advanced Maths object. I'll modify it to use the ol' formula if you don't have that extension.

Image Edited by the Author.

 
Image
http://uk.youtube.com/watch?v=j--8iXVv2_U
On the sixth day God created Manchester
"You gotta get that sand out your vaj!" x13
www.bossbaddie.com

»xerus



Registered
  28/06/2002
Points
  675

You've Been Circy'd!Game of the Week Winner
21st July, 2007 at 15:07:24 -

Heres one that I just thought of, just now...

Looking down and up
Start off with some arbitrary alterable value that you can use for this. I chose an alterable value in the player sprite

* When the player is standing on the ground,
* Not pushing left,
* Not Pushing Right,
* Is pushing Down,
* Alt Value D is < 60 (60 will be the max amount of pixels the player can push the camera down.)
- Add two to Alt Value D

* Alt Value D is > 0
- Sub one from Alt Value D

Now the camera would look something like this:
* Always
- Set Y position to Y("Player") + Alt Value D

Its a little rough, but with some more events you could smooth it out a bit. And that was for looking down only. Looking up just involves doing the same thing except with negative values in Alt Value D.


Image Edited by the Author.

 
n/a

DaVince

This fool just HAD to have a custom rating

Registered
  04/09/2004
Points
  7998

Game of the Week WinnerClickzine StaffHas Donated, Thank You!Cardboard BoxDos Rules!
21st July, 2007 at 16:01:17 -

"Not 2 cameras sorry, but 2 representations. One for X and one for Y positions."

X and Y scrolling speeds will act independently. That's why.

 
Old member (~2004-2007).

Dr. James MD

Addict

Registered
  08/12/2003
Points
  11941

First GOTW AwardSecond GOTW AwardThird GOTW AwardPicture Me This -Round 26- Winner!
21st July, 2007 at 16:05:11 -

Ooh, forgot to say, you can do things like rotation on the main "camera look to" object. I've done that for the swimming bit in Tormishire since it runs in 360 degrees. When on the ground it snaps back to left/right positions. Might put in looking up+down actually...

 
Image
http://uk.youtube.com/watch?v=j--8iXVv2_U
On the sixth day God created Manchester
"You gotta get that sand out your vaj!" x13
www.bossbaddie.com

DaVince

This fool just HAD to have a custom rating

Registered
  04/09/2004
Points
  7998

Game of the Week WinnerClickzine StaffHas Donated, Thank You!Cardboard BoxDos Rules!
21st July, 2007 at 16:09:19 -

Dude, that sounds extremely cool.

 
Old member (~2004-2007).

viva/volt

Awesome Sauce

Registered
  26/08/2006
Points
  1694

Game of the Week WinnerSilverNova MemberKlikCast StarVIP Member
21st July, 2007 at 21:58:04 -

With the smooth scrolling the formula is:

Always ->
- set X of Camera to X( "Camera" )+(X( "Player" )-X( "Camera" ))*0.045
- set Y of Camera to Y( "Camera" )+(Y( "Player" )-Y( "Camera" ))*0.09

Changing the decimals will change the speed. Yes that is the same as dividing them but who cares...

EDIT: After using Jimmi's 3 object system I have an example (Because Jimmi's was only an exe?) http://www.silvernova.co.uk/Examples/ScrollingStuff.mfa hope it helps someone...


Image Edited by the Author.

 
Image
http://bfollington.tumblr.com

Liquixcat

Administrator
Lazy Coder

Registered
  08/12/2002
Points
  201

VIP MemberLikes TDCKitty
22nd July, 2007 at 00:43:14 -

Ok, here's an example. It's for MMF2, use the code all you want.
http://www.liquixcat.com/backend/Camera.rar

Image Edited by the Author.

 
thinking is like pong, it's easy, but you miss sometimes.

Dr. James MD

Addict

Registered
  08/12/2003
Points
  11941

First GOTW AwardSecond GOTW AwardThird GOTW AwardPicture Me This -Round 26- Winner!
22nd July, 2007 at 19:13:55 -

CRAP! I did didn't I! oh I'm new at this example business.

edit: it's the open source now.

Image Edited by the Author.

 
Image
http://uk.youtube.com/watch?v=j--8iXVv2_U
On the sixth day God created Manchester
"You gotta get that sand out your vaj!" x13
www.bossbaddie.com

viva/volt

Awesome Sauce

Registered
  26/08/2006
Points
  1694

Game of the Week WinnerSilverNova MemberKlikCast StarVIP Member
23rd July, 2007 at 06:07:24 -

Pff 3 examples to do the same thing . Jimmi uses actives, I used co-ordinates ... And Jimmi knows what he's doing lol...

 
Image
http://bfollington.tumblr.com

Dr. James MD

Addict

Registered
  08/12/2003
Points
  11941

First GOTW AwardSecond GOTW AwardThird GOTW AwardPicture Me This -Round 26- Winner!
23rd July, 2007 at 06:32:08 -

I use co-ordinates in my games. Actives are just the super cheap quick and dirty way of doing it. Super... fly?

 
Image
http://uk.youtube.com/watch?v=j--8iXVv2_U
On the sixth day God created Manchester
"You gotta get that sand out your vaj!" x13
www.bossbaddie.com

Liquixcat

Administrator
Lazy Coder

Registered
  08/12/2002
Points
  201

VIP MemberLikes TDCKitty
23rd July, 2007 at 09:42:11 -

Solid engine, use mine. Wierd buggy jumping camera, use Jimmi's. Have fun.

 
thinking is like pong, it's easy, but you miss sometimes.

»xerus



Registered
  28/06/2002
Points
  675

You've Been Circy'd!Game of the Week Winner
31st July, 2007 at 14:11:40 -

Wee I'm going to add another post here!

For boss fights I rigged up a little camera setup thats kinda nifty.

Always
.. set x position of Target to (x("boss") + x("player"))/2
.. set y position of Target to (y("boss") + y("player"))/2

x position of Target > x("player") + 95
.. set x position of Target to x("player") + 95

x position of Target < x("player") - 95
.. set x position of Target to x("player") - 95

Now just set your camera smoothing events and whatever to focus on "Target" instead of the player, and its done. What this does is always set the camera position to inbetween the player and the boss. Then, if the player gets too far away from the boss the camera gets pulled along with the player so that the player can't leave the screen. It works pretty well, and its easier to keep an eye on your enemy.

Oh yeah, and you probably want to adjust "95" to fit your window size if you plan on using this. This was done in a 320 x 240 game.

 
n/a

Liquixcat

Administrator
Lazy Coder

Registered
  08/12/2002
Points
  201

VIP MemberLikes TDCKitty
1st August, 2007 at 11:06:14 -

I'm sure 95 can be a ratio of "Screen width:number" as well. That way the code doesn't need to be changed everytime.
Like instead of 95 use: screen width/2.5.

Anyways, very cool!

 
thinking is like pong, it's easy, but you miss sometimes.

nim



Registered
  17/05/2002
Points
  7233
2nd August, 2007 at 04:23:48 -

The method I use is similar to the code posted by Ben smileyface (not the example file - I haven't opened it.) If you're unfamiliar with that formula then do try to get your head around it because it's very useful.

Liquixcat - Why are you encouraging the use of fast loops to move camera objects? (I haven't opened your example file, I'm just referring to the code posted here and your comments to James.) Is there any difference between x("camera") + 5 and loop 5 times(x("camera")+1)? It's not essential to break out the fast loops every time you need to move an active object. I think you had the right intentions; people need to realise how useful fast loops can be, but they have their place.

Edit: Here's what I use. It's one event and doesn't need any extra active objects.

Always -
X( "player" )-((X( "player" )-(X Left Frame+((X Right Frame-X Left Frame)/2)))/1.1)
Y( "player" )-((Y( "player" )-(Y Top Frame+((Y Bottom Frame-Y Top Frame)/2)))/1.1)

Open source .mfa file: http://tinyurl.com/2h8ng4

Image Edited by the Author.

 
//

Ski

TDC is my stress ball

Registered
  13/03/2005
Points
  10130

GOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!KlikCast HelperVIP MemberWii OwnerStrawberryPicture Me This Round 28 Winner!PS3 OwnerI am an April Fool
Candy Cane
2nd August, 2007 at 15:53:46 -

Awesome! \/

 
n/a
   

Post Reply



 



Advertisement

Worth A Click