Help - Search - Members - Calendar
Full Version: I Have A Question About Camera Focus....
Game Maker Community > Working with Game Maker > Advanced Users Only
foody
Hello,

I have a question I need to ask, the game I making demands that I control eleven characters, each character I control have to have the camera focused on the character. The screen is composed of four borders, one to the left, one to the right, one above and one down. When the character moves to the edge of either the four screens, the screen should scroll in the reverse direction that the character is heading. Let us say for example the character is moving to the edge of the right screen, then the level should scroll into the left and so on. This works correctly when the game focuses or the camera during the initial of the level focuses on the main character and it is centered into the screen. The problem happens when the user pushes the button to tell the game to control the next player and the camera focuses on the next player. When the camera focuses on the next player it is no longer centered in the screen regardless of te location of player, so what happens that the screen up scrolling when the character is not neve close to the edge of screen. By click here you get to see a video example of what I am talking about, it is a live feed of my game in action and the problem that it is arising with. Now originally the code I use to set the focus of the camera is like this:

camera.position = animatedPlayer[x].position;

That sets the X, Y coordinate of the camera to be the same as the player's X and Y corrdinate. The size of the actual map is 510 by 510, however the size of the actual window or viewPort or Windows resolution is 800 by 600. When the player (even though the map size is 510 by 510) reaches to the edge of the screen resolution which is 800 by 600 the screen scrolls. That is why I use an if statement to determine wether the player have reached the edge of the screen, if the player reaches the edge of the screen which is by 800 to 600 the screen or level scrolls accordingly. However, that remains on the position 0,0 where the height and width is 800 by 600. If the camera loses focus on the default player or the actual camera have set it's focus on the new player it is no longer centered, so what happens is that sometimes the player have to move outside the edge of screen and MORE AND MORE and more before the screen starts scrolling, because the camera is no longer following the player. Any suggestions on this matter.
ragarnak
QUOTE (foody @ Oct 31 2009, 03:09 AM) *
Now originally the code I use to set the focus of the camera is like this:

camera.position = animatedPlayer[x].position;

That sets the X, Y coordinate of the camera to be the same as the player's X and Y corrdinate.
Too vague : nothing is told about how the "animatedPlayer[]" array is filled.
nick360
On you vidio it said you were making it for xbox360. which means that you are NOT using Game Maker, which means that this is NOT the right place to be asking this question. These forums are for question relating to the use of Game Maker.

What program are you using?
Revel
Yep. That video is from the XNA Game Studio. You can tell by the icon in the top left corner of the window (the Xbox 360 controller A.K.A. the default icon in XNA Studio). Also, the background color for the game is the same as the default background color for an XNA Studio game.

This forum is for Game Maker problems only.
ragarnak
People, please give the guy a chance. It could well be that he tries to re-create that game in GM ... whistle.gif
moikle
QUOTE (ragarnak @ Oct 31 2009, 11:17 AM) *
People, please give the guy a chance. It could well be that he tries to re-create that game in GM ... whistle.gif


in that case then just set a view, either in the room properties or in an object using view_ ... commands
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.