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
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.
"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
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
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!
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.
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
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
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.
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.
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.