|
How do I draw chat histories of all clients? |
foretion
Member #17,091
June 2019
|
first, see attachment(1.mp4) i did the following coding. 1) type chat message on client i want to save 5 chat message and draw them. what is the best way to implemented it? |
Edgar Reynaldo
Major Reynaldo
May 2007
|
Use a std::deque. Push front until 5 are received then push front and pop back for every message after that. You can use al_draw_text to draw the text. 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 |
foretion
Member #17,091
June 2019
|
Sorry, I use c lang. because it is my final exam of 'c language programming'class in my college. Do you know other solution? |
Frank Drebin
Member #2,987
December 2002
|
I would use a char array and strcpy():
|
foretion
Member #17,091
June 2019
|
Could you tell me that's mean? that code?? ---- |
Edgar Reynaldo
Major Reynaldo
May 2007
|
Don't initialize the first character to newline, initialize it to zero... You don't need a deque, as Frank Drebin showed clearly. A deque is just a concept. It doesn't matter if its C++ or C, it's a container, and you can implement containers in any language you wish. Frank implemented an array of 5 string buffers. When you get a new message, you move them all 'up' one and overwrite the first. Pretty simple, but effective. Also, the array dimensions are reversed. It should be an array of 5 MAX_LENGTH buffers, not MAX_LENGTH buffers of size 5... 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 |
Frank Drebin
Member #2,987
December 2002
|
Yeah Edgar is right... This should work better:
|
foretion
Member #17,091
June 2019
|
thank you everyone attachment file(1234.mp4) is the test screen |
|