|
|
| textprintf help |
|
red_4900
Member #9,776
May 2008
|
I'm a newbie here and also a newbie to the allegro library.this is the code that I have problem with : #include"allegro.h" I copied it straight from the book yet it did not compiled perfectly.the compiler said there's an error in line 15, which is the 'textprintf line'.any help would be greatly appreciated.thank you. And could someone show me how to distinguish the code from the text?something like |
|
Thomas Harte
Member #33
April 2000
|
Distinguish code from text using the [ code ] tags (but with no spaces). E.g. [ code ] As to the real problem — are you sure your compiler gave an error, not a warning? Can you supply the text of the error? In general textprintf is deprecated in favour of textprintf_ex — it's recommended that you use the latter instead. For you that should be as simple as: textprintf(screen, font, 0, 0, makecol(100,255,125), -1, "%dx%d", SCREEN_W, SCREEN_H); [My site] [Tetrominoes] |
|
torhu
Member #2,727
September 2002
|
What error messages do you get? textprintf is deprecated, textprintf_ex replaces it, but it should still work. And you can enclose you code in code tags, like this: <code>Your code here </code> EDIT: Well, I guess two replies are better than one, eh? |
|
LennyLen
Member #5,313
December 2004
|
Thomas Harte said: In general textprintf is deprecated in favour of textprintf_ex — it's recommended that you use the latter instead. For you that should be as simple as: textprintf(screen, font, 0, 0, makecol(100,255,125), -1, "%dx%d", SCREEN_W, SCREEN_H);
Pssst.... You forgot to rename the function: edit: red_4900 said: I copied it straight from the book Let me guess, the book was Game Programming All in One? Unfortunately, that book is full of errors and bad coding practices (such as including conio.h when none of the functions in that library are used).
|
|
Thomas Harte
Member #33
April 2000
|
Oh, yes, listen to LennyLen's correction to my post — don't listen to my original post. [My site] [Tetrominoes] |
|
red_4900
Member #9,776
May 2008
|
I did as what u guys told me but it showed this error: g++.exe test1.o test2.o Project1_private.res -o "Project1.exe" -L"C:/Dev-Cpp/lib" -mwindows -lalleg test2.o(.text+0x0):test2.c: multiple definition of `_mangled_main()' mingw32-make: *** [Project1.exe] Error 1 Execution terminated this is my code:
yes,I'm using the "Game Programming All In One".I cant find any other books that's noob-friendly. |
|
LennyLen
Member #5,313
December 2004
|
Quote: g++.exe test1.o test2.o Project1_private.res -o "Project1.exe" -L"C:/Dev-Cpp/lib" -mwindows -lalleg There are two object files in your project, even though you appear to only have one source file. Did you originally have a file in your project called test1.c that you removed and replaced with a new file called test2.c? Try creating a new project, as the code you just posted compiles as expected (no errors, just a warning).
|
|
Edgar Reynaldo
Major Reynaldo
May 2007
|
Don't use a semi-colon after END_OF_MAIN() , it's not supposed to be there. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
|
Ryan Stover
Member #9,755
May 2008
|
Hmmm that is weird... I have always put a semi-colon after END_OF_MAIN and it works fine. |
|
Edgar Reynaldo
Major Reynaldo
May 2007
|
END_OF_MAIN() manual entry - It may work but it still doesn't belong there. It's a define , not a statement that needs to be ended with a semi-colon. #define SOME_CODE \ for (int i = 0 ; i < 10 ; i++) {do_stuff();} // Which of the next two statements would be correct? SOME_CODE SOME_CODE; As you can see , the semi-colon would be inappropriate there. END_OF_MAIN() is a platform specific #define so there are several possible definitions.
So you can see that it doesn't need a semi-colon there. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
|
|