### Author Topic: lost in space  (Read 4393 times)

• Mr. Drawsprite
• Posts: 62
##### lost in space
« on: 2008-May-13 »
Sorry I am having a maths problem with the x_camera please can you help: I am making a first person space game, I am trying to use the X_camera as the window view and fly around space with planets, meteors and bandits . But I canâ€™t get the camera to move or show in the right way. I am using the list of variables below can you help?

Shipx = ship x position
Shipy = ship y position
Shipz = ship z position

Shipdegxz = axis of xz of ship in space
Shipdegxy = axis of xy of ship in space

motmentum = speed of movement along the axis

The not working code so far:

//setup camera directions
camx= INTEGER(shipx+(motmentum10)+(COS(shipdegxz)))
camz= INTEGER(shipz+(motmentum+10)+(SIN(shipdegxz))+(SIN(shipdegxy)))
camy= INTEGER(shipy+(motmentum+10+(COS(shipdegxy)))
X_CAMERA shipx, shipy, shipz,     camx, camy , camz

Next I need to move the ship along the axis:

shipx=INTEGER(shipx+(motmentum+(COS(shipdegxz))))
shipz=INTEGER(shipz+(motmentum+(SIN(shipdegxz)))+(motmentum+(SIN(shipdegxy))))
shipy=INTEGER(shipy+(motmentum+(COS(shipdegxy))))

Thanks, Max
« Last Edit: 2008-May-13 by Maxheadroom »

#### Kitty Hello

• code monkey
• Prof. Inline
• Posts: 10851
• here on my island the sea says 'hello'
##### Re: lost in space
« Reply #1 on: 2008-May-14 »
Direction in which the ship is pointing:
Code: (glbasic) [Select]
`// Shipdegxz  =Angle in X-Z direction. positive X-Axis=0Â°, positive Z-Axis=90Â°// Shipdegxy = Angle if inclination X-Z surface to Y Axis. 0Â°=XZ-Plane, 90Â°=positive Y axisdx = cos(Shipdegxz)dy = sin(Shipdegxy)dz = sin(Shipdegxz)// make direction the total length "1"ulen = dx*dx+dy*dy+dz*dzdx=dx/ulendy=dy/ulendz=dz/ulen`

Now it's easy:
Code: (glbasic) [Select]
`X_CAMERA shipx,shipy,shipz,  shipx+dx,shipy+dy,shipz+dz// moveinc shipx, dx*momentuminc shipy, dy*momentuminc shipz, dz*momentum`

• Mr. Drawsprite
• Posts: 62
##### Re: lost in space
« Reply #2 on: 2008-May-15 »
That’s fantastic and it sort of works, it looks so simple too when you know how, however just one small problem, the xz axis you can turn a full 360deg and all is working. But not on the xy axis if you try to flip over on a 360deg all my ship will to do is a sin curve and can’t flip over! Any ideas? it was funny the first time i crashed in to the 3 moon of dedeprime! lol
« Last Edit: 2008-May-15 by Maxheadroom »

• Mr. Drawsprite
• Posts: 62
##### Re: lost in space
« Reply #3 on: 2008-May-16 »
screen shot so far!

#### BumbleBee

• Global Moderator
• Prof. Inline
• Posts: 891
##### Re: lost in space
« Reply #4 on: 2008-May-16 »
Yes, i want to become a space commander. It seems my dream come true. It looks good. How about a demo?

Cheers
The day will come...

CPU Intel(R) Core(TM) i5-3570k, 3.4GHz, AMD Radeon 7800 , 8 GB RAM, Windows 10 Home 64Bit

• Mr. Drawsprite
• Posts: 62
##### Re: lost in space
« Reply #5 on: 2008-May-16 »
Will do on the demo but lots of coding first, things left to do collision, shooting and network ect ;  hopefully  it looks so good due to the amount of high quality sprites/BMPâ€™s used.

I have had a good look around the web but I canâ€™t find a good looking space station ,has anyone got a royalty free 2001 space station (.DDD file) or a really good looking asteroid you could pass my way? (got space ships and other stuff)
Thanks, Max