TileImage.htm 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <html>
  2. <head>
  3. <title>Blitz3D Docs</title>
  4. <link rel=stylesheet href=../css/commands.css type=text/css>
  5. </head>
  6. <body>
  7. <h1>TileImage handle,[x],[y],[frames]</h1>
  8. <h1>Parameters</h1>
  9. <table>
  10. <tr>
  11. <td>
  12. handle= variable holding the image's handle <br />
  13. x=starting x location of the tile; assumed 0 <br />
  14. y=starting y location of the tile; assumed 0 <br />
  15. frames=the frame of the image to tile; optional with imagestrip
  16. </td>
  17. </tr>
  18. </table>
  19. <h1>Description</h1>
  20. <table>
  21. <tr>
  22. <td>
  23. If you want to make a starfield or other easy tiled background, this is YOUR command. All you have to do is specify the image handle (an image loaded with the LoadImage or LoadAnimImage command). Optionally, you can specify a starting x and y location, as well as an optional frame. You can milk some serious parallax effects with a simple imagestrip with a couple of various starfields and the TileImage command.
  24. </td>
  25. </tr>
  26. </table>
  27. <h1><a href=../2d_examples/TileImage.bb>Example</a></h1>
  28. <table>
  29. <tr>
  30. <td>
  31. ; CreateImage/TileImage/ImageBuffer example <br />
  32. <br />
  33. ; Again, we'll use globals even tho we don't need them here <br />
  34. ; One variable for the graphic we'll create, one for a timer <br />
  35. Global gfxStarfield, tmrScreen <br />
  36. <br />
  37. ; Declare graphic mode <br />
  38. Graphics 640,480,16 <br />
  39. <br />
  40. ; Create a blank image that is 320 pixels wide and 32 high with 10 frames of 32x32 <br />
  41. gfxStarfield=CreateImage(32,32,10) <br />
  42. <br />
  43. ; loop through each frame of the graphic we just made <br />
  44. For t = 0 To 9 <br />
  45. ; Set the drawing buffer to the graphic frame so we can write on it <br />
  46. SetBuffer ImageBuffer(gfxStarfield,t) <br />
  47. ; put 50 stars in the frame at random locations <br />
  48. For y = 1 To 50 <br />
  49. Plot Rnd(32),Rnd(32) <br />
  50. Next <br />
  51. Next <br />
  52. <br />
  53. ; Double buffer mode for smooth screen drawing <br />
  54. SetBuffer BackBuffer() <br />
  55. <br />
  56. ; Loop until ESC is pressed <br />
  57. While Not KeyHit(1) <br />
  58. <br />
  59. ; Only update the screen every 300 milliseconds. Change 300 for faster or <br />
  60. ; slower screen updates <br />
  61. If MilliSecs() > tmrScreen+300 Then <br />
  62. Cls ; clear the screen <br />
  63. <br />
  64. ; Tile the screen with a random frame from our new graphic starting at <br />
  65. ; x=0 and y=0 location. <br />
  66. TileImage gfxStarfield,0,0,Rnd(9) <br />
  67. Flip ; Flip the screen into view <br />
  68. tmrScreen=MilliSecs() ; reset the time <br />
  69. End If <br />
  70. Wend <br />
  71. </td>
  72. </tr>
  73. </table>
  74. <br>
  75. <a target=_top href=../index.htm>Index</a><br>
  76. <br>
  77. Click <a href=http://www.blitzbasic.co.nz/b3ddocs/command.php?name=TileImage&ref=comments target=_blank>here</a> to view the latest version of this page online</body>
  78. </html>