Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
0 registered members (), 938 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rki, FranzIII, indonesiae, The_Judge, storrealba
18919 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
fantastic camera script #103240
12/21/06 08:58
12/21/06 08:58
Joined: Aug 2004
Posts: 1,305
New York
PrenceOfDarkness Offline OP
Serious User
PrenceOfDarkness  Offline OP
Serious User

Joined: Aug 2004
Posts: 1,305
New York
LOL, it's obviously fantastic because I made it duh. Actually the camera is pretty nice, and it took me a long time to get it working exactly how i wanted it to work. There are some miner problems that mabe someone could help me over come. When we are above directly above the player, (90 degrees from the horizonal) the left and right keys seem to stop working correctly, but i think i know how to fix that problem. When i set the limit to 89 degrees however the camera seems to twitch. Any solutions for the twitching at angle 89?

Incase you can't figure it out, the left and right arrow keys turn clockwise and counter clockwise about the player, the up and down moves the camera up and down while still keeping the distance from the camera to the player equal. The mouse wheel is the zoom in and zoom out (i think this should be changed since you going from keyboard to mouse, someone give me a better idea for where it should be on the keyboard and eventually i'll make it so the mouse moves the camera when u hold the middle button down i think, but only if you guys want it to). Also let me know if you guys want me to write a tutorial exactly on how i figured this out and how i did it; a break down of the components more or less.

One last thing, I added cam_speed to slow down how quickly the camera was moving. Eventually this is something that can be worked in to your options menu to give the player a greater range of freedom to how fast he wants the camera to move.

This is very easy to include, make sure your player pointer is set, and just call prence_camera() somewhere in your main script and your done.

And without further bs.. lol here is the code... (drama)

Code:

function prence_camera //Yes i know name was very origenal
{
var cam_dist = 200; //starting distance between camera and player
var cam_dist_z; //the distance when the z axis is used
var cam_ang; //the angle of the camera on the x and y axis
var cam_ang_z; //the angle between the z.axis and the horizon

var cam_speed = 0.2; // speed we want the camera to move, play with this

wait(-1);
while(1)
{
//camera
wait(1);
vec_set(temp.x, player.x);
vec_sub(temp.x, camera.x);
vec_to_angle(camera.pan, temp); // rotate camera toward player

cam_dist += mickey.z * cam_speed; //zoom with mouse wheel
cam_ang += (key_cur - key_cul) * cam_speed; //curse buttons
cam_ang_z += (key_cuu - key_cud) * cam_speed;

cam_ang_z = max(0,min(cam_ang_z,89)); //dont go above 89degrees
cam_dist = min(1000,max(cam_dist,50));//dont zoom out more then
//1000 and dont zoom in more then 50
cam_dist_z = fcos(cam_ang_z,cam_dist); //trig don't bother
camera.x = player.x + fcos(cam_ang,cam_dist_z);
camera.y = player.y + fsin(cam_ang,cam_dist_z);
camera.z = player.z + fsin(cam_ang_z,cam_dist);
camera.z = max(player.z,camera.z); //don't go underground
}
}



If u can fix the twitching that happens when u look down above i believe it's 80 degrees let me know please. Let the comments begin lol.


"There is no problem that can't be solved with time and determination." -me
prenceofdarkness for instant messages on AIM.

Looking for a model designer
PLEASE, SEND ME A PRIVATE MESSAGE OR EMAIL IF YOU'RE INTERESTED.
Re: fantastic camera script [Re: PrenceOfDarkness] #103241
12/21/06 09:13
12/21/06 09:13
Joined: Aug 2004
Posts: 1,305
New York
PrenceOfDarkness Offline OP
Serious User
PrenceOfDarkness  Offline OP
Serious User

Joined: Aug 2004
Posts: 1,305
New York
lol updated the script already... the mouse now also can be used, just hold down ur middle button or the mouse wheel and move ur mouse around. Page up and page down now also zoom in and out.

Code:

function prence_camera //ya i know, amazing
{
var cam_dist = 200;
var cam_dist_z;
var cam_ang;
var cam_ang_z;

var cam_speed = 0.2;

wait(-1);
while(1)
{
//camera
wait(1);
vec_set(temp.x, my.x);
vec_sub(temp.x, camera.x);
vec_to_angle(camera.pan, temp); // rotate camera to the player

cam_dist += mickey.z + (key_pgup - key_pgdn) * cam_speed;

cam_ang += (key_cur - key_cul) * cam_speed;
cam_ang_z += (key_cuu - key_cud) * cam_speed;

if(mouse_middle == 1)
{
cam_ang += mickey.x * cam_speed;
cam_ang_z += mickey.y * cam_speed;
}

cam_ang_z = max(0,min(cam_ang_z,89)); //dont go above 89degrees
cam_dist = min(1000,max(cam_dist,50));

cam_dist_z = fcos(cam_ang_z,cam_dist); //trig don't bother
camera.x = my.x + fcos(cam_ang,cam_dist_z);
camera.y = my.y + fsin(cam_ang,cam_dist_z);
camera.z = my.z + fsin(cam_ang_z,cam_dist);
camera.z = max(my.z,camera.z); //don't go underground
}
}




still need anti twitching code...

