Thread: Error: expected identifier or ‘(’ before ‘{’ token

  1. #46
    Registered User jeffcobb's Avatar
    Join Date
    Dec 2009
    Location
    Henderson, NV
    Posts
    875
    Thanks MK; I could not figure out what he was trying to say with that...
    C/C++ Environment: GNU CC/Emacs
    Make system: CMake
    Debuggers: Valgrind/GDB

  2. #47
    Registered User
    Join Date
    May 2010
    Posts
    30
    I tried to put a blank place in the screen, and pressing key to pass images, but it goes way too slow, and I can't get out, I had to turn off the computer to get out. Well, at least I got one line displayed - that's a beginning. In the following code, I have only the first line, because it is just to test... When it work's, I put the real text.

    Current:

    Code:
    //Este programa foi feito por X.
    //Notas:
    //O comando printf introduz texto para o ecrã. O "\n" significa introduzir numa nova linha.
    //Já pus o título. Seguir o seu exemplo. Meter o resto por baixo. Não mexer nas outras coisas.
    //Have fun!
    //P.S.
    //O texto que começa com "//" são comentários. Não são interpretados pelo compilador, e não aparecem no programa em si.
    
    #include <stdio.h>
    #include <allegro.h>
    
    int main(void)
    {
       BITMAP *bmp; 
       PALETTE palette; 
       allegro_init(); 
       set_color_depth(24);
       set_gfx_mode(GFX_AUTODETECT, 800, 600, 0, 0); 
       install_keyboard();
    
    int sleepTime = 1;
    
    	readkey();
       
    	clear_to_color(screen, makecol(255, 255, 255));
    	
    	bmp = load_bitmap("PC.bmp", palette); 
       draw_sprite(screen, bmp, 0, 0); 
    
    	release_screen();
    sleep(sleepTime);
    
       textout(screen, font, "Linguagem Binária\n", 255, 255, 255);
       
       sleep(sleepTime);
    	
    	textout(screen, font, "Linguagem Binária\n", 1, 2, 10);
    	
    	sleep(sleepTime);
    	
    	textout(screen, font, "Linguagem Binária\n", 1, 3, 10);
    	
    	sleep(sleepTime);
    	
    	textout(screen, font, "Linguagem Binária\n", 1, 4, 10);
    	
    	sleep(sleepTime);
    	
    	textout(screen, font, "Linguagem Binária\n", 1, 5, 10);
    	
    	sleep(sleepTime);
    	
    	textout(screen, font, "Linguagem Binária\n", 1, 6, 10);
    	
    	sleep(sleepTime);
    	
    	textout(screen, font, "Linguagem Binária\n", 1, 7, 10);
    	
    	sleep(sleepTime);
    	
    	textout(screen, font, "Linguagem Binária\n", 1, 8, 10);
    	
    	sleep(sleepTime);
    	
    	textout(screen, font, "Linguagem Binária\n", 1, 9, 10);
    	
    	sleep(sleepTime);
    	
    	textout(screen, font, "Linguagem Binária\n", 1, 10, 10);
    	
    	sleep(sleepTime);
       
       release_screen();
       
       bmp = load_bitmap("Super.bmp", palette); 
       draw_sprite(screen, bmp, 1, 1); 
    
    release_screen();
    	
    	sleep(sleepTime);
       
       release_screen();
       bmp = load_bitmap("PDA.bmp", palette); 
       draw_sprite(screen, bmp, 2, 2); 
    
    sleep(sleepTime);
       
       textout(screen, font, "Linguagem Binária\n", 1, 15, 10);
    	sleep(sleepTime);
       
       bmp = load_bitmap("consti.bmp",palette); 
       draw_sprite(screen, bmp, 3, 3); 
    
    sleep(sleepTime);
       
       textout(screen, font, "Linguagem Binária\n", 1, 25, 10);
       
       sleep(sleepTime);
       
       textout(screen, font, "Linguagem Binária\n", 1, 1, 10);
       
       sleep(sleepTime);
       
       textout(screen, font, "Linguagem Binária\n", 1, 1, 10);
       
       sleep(sleepTime);
       
       textout(screen, font, "Linguagem Binária\n", 1, 1, 10);
    	
    	sleep(sleepTime);
       bmp = load_bitmap("SO.bmp", palette); 
       draw_sprite(screen, bmp, 4, 4); 
    
    sleep(sleepTime);
       
       textout(screen, font, "Linguagem Binária\n", 1, 30, 10);
       
       sleep(sleepTime);
       
       textout(screen, font, "Linguagem Binária\n", 1, 31, 10);
       
       sleep(sleepTime);
       
       textout(screen, font, "Linguagem Binária\n", 1, 32, 10);
       
       sleep(sleepTime);
       
       textout(screen, font, "Linguagem Binária\n", 1, 33, 10);
       
       sleep(sleepTime);
       
       textout(screen, font, "Linguagem Binária\n", 1, 34, 10);
       
       sleep(sleepTime);
       
       textout(screen, font, "Linguagem Binária\n", 1, 35, 10);
       
       sleep(sleepTime);
       
       textout(screen, font, "Linguagem Binária\n", 1, 36, 10);
       
       sleep(sleepTime);
       
       textout(screen, font, "Linguagem Binária\n", 1, 37, 10);
       
       sleep(sleepTime);
       
       textout(screen, font, "Linguagem Binária\n", 1, 38, 10);
       
       sleep(sleepTime);
       
       textout(screen, font, "Linguagem Binária\n", 1, 39, 10);
      
      sleep(sleepTime);
       
       
       textout(screen, font, "Linguagem Binária\n", 1, 40, 10);
       
       sleep(sleepTime);
       
       textout(screen, font, "Linguagem Binária\n", 1, 41, 10);
       
       sleep(sleepTime);
       
       textout(screen, font, "Linguagem Binária\n", 1, 42, 10);
       
       sleep(sleepTime);
       
       textout(screen, font, "Linguagem Binária\n", 1, 43, 10);
       
       sleep(sleepTime);
       
       textout(screen, font, "Linguagem Binária\n", 1, 44, 10);
    
    sleep(sleepTime);
    
    bmp = load_bitmap("Ubuntu.bmp",palette); 
       draw_sprite(screen, bmp, 5, 5); 
    
    sleep(sleepTime);
    	
       bmp = load_bitmap("XP.bmp", palette); 
       draw_sprite(screen, bmp, 6, 6); 
    sleep(sleepTime);
    	
       bmp = load_bitmap("7.bmp", palette); 
       draw_sprite(screen, bmp, 7, 7); 
    
    sleep(sleepTime);
    
    textout(screen, font, "Linguagem Binária\n", 1, 55, 10);
    
    sleep(sleepTime);
    
    textout(screen, font, "Linguagem Binária\n", 1, 56, 10);
    
    sleep(sleepTime);
    
    textout(screen, font, "Linguagem Binária\n", 1, 57, 10);
    
    sleep(sleepTime);
    
    textout(screen, font, "Linguagem Binária\n", 1, 58, 10);
    
    sleep(sleepTime);
       bmp = load_bitmap("command.bmp", palette); 
       draw_sprite(screen, bmp, 8, 8); 
    
    sleep(sleepTime);
    
    textout(screen, font, "Linguagem Binária\n", 1, 65, 10);
    
    sleep(sleepTime);
    
    textout(screen, font, "Linguagem Binária\n", 1, 66, 10);
    
    sleep(sleepTime);
    
    textout(screen, font, "Linguagem Binária\n", 1, 67, 10);
    
    sleep(sleepTime);
    
    textout(screen, font, "Linguagem Binária\n", 1, 68, 10);
    
    sleep(sleepTime);
    
    textout(screen, font, "Linguagem Binária\n", 1, 69, 10);
    
    sleep(sleepTime);
    
    textout(screen, font, "Linguagem Binária\n", 1, 70, 10);
    
    sleep(sleepTime);
    
    textout(screen, font, "Linguagem Binária\n", 1, 71, 10);
    
    sleep(sleepTime);
    
    textout(screen, font, "Linguagem Binária\n", 1, 72, 10);
    
    sleep(sleepTime);
    
    textout(screen, font, "Linguagem Binária\n", 1, 73, 10);
    
    sleep(sleepTime);
    
    textout(screen, font, "Linguagem Binária\n", 1, 74, 10);
    
    sleep(sleepTime);
    
    textout(screen, font, "Linguagem Binária\n", 1, 75, 10);
    
    sleep(sleepTime);
    
    textout(screen, font, "Linguagem Binária\n", 1, 76, 10);
    
    sleep(sleepTime);
    
    textout(screen, font, "Linguagem Binária\n", 1, 77, 10);
    
    sleep(sleepTime);
       textout(screen, font, "Linguagem Binária\n", 1, 78, 10);
       getchar();
       return 0;
    }
    END_OF_MAIN()
    Help?

  3. #48
    Registered User jeffcobb's Avatar
    Join Date
    Dec 2009
    Location
    Henderson, NV
    Posts
    875
    I cannot help with your graphics mode problem (I avoid graphics mode for just these (seemingly) stupid reasons. However if your app seems to get stuck in memory on Linux you can to a killall <yourappname>, obviously filling in the name of your app to blow it out of memory (do this from another terminal). If you are still calling it what you did, killall main.exe will work. Rebooting a UNIX box is the last refuge of the desperate.
    C/C++ Environment: GNU CC/Emacs
    Make system: CMake
    Debuggers: Valgrind/GDB

  4. #49
    Registered User jeffcobb's Avatar
    Join Date
    Dec 2009
    Location
    Henderson, NV
    Posts
    875
    I am not sure what the screen var is you are writing to but I Googled this and saw a very different method of writing text to the screen here:
    GameDev.net - Text Input in an Allegro Game

    They are writing to a blank bitmap and then blitting it to the screen (it looks like; this is not my preserve)...
    C/C++ Environment: GNU CC/Emacs
    Make system: CMake
    Debuggers: Valgrind/GDB

  5. #50
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Just based on reading the manual for Allegro, once you've done install_keyboard you can't use the usual input functions, so getchar() will never happen unless you release the keyboard. You should probably set up a keyboard handler so you can type Q to stop things or whatever.

    Does the text move down every second like it's supposed to? Given you're moving it by one pixel(?) every time without clearing the old stuff, it might be hard to tell.

  6. #51
    Registered User jeffcobb's Avatar
    Join Date
    Dec 2009
    Location
    Henderson, NV
    Posts
    875
    Tab: yeah Allegro (I googled a bit while helping him yesterday) has a work-alike for getchar() though ATM (lack of sleep) what it is escapes me)...
    C/C++ Environment: GNU CC/Emacs
    Make system: CMake
    Debuggers: Valgrind/GDB

  7. #52
    Registered User
    Join Date
    May 2010
    Posts
    30
    How much pixels are a line?

  8. #53
    Registered User jeffcobb's Avatar
    Join Date
    Dec 2009
    Location
    Henderson, NV
    Posts
    875
    Depends on your screen resolution. 800x600 means......
    C/C++ Environment: GNU CC/Emacs
    Make system: CMake
    Debuggers: Valgrind/GDB

  9. #54
    Registered User
    Join Date
    May 2010
    Posts
    30
    I'm in class. I really need some help...

  10. #55
    Registered User
    Join Date
    May 2010
    Posts
    30
    How do I put different sleeptime's seconds? And don't want the same time. I'm almost there...

    I typed:

    Code:
    (...)
    int sleepTime;
    (...)
    sleep(sleepTime)=1;
    (...)
    sleep(sleepTime)=2;
    Etc etc... It gives me the error:

    Code:
    error: lvalue required as left operand of assignment
    What can I do? I know the next time I build, it will do what I want... I drawed a blank bitmap do the middle of the screen (as sugested) and in the textouts I inserted different pixels to each. 38 pixels ~ 1cm. I followed that. Wish me luck!

  11. #56
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    You need to assign to sleeptime.
    Code:
    sleeptime=1;
    sleep(sleeptime);

  12. #57
    Registered User
    Join Date
    Sep 2008
    Posts
    60
    it hurts ... my eyes ... !!

    Way too many brackets. The way jeff formatted the code makes much more sence.

  13. #58
    Registered User
    Join Date
    May 2010
    Posts
    30
    I have a question about the textout pixels.

    It has, for example:

    Code:
    255,255,255
    What's the number I have to change to put 38 pixels down? And I have to increase or decrease the number?

    E changed the first one up, but it isn't... The letters are over each other. But I'm almost there... When I find the pixels I have to change, I finish.

  14. #59
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    textout isn't a standard C function. Go ask whomever has given you the function how to use it.


    Quzah.
    Hope is the first step on the road to disappointment.

  15. #60
    Registered User
    Join Date
    May 2010
    Posts
    30
    I asked Google, but he didn't retreave what I want... Ignore the textouts. Tell me about the pixels.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  2. Connecting to a mysql server and querying problem
    By Diod in forum C++ Programming
    Replies: 8
    Last Post: 02-13-2006, 10:33 AM
  3. Why wont my function exit correctly?
    By LightsOut06 in forum C Programming
    Replies: 2
    Last Post: 10-09-2005, 09:23 PM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  5. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM

Tags for this Thread