Camera help needed.

Talk about making games.

Camera help needed.

Postby NevenResnik » Sat Jul 03, 2010 2:59 pm

Hey. I have a background (lawn in this case) that is larger than the camera, so that the player moves around it with arrowkeys. Now I need help with the scripts which will forbid the view actor to move out of the field, and therefor expose the blank background. Any help would be appreciated.
NevenResnik
 
Posts: 42
Joined: Mon May 31, 2010 9:59 am
Score: 0 Give a positive score

Re: Camera help needed.

Postby Hblade » Sat Jul 03, 2010 3:03 pm

Find out the image width and height
Then find out the image X and y

When moving the view, only have hit move when its greater than or equal to the images x and y, then when it reaches the images width or height, width-view_width and height-view_height, it simply doesnt move :D Use a variable or something to determan that.

I could get into full detail if you'd like :o
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Camera help needed.

Postby NevenResnik » Sat Jul 03, 2010 4:17 pm

Well, I did try, but obviously did something wrong, since it isn't working. Could you please get 'in more detail'?

Thanks! :P
NevenResnik
 
Posts: 42
Joined: Mon May 31, 2010 9:59 am
Score: 0 Give a positive score

Re: Camera help needed.

Postby Hblade » Sat Jul 03, 2010 4:42 pm

k, but I'll make a video showing how :D
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Camera help needed.

Postby Bee-Ant » Sat Jul 03, 2010 4:55 pm

All you need to do is to define the left most, top most, right most and the bottom most coordinates of the Background into variables.

view->DrawActor->ScriptEditor:
Code: Select all
int Left=<your left most x coordinate value here>;
int Top=<your up most y coordinate value here>;
int Right=<your right most x coordinate value here>;
int Bottom=<your bottom most y coordinate value here>;
x=max(Left,min(x,Right-width)); //limit the x movement
y=max(Top,min(y,Bottom-height)); //limit the y movement
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score


Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest