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

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