centering the screen between two objects
Author: | ds-guru
|
Submitted: | 30th May, 2005
|
Views: | 5138
| Rated: |
|
|
hello, this is my first article, i hope you like it.
centering the screen between two or more objects.
this camera technique can be used for games with more than 1 player on 1 scrolling screen. (example: zelda four swords adventures)
it can also be handy for a topdown shooter when the camera is centered between the mouse and the player.
this may seem a complicated task but it is very easy when you know how to.
let's start with the simpelest one. a topdown shooter camera.
create these objects: -active object "player"
-active object "pointer"
-active object "camera"
you can add your own movement to "player" it is not of importance.
first create this event
always: -set "pointer" postition to XMouse, YMouse (you know how)
always: -make "camera" invisible, center screen at 0,0 from "camera",
set X of "camera" to ( X( "player" ) + X( "pointer" ) ) / 2
set Y of "camera" to ( Y( "player" ) + Y( "pointer" ) ) / 2
that's it, the complete camera system.
this can be modified to support more active objects.
it would be something like this:
always: set X of "camera" to
(( X( "player") + X( "player2" ) + X( "player3" ))/3
(( Y( "player") + Y( "player2" ) + Y( "player3" ))/3
same with 4 players or more.
hope you learned something outa this.
comments please.
|
|
ds-guru
Registered 26/12/2003
Points 111
|