-
Is C dull?
Hi, I havent tried programming in years, the last time i tried to learn was with turbo pascal. I remember the lessons were like making flashing backgrounds and changing text and background colours and making beeps with different pitches and stuff like that. So far all the tutorials on c I have found been concerned with text and numbers, can c do stuff with sound and colour as well and are there any tutorials for it or is that what direct x is for?
-
The only thing your lessons taught you was how to change the colour and do stuff like this?
...just curious..
-
It's OS dependent.
Try this (it works on my linux console)
Code:
#define FORE_BLACK 30
#define FORE_RED 31
#define FORE_GREEN 32
#define FORE_YELLOW 33
#define FORE_BLUE 34
#define FORE_MAGENTA 35
#define FORE_CYAN 36
#define FORE_WHITE 37
#define BACK_BLACK 40
#define BACK_RED 41
#define BACK_GREEN 42
#define BACK_YELLOW 43
#define BACK_BLUE 44
#define BACK_MAGENTA 45
#define BACK_CYAN 46
#define BACK_WHITE 47
static int textc=FORE_WHITE;
void textcolor(int col)
{
printf("\033[1;%dm",col);
textc=col;
}
void backcolor(int col)
{
printf("\033[1;%d;%dm",textc,col);
}
// how to set text attribute such as blinking or inverse?
printf("\033[0m normal \033[0m\n");
printf("\033[5m blinking normal \033[0m\n");
printf("\033[7m inverse \033[0m\n");
printf("\033[7m\033[5m blinking inverse \033[0m\n");
printf("\033[2m suppress \033[0m\n");
printf("\033[1m bold \033[0m\n");
-
Well it was back in highschool about 5 years ago, obviously we would have learnt other stuff but the only thing i remember clearly about it was a quiz game i wrote with flashing colours and beeps and stuff. I suppose they taught that first to try keep a room full of teenagers entertained without boring the sh$t out of them.
.................................................. ....
About the code above, i'm on windows xp with msvc++ and that code has no effect
Thanks anyway, theres bound to be some info around somewhere
-
whats the point of just making beepy, flashing programs - i thought the idea of programming was to make useful aplications.
If you havnt programmes for years, i dont recommend going straight for directX, go for vb to ease you bac in, then winapi, then shift to DX
-
Thanks for the advice iain, theres no point to the programs except for learning purposes, whats the point of hello world?
I was just curious how c managed graphics and sound
-
Hello world exists to teach you concepts.
C/C++ handle graphics and sound through the use of APIs. Common ones (around here) include Allegro, SDL, WinAPI, DirectX, and OpenGL.