Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 
 
 

75 строки
1.2 KiB

  1. #include <stdlib.h>
  2. #include "common.h"
  3. /* Init tunnel */
  4. player * create_player( game *g )
  5. {
  6. player *p = malloc(sizeof(player));
  7. p->x = g->w / 2;
  8. p->y = g->h - 3;
  9. p->dir = 0;
  10. p->weapon = 0;
  11. p->nuke = 0;
  12. return p;
  13. }
  14. void free_player( player *p )
  15. {
  16. free( p );
  17. }
  18. void draw_player( game *g, player *p )
  19. {
  20. GFX_GOTO( p->x + 2, p->y - 2 );
  21. GFX_COLOR( GREEN );
  22. GFX_WRITE( '/' );
  23. GFX_WRITE( '\\' );
  24. GFX_GOTO( p->x + 1, p->y - 1 );
  25. GFX_WRITE( '(' );
  26. GFX_COLOR( YELLOW );
  27. GFX_WRITE( '(' );
  28. GFX_WRITE( ')' );
  29. GFX_COLOR( GREEN );
  30. GFX_WRITE( ')' );
  31. GFX_GOTO( p->x, p->y );
  32. GFX_COLOR( GREEN );
  33. GFX_WRITE( 'I' );
  34. GFX_WRITE( '<' );
  35. GFX_WRITE( '_' );
  36. GFX_WRITE( '_' );
  37. GFX_WRITE( '>' );
  38. GFX_WRITE( 'I' );
  39. }
  40. void update_player( game *g, player *p )
  41. {
  42. if( p->weapon )
  43. {
  44. p->weapon--;
  45. }
  46. if( p->nuke )
  47. {
  48. p->nuke--;
  49. }
  50. if( p->dir < 0 )
  51. {
  52. if( p->dir == -3 && p->x > -2 ) p->x -= 1;
  53. else if( p->x > -1 ) p->x -= 1;
  54. p->dir++;
  55. }
  56. else if( p->dir > 0 )
  57. {
  58. if( p->dir == 3 && p->x < g->w - 8 ) p->x += 1;
  59. else if( p->x < g->w - 7 ) p->x += 1;
  60. p->dir--;
  61. }
  62. }