|
help with alegro api |
Money
Member #6,730
December 2005
|
Posted on 12-29-2005 4:43 PM int do_menu(MENU *menu, int x, int y); i can't get it to work..i tried MENU* aMenu; //then do_menu(aMenu, 200, 200); //but the program crashed..so then i looked into MENU //its a struct, //typedef struct MENU // char *text; - the text to display for the menu item //sodo i need to define aMenu or what? i need help |
BAF
Member #2,981
December 2002
|
Yep.
|
Money
Member #6,730
December 2005
|
ohhh, ok , thanks ...that made me understand the allegro api like a lot better |
Fladimir da Gorf
Member #1,565
October 2001
|
The crash was because the pointer was null (eg. not set). You need an array of MENU objects instead of an empty pointer (as in BAF's code) OpenLayer has reached a random SVN version number ;) | Online manual | Installation video!| MSVC projects now possible with cmake | Now alvailable as a Dev-C++ Devpack! (Thanks to Kotori) |
BAF
Member #2,981
December 2002
|
You're welcome. Welcome to Allegro.cc, by the way... I forgot to say that in my post in your other thread. |
Money
Member #6,730
December 2005
|
btw, im using c++ not c can u give it to me in c form? because this is what i had
/errors Project : Win32 Application |
Neil Walker
Member #210
April 2000
|
you missed the = sign off the array definition. also, when you use some of the GUI stuff, you have to make explicit casts when using C++. btw, if you are looking at gui stuff, you could always look in the library section at 'masking', it's a c++ based GUI that produces something a lot prettier. Neil. wii:0356-1384-6687-2022, kart:3308-4806-6002. XBOX:chucklepie |
Money
Member #6,730
December 2005
|
ummm..
/errors |
BAF
Member #2,981
December 2002
|
Why are you trying to call main from your menu? And you cant define your menu as nothing in main then expect it to work. And readkey should be readkey(). |
Money
Member #6,730
December 2005
|
what do u mean define my menu as nothing? is this right?
make yourself clearer please |
Neil Walker
Member #210
April 2000
|
http://www.allegro.cc/resource/resource-view.php?id=63 Is Miran's MasKinG (put random letters capitalised) and will probably suite you better as it is c++, easy to use, and has lots of simple examples. Neil. wii:0356-1384-6687-2022, kart:3308-4806-6002. XBOX:chucklepie |
Evert
Member #794
November 2000
|
If you haven't seen it yet, Allegro comes with a couple of example programmes that you can learn from (in allegro/examples/). For instance exgui.c (attached; I didn't know posts had a size limit...) It's not the shortest possible programme that shows you how to do menus or use the GUI (which, by the way, is not great for use inside an actual game because it's quite ugly unless you use your own dialog routines), but it is intended to show you how things work and explain things. One more suggestion, if I may: Quote: u Please take the extra two keystrokes and write it out as `you'. For me, `u' is a sound that doesn't even exist in English and seeing it where `you' is intended interrupts the flow of the text. In other words, it makes it harder for me to read and I find it annoying. |
Money
Member #6,730
December 2005
|
thanks neil, thats great...i don't possibly see how these people code games in C, i have to have classes C to me is unorganized like h**l |
IonBlade
Member #3,521
May 2003
|
Try this site: http://www.cprogramming.com/tutorial.html It's where I learned most of the basics. I remember how nonsensical it all seemed, and I thought I'd never get past the boring stuff.. but because I couldn't give up the chance to make cool games, I kept at it. I suggest you do the same. By the way, if you're wondering whether to do the C tutorials or C++ tutorials, it might not matter. I started on C++ and I still understand+write plain C code. Starting in plain C might introduce another learning curve if you start C++ later on, though. ------ "I've got to choose my words carefully so that I'm not misunderstood, but I think there are fewer developers around today who think about making a good game. As a creator, I find that sad..." - Hideo Kojima |
Money
Member #6,730
December 2005
|
umm, sorry to burst your bubble ION, but i know c++, when i said classes i mean OO classes, |
IonBlade
Member #3,521
May 2003
|
Quote: when i said classes i mean OO classes Oh, whoops Quote: sorry to burst your bubble ION, but i know c++ You may know C++, but do you how to use it to create games from scratch? IE, create a main loop and set different functions for input, drawing, and logic? ------ "I've got to choose my words carefully so that I'm not misunderstood, but I think there are fewer developers around today who think about making a good game. As a creator, I find that sad..." - Hideo Kojima |
BAF
Member #2,981
December 2002
|
Quote: Is Miran's MasKinG (put random letters capitalised) and will probably suite you better as it is c++, easy to use, and has lots of simple examples. Its MASkinG. Easy to remember. M and A are his initials, Skin for skinnable, and G for GUI. |
razor
Member #2,256
April 2002
|
Quote: umm, sorry to burst your bubble ION, but i know c++ Don't be so quick to attack people, remember they are trying to help you (for free at that!). A few points that I don't think have been mentioned to you:
[list ordered] </ol> [/list] Anyways, back on topic, don't give up with the allegro GUI so quickly, while it isn't the greatest thing ever it's good to know how it works because if you can figure this out then you can figure out the rest of allegro on your own. About your code, make sure mymenu is defined before you use it. This is something you should know from all C/C++ programming you have done. Remember allegro is just a library, IE a bunch of functions, nothing more. While some of them work together they still function under the rules of C/C++. Whoooo Oregon State University |
Money
Member #6,730
December 2005
|
alright, im sorry. here is my source, i redid it. everytime i run it , it crashes.
|
Onewing
Member #6,152
August 2005
|
Don't you need to: set_gfx_mode ------------ |
Money
Member #6,730
December 2005
|
ok, i got it to work. it was just some technical difficulties with the compiler , thanks |
Onewing
Member #6,152
August 2005
|
Quote: The color depth of the graphic mode has to be specified before calling this function with set_color_depth(). Also, you can use allegro_message() or, for a more acurate method, a debugger to find out where the program is crashing and then you can say more than "it crashes". When I'm at work, I sometimes get a call from somebody saying "their computer doesn't work." That's a very vague statement and usually, it's something stupid. My first question is always, "is your monitor turned on?" (yes, sometimes that is the problem). So, with more details, it's easier to solve your problem. ------------ |
Evert
Member #794
November 2000
|
Quote: Also, you can use allegro_message() [...] to find out where the program is crashing and then you can say more than "it crashes". Note that you should not use allegro_message() after you've called set_gfx_mode(), unless you call set_gfx_mode(GFX_TEXT,...) again first. |
BAF
Member #2,981
December 2002
|
SS said:
Quote: The color depth of the graphic mode has to be specified before calling this function with set_color_depth().
You don't have to set the color depth (defaults to 8), but if you are going to set it, you must set it before setting the gfx mode. Quote: ok, i got it to work. it was just some technical difficulties with the compiler , thanks Nah, the only problem was not calling set_gfx_mode. |
|