Advertisement
hihelloo

hihello2

Nov 26th, 2023
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
QBasic 2.93 KB | Software | 0 0
  1. CLS
  2. SCREEN _NewImage(1920, 1080, 8)
  3. _FullScreen _SquarePixels
  4.  
  5. DIM SHARED particlex
  6. DIM SHARED particley
  7. DIM SHARED particler
  8.  
  9.  
  10. DO
  11.     PCOPY _Display, 1
  12.     LINE (10, 10)-(130, 30), 11, B
  13.     IF particles < 2 THEN
  14.         LOCATE 3, 3
  15.         PRINT "PLACE PLANET "
  16.     ELSE
  17.         LOCATE 3, 3
  18.         PRINT "PLANET PLACED"
  19.     END IF
  20.  
  21.     _Display
  22.     PCOPY 1, _Display
  23.  
  24.     WHILE _MouseInput
  25.         IF _MouseX >= 10 AND _MouseY >= 10 AND _MouseX <= 120 AND _MouseY <= 30 AND _MouseButton(1) = -1 THEN
  26.             PCOPY _Display, 1
  27.             IF particles < 2 THEN
  28.                 particles = particles + 1
  29.                 placeplanet 4, particles
  30.             ELSE
  31.                 LOCATE 3, 3
  32.                 PRINT "MAX PLACED   "
  33.                 SLEEP 2
  34.             END IF
  35.             _Display
  36.             PCOPY 1, _Display
  37.         END IF
  38.     WEND
  39. LOOP UNTIL INKEY$ = CHR$(27)
  40. SYSTEM
  41.  
  42. SUB placeplanet (radius, particles)
  43.     drawn = 0
  44.     DO
  45.         PCOPY _Display, 1
  46.         LINE (10, 10)-(130, 30), 11, B
  47.         LOCATE 3, 3
  48.         PRINT "PLACE PLANET"
  49.         LOCATE 3, 20
  50.         PRINT radius
  51.         PRINT particlex
  52.         PRINT particley
  53.         PRINT particler
  54.         PRINT distance
  55.         PRINT xCenter
  56.         PRINT yCenter
  57.  
  58.         DrawCircle xCenter, yCenter, radius
  59.         _Display
  60.         PCOPY 1, _Display
  61.         WHILE _MouseInput
  62.  
  63.             xCenter = _MouseX
  64.             yCenter = _MouseY
  65.             IF particles >= 2 THEN
  66.                 distance = ((ABS(xCenter - particlex)) ^ 2 + (ABS(yCenter - particley)) ^ 2) ^ (1 / 2)
  67.                 IF distance >= particler + radius THEN
  68.                     prev_xCenter = xCenter
  69.                     prev_yCenter = yCenter
  70.                     prev_radius = radius
  71.                 END IF
  72.  
  73.                 IF distance < particler + radius + 2 THEN
  74.                     xCenter = prev_xCenter
  75.                     yCenter = prev_yCenter
  76.                     radius = prev_radius
  77.                 END IF
  78.             END IF
  79.  
  80.             IF particles = 1 THEN
  81.                 particlex = _MouseX
  82.                 particley = _MouseY
  83.                 particler = radius
  84.             END IF
  85.  
  86.  
  87.  
  88.             IF radius < 1 THEN
  89.                 radius = 1
  90.             ELSEIF radius > 450 THEN
  91.                 radius = 450
  92.             ELSEIF _MouseWheel = -1 THEN
  93.                 radius = radius + 2
  94.             ELSEIF _MouseWheel = 1 THEN
  95.                 radius = radius - 2
  96.             ELSEIF _MouseButton(2) = -1 THEN
  97.  
  98.                 DrawCircle xCenter, yCenter, radius
  99.                 drawn = 1
  100.  
  101.             END IF
  102.         WEND
  103.     LOOP UNTIL INKEY$ = CHR$(27) OR drawn = 1
  104. END SUB
  105.  
  106. SUB DrawCircle (xCenter, yCenter, radius)
  107.     FOR angle = 1 TO 720
  108.         radians = angle * (_Pi / 360)
  109.         x = xCenter + radius * COS(radians)
  110.         y = yCenter + radius * SIN(radians)
  111.         PSET (x, y), _RGB(255, 0, 0)
  112.     NEXT angle
  113. END SUB
  114.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement