How to use different colours?

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Oct 2004
Posts: 8
Reputation: Simplicity is an unknown quantity at this point 
Solved Threads: 0
Simplicity Simplicity is offline Offline
Newbie Poster

How to use different colours?

 
0
  #1
Oct 24th, 2004
Hey guys,
For the snake game, I need to use different colours for the snake and food. At least two different colours must be used (other than white and black). How can I change the colours? I tried many ways but none did it properly !

This is the full code where I think it should go somewhere in here:
  1. static int map_board_x_to_screen_x(int board_x) {
  2. return BOARD_X_OFFSET + board_x;
  3. }
  4.  
  5. static int map_board_y_to_screen_y(int board_y) {
  6. return BOARD_Y_OFFSET + board_y;
  7. }
  8.  
  9. void init_screen() {
  10. /*
  11. ** Initialise the screen, by setting it to normal display mode
  12. ** and clear the screen.
  13. */
  14. normal_display_mode();
  15. clear_terminal();
  16.  
  17. draw_horizontal_line(map_board_y_to_screen_y(-1),
  18. map_board_x_to_screen_x(-1),
  19. map_board_x_to_screen_x(BOARD_WIDTH));
  20. draw_horizontal_line(map_board_y_to_screen_y(BOARD_ROWS),
  21. map_board_x_to_screen_x(-1),
  22. map_board_x_to_screen_x(BOARD_WIDTH));
  23. draw_vertical_line(map_board_x_to_screen_x(-1),
  24. map_board_y_to_screen_y(-1),
  25. map_board_y_to_screen_y(BOARD_ROWS));
  26. draw_vertical_line(map_board_x_to_screen_x(BOARD_WIDTH),
  27. map_board_y_to_screen_y(-1),
  28. map_board_y_to_screen_y(BOARD_ROWS));
  29.  
  30. move_cursor(SCORE_X_OFFSET, 5);
  31. printf_P(PSTR("SCORE"));
  32. output_score();
  33.  
  34. }
  35.  
  36. void output_score() {
  37. move_cursor(SCORE_X_OFFSET,6);
  38. printf_P(PSTR("%ld"), get_score());
  39. }
  40.  
  41. void display_character_at(int8_t x, int8_t y, char c) {
  42. move_cursor(map_board_x_to_screen_x(x),
  43. map_board_y_to_screen_y(y));
  44. putchar(c);
  45. }
  46.  
  47. void display_food_at(int8_t x, int8_t y) {
  48. display_character_at(x, y, '#');
  49. }
  50.  
  51. void display_snake_at(int8_t x, int8_t y) {
  52. reverse_video();
  53. display_character_at(x, y, 'O');
  54. normal_display_mode();
  55. }
  56.  
  57.  
  58. void display_blank_at(int8_t x, int8_t y) {
  59. display_character_at(x, y, ' ');
  60. }
  61.  
  62. void game_over_message(void) {
  63. move_cursor(SCORE_X_OFFSET, 7);
  64. printf("Game over");
  65. }
Help PLEASE :cry:
Everything is okay in the end...
If it's not okay, then it's not the end.
:cool:
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 8
Reputation: Simplicity is an unknown quantity at this point 
Solved Threads: 0
Simplicity Simplicity is offline Offline
Newbie Poster

Re: How to use different colours?

 
0
  #2
Oct 24th, 2004
One more thing changing colours has to be using escape sequences..
Everything is okay in the end...
If it's not okay, then it's not the end.
:cool:
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C Forum


Views: 1921 | Replies: 1
Thread Tools Search this Thread



Tag cloud for C
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC