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.

DarkBASIC Discussion / Need Help setting Camera

Author
Message
Dr Eggman
3
Years of Service
User Offline
Joined: 27th Dec 2014
Location: In The Space Coloney Ark
Posted: 25th Mar 2015 10:01
Hello

I am having trouble getting the camera to work right,
How can I make it so The Camera follows the
Object Forward and Back Only, Not Left, Right, Up or Down?

I have tried a couple of ways and cant get it to work,
Here is my Code



Its basically Just the Free Flight Example in Dark Basic,

Any Help would be Much Appreciated,
Thank you.

Ill Be Back, With a New Robot!
That has Super Laser Eyes,
And He'll Feed me Ham! Evil Ham..
LBFN
11
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 26th Mar 2015 02:17
To simply move the object back and forth, your main loop would look something like this:



So many games to code.....so little time.
Dr Eggman
3
Years of Service
User Offline
Joined: 27th Dec 2014
Location: In The Space Coloney Ark
Posted: 26th Mar 2015 04:13
Thank you For your Help,
But I think I explained it Wrong..

I wanted to get it so you can move the
Ship Left, Right, Up and Down, And the Camera Stays
In the Same Spot And only follows the Ship Forward
And doesn't Move Any Other Direction.

Thank you.

Ill Be Back, With a New Robot!
That has Super Laser Eyes,
And He'll Feed me Ham! Evil Ham..
Dr Eggman
3
Years of Service
User Offline
Joined: 27th Dec 2014
Location: In The Space Coloney Ark
Posted: 26th Mar 2015 04:41
Hey, Another Question,
Why Does the Loop Command Sometimes
Get this Error Message When I Add
Certain Stuff To My Program?

"Syntax Error. Nesting Error"

What does it Mean and How do
I Fix it?

Thank you.

Ill Be Back, With a New Robot!
That has Super Laser Eyes,
And He'll Feed me Ham! Evil Ham..
LBFN
11
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 27th Mar 2015 00:45
Quote: "I wanted to get it so you can move the
Ship Left, Right, Up and Down, And the Camera Stays
In the Same Spot And only follows the Ship Forward
And doesn't Move Any Other Direction.
"


Okay, here is some code that should help you do that. It's not very elegant, but should give you something to build upon.




Quote: "Why Does the Loop Command Sometimes
Get this Error Message When I Add
Certain Stuff To My Program?

"Syntax Error. Nesting Error"

What does it Mean and How do
I Fix it?"


A nesting error occurs when certain calls are made that do not have the latter code in place. For example, if you place the command DO, without having the LOOP command in your code it will error. This holds true for IF amd ENDIF, REPEAT and UNTIL, WHILE and ENDWHILE, etc. You simply cannot have one without the other. The fix is simple; put the completing command into your code.

It is proper to indent your code so that the above commands are in the same place horizontally on the screen and that any code contained within them is indented. This is cleaner and more readable, and will help you in troubleshooting (problems like this, actually). If you look at the code in the snippet above, you can see where I indented the code within the if / endif and they are in the same place horizontally.

So many games to code.....so little time.
Dr Eggman
3
Years of Service
User Offline
Joined: 27th Dec 2014
Location: In The Space Coloney Ark
Posted: 27th Mar 2015 04:41 Edited at: 27th Mar 2015 04:44
Thank you very much,

This is the Code Now..



The Ships movement is Great, but..
Its moving quite slow..
I took a look and couldn't find a way to speed it up.

The Camera is Good too but
Ive noticed the camera does move
Left Right Up And Down..
Is there any way to change the camera part
of the code to make it so
camera only moves In the direction the ships facing?

I Don't mind if the ship can
Move Off the screen, I Can Fix That Later on.

Thank you Very Much.

Ill Be Back, With a New Robot!
That has Super Laser Eyes,
And He'll Feed me Ham! Evil Ham..
LBFN
11
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 28th Mar 2015 01:51
Quote: "The Ships movement is Great, but..
Its moving quite slow..
I took a look and couldn't find a way to speed it up."

You can see that the #2 object is moved by 5 units, whether up, down, left or right. All you need to do is increase that amount to make it faster. So, if you change the 5 to say, 25, it will move faster. Bear in mind, that at some point, you are going to need to do some collision-checking and moving 25 units at a time is a lot in my view.

