Author Topic: Fire Vortex 🔥  (Read 3316 times)

0 Members and 1 Guest are viewing this topic.

Offline loudar

  • Newbie
  • Posts: 73
  • improve it bit by bit.
    • View Profile
Fire Vortex 🔥
« on: August 28, 2020, 09:51:26 am »
It goes up.

Code: QB64: [Select]
  1. REM Fire Vortex
  2.  
  3. SCREEN _NEWIMAGE(1280, 720, 32)
  4.  
  5. 'global
  6. time = 0
  7. gravity = -1
  8. originx = _WIDTH / 2
  9. originy = _HEIGHT
  10. xspread = 30
  11. yspread = 50
  12. sinstretch = 50
  13. 'pulltoorigin = 0.2 '1 is no pull, below 1 is towards, above one is away
  14.  
  15. TYPE particle
  16.     ox AS _FLOAT 'origin x
  17.     oy AS _FLOAT 'origin y
  18.     x AS _FLOAT 'current x
  19.     y AS _FLOAT 'current y
  20.     w AS _FLOAT 'size
  21.     s AS _FLOAT 'speed
  22.     c AS _UNSIGNED LONG 'color
  23.     d AS _FLOAT 'deviation
  24.     f AS _FLOAT 'falloff
  25. REDIM SHARED maxparticles
  26. maxparticles = 10000
  27. REDIM SHARED p(maxparticles) AS particle
  28.  
  29. particle = 0: DO: particle = particle + 1
  30.     r = RND * xspread
  31.     r = (r / xspread) * (r / xspread) * xspread
  32.     flip = INT(RND * 2)
  33.     IF flip = 1 THEN r = -r
  34.     p(particle).ox = r
  35.  
  36.     r = RND * yspread
  37.     r = (r / yspread) * (r / yspread) * yspread
  38.     r = (1 - ((r / yspread) * (r / yspread))) * yspread
  39.     p(particle).oy = r
  40.     p(particle).w = 1
  41.     p(particle).s = (RND * 2)
  42.     p(particle).c = _RGBA(255, 0 + (RND * 140), 0, RND * 255)
  43.     p(particle).d = (xspread * 2) + ((RND * (xspread / 5)) - (xspread / 10))
  44.     p(particle).f = 100 + (RND * 50)
  45. LOOP UNTIL particle = maxparticles
  46.  
  47.     time = time + 1
  48.     CLS
  49.     particle = 0: DO: particle = particle + 1
  50.         dif = (p(particle).y - p(particle).oy)
  51.         IF dif < 0 THEN dif = -dif
  52.         pulltoorigin = (dif * (xspread * xspread / 10000) / (xspread / 2))
  53.         'pulltoorigin = 1
  54.         dev = p(particle).d * (p(particle).f / dif)
  55.         sinoffset = ((p(particle).ox / xspread) * _PI * 2)
  56.         p(particle).x = originx + ((p(particle).ox + (SIN((dif / sinstretch) - sinoffset) * dev)) * pulltoorigin)
  57.         p(particle).y = originy + p(particle).oy + (p(particle).s * time * gravity)
  58.         div = p(particle).x - originx
  59.         IF div < 0 THEN div = -div
  60.         'p(particle).c = _RGBA(_RED(p(particle).c), _GREEN(p(particle).c), _BLUE(p(particle).c), 255 * (1 - (div / (xspread / 2))))
  61.         CIRCLE (p(particle).x, p(particle).y), p(particle).w, p(particle).c
  62.     LOOP UNTIL particle = maxparticles
  63.     _DISPLAY
  64.     _LIMIT 60
  65. LOOP UNTIL Taste$ = CHR$(27)
Check out what I do besides coding: http://loudar.myportfolio.com/

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Fire Vortex 🔥
« Reply #1 on: August 28, 2020, 01:05:51 pm »
That's pretty cool!

Thanks for screen dimensions that don't exceed my screen :)

Offline loudar

  • Newbie
  • Posts: 73
  • improve it bit by bit.
    • View Profile
Re: Fire Vortex 🔥
« Reply #2 on: August 28, 2020, 01:42:19 pm »
@bplus I have learned! :p
Check out what I do besides coding: http://loudar.myportfolio.com/