|
|
| allegro and message boxes |
|
jimmy james
Member #6,105
August 2005
|
I just started using allegro,and this is my first step into game/graphical programming. I never used c, only c++. Ok now that thats out of the way, im trying to learn the ins and outs of allegro and basic graphics stuff in general. I just got allegro a couple weeks ago, and im just trying out everything. My first game im building is just a simple game i made in c++ that will stay pretty much textual. I learned to use algif to add a gif to my game(as an icon for each player). What im looking for is how to make a message/dialog box pop up and ask for the players name. I have absolutely no clue how to do this, as ive never used visual c++ or anything like that. Is this even possible, and is it worth it? If its overly difficult let me know, if not can someone post some code of how to do this? Thanks. Also is there a way to make my gif (animated) run in the background. Right now i have to choose between my gif moving or my game continuing. It waits for the gif animation to complete then continues. Anything i can do about that? Thanks |
|
Frank Drebin
Member #2,987
December 2002
|
- you know that you don't have to use c with allegro you can also stay with c++ |
|
Derezo
Member #1,666
April 2001
|
Here is 23yrold3yrold's input box code from this thread. There is also a C version there.
"He who controls the stuffing controls the Universe" |
|
jimmy james
Member #6,105
August 2005
|
ok i guess i wasnt clear enough. I have no problem getting input from the user. I use gstream in place of my cin and cout. I wanted to accomplish the input in a different means tho, from a popup box. A box that pops up and says "Enter Name of Player 1:" then has a textbox to take the input, you know what im sayin? Many games have them to input the name of the player if he/she get the hi score etc etc... Something like that, not just getting basic input in the window, i want a SEPERATE window to popup and get the input and have that input placed into my name string. |
|
ReyBrujo
Moderator
January 2001
|
I don't remember any straight function. You would need to create your own resource with the popup, the buttons and the place where the user would write the test, and handle the different events. -- |
|
jimmy james
Member #6,105
August 2005
|
but how do i make the popup window? If someone could tell me how to make the popup window, i could just use the allegro stuff and gstream to get the input, and figure out the textbox in the window later, baby steps. But i have no clue how to make a popup allegro window from my original allegro window. |
|
Derezo
Member #1,666
April 2001
|
You really answered you own question. Just use the allegro stuff and gstream to get the input.
"He who controls the stuffing controls the Universe" |
|
jimmy james
Member #6,105
August 2005
|
your code doesnt make a popup window, after working with it for a while i got a window to appear, but i had to put allegro_init() and set_gfx_mode in the popup function, but how do i destroy the window? After the window opens everything freezes. Does anyone know how to do this effectively? |
|
Jonny Cook
Member #4,055
November 2003
|
Quote:
your code doesnt make a popup window, after working with it You probably should have already called them at the beggining of the program. Not sure if this was what you are trying to accomplish, but I've made an example.
Hope that helps. The face of a child can say it all, especially the mouth part of the face. |
|
jimmy james
Member #6,105
August 2005
|
i attatched a photo of my screen. This is what im looking for, just want it to work. Mine wont work, after it gets to where its at it freezes and i have to go to program reset. If anyone has done this can you post a how to on how to make this second window work. Thanks |
|
Jonny Cook
Member #4,055
November 2003
|
Ohhh, you want it to open in a new window? I wasn't even aware you could do something like that. But really, is that even necessary? I think it just complicates things. Plus that could never work in DOS. [edit] The face of a child can say it all, especially the mouth part of the face. |
|
jimmy james
Member #6,105
August 2005
|
ok heres the code. Ive been messing with it since ive been home and i got it to work. If you want to run my code you need gstream. The only problem i have is for this to work the initial window is useless after i call the new window. So i have to close the window, open the new one, then open another one after that one. So it starts with a small window, it dissapears and goes to a small one that asks your name, and places it into a string. then that one closes and a window identical in size and position to the first window opens and displays the name you entered. Id like to find out how to do this but not have to close the first window, a way to go back to the original window. Does anyone know or ever done this before? Anyway heres my code [CODE] string Popup(); // Installing the keyboard handler. textout(screen, font, "This is the initial window!", 1, 1, 10); // Some Allegro magic to deal with WinMain(). string Popup() // Set the resolution to 640 by 480 with SAFE autodetection. |
|
Jonny Cook
Member #4,055
November 2003
|
Quote: Id like to find out how to do this but not have to close the first window, a way to go back to the original window I don't think Allegro supports that, as it would not be possible under DOS. The face of a child can say it all, especially the mouth part of the face. |
|
Kitty Cat
Member #2,815
October 2002
|
More or less... -- |
|
Rick
Member #3,572
June 2003
|
You can only create the one window with allegro. You will have to create you own "window". This isn't like MS Windows programming where you can create multiple windows. You can use allegro's gui code, or create your own "window" system. ======================================================== |
|
jimmy james
Member #6,105
August 2005
|
i got it all to work great, except the i had to exit the old window, so it starts with a welcome screen window thingy, then closes and opens a new window and asks for name of player one, then closes and opens another window that asks for player 2's name, then closes and opens another window where the actual game takes place, i like it better this way than creating a bitmap inside my window and using that as a "window", but for most apps my way isnt at all usefull. |
|
|