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 / need help with functions please

Author
Message
ultimate skimmer
20
Years of Service
User Offline
Joined: 24th Apr 2004
Location: u.s.a
Posted: 10th Jun 2004 04:24 Edited at: 10th Jun 2004 04:31
hello everybody i am realy new to darkbasic so here goes. i am trying to get a sphere to move around on the screen with other object around to interact with. but i cant get the chase camera to work. i used mostly code from the tutorials but when ever i try to run the program it says "run time error at line 26. program ran into a function declaration at line 26." and it wont work. i know the solution is probably simple but i have been trying realy hard to fix it but i cant. thank you for any help.
p.s. i am using dark basic classic

ultimate skimmer
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 10th Jun 2004 05:08
move your function code to the bottom of the page, after the do-loop block


* DBP_NETLIB_v1.2 - NOW WITH VARIABLE WATCHER! * Click Logo
ultimate skimmer
20
Years of Service
User Offline
Joined: 24th Apr 2004
Location: u.s.a
Posted: 10th Jun 2004 05:28
haha oh my god thank you very much i cant believe it was thet simple lol

ultimate skimmer
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 10th Jun 2004 05:47
don't worry - it will get more difficult as you go

good luck


* DBP_NETLIB_v1.2 - NOW WITH VARIABLE WATCHER! * Click Logo
ultimate skimmer
20
Years of Service
User Offline
Joined: 24th Apr 2004
Location: u.s.a
Posted: 12th Jun 2004 03:47
hi again now i have another problem. i am trying to code my own camera but i am having problems.once i fix all of the problems the editor says i have when i try to run the program it will just open and close. i have tried alot of different things and nothing will fix it. thanks in advance

ultimate skimmer
ultimate skimmer
20
Years of Service
User Offline
Joined: 24th Apr 2004
Location: u.s.a
Posted: 12th Jun 2004 04:10
oh yeah i just got a site with free webs so if anybody could tell me how to upload files onto it tha would help because it is realy stupid right now
http://www.freewebs.com/ultraklhipster/

ultimate skimmer
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 12th Jun 2004 10:21
Okay,

The first thing you have to remember is that variables in functions are LOCAL unless they have been defined as GLOBAL. (Or defined as arrays in DBC.)

What I mean is, you have a;

position camera y_1 + 20,z_1 + 20,x_1

command in the function but the values of y_1, z_1, and x_1 are all ZERO when you enter the function, because have not declared them as;

GLOBAL X_1, Y_1, Z_1

in the upper part of the program. Thus your camera will never move beyond the values of 20, 20, 0.

If you're using DBC use the line of;

DIM X(1), Y(1), Z(1)

and in the function use;

position camera y(1) + 20,z(1) + 20,x(1)

this will solve your problem...
S.

Any truly great code should be indisguishable from magic.
ultimate skimmer
20
Years of Service
User Offline
Joined: 24th Apr 2004
Location: u.s.a
Posted: 12th Jun 2004 18:35 Edited at: 12th Jun 2004 18:51
it still just exits after the screen turns black and it doesnt tell me that there are any errors
by the way i am using bark basic classic

here is the updated code


ultimate skimmer
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 13th Jun 2004 00:13
You have an error in this line



You also haven't updated the following line to use the array values



*** Coming soon - Network Plug-in - Check my site for info ***
For free Plug-ins, source and the Interface library for Visual C++ 6, .NET and now for Dev-C++ http://www.matrix1.demon.co.uk
ultimate skimmer
20
Years of Service
User Offline
Joined: 24th Apr 2004
Location: u.s.a
Posted: 13th Jun 2004 00:53
thank you ianm but it still wont work it just turns the screen black and then just returns to the editor and it says that there is no errors and i am also positive that the file names are correct if that matters. i also changed my code and took out some stuff like the broom control and collisions but it still doesnt work so i have no idea what it could be.



ultimate skimmer
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 13th Jun 2004 01:37
Okay,

The first error I got with this code was that the "matrix didn't exist" in line 18 -- or at that point where you attempt to get the ground height. Move your "make matrix" up above the get height one, or move the get height to below the make matrix.

