Author Topic: Sound Horns Display  (Read 977 times)

0 Members and 1 Guest are viewing this topic.

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Sound Horns Display
« on: June 05, 2020, 09:21:16 pm »
There's no sound here, but I decided to check out cones today and what I can do with them. So I figured out how to make that sound horn animation of horns increasing in size going toward 4 different corners of the screen at different times. This might be good with a sound program you make or anything like that.

Code: QB64: [Select]
  1. 'Sound Horns  by Sierraken
  2. 'On June 5, 2020.
  3. 'Feel free to use any of this on your apps.
  4. _TITLE "Sound Horns - by Sierraken"
  5. SCREEN _NEWIMAGE(800, 600, 32)
  6.  
  7. start:
  8. a$ = INKEY$
  9. IF a$ = CHR$(27) THEN END
  10. s = 0
  11. xx = 400
  12. yy = 300
  13. 'Choose size of cone.
  14. dd = INT(RND * 20) + 10
  15. 'Choose direction of cone.
  16. dd2 = INT(RND * 4) + 1
  17. IF dd2 = 1 THEN st = -.0625: dd = -dd
  18. IF dd2 = 2 THEN st = -.0625: dd = -dd
  19. IF dd2 = 3 THEN st = .0625: dd = dd
  20. IF dd2 = 4 THEN st = .0625: dd = dd
  21. 'Choose color of cone.
  22. cl1 = INT(RND * 200) + 55
  23. cl2 = INT(RND * 200) + 55
  24. cl3 = INT(RND * 200) + 55
  25.  
  26. go:
  27. IF dd < 0 THEN dd = dd - 20
  28. IF dd >= 0 THEN dd = dd + 20
  29. 'Calculate and draw cone.
  30. FOR d = 0 TO dd STEP st
  31.     s = s + 3
  32.     x = COS(s * 3.141592 / 180) * d + d
  33.     y = SIN(s * 3.151492 / 180) * d - d
  34.     IF dd2 = 1 THEN x = x: y = y
  35.     IF dd2 = 2 THEN x = -x: y = -y
  36.     IF dd2 = 3 THEN x = x: y = -y
  37.     IF dd2 = 4 THEN x = -x: y = y
  38.     CIRCLE (x + xx, y + yy), 2, _RGB32(cl1, cl2, cl3)
  39. _DELAY .075
  40. IF dd > 100 OR dd < -100 THEN
  41.     dd = 0
  42.     GOTO start:
  43.