screen edge

Posted By: DuaneDawson

screen edge - 02/07/14 20:36

Hi, I am looking for information, about how to keep the player with in the screen edge,

at the moment it moves but disappears off screen.

looking through the manual, but cant find anything about it.
Posted By: sivan

Re: screen edge - 02/08/14 08:51

move the camera together with player similarly as in workshop 24
Posted By: DuaneDawson

Re: screen edge - 02/11/14 13:49

Hi I am trying to create, a top down space shooter, where you control a ship
and the back ground scrolls below you, so the camera would not be fixed, the ship would have free movement with in the screen area, to be fare I could do with as much help advise on how to do this project.

in my understanding of how im going to this is, I have a ship model, that at the moment as the camera set to look down on it, ive some basic control to move the ship, up down left and right.

I was thinking to stop the ship going off screen was to have for blocks that form a square around the ship, that would stay static and be invisible.
then build the level and enemy that scroll towards the player.

but then im thinking this could be a problem as the level and enemy coming towards the player would not beable to pass the block keeping the player within the screen.

what is the best thing to do, is there any kind of tutorial for this kind of project?


cheeers
Posted By: Superku

Re: screen edge - 02/11/14 15:17

Assuming your player ship is on z = 0, try to calculate the position (or find it by trial and error) that is in the center of the screen with z = 0 (obviously this is camera.xy when camera.tilt = -90). Then simply limit the player movement, for example using clamp, to said position +- some quants in all 4 directions.
Posted By: DuaneDawson

Re: screen edge - 02/11/14 15:50

ok i know the position of its xyz where its at 0, but what information should i be looking at from the manual to do what you said about limiting the movement?



cheers
Posted By: Superku

Re: screen edge - 02/11/14 17:26

The easiest way, as already stated, would probably be "clamp".
Example:

player.x += ...
player.x = clamp(player.x,center_pos.x-200,center_pos.x+200);
player.y = clamp(player.y,center_pos.y-300,center_pos.y+300);
Posted By: DuaneDawson

Re: screen edge - 02/11/14 19:14

ok thank ill have a play around.
Posted By: DuaneDawson

Re: screen edge - 02/12/14 18:46

thanks for that everything works great laugh
© 2024 lite-C Forums