home *** CD-ROM | disk | FTP | other *** search
/ Game Programming for Teens / GameProgrammingForTeens.iso / Source / chapter07 / demo07-08.bb < prev    next >
Encoding:
Text File  |  2003-04-06  |  1.5 KB  |  67 lines

  1. ;demo07-08.bb - Demonstrates Scaling with ScaleImage
  2. Graphics 1024,768 
  3.  
  4. ;Make sure AutoMidHandle is true
  5. AutoMidHandle True
  6.  
  7. ;STRUCTURES
  8. ;The point structure defines one coordinate point
  9. Type point
  10.     Field x,y
  11. End Type 
  12.  
  13. ;Create the three vertices
  14. point1.point = New point
  15. point2.point = New point
  16. point3.point = New point
  17.  
  18.  
  19.  
  20.  
  21. ;VARIABLES
  22. ;These variables are in local coordinates and define the positions of the vertices
  23. point1\x= 100
  24. point1\y= 0
  25. point2\x= 200
  26. point2\y= 200
  27. point3\x= 0
  28. point3\y = 200
  29.  
  30. ;Create a buffer with the proper height and width
  31. image = CreateImage( (point2\x - point3\x) + 1, (point2\y - point1\y) + 1 )
  32.  
  33.  
  34. ;MAIN SECTION
  35.  
  36. ;Place text at bottom left of screen
  37. Locate 0,700 
  38. Print "This is our first triangle." 
  39.  
  40. ;Set default buffer to the image we created so that we can draw the triangle directly to it
  41. SetBuffer ImageBuffer(image)
  42.  
  43. ;Draw the triangle on the new buffer
  44. Line point1\x, point1\y, point2\x, point2\y
  45. Line point2\x, point2\y, point3\x, point3\y
  46. Line point3\x, point3\y, point1\x, point1\y
  47.  
  48. ;Go back to front buffer
  49. SetBuffer FrontBuffer()
  50.  
  51. ;Draw the image centered on screen
  52. DrawImage image,512,384
  53.  
  54.  
  55. ;Find the scaling factor
  56. sxy# = Input ("What would you like the scaling factor to be? (Ex: 50% = .5)? ==> ") ;What is the scaling factor
  57.  
  58. ;Scale the image by its scaling factos
  59. ScaleImage image,sxy#,sxy#
  60.  
  61.  
  62. ;Draw the new image
  63. DrawImage image,512,384
  64.  
  65. Print "Press any key to exit." 
  66. ;Wait for a key before exiting
  67. WaitKey