Author Topic: lost in space  (Read 4393 times)

Offline Maxheadroom

  • Mr. Drawsprite
  • **
  • Posts: 62
    • View Profile
    • http://www.hot-apartments.co.uk
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 »

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10851
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
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 axis

dx = cos(Shipdegxz)
dy = sin(Shipdegxy)
dz = sin(Shipdegxz)

// make direction the total length "1"
ulen = dx*dx+dy*dy+dz*dz
dx=dx/ulen
dy=dy/ulen
dz=dz/ulen


Now it's easy:
Code: (glbasic) [Select]
X_CAMERA shipx,shipy,shipz,  shipx+dx,shipy+dy,shipz+dz

// move
inc shipx, dx*momentum
inc shipy, dy*momentum
inc shipz, dz*momentum

Offline Maxheadroom

  • Mr. Drawsprite
  • **
  • Posts: 62
    • View Profile
    • http://www.hot-apartments.co.uk
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 »

Offline Maxheadroom

  • Mr. Drawsprite
  • **
  • Posts: 62
    • View Profile
    • http://www.hot-apartments.co.uk
Re: lost in space
« Reply #3 on: 2008-May-16 »
screen shot so far!


Offline BumbleBee

  • Global Moderator
  • Prof. Inline
  • *******
  • Posts: 891
    • View Profile
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?  =D

Cheers
The day will come...

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

Offline Maxheadroom

  • Mr. Drawsprite
  • **
  • Posts: 62
    • View Profile
    • http://www.hot-apartments.co.uk
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
 :good:

Offline Maxheadroom

  • Mr. Drawsprite
  • **
  • Posts: 62
    • View Profile
    • http://www.hot-apartments.co.uk
Re: lost in space
« Reply #6 on: 2008-May-16 »
That’s a really great idea, it’s not working for me either, I can't change the dials and I wanted radar for the incoming stuff. I will just have to knock one up, (I will put it on the to-do list). 

max...