| | |
How to use different colours?
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Oct 2004
Posts: 8
Reputation:
Solved Threads: 0
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:
Help PLEASE :cry:
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:
C Syntax (Toggle Plain Text)
static int map_board_x_to_screen_x(int board_x) { return BOARD_X_OFFSET + board_x; } static int map_board_y_to_screen_y(int board_y) { return BOARD_Y_OFFSET + board_y; } void init_screen() { /* ** Initialise the screen, by setting it to normal display mode ** and clear the screen. */ normal_display_mode(); clear_terminal(); draw_horizontal_line(map_board_y_to_screen_y(-1), map_board_x_to_screen_x(-1), map_board_x_to_screen_x(BOARD_WIDTH)); draw_horizontal_line(map_board_y_to_screen_y(BOARD_ROWS), map_board_x_to_screen_x(-1), map_board_x_to_screen_x(BOARD_WIDTH)); draw_vertical_line(map_board_x_to_screen_x(-1), map_board_y_to_screen_y(-1), map_board_y_to_screen_y(BOARD_ROWS)); draw_vertical_line(map_board_x_to_screen_x(BOARD_WIDTH), map_board_y_to_screen_y(-1), map_board_y_to_screen_y(BOARD_ROWS)); move_cursor(SCORE_X_OFFSET, 5); printf_P(PSTR("SCORE")); output_score(); } void output_score() { move_cursor(SCORE_X_OFFSET,6); printf_P(PSTR("%ld"), get_score()); } void display_character_at(int8_t x, int8_t y, char c) { move_cursor(map_board_x_to_screen_x(x), map_board_y_to_screen_y(y)); putchar(c); } void display_food_at(int8_t x, int8_t y) { display_character_at(x, y, '#'); } void display_snake_at(int8_t x, int8_t y) { reverse_video(); display_character_at(x, y, 'O'); normal_display_mode(); } void display_blank_at(int8_t x, int8_t y) { display_character_at(x, y, ' '); } void game_over_message(void) { move_cursor(SCORE_X_OFFSET, 7); printf("Game over"); }
Everything is okay in the end...
If it's not okay, then it's not the end. :cool:
If it's not okay, then it's not the end. :cool:
![]() |
Similar Threads
- Do colours/themes have an effect on a forum/community? (Social Media and Online Communities)
- Vertical colours lines in my screen laptop (please help!) (Monitors, Displays and Video Cards)
- only 16 colours (Windows 95 / 98 / Me)
- IE6 - Not displaying background colours... (Web Browsers)
- ugly colours in IE?!? (Web Browsers)
Other Threads in the C Forum
- Previous Thread: How can I write a program with 3 classes?
- Next Thread: evaluation of stacks
Views: 1921 | Replies: 1
| Thread Tools | Search this Thread |
Tag cloud for C
#include adobe ansi array arrays asterisks binarysearch calculate centimeter char command convert copyimagefile cprogramme creafecopyofanytypeoffileinc directory dynamic fflush file fork forloop framework frequency functions getlasterror givemetehcodez grade graphics gtkgcurlcompiling hacking hardware highest homework inches incrementoperators kernel km lazy linked linkedlist linux linuxsegmentationfault list lists locate logical_drives looping loopinsideloop. match matrix microsoft motherboard multi mysql number opendocumentformat opensource owf pattern pdf performance pointer pointers posix problem probleminc process program programming radix recursion recv repetition research scanf scheduling scripting segmentationfault sequential shape socket socketprograming spoonfeeding stack standard string strings structures student systemcall testautomation threads turboc unix user variable voidmain() wab win32 windows.h





