BBC BASIC for Windows
Programming >> Graphics and Games >> Graphics Window For Text Adventure
http://bb4w.conforums.com/index.cgi?board=graphics&action=display&num=1294479584

Graphics Window For Text Adventure
Post by Ironman on Jan 8th, 2011, 08:39am

Hello, can somebody please tell me how to place an image (jpg or whatever) in a window with a text input/output window below for a graphic/text adventure game.
Any help would me much appreciated.
smiley
Re: Graphics Window For Text Adventure
Post by admin on Jan 8th, 2011, 11:35am

on Jan 8th, 2011, 08:39am, Ironman wrote:
Hello, can somebody please tell me how to place an image (jpg or whatever) in a window with a text input/output window below for a graphic/text adventure game.

Here's an example of doing that when the image is a BMP file:

Code:
      WindowWidth% = 640
      WindowHeight% = 512
      CharWidth% = 8
      CharHeight% = 16
      TextRows% = 4
      Image$ = "C:\Windows\Web\Wallpaper\Bliss.bmp"
      
      REM Setup the window:
      VDU 23,22,WindowWidth%;WindowHeight%;CharWidth%,CharHeight%,16,128
      
      REM Create a text viewport at the bottom:
      VDU 28,0,WindowHeight%/CharHeight%-1,WindowWidth%/CharWidth%-1, \
      \   WindowHeight%/CharHeight%-TextRows%
      
      REM Display the image at the top:
      SYS "SetStretchBltMode", @memhdc%, 4
      OSCLI "DISPLAY """ + Image$ + """ 0,"+STR$(TextRows%*CharHeight%*2) + "," + \
      \ STR$(WindowWidth%*2) + "," + STR$(WindowHeight%*2-TextRows%*CharHeight%*2)
      
      REM Output some text:
      PRINT "This is some text" 

If the image is a JPG you'll need to use the code listed in the Help documentation:

http://www.bbcbasic.co.uk/bbcwin/manual/bbcwine.html#gifjpeg

Richard.
Re: Graphics Window For Text Adventure
Post by Ironman on Jan 8th, 2011, 1:39pm

Thankyou so much Richard. I've copied the listing you gave me and will be experimenting with it. smiley