oh ya and about the licence... if u wanna use this camera you must display my logo when ur game starts for no less then 31536001 seconds (1 more then a year), OR you can give me credit some where in your credit thingy, or... you can give me no credit at all (it's okay i wont get mad and file charges) the choice is yours.

Last edited by PrenceOfDarkness; 12/21/06 09:18.

"There is no problem that can't be solved with time and determination." -me
prenceofdarkness for instant messages on AIM.

Looking for a model designer
PLEASE, SEND ME A PRIVATE MESSAGE OR EMAIL IF YOU'RE INTERESTED.
Re: fantastic camera script [Re: PrenceOfDarkness] #103242
12/21/06 12:55
12/21/06 12:55
Joined: Mar 2006
Posts: 2,758
Antwerp,Belgium
frazzle Offline
Expert
frazzle  Offline
Expert

Joined: Mar 2006
Posts: 2,758
Antwerp,Belgium
Thnx for the camera code PrenceOfDarkness, you can't have enough camera codes these last months
But I ask you as I have asked Stansmedia about his sun flare contribution, are you cheerfull enough to build up a not precomplided level with this camera code in it so it easiyer for the user to implant it into any project Btw, thxn for the update !!

Cheers

Frazzle


Antec® Case
Intel® X58 Chipset
Intel® i7 975 Quad Core
8 GB RAM DDR3
SSD OCZ®-VERTEX2 3.5 x4 ; HD 600 GB
NVIDIA® GeForce GTX 295 Memory 1795GB
Re: fantastic camera script [Re: frazzle] #103243
12/21/06 13:01
12/21/06 13:01
Joined: Jun 2006
Posts: 2,640
Earth
Germanunkol Offline
Expert
Germanunkol  Offline
Expert

Joined: Jun 2006
Posts: 2,640
Earth
I agree... thanks for the code!
I was getting a strange result at first, but I think that was due to some of my own code I had in the project... looks cool, and it's a very useful type of camera


~"I never let school interfere with my education"~
-Mark Twain
Re: fantastic camera script [Re: Germanunkol] #103244
12/21/06 14:06
12/21/06 14:06
Joined: Apr 2005
Posts: 2,332
Germany, BaWü
aztec Offline

Expert
aztec  Offline

Expert

Joined: Apr 2005
Posts: 2,332
Germany, BaWü
Nice the first ever sentence I´ve seen wich starts with LOL
by the way: its a great code
you cant have enough of these
Regards
Aztec


Visit:
schwenkschuster-design.de
Re: fantastic camera script [Re: aztec] #103245
12/21/06 16:13
12/21/06 16:13
Joined: Aug 2003
Posts: 842
alabama
Drittz_Dourden Offline
User
Drittz_Dourden  Offline
User

Joined: Aug 2003
Posts: 842
alabama
From what i have read , the camera code sounds like that of which Final Fantasy XI used ...which in return is great for me cause i loved that camera work...and have been looking/trying to create... so hope it works

Daniel

Re: fantastic camera script [Re: Drittz_Dourden] #103246
12/21/06 16:30
12/21/06 16:30
Joined: Apr 2005
Posts: 1,988
Canadian, Eh
DLively Offline
Serious User
DLively  Offline
Serious User

Joined: Apr 2005
Posts: 1,988
Canadian, Eh
Its a bit twitchy when i try and move it... but other than that, i think that it would work great

Thanks for the contribution...

Link


A8 Pro 8.45.4
YouTube: Create Games For Free
Free Resources: www.CGForFree.com
Re: fantastic camera script [Re: DLively] #103247
12/21/06 17:15
12/21/06 17:15
Joined: Feb 2006
Posts: 2,185
mpdeveloper_B Offline
Expert
mpdeveloper_B  Offline
Expert

Joined: Feb 2006
Posts: 2,185
so because you wrote it makes it good?
lol, kidding, but would you make a demo?


- aka Manslayer101
Re: fantastic camera script [Re: mpdeveloper_B] #103248
12/21/06 22:14
12/21/06 22:14
Joined: Aug 2004
Posts: 1,305
New York
PrenceOfDarkness Offline OP
Serious User
PrenceOfDarkness  Offline OP
Serious User

Joined: Aug 2004
Posts: 1,305
New York
i would gladly make a demo, but i don't know any good uploading sites. The code is stand alone. All u need is 2 start a new project... add an entity and assign it to the player pointer through player=my, thats what i'm gonna do lol.. finally the twitching is a big problem, i ask you all to help me out on that, i can't figure it out..


"There is no problem that can't be solved with time and determination." -me
prenceofdarkness for instant messages on AIM.

Looking for a model designer
PLEASE, SEND ME A PRIVATE MESSAGE OR EMAIL IF YOU'RE INTERESTED.
Re: fantastic camera script [Re: PrenceOfDarkness] #103249
12/22/06 07:56
12/22/06 07:56
Joined: Jun 2006
Posts: 2,640
Earth
Germanunkol Offline
Expert
Germanunkol  Offline
Expert

Joined: Jun 2006
Posts: 2,640
Earth
Suggestion: in the next update, you could change the code to use only the "player" pointer instead of the "my" pointer. That way it could be called from any where, like the main function, too...

Last edited by Germanunkol; 12/22/06 07:57.

~"I never let school interfere with my education"~
-Mark Twain
Page 1 of 2 1 2

Moderated by  adoado, checkbutton, mk_1, Perro 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1