Author Topic: Steering wheel  (Read 4330 times)

0 Members and 1 Guest are viewing this topic.

FellippeHeitor

  • Guest
Steering wheel
« on: July 16, 2018, 08:12:03 pm »
I don't know what this will be used for (or if it will) but it's fun to run for now:

Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(600, 600, 32)
  2.  
  3.     CLS
  4.     PRINT a
  5.     CircleFill _WIDTH / 2, _HEIGHT / 2, 250, _RGB32(map(a, -_PI, _PI, 0, 255), 0, map(a, -_PI, _PI, 255, 0))
  6.     CircleFill _WIDTH / 2 + COS(a - (_D2R(90))) * 200, _HEIGHT / 2 + SIN(a - (_D2R(90))) * 200, 5, _RGB32(255, 255, 255)
  7.  
  8.     IF _KEYDOWN(19200) THEN 'left
  9.         a = a - .1
  10.     END IF
  11.  
  12.     IF _KEYDOWN(19712) THEN 'right
  13.         a = a + .1
  14.     END IF
  15.  
  16.     IF a > 0 THEN a = a - map(a, 0, _PI, .01, .1)
  17.     IF a < 0 THEN a = a + map(a, 0, -_PI, .01, .1)
  18.  
  19.     _DISPLAY
  20.     _LIMIT 60
  21.  
  22. FUNCTION map! (value!, minRange!, maxRange!, newMinRange!, newMaxRange!)
  23.     map! = ((value! - minRange!) / (maxRange! - minRange!)) * (newMaxRange! - newMinRange!) + newMinRange!
  24.  
  25. SUB CircleFill (x AS LONG, y AS LONG, R AS LONG, C AS _UNSIGNED LONG)
  26.     x0 = R
  27.     y0 = 0
  28.     e = 0
  29.     DO WHILE y0 < x0
  30.         IF e <= 0 THEN
  31.             y0 = y0 + 1
  32.             LINE (x - x0, y + y0)-(x + x0, y + y0), C, BF
  33.             LINE (x - x0, y - y0)-(x + x0, y - y0), C, BF
  34.             e = e + 2 * y0
  35.         ELSE
  36.             LINE (x - y0, y - x0)-(x + y0, y - x0), C, BF
  37.             LINE (x - y0, y + x0)-(x + y0, y + x0), C, BF
  38.             x0 = x0 - 1
  39.             e = e - 2 * x0
  40.         END IF
  41.     LOOP
  42.     LINE (x - R, y)-(x + R, y), C, BF

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Steering wheel
« Reply #1 on: July 17, 2018, 12:00:25 am »
  • Best Answer
  • Interesting, like it's spring loaded and self righting.