Author Topic: Four Animated Scenes  (Read 1200 times)

0 Members and 1 Guest are viewing this topic.

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Four Animated Scenes
« on: June 18, 2020, 08:44:29 pm »
Today I made four animated scenes. One shows a television's static, one shows a river, one shows a pond, and one shows snow falling down. Thanks for B+ for the array teaching from the space warp I did the other day. I used that information to make the falling snow but geared it my own way some. Press the space bar to see each one. After the 4th one it goes back to the 1st.

Code: QB64: [Select]
  1. 'Four Animated Scenes
  2. 'By Sierraken on June 18, 2020.
  3. 'Press the Space Bar to see each one.
  4. 'Thanks to B+ for teaching me more about arrays.
  5.  
  6. SCREEN _NEWIMAGE(800, 600, 32)
  7. _TITLE "Press space bar to see more."
  8. nSnow = 32
  9. DIM x(1 TO nSnow), y(1 TO nSnow), s(1 TO nSnow), speed(1 TO nSnow)
  10.  
  11. start:
  12. 'One: Television
  13.     fx2 = fx2 + 1
  14.     IF fx2 > 5 THEN fx2 = 1
  15.     FOR fy = 100 TO 300
  16.         FOR fx = 300 TO 500
  17.             IF tt = 0 THEN t = t + 1
  18.             IF t > 10 THEN tt = 1
  19.             IF tt = 1 THEN t = t - 1
  20.             IF t < -10 THEN tt = 0
  21.             PSET ((SIN(fy * 0.017453 / fx2) * t) + fx, (SIN(fx * 0.017453 / fx2) * t) + fy), _RGB32(200, 200, 200)
  22.         NEXT fx
  23.     NEXT fy
  24.     FOR tv = 0 TO 30
  25.         LINE (300 - tv, 100 - tv)-(500 + tv, 300 + tv), _RGB32(150, 127, 0), B
  26.     NEXT tv
  27.     FOR sz = .25 TO 4 STEP .25
  28.         CIRCLE (450, 315), sz, _RGB32(0, 0, 0)
  29.         CIRCLE (475, 315), sz, _RGB32(0, 0, 0)
  30.     NEXT sz
  31.     LINE (390, 330)-(410, 380), _RGB32(150, 127, 0), BF
  32.     LINE (330, 380)-(470, 400), _RGB32(150, 127, 0), BF
  33.     _DISPLAY
  34.     CLS
  35.     a$ = INKEY$
  36.     IF a$ = CHR$(27) THEN END
  37.     IF a$ = " " THEN GOTO two:
  38. two:
  39. fx2 = 0
  40. t = 0: tt = 0
  41.  
  42. 'Two: Creek
  43.     _LIMIT 15
  44.     LINE (0, 0)-(800, 300), _RGB32(0, 150, 255), BF
  45.     LINE (0, 300)-(800, 600), _RGB32(0, 255, 172), BF
  46.     LINE (0, 400)-(800, 550), _RGB32(127, 172, 255), BF
  47.     FOR hills = 1 TO 800 STEP 150
  48.         FOR sz = .25 TO 125 STEP .25
  49.             hc = hc + .25
  50.             CIRCLE (hills, 300), sz, _RGB32(0, 255 - hc, 0), 2 * _PI, _PI
  51.         NEXT sz
  52.         hc = 0
  53.     NEXT hills
  54.     fx2 = fx2 + 2
  55.     IF fx2 > 5 THEN fx2 = 1
  56.     FOR fy = 400 TO 550
  57.         FOR fx = 1 TO 800
  58.             IF tt = 0 THEN t = t + .2
  59.             IF t > 8 THEN tt = 1
  60.             IF tt = 1 THEN t = t - .2
  61.             IF t < -8 THEN tt = 0
  62.             PSET ((SIN(fy * 2.017453 / fx2) * t) + fx, (SIN(fx * 4.017453 / fx2) * t) + fy), _RGB32(20, 80, 255)
  63.         NEXT fx
  64.     NEXT fy
  65.     _DISPLAY
  66.     CLS
  67.     a$ = INKEY$
  68.     IF a$ = CHR$(27) THEN END
  69.     IF a$ = " " THEN GOTO three:
  70. three:
  71. fx2 = 0
  72. t = 0: tt = 0
  73.  
  74. 'Three: Pond
  75. tt = 1
  76. t = 155
  77. LINE (0, 300)-(800, 600), _RGB32(0, 255, 172), BF
  78. LINE (0, 0)-(800, 300), _RGB32(0, 150, 255), BF
  79. FOR hills = 1 TO 900 STEP 175
  80.     FOR sz = .25 TO 125 STEP .25
  81.         hc = hc + .25
  82.         CIRCLE (hills, 300), sz, _RGB32(0, 255 - hc, 0), 2 * _PI, _PI
  83.     NEXT sz
  84.     hc = 0
  85. NEXT hills
  86.     cir = cir + .25
  87.     t = t + tt
  88.     IF t > 255 THEN t = 155
  89.     IF cir > 175 THEN cir = .5
  90.     CIRCLE (400, 450), cir, _RGB32(0, 0, t), , , .75
  91.     _DISPLAY
  92.     a$ = INKEY$
  93.     IF a$ = CHR$(27) THEN END
  94.     IF a$ = " " THEN GOTO four:
  95. four:
  96. fx2 = 0
  97. t = 0: tt = 0
  98.  
  99. 'Four: Snow
  100. FOR i = 1 TO nSnow
  101.     x(i) = RND * 800 + 1
  102.     y(i) = 0
  103.     speed(i) = RND * 5 + 1
  104.     s(i) = RND * 5
  105.     IF s(i) < 1 THEN s(i) = 1
  106.     IF s(i) > 5 THEN s(i) = 1
  107. L = 200
  108.     _LIMIT 100
  109.     PAINT (2, 2), _RGB32(122, 144, 155)
  110.     FOR i = 1 TO nSnow
  111.         y(i) = y(i) + speed(i)
  112.         FOR sze = .25 TO s(i) STEP .25
  113.             CIRCLE (x(i), y(i)), sze, _RGB32(255, 255, 255)
  114.         NEXT
  115.     NEXT
  116.     _DISPLAY
  117.     CLS
  118.     FOR i = 1 TO nSnow
  119.         ' is x or y off screen?
  120.         IF x(i) > _WIDTH OR x(i) < 0 THEN s(i) = RND * 5 + 1: y(i) = 0: x(i) = RND * 800 + 1: speed(i) = RND * 5 + 1
  121.         IF y(i) > _HEIGHT OR y(i) < 0 THEN s(i) = RND * 5 + 1: y(i) = 0: x(i) = RND * 800 + 1: speed(i) = RND * 5 + 1
  122.     NEXT
  123.     a$ = INKEY$
  124.     IF a$ = CHR$(27) THEN END
  125.     IF a$ = " " THEN CLS: GOTO start:
  126.  

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Four Animated Scenes
« Reply #1 on: June 18, 2020, 09:56:38 pm »
Wow code is looking more normal to me,

I like snow and TV best, static on TV is cool!

Offline OldMoses

  • Seasoned Forum Regular
  • Posts: 469
    • View Profile
Re: Four Animated Scenes
« Reply #2 on: June 18, 2020, 10:54:56 pm »
I think I see dead people in that TV... ;)

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Four Animated Scenes
« Reply #3 on: June 18, 2020, 11:14:02 pm »
LOL OldMoses! Thanks guys. :). I use these examples to get code from later. :) Maybe others will do the same here.

Offline Ashish

  • Forum Resident
  • Posts: 630
  • Never Give Up!
    • View Profile
Re: Four Animated Scenes
« Reply #4 on: June 19, 2020, 01:49:46 am »
Nice! Awesome! I like it!
Keep posting programs like this! :)
if (Me.success) {Me.improve()} else {Me.tryAgain()}


My Projects - https://github.com/AshishKingdom?tab=repositories
OpenGL tutorials - https://ashishkingdom.github.io/OpenGL-Tutorials

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: Four Animated Scenes
« Reply #5 on: June 19, 2020, 10:59:42 am »
Yeah, it's really nice.

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Four Animated Scenes
« Reply #6 on: June 20, 2020, 10:50:59 pm »
Thanks Ashish and Petr. :)