Author Topic: RGB Firework  (Read 2032 times)

0 Members and 1 Guest are viewing this topic.

Peter

  • Guest
RGB Firework
« on: December 06, 2015, 12:29:05 PM »
Hello,
Code: [Select]
include "asm.inc"
window 640,480,1
SetFrames 12

LoadSprite "bmp/e5x.bmp",5
LoadSprite "bmp/b5x.bmp",5
LoadSprite "bmp/c5x.bmp",5

Type STARS
  sys x, y
End Type
STARS s[200]

for j=0 to 200
    s[j].x = rand(0,639)
    s[j].y = rand(0,479)
next

int z[16], zx[16], zy[16]
int b[16], bx[16], by[16]
int c[16], cx[16], cy[16]

for i=0 to <16
    z [i] = rand(0, 4)  : b [i]  = rand(0, 4) : c [i] = rand(0, 4)
    zx[i] = rand(0,512) : bx[i] = rand(0,512) : cx[i] = rand(0,512)
    zy[i] = rand(0,352) : by[i] = rand(0,352) : cy[i] = rand(0,352)
next

while key(27)=0
cls 0,0,0
for j=0 to <200
    color j+55,j+55,j+55
    fillcircle s[j].x, s[j].y, 4
next
for i=0 to <16
    Sprite 1,zx[i],zy[i],128,128,z[i]
    Sprite 2,bx[i],by[i],128,128,b[i]
    Sprite 3,cx[i],cy[i],128,128,c[i]
next

for i=0 to <16
    z[i] +=1
    b[i] +=1
    c[i] +=1
    if z [i] = 5
       z [i] = 0
       zx[i] = rand(0,512)
       zy[i] = rand(0,352)
    end if
    if b [i] = 5
       b [i] = 0
       bx[i] = rand(0,512)
       by[i] = rand(0,352)
    end if
    if c [i] = 5
       c [i] = 0
       cx[i] = rand(0,512)
       cy[i] = rand(0,352)
    end if
next   
text 210,8,14,"RGB FIREWORK"
sync()
wend
winEnd

.

Mike Lobanovsky

  • Guest
Re: RGB Firework
« Reply #1 on: December 06, 2015, 03:19:12 PM »
Hi Peter,

I'm not exactly sure how your SetFrames() and Sync() work but your fireworks can be emulated more or less exactly with the following FBSL code:

Code: OxygenBasic
  1. ' !!! FBSL BASIC !!!
  2. #Option  Implicit
  3. #Include "mingfx.inc"
  4.  
  5. width  = 640
  6. height = 480
  7.  
  8. ns = 200: nf = width \ 40
  9. delay = 0.4
  10.  
  11. red = LoadSprite("sprite\e5x.bmp", 480, 96, 5)
  12. grn = LoadSprite("sprite\c5x.bmp", 480, 96, 5)
  13. blu = LoadSprite("sprite\b5x.bmp", 480, 96, 5)
  14.  
  15. Dim stars[0 To ns, 0 To 1]
  16. For i = 0 To ns
  17.   stars[i, 0] = Rnd() * width
  18.   stars[i, 1] = Rnd() * height
  19. Next
  20.  
  21. Dim %z[nf], zx[nf], zy[nf]
  22. Dim %b[nf], bx[nf], by[nf]
  23. Dim %c[nf], cx[nf], cy[nf]
  24. For i = 0 To nf
  25.   z [i] = Rnd() * 4: b[i] = Rnd() * 4: c[i] = Rnd() * 4
  26.   zx[i] = Rnd() * (width  - 128): bx[i] = Rnd() * (width  - 128): cx[i] = Rnd() * (width  - 128)
  27.   zy[i] = Rnd() * (height - 128): by[i] = Rnd() * (height - 128): cy[i] = Rnd() * (height - 128)
  28. Next
  29.  
  30. Window(width, height, FALSE, "Peter's Fireworks")
  31.  
  32. Animate
  33.   Screen(0, 0, 0)
  34.   For j = 0 To ns
  35.     Ink(j + 55, j + 55, j + 55)
  36.     FillCircle(stars[j, 0], stars[j, 1], 4)
  37.   Next
  38.   For i = 0 To nf
  39.     DrawSprite(red, zx[i], zy[i], 128, 128, z[i])
  40.     DrawSprite(grn, bx[i], by[i], 128, 128, b[i])
  41.     DrawSprite(blu, cx[i], cy[i], 128, 128, c[i])
  42.   Next
  43.   If Incr(delay, 0.1) > 0.4 Then
  44.     delay = 0.0
  45.     For i = 0 To nf
  46.       z[i] = z[i] + 1
  47.       b[i] = b[i] + 1
  48.       c[i] = c[i] + 1
  49.       If z[i] = 5 Then
  50.         z [i] = 0
  51.         zx[i] = Rnd() * (width  - 128)
  52.         zy[i] = Rnd() * (height - 128)
  53.       End If
  54.       If b[i] = 5 Then
  55.         b [i] = 0
  56.         bx[i] = Rnd() * (width  - 128)
  57.         by[i] = Rnd() * (height - 128)
  58.       End If
  59.       If c[i] = 5 Then
  60.         c [i] = 0
  61.         cx[i] = Rnd() * (width  - 128)
  62.         cy[i] = Rnd() * (height - 128)
  63.       End If
  64.     Next
  65.   End If
  66.   Message(width \ 2 - 100, 8, 14, "RGB FIREWORK", &HFFFFFF)
  67.   Redraw()
  68.   Wait(10)
  69. Forever

.