Advertisement
Guest User

Untitled

a guest
Dec 6th, 2017
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.25 KB | None | 0 0
  1. typedef struct Relativity {
  2. char xzOffset;
  3. char yOffset;
  4. int distance;
  5. } Relativity_t;
  6.  
  7. void lcars_RenderViewScreen(void){
  8. char i;
  9. int vWidth = 228, vHeight = 173;
  10. for( i = 0; i <= (sizeof(MapData)/sizeof(MapObject_t)); i++){
  11. MapObject_t *object = &MapData[i];
  12. if( object->type == OBJ_SHIP || object->type == OBJ_PROJ ){
  13. Relativity_t data;
  14. GetOffsets(&data, object->Position.coords[0] - PlayerData->Position.coords[0], object->Position.coords[1] - PlayerData->Position.coords[1], object->Position.coords[2] - PlayerData->Position.coords[2]);
  15. if( data.distance <= VISUAL_RANGE ){
  16. unsigned char diffXZ, diffY;
  17.  
  18. diffXZ = data.xzOffset - PlayerData->Position.angles[0];
  19. if( diffXZ > 128 ) diffXZ = 256 - diffXZ;
  20. diffY = data.yOffset - PlayerData->Position.angles[1];
  21. if( diffY > 128 ) diffY = 256 - diffY;
  22.  
  23. if( (diffXZ <= 45) && (diffY <= 45) ){
  24. char tempXZ, tempY;
  25. int xcoord = data.xzOffset - PlayerData->Position.angles[0] + 45;
  26. char ycoord = data.yOffset - PlayerData->Position.angles[1] + 45;
  27. int scale = 10 * data.distance / VISUAL_RANGE;
  28. scale = 11 - scale;
  29. scale += (scale == 0);
  30. xcoord = (xcoord * vWidth) / 91;
  31. ycoord = (ycoord * vHeight) / 91;
  32. if(object->type == OBJ_SHIP)
  33. gfx_ScaledTransparentSprite_NoClip(sprite_BorgSphere, xcoord, ycoord, scale, scale);
  34. if(object->type == OBJ_PROJ)
  35. gfx_ScaledTransparentSprite_NoClip(sprite_Phaser, xcoord, ycoord, scale, scale);
  36. }
  37. }
  38. }
  39. }
  40. }
  41.  
  42. void GetOffsets( Relativity_t *data, int delta_x, int delta_y, int delta_z){
  43. int xzangle = atan( delta_y / delta_z );
  44. int yangle = atan( delta_x / delta_z );
  45. double partDist = (delta_x * delta_x) + (delta_y * delta_y) + (delta_z * delta_z);
  46. data->xzOffset = 255 * xzangle / 360;
  47. data->yOffset = 255 * yangle / 360;
  48. data->distance = sqrt(partDist);
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement