|
Post by eemoasche on Jun 24, 2022 14:22:18 GMT -5
Hi, so I've been getting into making small little text based games with BASIC and I wanted to include image hints for some of the puzzles. There came two problems: I can't figure out the correct "Bitmap format" and the FreeForm editor disappeared from my Liberty BASIC menu. Please help
|
|
|
Post by tsh73 on Jun 24, 2022 15:32:36 GMT -5
usually if you save from Microsoft Paint it works OK (and by default it is 24-bit bitmap).
I had problems before with bitmaps saved from GIMP then using less then 256 colors It looks like GIMP optimizes file saving only colors necessary While LB reads only files with 256 colors palette (even id actual color number is less) Well, this is my guess.
|
|
|
Post by eemoasche on Jun 24, 2022 17:12:12 GMT -5
I get a runtime error index 876515 is outside of collection bounds. Attachments:
|
|
|
Post by eemoasche on Jun 24, 2022 18:55:21 GMT -5
Ok, I got the bitmap to load, now how do I open a window with the bitmap as the background?
|
|
|
Post by Rod on Jun 25, 2022 2:46:29 GMT -5
You would need to use a graphicbox. Either as the whole display or here as a control on a form with other controls. It may give you some ideas, or at least let you frame your next question.
'graphicbox display swapped in for transparent text display 'this allows text on a background 'mini adventure by rod 'an adaptation of code provided by Alyce True=1 False=0 [WindowSetup] NOMAINWIN WindowWidth = 511 : WindowHeight = 358 UpperLeftX = INT((DisplayWidth-WindowWidth)/2) UpperLeftY = INT((DisplayHeight-WindowHeight)/2)
[ControlSetup] statictext #main.s1, "Type here. Hit 'ENTER.'", 10, 260, 169, 25 statictext #main.s2, "Tunnel Lore.", 10, 10, 169, 25 'button with extension *default* is activated in dialog window 'when user hits *ENTER* 'very clever tip to remember button #main.default, "Okay",[processinput],UL, 380, 290, 105, 25 button #main.quit, "Quit",[quit],UL, 380, 255, 105, 25 textbox #main.type, 10, 290, 355, 24 graphicbox #main.display, 10, 40, 490, 210
Open "My Great Adventure" for Dialog as #main #main "trapclose [quit]" #main "font ms_sans_serif 10"
'here we set up for transparent text 'get the handle of the graphicbox hWD=hwnd(#main.display) 'get the handle of the Device Context in that window CallDll #user32, "GetDC", hWD as ulong, hDC as ulong 'set text to render with transparent background calldll #gdi32, "SetBkMode",hDC as ulong,_TRANSPARENT as long, re as long
'here we load or draw the background #main.display "down ; fill green ; backcolor red ; place 200 50 ; circlefilled 50 ; flush bak" #main.display "color darkgreen"
gosub [data] 'build the array of information to use in the adventure
[awaitinput] #main.type "" 'clear typing box #main.type "!setfocus" 'set focus so typing goes into textbox wait 'now sit and wait for some user input, an "event"
[quit] close #main : END
[processinput] #main.type "!contents? txt$" 'get text typed by user
select case upper$(left$(txt$,1)) 'make it uppercase and use the first letter only case "N" if moven$<>"" then move$="You walk North" loc$=moven$ move=True else move$="You cannot go North" move=False end if case "S" if moves$<>"" then move$="You walk South" loc$=moves$ move=True else move$="You can't go South" move=False end if case "E" if movee$<>"" then move$="You walk East" loc$=movee$ move=True else move$="You are not able to go East" move=False end if case "W" if movew$<>"" then move$="You walk West" loc$=movew$ move=True else move$="You can't go West" move=False end if case "T" if o$<>"" then #main.display "\You pick up the "+o$ else #main.display "\There is nothing to pick up." end if goto [awaitinput] ' you will need to add code to remove the item from the location$() and add it to your inventory$ case "L" #main.display, "\I didn't bring my glasses so can't see anything." goto [awaitinput] case else #main.display "\I don't yet understand that word." #main.display "\I do understand North South East West Look Take" goto [awaitinput] end select
[displaylocation] 'discard old drawing 'place the cursor 'redraw the background to clear the screen #main.display "discard ; place 0 0 ; redraw bak" #main.display "\";move$ desc$="" n$="" moven$="" s$="" moves$="" e$="" movee$="" w$="" movew$="" o$="" for n=1 to 100 if left$(location$(n),7)=loc$+"DESC" then desc$=right$(location$(n),len(location$(n))-7) if left$(location$(n),4)=loc$+"N" then n$=right$(location$(n),len(location$(n))-7) : moven$=mid$(location$(n),5,3) if left$(location$(n),4)=loc$+"S" then s$=right$(location$(n),len(location$(n))-7) : moves$=mid$(location$(n),5,3) if left$(location$(n),4)=loc$+"E" then e$=right$(location$(n),len(location$(n))-7) : movee$=mid$(location$(n),5,3) if left$(location$(n),4)=loc$+"W" then w$=right$(location$(n),len(location$(n))-7) : movew$=mid$(location$(n),5,3) if left$(location$(n),4)=loc$+"O" then o$=right$(location$(n),len(location$(n))-7) next n #main.display "\";desc$ if n$<>"" then #main.display "\To the north ";n$ if s$<>"" then #main.display "\To the south ";s$ if e$<>"" then #main.display "\To the east ";e$ if w$<>"" then #main.display "\To the west ";w$ if o$<>"" then #main.display "\At your feet there is a ";o$ #main.display "\What do you want to do?" goto [awaitinput]
[data] dim location$(100) restore read d$ n=1 while d$<>"EndofData" location$(n)=d$ n=n+1 read d$ wend loc$="001" goto [displaylocation]
'whats going on here looks complicated but its not really, we number every location 'in the adventure starting with 001, You then add locations to 001, if we add another 'location North of 001 we write a data line that says 001N002 002 is the location you 'get to if you go North. Each location has a main DESC and for each directional move 'from that location we write a line explaining what we see 001N002Description. 'You can also put an object at the location with 001OBJsword. This is just one way of 'doing it, study other examples and choose one you feel comfortable with.
data, "001DESCYou are standing beside a hill in the pale evening sun." data, "001N002you spy the entrance to a cave." data, "001OBJEtar torch and a stone flint." data, "002DESCYou are in the entrance of a low cave." data, "002N005the light fades quickly in a low dank tunnel." data, "002S001is the tunnel entrance." data, "002E003you see the entrance to a guard hut." data, "002W004there is what looks like a storage room." data, "002OBJEsword" data, "003DESCThe hut is deserted but lights blink on a control panel." data, "003W002is the tunnel." data, "004DESCThe door has been forced and the storage room is empty." data, "004E005is the tunnel." data, "005DESCThe tunnel is blocked by fallen rubble." data, "005S002is the entrance to the tunnel." data, "EndofData"
|
|
|
Post by Walt Decker on Jun 25, 2022 9:41:54 GMT -5
You can also use a DLL found here or WMLiberty.dll found at bay6
|
|
|
Post by Rod on Jun 25, 2022 13:08:51 GMT -5
Yeah, a graphicbox is more than enough to get the job done. No need for callback or dll involvement especially for beginners.
|
|
|
Post by Walt Decker on Jun 25, 2022 13:41:31 GMT -5
Yeah, a graphicbox is more than enough to get the job done. No need for callback or dll involvement especially for beginners. Any LB programmer should be aware that there are tools available that will produce the desired effect the way s/he wants without resorting to work-arounds.
|
|
|
Post by Rod on Jun 25, 2022 14:57:16 GMT -5
Using a graphicbox is not a workaround, it is pure Liberty and a very powerful part of the toolset.
|
|
|
Post by Walt Decker on Jun 25, 2022 15:08:37 GMT -5
It is a work-around because it requires something the OP has not requested.
|
|
|
Post by Rod on Jun 26, 2022 3:04:17 GMT -5
I have edited my original code. The API call to force transparent text was missing. Dont spend too much time on the adventure code just concentrate on how I open a graphic resource and draw text to it. Discarding,redrawing and cursor placement for \text drawing are all shown.
|
|