Quote: "The Camera is Good too but
Ive noticed the camera does move
Left Right Up And Down..
Is there any way to change the camera part
of the code to make it so
camera only moves In the direction the ships facing?"


Not sure what you mean here. I revised your code to do what I think you are asking here.



Note: You GOSUB to the Flight subroutine, but this is unneeded, so I REMed it out. To me, it would be better to write a subroutine that you could call from your main DO - LOOP called MovePlayer, or something like that. It would make more sense. Also, you didn't have a SYNC rate set, so I set it at 60. Otherwise, it will run as fast as the host computer can run, which would not necessarily be a good thing.

So many games to code.....so little time.
Dr Eggman
3
Years of Service
User Offline
Joined: 27th Dec 2014
Location: In The Space Coloney Ark
Posted: 28th Mar 2015 03:56 Edited at: 28th Mar 2015 06:44
Yes! This Is Exactly What I Wanted,
I Think I can do the Rest from Here,

Thank you Very Much for your Help,
I Really Appreciate It!


Wait.. One Last Thing

Does a 3D Model have to be in the
same folder as the Dark Basic Program
to be able to load it? Because I cant
seem to be able to put it into my game,

It is X File and is in the Same Folder
as the program But still won't load

is there more to loading a 3d Model then this?



Because that's what i use and it doesn't work.

Thanks Again.

Ill Be Back, With a New Robot!
That has Super Laser Eyes,
And He'll Feed me Ham! Evil Ham..
LBFN
11
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 30th Mar 2015 05:15
Quote: "Does a 3D Model have to be in the
same folder as the Dark Basic Program
to be able to load it?"


It is no different than an image. The same info I gave you about an image would apply to a 3D model. Unless you specify a path to the model's location, DBC will assume it is in the same folder as the .dba file.

Does it give you an error message? Usually these errors are caused from DBC not 'finding' the 3D model.

Quote: "is there more to loading a 3d Model then this?

load Object "(Object.X)",1
Position Object 1,(X),(Y),(Z)

"


Is "(Object.X)" the actual name of the file? I expect not. You don't need to add brackets. I assume the filename is actually Object.x. If so, assuming it is in the same folder as the .dba program, you would simply code it as



Also, your positioning code does not look right. Again, brackets have been added where they are not typically needed. You have positioned objects in your code already, so I assume this is just a typo.

So many games to code.....so little time.
Dr Eggman
3
Years of Service
User Offline
Joined: 27th Dec 2014
Location: In The Space Coloney Ark
Posted: 30th Mar 2015 06:03
Object.x is not the name of the file,
i just did (Object) instead of the real name.
And (X),(Y),(Z) Is just where I put the X,Y And Z Position.


Actually it doesn't display an error message,
It just doesn't seem to put the Model in my Program,
I can run my Program Fine without any Error messages,
Though My Models just not there,

Im not sure what the Problem Is,
I'll try the Full Directory when loading
the Model and see if it Works..

Thank you.

Ill Be Back, With a New Robot!
That has Super Laser Eyes,
And He'll Feed me Ham! Evil Ham..
LBFN
11
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 30th Mar 2015 06:29
Quote: "Actually it doesn't display an error message,
It just doesn't seem to put the Model in my Program,
I can run my Program Fine without any Error messages,
Though My Models just not there,"


A few things come to mind. First, maybe the positioning of the model is far different than what the camera is or maybe it is below any 'land' surface you have setup. Try positioning the camera at the model's position, set the camera to the object's orientation and then move the camera back, say 200 units, and then point the camera at the model.

Secondly, maybe the object is really, really small and you can't see it. You could try scaling it up to see if it appears.

You could try setting the object to wireframe mode; see the SET OBJECT command. You should be able to see at least where it is positioned.

You could also try coloring the object instead of texturing it.

Hopefully one of these will help. If not, if you want to email me the object, I will look at it to see if I can figure it out.

So many games to code.....so little time.
Dr Eggman
3
Years of Service
User Offline
Joined: 27th Dec 2014
Location: In The Space Coloney Ark
Posted: 30th Mar 2015 08:20
I'll Try these and see if they work,
Thanks

Ill Be Back, With a New Robot!
That has Super Laser Eyes,
And He'll Feed me Ham! Evil Ham..

Login to post a reply

Server time is: 2018-09-23 13:34:02
Your offset time is: 2018-09-23 13:34:02