Hi, Allegro help - Printable Version +- Qbasicnews.com (http://qbasicnews.com/newforum) +-- Forum: Qbasic "like" compilers/interpreters (http://qbasicnews.com/newforum/forum-5.html) +--- Forum: FB Discussion & Programming Help (http://qbasicnews.com/newforum/forum-15.html) +--- Thread: Hi, Allegro help (/thread-7933.html) |
Hi, Allegro help - speedlemon - 08-21-2005 I read aetherfox's tutorial on the allegro game programming library.. i simply found it very useful. well, i read that entire thing, but i wish there was more stuff like that. i downloaded a lot of allegro manuals/tutorials for c++. however, since im not that good at c++ or even something more like a c, i was wondering if any of you knew another tutorial, or i was wondering if it would be against the rules to just use this thread to ask questions on specific c++ code/just general things about allegro that i dont understand. instead of making a new thread each time. heres the first question- how can i possible load graphics? heres is what i tried but i got an error? oh and also, this isnt the entire program, this is just the part giving me problems. Code: dim shared TestPalette as Palette sorry if thats not even close to what its supposed to be, but its the best i could make out of the c++ Hi, Allegro help - red_Marvin - 08-21-2005 loading bitmaps should be something like: [syntax="qbasic"]dim mybitmap as bitmap ptr dim pal as palette mybitmap=load_bitmap("filename", @pal) if mybitmap = 0 then 'Something went wrong else 'Good Goood (Pet evil cat and laugh manically) end if destroy_bitmap mybitmap[/syntax] ^Untested generate_332_palette is a void function and should thus be called as a sub = omit the parentheses... Hi, Allegro help - speedlemon - 08-21-2005 thank you red_Marvin for answering my question here. I will test that later for sure now. Hi, Allegro help - speedlemon - 08-21-2005 [syntax="php"]#include "allegro.bi" OPTION EXPLICIT dim shared smilepic as bitmap ptr dim shared apalette as palette dim shared x,y DIM SHARED DBLBuffer AS BITMAP PTR DIM SHARED Game_State AS SINGLE DIM SHARED White AS INTEGER DECLARE SUB InitAllegro(SWidth = 640, SHeight = 480, CDepth = 16, Fullscreen = 0, WTitle AS STRING = "Allegro + freeBasic") DECLARE SUB CloseAllegro() DECLARE SUB InitGame() DECLARE SUB Game() DECLARE SUB EndGame() InitAllegro () InitGame() Clear_Bitmap SCREEN Clear_Bitmap DBLBuffer Clear_KeyBuf DO Acquire_Bitmap(DBLBuffer) Game() Release_Bitmap(DBLBuffer) VSYNC Blit DBLBuffer, SCREEN, 0, 0, 0, 0, SCREEN_W, SCREEN_H Clear_Bitmap DBLBuffer IF Key(KEY_ESC) THEN Game_State = 1 LOOP UNTIL Game_State = 1 EndGame() CloseAllegro() SUB InitAllegro(SWidth = 640, SHeight = 480, CDepth = 16, Fullscreen = 0, WTitle AS STRING = "Allegro + freeBasic") Allegro_Init Install_Keyboard Install_Timer Install_Mouse Set_Color_Depth CDepth IF Fullscreen = 0 THEN IF Set_GFX_Mode(GFX_AUTODETECT_WINDOWED, SWidth, SHeight, 0, 0) < 0 THEN Allegro_Message "Unable to set any graphic mode" + Chr(13) + Allegro_Error + Chr(13) END 1 END IF END IF IF Fullscreen = 1 THEN IF Set_GFX_Mode(GFX_AUTODETECT_FULLSCREEN, SWidth, SHeight, 0, 0) < 0 THEN Allegro_Message "Unable to set any graphic mode" + Chr(13) + Allegro_Error + Chr(13) END 1 END IF END IF Set_Window_Title WTitle DBLBuffer = Create_Bitmap (SCREEN_W, SCREEN_H) IF DBLBuffer = NULL THEN Allegro_Exit Allegro_Message "Not enough memory." END 1 END IF Text_Mode(-1) Game_State = 0 White = MakeCol(255,255,255) END SUB SUB CloseAllegro() Destroy_Bitmap DBLBuffer Remove_Keyboard Remove_Timer Remove_Mouse Allegro_Exit END 0 END SUB SUB InitGame() smilepic = load_bmp("Smile.bmp",@apalette) END SUB SUB Game() floodfill dblbuffer,100,100,white blit smilepic,dblbuffer,0,0,x,y,145,138 x=x+5 y=y+3 END SUB SUB EndGame() destroy_bitmap(smilepic) END SUB [/syntax] alright, this is the entire program. right now, this works. but its throwing an error. im not really sure why? and i have another question. i have help file for allegro, and it tells me some stuff but its all in c++. but i used it to find out some stuff. but i would like to be able to do transparent stuff. but the only transparent stuff i can find in the manual is like this, draw_trans_sprite(bitmap, sprite, x, y) something like that but i dont know how to make a sprite to do that. but i think it might have to do with palette or something like truecolor mode is. unfortuanlately, i dont know what either one of those means. :oops: Hi, Allegro help - speedlemon - 08-23-2005 ok. by now i figured out how to do my last question. however, rotation's giving me a problem. there's no errors, its just not rotating. this is what the code is, and you can see the entire program if you download it. Code: rotate_sprite dblbuffer, smilepic, 100, 100, 64 next problem; im not really sure why. and when it loads the graphic, its throwing a warning(u can see this when you download and test for yourself). id post the code, but its pretty much the same as last one except this time it is for rotating. instead, ill just post the zip file, so you can check it out for yourself. please help! http://www.ezupload.org/?w=download&id=8054&name=RP.ZIP (don't right click and attempt to save target :wink: ) |