Second; I had to turn off (or rem out) the fog stuff. I did this mostly to make certain I see the entire horizon, thus not limiting any view of the world you've created.

Third; I don't know why you call the function "move camera" because it doesn't really move the camera, but does move the object the camera is supposedly looking at. Since you never change the values of x(1), y(1) or z(1) the camera remains fixed while object 7 moves.

And fourth, I had to load my own object files in order to run this, for which I loaded some static forms from the library of DBC. This is what made me wait until I had the time to look up the files before attempting to run the code.

Fifth; Given the positioning supplied by the code it took a "long time" for object 7 to move close enough to the camera for me to actually see it, where it showed up on the screen as working.

And finally, if the screen goes black for you and remains as such, I propose that you do not have direct-x installed, or it is not installed correctly. I had this problem when I first ran the free download, such that I had to re-install direct-x for I could see anything.

Hope this helps...
S.

Any truly great code should be indisguishable from magic.
ultimate skimmer
20
Years of Service
User Offline
Joined: 24th Apr 2004
Location: u.s.a
Posted: 13th Jun 2004 01:58 Edited at: 13th Jun 2004 02:00
the make matrix thing made it so i could finaly see the matrix and the program didnt close out.now i just have to work out how to fix the other problems. thank you SandraD
p.s. i call the function move camera because i am trying to make the camera follow object 7 like a chase cam

ultimate skimmer
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 13th Jun 2004 03:03 Edited at: 13th Jun 2004 03:06
Ah...

In that case I propose you use the following code, to set the camera where you want it;

x(1)=object position x(7)
y(1)=object position y(7)
z(1)=object position z(7)
position camera x(1)+20, z(1)+20, y(1)
point camera x(1), y(1), z(1)

this will follow the moving object I believe....
S.

(I'll have to try it myself.)

Any truly great code should be indisguishable from magic.
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 13th Jun 2004 03:32
Okay,

After playing with the different perspectives and all I've come up with the following code;



though the distance of +20 is "a little close" on object 7 this does follow the thing, so there ya go...

good luck!
S.

Any truly great code should be indisguishable from magic.
ultimate skimmer
20
Years of Service
User Offline
Joined: 24th Apr 2004
Location: u.s.a
Posted: 13th Jun 2004 04:28
wow thank you so much that helped alot ive been trying to get the camera to follow something for about a week now and it finaly works.

ultimate skimmer
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 13th Jun 2004 07:10 Edited at: 13th Jun 2004 07:10
Glad to be of help...

Any truly great code should be indisguishable from magic.
Soy Cocktail
20
Years of Service
User Offline
Joined: 23rd Dec 2003
Location:
Posted: 13th Jun 2004 13:25 Edited at: 13th Jun 2004 13:26
may be a little late to post a camera movement function, but i recently made my own it takes perimiters so you can set which camer follows which object

when the mouse is at the edges of the screen in 1024x768x32 display mode it moves the camera around the object

global ang#=1.0
global height#=500.0
needs to be above your main loop for dbpro and variable arrays for dbc
ultimate skimmer
20
Years of Service
User Offline
Joined: 24th Apr 2004
Location: u.s.a
Posted: 14th Jun 2004 02:03 Edited at: 14th Jun 2004 02:08
thank you johny tightlips it is not to late to post a camera function at least not for me ,now i know even more abou cameras. but i cant get the camera to rotate when it hits the right edge of the screen or when it hits the bottom but oh well i guess that is just something for me to work on

ultimate skimmer
Soy Cocktail
20
Years of Service
User Offline
Joined: 23rd Dec 2003
Location:
Posted: 14th Jun 2004 15:08
well in Dark Basic Professional add global ang#=1.0 at the top of your code before your loops

in Darb Basic Classic use variable arrays suc as Dim ang#(1) : ang#(1)=1.0 and change anything in the function called ang# to ang#(1)

the code was written in Dark Basic Professional

Login to post a reply

Server time is: 2024-09-22 13:36:58
Your offset time is: 2024-09-22 13:36:58