Loading ...
Sorry, an error occurred while loading the content.

47158StretchBlt2

Expand Messages
  • mrossi8888
    Nov 13, 2013
    • 0 Attachment

      Dear Rod,

      I cannot get this to wrap around and form a seam.  I have pasted entire code for the game.  Just ignore the game code and try to see what is wrong with StrectchBlt.

      I appreciate it very much but if you do not hve the time I understand.

      Sincerely,

      Marc

      ' code start

      NOMAINWIN

      Menu #runner,"&Program", "&About", [whatabout]
      Menu #runner, "&Exit", "&Quit", [quit]
      dim alienboong(3,3)  ' alien ships are made in this array
      WindowWidth = 500
      WindowHeight = 700
      UpperLeftX=INT((DisplayWidth-WindowWidth)/2)
      UpperLeftY=INT((DisplayHeight-WindowHeight)/2)
      graphicbox #runner.score, 0, 0, 100, 30
      graphicbox #runner.totalnum, 400, 0, 100, 30
      open "Space Destroyer" for graphics_nf_nsb  as #runner
      print #runner, "trapclose [quit]"
      global energy
      global deadboong1
      global deadboong2

      global score
      global start
      varx = 235
      vary = 420
      energy = 4
      score = 0

      bx = 0
      by = 0
      start = 1

      ' open the dll file used for TransparentBlt
      open "msimg32.dll" for dll as #m


      print #runner, "down ; fill black"
      print #runner, "color white"
      for d = 1 to 700
      print #runner, "set ";int(rnd(0)*500);" ";int(rnd(0)*600)
      next d
      print #runner, "getbmp bmp 0 30 500 700"

              print #runner, "drawbmp bmp 500 30"
       print #runner, "getbmp bmp 10 30 500 350"


      'loadbmp "total","total.bmp"

      print #runner.score, "place 10 20 ;\Energy=";energy
      print #runner.totalnum, "place 10 20 ;\Score=";score
      times = times + 1

           'sDC is our screen buffer, (DC handle to the graphicsbox)
           sDC=GetDC(hwnd(#runner))

           'mDC is a copy of the screen in memory
           mDC=CreateCompatibleDC(sDC)

          ' select our bmp graphic resource into the memory dc
          hBitmap=hbmp("bmp")

          oldBmp=SelectObject(mDC,hBitmap)

      ' draw initial ship

      call TransparentBlt  sDC,varx,vary,125,155,mDC,585,245,155,285,0 'destination x pos ,destination y pos ,destination width desired ,destination height desired
                                             ' x location to start from source, y location to start from source,width desired from source, height desired from source

                                                                  ' blue dot is 390, 170

      shipx = varx
      shipy = vary

      ' move the ship
      print #runner, "setfocus;when characterInput [moveship]"

      [moveship]
      k$ = Inkey$
      if asc(right$(k$, 1)) = _VK_RIGHT then
      shipx=shipx + 10
      end if
      if shipx >= 450 then
      shipx = 450
      end if
      if asc(right$(k$, 1)) = _VK_LEFT then
      shipx = shipx - 10
      end if
      if shipx <= 1 then
      shipx = 1
      end if
      if asc(right$(k$, 1)) = _VK_UP then
      shipy = shipy - 10
      end if
      if shipy <= 250 then
      shipy = 250
      end if
      if asc(right$(k$, 1)) = _VK_DOWN then
      shipy = shipy  + 10
      end if
      if shipy >= 550 then
      shipy = 550
      end if
      if k$ = " " then  ' spacebar shoots weapon from spaceship
      goto [shoot]
      end if

       


      ' from inkey$
      ' move the ship

      call TransparentBlt  sDC,shipx,shipy,50,65,mDC,360,240,155,158,0 'destination x pos ,destination y pos ,destination width desired ,destination height desired
                                             ' x location to start from source, y location to start from source,width desired from source, height desired from source'destination x pos ,destination y pos ,destination width desired ,destination height desired
      shootx = shipx + 25   ' offset shoot from middle of ship
      shooty = shipy

         if times = 1 then
      gosub [enemyships]
      end if

      wait
      [enemyships]
      times = 2
      ' position 2 ships ready for battle
      ' make the enemy ships random
      for a = 1 to 2
        for b = 1 to 2
        alienboong(a,b) = int(rnd(b) * 249) + 1       ' make random spaced alien ships in 2d array
      next b
      next a

      enemyx1 = alienboong(1,1)
      enemyx2 = alienboong(2,1)
      enemyy1 = alienboong(1,2)
      enemyy2 = alienboong(2,2)
      print enemyx1
      print enemyy1
      print enemyx2
      print enemyy2

      ' position of enemy ships
      ' make enemy bombs
      call TransparentBlt  sDC, enemyx1,enemyy1,75,80,mDC,80,200,210,180,0 'destination x pos ,destination y pos ,destination width desired ,destination height desired
                                             ' x location to start from source, y location to start from source,width desired from source, height desired from source
      call TransparentBlt  sDC, enemyx2,enemyy2,75,80,mDC,80,200,210,180,0 'destination x pos ,destination y pos ,destination width desired ,destination height desired
                                             ' x location to start from source, y location to start from source,width desired from source, height desired from source

      mox = enemyx1
      moy = enemyy1 + 50
      mox2 = enemyx2
      moy2 = enemyy2 + 50

      timer 50,  [movement]

      [movement]
      ' move the background

      y = y - 1
      newy=abs(y)
      if newy = 350 then y=30

      call StretchBlt sDC,0,30,500,700,mDC,0,y,500,350  'destination x pos 'destination y pos destination width desired 'destination height desired
                                                'source 'x location to start from source 'y location to start from source 'width desired from source 'height desired from source 'dwRasterOperation
      wait


      ' make the enemy shoot its bombs ********************************************************************************************************************************
      'print #runner, "backgroundxy ";bx;" ";by
      by = by - 3

      moy=moy+10
      moy2=moy2+10


      if moy>=900 or moy2 >= 900 then
       mox = enemyx1
      mox2 = enemyx2
      moy = enemyy1 + 50
      moy2 = enemyy2 + 50
      end if

       


      call TransparentBlt,sDC,mox,moy,20,25,mDC,390, 170,78,78,0  'destination x pos ,destination y pos ,destination width desired ,destination height desired
                                      ' x location to start from source, y location to start from source,width desired from source, height desired from source
                                    ' color to make transparent 0=Black

      call TransparentBlt,sDC,mox2,moy2,20,25,mDC,390, 170,78,78,0 'destination x pos ,destination y pos ,destination width desired ,destination height desired
                                      ' x location to start from source, y location to start from source,width desired from source, height desired from source
                                    ' color to make transparent 0=Black

      'wait
      [shoot]
      call TransparentBlt  sDC,shootx,shooty,10,25,mDC,425,100,35,35,0 'destination x pos ,destination y pos ,destination width desired ,destination height desired
      shooty = shooty - 20                     ' x location to start from source, y location to start from source,width desired from source, height desired from source
      call TransparentBlt  sDC,shootx,shooty,10,25,mDC,425,100,35,35,0 'destination x pos ,destination y pos ,destination width desired ,destination height desired
                                          ' x location to start from source, y location to start from source,width desired from source, height desired from source

      wait
      Function GetDC(hWnd)
          CallDLL #user32, "GetDC",_
              hWnd As ulong,_  'window or control handle
              GetDC As ulong   'returns device context
          End Function

      Sub ReleaseDC hWnd, hDC
          CallDLL#user32,"ReleaseDC",_
              hWnd As ulong,_  'window or control handle
              hDC As ulong,_   'handle of DC to delete
              result As Long
          End Sub

      Function CreateCompatibleDC(hDC)
          CallDLL #gdi32,"CreateCompatibleDC",_
              hDC As ulong,_               'window DC
              CreateCompatibleDC As ulong  'memory DC
          End Function

      Sub DeleteDC hDC
          CallDLL #gdi32, "DeleteDC",_
          hDC As ulong,_   'memory DC to delete
          r As Boolean
          End Sub

      Sub StretchBlt hDCdest,x,y,w,h,hDCsrc,x2,y2,w2,h2
          CallDLL #gdi32, "SetStretchBltMode",_
              hDCdest As ulong,_       'device context
              _COLORONCOLOR As Long,_ 'color reduction mode
              RESULT As Long
          CallDLL #gdi32, "StretchBlt",_
              hDCdest As ulong,_   'destination
              x As Long,_         'destination x pos
              y As Long,_         'destination y pos
              w As Long,_         'destination width desired
              h As Long,_         'destination height desired
              hDCsrc As ulong,_    'source
              x2 As Long,_        'x location to start from source
              y2 As Long,_        'y location to start from source
              w2 As Long,_        'width desired from source
              h2 As Long,_        'height desired from source
              _SRCCOPY As long,_ 'dwRasterOperation
              RESULT As Boolean
          End Sub

      Sub TransparentBlt hDCdest,x,y,w,h,hDCsrc,x2,y2,w2,h2,crTransparent
          calldll #m, "TransparentBlt",_
              hDCdest As uLong,_  'destination
              x As Long,_         'destination x pos
              y As Long,_         'destination y pos
              w As Long,_         'destination width desired
              h As Long,_         'destination height desired
              hDCsrc As uLong,_    'source
              x2 As Long,_        'x location to start from source
              y2 As Long,_        'y location to start from source
              w2 As Long,_        'width desired from source
              h2 As Long,_        'height desired from source
              crTransparent as ulong,_ 'color to make transparent 0=Black
              result as boolean
          end sub


      Function SelectObject(hDC,hObject)
          CallDLL #gdi32,"SelectObject",_
              hDC As ulong,_        'memory device context
              hObject As long,_    'handle of object
              SelectObject As long 'returns previously selected object
          End Function

       

       

       

      wait
      [whatabout]


      notice "Space Destroyer" + chr$(13)  + chr$(13); "     By m f r   2013"


      wait
      [quit]
      unloadbmp "total"
      call ReleaseDC hwnd(#runner), gDC
      call DeleteDC mDC
      close #runner
      close #m
      end  ' end program


      ' code end

    • Show all 2 messages in this topic