Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / camera movements

Author
Message
dononeton
20
Years of Service
User Offline
Joined: 12th Jun 2004
Location: Tusaloosa, AL : USA
Posted: 1st Feb 2007 03:16


I want to move the camera when the mouse hits the edge of the screen. The second if works but in the direction of the camera is facing
dononeton
20
Years of Service
User Offline
Joined: 12th Jun 2004
Location: Tusaloosa, AL : USA
Posted: 1st Feb 2007 03:29 Edited at: 1st Feb 2007 03:38
Well I got it. Forgot to put the variable in the function
dononeton
20
Years of Service
User Offline
Joined: 12th Jun 2004
Location: Tusaloosa, AL : USA
Posted: 1st Feb 2007 03:56
New question. This code only works when the mouse cursor hits the top and the right sides of the screen. Any ideas?
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 1st Feb 2007 04:31
What's with all the # symbols????

Do you know what they actually do?

TDK_Man

dononeton
20
Years of Service
User Offline
Joined: 12th Jun 2004
Location: Tusaloosa, AL : USA
Posted: 1st Feb 2007 05:34 Edited at: 1st Feb 2007 05:41
It makes the variable a float right? I guess I dont need them. I am moving in whole numbers anyway.SO the variable needs to hold int value. This my RTS Camera so far
Pillarofire
20
Years of Service
User Offline
Joined: 31st Dec 2003
Location: Good Question, <looks around.>
Posted: 1st Feb 2007 07:03
Might I point out that if you change screen resolutions your code will break. I would still use SH & SW



But thats just me because I would be too lazy to try and find those lines again when/if I changed screen resolutions.
dononeton
20
Years of Service
User Offline
Joined: 12th Jun 2004
Location: Tusaloosa, AL : USA
Posted: 1st Feb 2007 14:53
I know if I change my screen resolution my code will break. I couldn't get the movement when I put the cursor at the left side and the bottom. For some reason screen height() and screen width() are returning 0
Pillarofire
20
Years of Service
User Offline
Joined: 31st Dec 2003
Location: Good Question, <looks around.>
Posted: 1st Feb 2007 19:24
Sorry I wasn't trying to be a jerk.

About screen height() and screen width() returning 0;
It is possible that SH and SW are zero because they are in a function and were not declared global. Are your sure that they are global?
Kieran
18
Years of Service
User Offline
Joined: 6th Aug 2006
Location: Hamilton, New Zealand
Posted: 1st Feb 2007 19:28 Edited at: 1st Feb 2007 19:28
no screen height() and screen width() return the right and bottom of the screen, you need two other variables saying the left and right which are



screen height() returns the height of the screen, say your screen is 1024x768 screen height() returns 768 and screen width() returns 1024, when you add to the x variable it heads right when you add to the y variable it heads down

EDIT: if i need to explain further let me know

~Kieran
dononeton
20
Years of Service
User Offline
Joined: 12th Jun 2004
Location: Tusaloosa, AL : USA
Posted: 2nd Feb 2007 01:32 Edited at: 2nd Feb 2007 05:28
Thanks guys I wasn't thinking right

I re-wrote the function and it works just fine
here it is
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 2nd Feb 2007 06:22
Quote: "It makes the variable a float right?"


Yes, that's right. (A lot of users actually think that putting the hash symbol on the end of a variable name simply makes it a number).

Sorry - I didn't make myself clear though. You don't need to make all your variables integers - just the ones that you know will never need to store floats.

Anything to do with 2D screen positions should be integer, but anything to do with 3D object positions should be floats.

This is because it's possible for your 3D world to be scaled so small that moving an object one 3D world unit makes it jump a large distance and appear not to move smoothly.

It's therefore perfectly normal to move an object say 0.01 world units. As this is a float number, then the variables used should also be of type float.

Even when using float variables, you can still use them to store whole numbers, but going by the book you should use 1.0 instead of 1 or 2.0 instead of 2. (It still works if you don't though).

TDK_Man

Login to post a reply

Server time is: 2024-11-26 00:25:21
Your offset time is: 2024-11-26 00:25:21