Thread: simple graphics in C... ??

  1. #1
    Registered User
    Join Date
    Jun 2003
    Posts
    60

    simple graphics in C... ??

    As I said (sometime ago..) this is my first attempt with computer languages,.. {I landed with "C" }

    Im looking for some entertainment.............

    Is it possible to produce simple graphics or moving strings with C ?

    I hear the magic of infinite loops.. and such rolling statements,..

    I remember those images seen from SMS's [from our mobile phones].. where a simple array of dots or characters produce another image when seen from afar.

    any ideas ??

    please give me a sample of a source code which activates a printf statement with an infinite loop....

    {I hope my grammar is correct...}

    Thanks !!

  2. #2
    Registered User
    Join Date
    Jun 2003
    Posts
    60

    OS and compiler

    Im on Windows XP,.. and Turbo C..

    that's all I can say... Im sure about the Turbo C..
    but not with any other specifications...

    does it make any difference ??,.. its still C language right ??

  3. #3
    Registered User
    Join Date
    Jun 2003
    Posts
    60

    just the thing we use.....

    Yup !!

    I had the whole thing from my instructor,...
    and that's the same compiler we use for our laboratory exercises,

    I have no choice, but to be in...

    I think we're just walking with our tip toes for a while,.. before taking the real big leap.

    Could anyone please give me any hint on my queries ??
    infinite loops,... and moving strings...

    im not really aware of the terms,.. im just guessing..

  4. #4
    Registered User
    Join Date
    Jul 2002
    Posts
    913
    im not sure why you want it, but heres a infinite loop:
    Code:
    #include <stdio.h>
    
    int main() {
        while(!0) 
            printf("im a annoying loop, please kill me!\n");
            
        return 0;
    }
    Is it possible to produce simple graphics or moving strings with C ?
    there are alot of graphics libraries, but nothing in c.

    moving strings could be faked without a special library.
    Code:
    #define TIME    1000000000
    
    #include <stdio.h>
    #include <string.h>
    
    int main() {
        char string[] = "test";
        char *print = NULL;
        
        int x = 0;
        int y;
        
        while(x < strlen(string)) {
            print = &string[x];
            
            printf("%s", print);
            
            for(y = 0; y < TIME; ++y)
                ;;
            system("cls");
            
            ++x;
        }
        
            
        return 0;
    }

  5. #5
    and the Hat of Clumsiness GanglyLamb's Avatar
    Join Date
    Oct 2002
    Location
    between photons and phonons
    Posts
    1,110
    I remember those images seen from SMS's [from our mobile phones].. where a simple array of dots or characters produce another image when seen from afar.
    This is how i made my things that would be displayed using 13h mode. I used to put everything in a 2-d array and then you just loop trough the array, but in the end if you want to keep it simple you could go with a 100 printf statements and then everything between the " would be the same as the things in the array...

    But i guess a 2d-array would be the best and fastest (to type that is, dont know about the time it takes to do 100 printf and the time it takes to loop trough a huge 2d-array).

    ::/edit::
    When i used the array i did something like an "x" represents a white dot and a "space" would represent a black dot...After the array reading and display function is done it isnt that hard to implement other things like an "o" represents a yellow dot....
    Last edited by GanglyLamb; 07-10-2003 at 05:08 AM.

  6. #6
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    Without jumping through some heavy hoops, graphics in a console is pretty limited. The basic stuff is covered in my tutorial here. Page 3 in particular. The code is C++ but the functions and techniques are the same in C, just use printf() instead of cout!
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  7. #7
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    If you run in mode 13h you are not as limited in the graphics department. Let us not forget quake and all the other DOS games of yester-year (well maybe more than that). Check out the dos boards for some help. There is some site i think [edit]http://www.brackeen.com/home/vga/basics.html[/edit] or something like that that has a good tutorial.
    Last edited by master5001; 07-11-2003 at 11:04 PM.

  8. #8
    Registered User Casey's Avatar
    Join Date
    Jun 2003
    Posts
    47
    >>If you run in mode 13h you are not as limited in the graphics department.
    I didn't know that you could run in mode 13h on Windows XP. How is it done?

  9. #9
    and the Hat of Clumsiness GanglyLamb's Avatar
    Join Date
    Oct 2002
    Location
    between photons and phonons
    Posts
    1,110
    13h in XP works as fine as in any windows, at least thats my experience. So far nobody that uses XP has been complaining about a thing when i send them my new project wich also uses 13h.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. simple 2d "putpixel" api for windows?
    By spiky in forum C Programming
    Replies: 2
    Last Post: 10-27-2005, 02:44 PM
  2. Graphics tutorial
    By ssjnamek in forum C++ Programming
    Replies: 1
    Last Post: 08-15-2005, 02:13 AM
  3. a simple Dev-C++ game graphics system
    By shintaro in forum Game Programming
    Replies: 1
    Last Post: 08-11-2005, 05:49 PM
  4. Tutorial for making better computer graphics?
    By supertoad in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 05-02-2005, 12:19 AM
  5. Very simple question, problem in my Code.
    By Vber in forum C Programming
    Replies: 7
    Last Post: 11-16-2002, 03:57 PM