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

  1. ;demo07-05.bb - Demonstrates Scaling Lines in a downward fashion.
  2.  
  3. Graphics 1024,768 ;set up graphics
  4.  
  5.  
  6.  
  7. ;STRUCTURES
  8. ;The point type defines a single local coordinate position
  9. Type point
  10.     Field x,y
  11. End Type 
  12.  
  13. ;Create the three vertices of the triangle
  14. point1.point = New point
  15. point2.point = New point
  16. point3.point = New point
  17.  
  18.  
  19.  
  20.  
  21. ;VARIABLES
  22. ;These variables define each vertex and are in local coordinates
  23. point1\x= 0
  24. point1\y= 0
  25. point2\x= 100
  26. point2\y= 100
  27. point3\x= -100
  28. point3\y = 100
  29.  
  30. ;CONSTANTS
  31. ;The global indicators that is added to each local coordinate to place it on screen
  32. Const xs = 512
  33. Const ys = 284
  34.  
  35.  
  36. ;MAIN SECTION
  37. ;Make sure text appears at bottom of screen
  38. Locate 0,700
  39. Print "This is our first triangle." 
  40.  
  41. ;Draw out first triangle
  42. Line point1\x + xs, point1\y + ys, point2\x + xs, point2\y + ys
  43. Line point2\x + xs, point2\y + ys, point3\x + xs, point3\y + ys
  44. Line point3\x + xs, point3\y + ys, point1\x + xs, point1\y + ys
  45.  
  46.  
  47. ;Find scaling factor from user
  48. sxy# = Input ("What would you like the scaling factor to be? (Ex: 50% = .5)? ==> ") 
  49.  
  50. ;Multiply all the coordinates by the scaling factor
  51. point1\x = point1\x * sxy#
  52. point1\y = point1\y * sxy#
  53. point2\x = point2\x * sxy#
  54. point2\y = point2\y * sxy#
  55. point3\x = point3\x * sxy#
  56. point3\y = point3\y * sxy#
  57.     
  58.  
  59.  
  60. ;Change the default color to green
  61. Color 0,255,0
  62.  
  63. ;Draw final triangle (with scaled coordinates) in green
  64. Line point1\x + xs, point1\y + ys, point2\x + xs, point2\y + ys
  65. Line point2\x + xs, point2\y + ys, point3\x + xs, point3\y + ys
  66. Line point3\x + xs, point3\y + ys, point1\x + xs, point1\y + ys
  67.  
  68. Print "Press any key to exit." 
  69.  
  70. ;Wait for user to press a key before exiting
  71. WaitKey