Author Topic: U.S. Flag  (Read 3111 times)

0 Members and 1 Guest are viewing this topic.

Offline SierraKen

  • Forum Resident
  • Posts: 1454
Re: U.S. Flag
« Reply #15 on: May 15, 2020, 11:56:36 am »
Great work Vince!
Stxaxtic, I posted yours above already. :)

Offline SierraKen

  • Forum Resident
  • Posts: 1454
Re: U.S. Flag
« Reply #16 on: June 06, 2020, 09:33:32 pm »
Today I decided to make the stars on this flag look better without using DATA lines. I also added random hills in the background. Pressing the Space Bar makes different random hills in the background. I added a picture here.

Code: QB64: [Select]
  1. 'Made to honor the U.S. Flag.
  2. 'Feel free to use any or all of this code in your own applications or games.
  3. 'By Sierraken on May 11, 2020.
  4. 'Updated with better stars without using DATA lines and random hills on June 6, 2020.
  5.  
  6. _LIMIT 300
  7. _TITLE "U.S. Flag - Press Space Bar to change hills."
  8. SCREEN _NEWIMAGE(800, 600, 32)
  9. Go:
  10. x = 150
  11. y = 100
  12.  
  13. 'Sky
  14. PAINT (2, 2), _RGB32(0, 205, 255)
  15.  
  16. 'Random Hills
  17. hills = INT(RND * 40) + 3
  18. FOR h = 1 TO hills
  19.     hx = INT(RND * 800) + 1
  20.     size = INT(RND * 450) + 75
  21.     cl = INT(RND * 155) + 100
  22.     shape = RND
  23.     FOR sz = .25 TO size STEP .25
  24.         CIRCLE (hx, 599), sz, _RGB32(10, cl, 20), , , shape
  25.     NEXT sz
  26. 'Stars
  27. LINE (x, y)-(x + 185, y + 130), _RGB32(0, 0, 255), BF
  28. FOR xx = 155 TO 345 STEP 32
  29.     FOR yy = 105 TO 220 STEP 28
  30.         LINE (xx + 2, yy + 12)-(xx + 7, yy), _RGB32(255, 255, 255)
  31.         LINE (xx + 7, yy)-(xx + 13, yy + 12), _RGB32(255, 255, 255)
  32.         LINE (xx + 13, yy + 12)-(xx, yy + 5), _RGB32(255, 255, 255)
  33.         LINE (xx, yy + 5)-(xx + 15, yy + 5), _RGB32(255, 255, 255)
  34.         LINE (xx + 15, yy + 5)-(xx + 2, yy + 12), _RGB32(255, 255, 255)
  35.         PAINT (xx + 7, yy + 2), _RGB32(255, 255, 255)
  36.         PAINT (xx + 7, yy + 6), _RGB32(255, 255, 255)
  37.         PAINT (xx + 11, yy + 10), _RGB32(255, 255, 255)
  38.         PAINT (xx + 4, yy + 10), _RGB32(255, 255, 255)
  39.         PAINT (xx + 3, yy + 6), _RGB32(255, 255, 255)
  40.         PAINT (xx + 12, yy + 6), _RGB32(255, 255, 255)
  41.     NEXT yy
  42. NEXT xx
  43.  
  44. FOR xx = 172 TO 329 STEP 32
  45.     FOR yy = 118.9 TO 213.05 STEP 28
  46.         LINE (xx + 2, yy + 12)-(xx + 7, yy), _RGB32(255, 255, 255)
  47.         LINE (xx + 7, yy)-(xx + 13, yy + 12), _RGB32(255, 255, 255)
  48.         LINE (xx + 13, yy + 12)-(xx, yy + 5), _RGB32(255, 255, 255)
  49.         LINE (xx, yy + 5)-(xx + 15, yy + 5), _RGB32(255, 255, 255)
  50.         LINE (xx + 15, yy + 5)-(xx + 2, yy + 12), _RGB32(255, 255, 255)
  51.         PAINT (xx + 7, yy + 2), _RGB32(255, 255, 255)
  52.         PAINT (xx + 7, yy + 6), _RGB32(255, 255, 255)
  53.         PAINT (xx + 11, yy + 10), _RGB32(255, 255, 255)
  54.         PAINT (xx + 4, yy + 10), _RGB32(255, 255, 255)
  55.         PAINT (xx + 3, yy + 6), _RGB32(255, 255, 255)
  56.         PAINT (xx + 12, yy + 6), _RGB32(255, 255, 255)
  57.     NEXT yy
  58. NEXT xx
  59.  
  60. 'Stripes
  61. FOR rs = 100 TO 230 STEP 37.2
  62.     w = w + 1
  63.     LINE (335, rs)-(612.5, rs + 18.6), _RGB32(255, 0, 0), BF
  64.     IF w > 3 THEN GOTO nex:
  65.     LINE (335, rs + 18.6)-(612.5, rs + 37.2), _RGB32(255, 255, 255), BF
  66. NEXT rs
  67. nex:
  68. w = 0
  69. FOR rs = 230 TO 341.6 STEP 37.2
  70.     r = r + 1
  71.     LINE (150, rs)-(612.5, rs + 18.6), _RGB32(255, 255, 255), BF
  72.     IF r > 3 THEN GOTO nex2:
  73.     LINE (150, rs + 18.6)-(612.5, rs + 37.2), _RGB32(255, 0, 0), BF
  74. NEXT rs
  75. nex2:
  76. r = 0
  77.  
  78. 'Flag Pole
  79. FOR sz = .25 TO 10 STEP .25
  80.     CIRCLE (145, 80), sz, _RGB32(122, 128, 166)
  81. NEXT sz
  82. LINE (142, 80)-(147, 600), _RGB32(122, 128, 166), BF
  83. 'Wait for key.
  84.     a$ = INKEY$
  85.     IF a$ = " " THEN GOTO Go:
  86.     IF a$ = CHR$(27) THEN END
  87.  
Ken's US Flag Program 2.jpg
* Ken's US Flag Program 2.jpg (Filesize: 87.52 KB, Dimensions: 804x626, Views: 347)
« Last Edit: June 06, 2020, 09:42:02 pm by SierraKen »

Offline Ashish

  • Forum Resident
  • Posts: 630
  • Never Give Up!
Re: U.S. Flag
« Reply #17 on: June 07, 2020, 01:32:18 am »
Good work... Nice graphics. :)
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 SierraKen

  • Forum Resident
  • Posts: 1454
Re: U.S. Flag
« Reply #18 on: June 07, 2020, 01:13:45 pm »
Thanks Ashish :). My first flag I made a month ago has stars that are very "curvy" looking so I decided to make them look a little sharper and better and without the DATA lines. So what I did was just use  LINE commands making a star just like you would draw it on paper. Then I used PAINT commands to fill in the gaps. :)
« Last Edit: June 07, 2020, 01:14:54 pm by SierraKen »

Offline SierraKen

  • Forum Resident
  • Posts: 1454
Re: U.S. Flag
« Reply #19 on: June 16, 2020, 12:40:33 am »
Tonight I was able to use my water waves formula to capture the colors of my flag and make the flag wave. I also added a night/day cycle for the sky. I had to delete the hills though because I couldn't figure out the PUTIMAGE stuff again, not sure if it's even possible to keep an animation moving and grab new hills and keep them in the background. I tried it with just using arrays, without the PUTIMAGE stuff and it just slowed the flag animation down greatly and got slower as it went. I do use a huge amount of memory to grab the entire flag and put every pixel in memory to make it wave, I hope it's not too much for one DIM statement. Anyhow, please check it out. I've wanted to make a flag wave for a very long time. It's not as good as the realistic one somewhere else on this thread, but it's an accomplishment for me. :)

Code: QB64: [Select]
  1. 'Made to honor the U.S. Flag.
  2. 'Feel free to use any or all of this code in your own applications or games.
  3. 'By Sierraken on May 11, 2020.
  4. 'Updated to make the flag wave and night and day cycle on June 15, 2020.
  5.  
  6. _TITLE "U.S. Flag"
  7. SCREEN _NEWIMAGE(800, 600, 32)
  8. x = 150
  9. y = 100
  10. DIM cf&(113000)
  11.  
  12. 'Stars
  13. LINE (x, y)-(x + 185, y + 130), _RGB32(0, 0, 255), BF
  14. FOR xx = 155 TO 345 STEP 32
  15.     FOR yy = 105 TO 220 STEP 28
  16.         LINE (xx + 2, yy + 12)-(xx + 7, yy), _RGB32(255, 255, 255)
  17.         LINE (xx + 7, yy)-(xx + 13, yy + 12), _RGB32(255, 255, 255)
  18.         LINE (xx + 13, yy + 12)-(xx, yy + 5), _RGB32(255, 255, 255)
  19.         LINE (xx, yy + 5)-(xx + 15, yy + 5), _RGB32(255, 255, 255)
  20.         LINE (xx + 15, yy + 5)-(xx + 2, yy + 12), _RGB32(255, 255, 255)
  21.         PAINT (xx + 7, yy + 2), _RGB32(255, 255, 255)
  22.         PAINT (xx + 7, yy + 6), _RGB32(255, 255, 255)
  23.         PAINT (xx + 11, yy + 10), _RGB32(255, 255, 255)
  24.         PAINT (xx + 4, yy + 10), _RGB32(255, 255, 255)
  25.         PAINT (xx + 3, yy + 6), _RGB32(255, 255, 255)
  26.         PAINT (xx + 12, yy + 6), _RGB32(255, 255, 255)
  27.     NEXT yy
  28. NEXT xx
  29.  
  30. FOR xx = 172 TO 329 STEP 32
  31.     FOR yy = 118.9 TO 213.05 STEP 28
  32.         LINE (xx + 2, yy + 12)-(xx + 7, yy), _RGB32(255, 255, 255)
  33.         LINE (xx + 7, yy)-(xx + 13, yy + 12), _RGB32(255, 255, 255)
  34.         LINE (xx + 13, yy + 12)-(xx, yy + 5), _RGB32(255, 255, 255)
  35.         LINE (xx, yy + 5)-(xx + 15, yy + 5), _RGB32(255, 255, 255)
  36.         LINE (xx + 15, yy + 5)-(xx + 2, yy + 12), _RGB32(255, 255, 255)
  37.         PAINT (xx + 7, yy + 2), _RGB32(255, 255, 255)
  38.         PAINT (xx + 7, yy + 6), _RGB32(255, 255, 255)
  39.         PAINT (xx + 11, yy + 10), _RGB32(255, 255, 255)
  40.         PAINT (xx + 4, yy + 10), _RGB32(255, 255, 255)
  41.         PAINT (xx + 3, yy + 6), _RGB32(255, 255, 255)
  42.         PAINT (xx + 12, yy + 6), _RGB32(255, 255, 255)
  43.     NEXT yy
  44. NEXT xx
  45.  
  46. 'Stripes
  47. FOR rs = 100 TO 230 STEP 37.2
  48.     w = w + 1
  49.     LINE (335, rs)-(612.5, rs + 18.6), _RGB32(255, 0, 0), BF
  50.     IF w > 3 THEN GOTO nex:
  51.     LINE (335, rs + 18.6)-(612.5, rs + 37.2), _RGB32(255, 255, 255), BF
  52. NEXT rs
  53. nex:
  54. w = 0
  55. FOR rs = 230 TO 341.6 STEP 37.2
  56.     r = r + 1
  57.     LINE (150, rs)-(612.5, rs + 18.6), _RGB32(255, 255, 255), BF
  58.     IF r > 3 THEN GOTO nex2:
  59.     LINE (150, rs + 18.6)-(612.5, rs + 37.2), _RGB32(255, 0, 0), BF
  60. NEXT rs
  61. nex2:
  62. r = 0
  63. FOR fy = 100 TO 341.6
  64.     FOR fx = 150 TO 612.5
  65.         t5 = t5 + 1
  66.         cf&(t5) = POINT(fx, fy)
  67.     NEXT fx
  68. NEXT fy
  69. t = 20
  70.     _LIMIT 20
  71.     'Sky
  72.     hour$ = LEFT$(TIME$, 2)
  73.     hour = VAL(hour$)
  74.     IF hour < 21 AND hour >= 6 THEN
  75.         PAINT (2, 2), _RGB32(0, 205, 255)
  76.     END IF
  77.  
  78.     'Flag Pole
  79.     FOR sz = .25 TO 10 STEP .25
  80.         CIRCLE (145, 80), sz, _RGB32(122, 128, 166)
  81.     NEXT sz
  82.     LINE (142, 80)-(147, 600), _RGB32(122, 128, 166), BF
  83.     FOR fy = 100 TO 341.6
  84.         FOR fx = 150 TO 612.5
  85.             t6 = t6 + 1
  86.             PSET (fx, (SIN(fx * 0.017453) * t) + fy), cf&(t6)
  87.         NEXT fx
  88.     NEXT fy
  89.     fx2 = fx2 + 1
  90.     IF fx2 = 242 THEN fx2 = 0
  91.     t6 = 0
  92.     IF tt = 0 THEN t = t + 1
  93.     IF t > 30 THEN tt = 1
  94.     IF tt = 1 THEN t = t - 1
  95.     IF t < -30 THEN tt = 0
  96.     a$ = INKEY$
  97.     IF a$ = CHR$(27) THEN END
  98.     _DISPLAY
  99.     CLS
  100.  
« Last Edit: June 16, 2020, 12:46:58 am by SierraKen »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: U.S. Flag
« Reply #20 on: June 16, 2020, 11:56:25 am »
Wave back to you Ken, coming along nicely!

Since last night Podcast, I've been thinking about layers allot.

Do the hills on completely different screen:
hills& = _Newimage(_width, _height, 32)

_DEST hills&
'now draw just hills like normal

'now back to main screen
_DEST 0

'use hills for background and then draw flag in fore ground on top of background.

_PUTIMAGE , hills&, 0  'my background hills

'draw flag

'use _PUTIMAGE , hills&, 0  'my background hills to CLS putting the background in loop for waving flag drawing

Might be more details to get it working but that is gist I think.
« Last Edit: June 16, 2020, 12:06:09 pm by bplus »

Offline SierraKen

  • Forum Resident
  • Posts: 1454
Re: U.S. Flag
« Reply #21 on: June 16, 2020, 02:15:36 pm »
Thanks b+, it works perfectly now! I also made the flag waving look more realistic.

Code: QB64: [Select]
  1. 'Made to honor the U.S. Flag.
  2. 'By Sierraken
  3. 'Feel free to use any or all of this code in your own applications or games.
  4. 'Updated with better flag waving and a hills fix on June 16, 2020.
  5. 'Thank you to B+ for a little help on the hills!
  6.  
  7. _TITLE "U.S. Flag - Use space bar to change hills background."
  8. SCREEN _NEWIMAGE(800, 600, 32)
  9. x = 150
  10. y = 100
  11. DIM cf&(113000)
  12.  
  13. GOSUB hills:
  14.  
  15. 'Stars
  16. LINE (x, y)-(x + 185, y + 130), _RGB32(0, 0, 255), BF
  17. FOR xx = 155 TO 345 STEP 32
  18.     FOR yy = 105 TO 220 STEP 28
  19.         LINE (xx + 2, yy + 12)-(xx + 7, yy), _RGB32(255, 255, 255)
  20.         LINE (xx + 7, yy)-(xx + 13, yy + 12), _RGB32(255, 255, 255)
  21.         LINE (xx + 13, yy + 12)-(xx, yy + 5), _RGB32(255, 255, 255)
  22.         LINE (xx, yy + 5)-(xx + 15, yy + 5), _RGB32(255, 255, 255)
  23.         LINE (xx + 15, yy + 5)-(xx + 2, yy + 12), _RGB32(255, 255, 255)
  24.         PAINT (xx + 7, yy + 2), _RGB32(255, 255, 255)
  25.         PAINT (xx + 7, yy + 6), _RGB32(255, 255, 255)
  26.         PAINT (xx + 11, yy + 10), _RGB32(255, 255, 255)
  27.         PAINT (xx + 4, yy + 10), _RGB32(255, 255, 255)
  28.         PAINT (xx + 3, yy + 6), _RGB32(255, 255, 255)
  29.         PAINT (xx + 12, yy + 6), _RGB32(255, 255, 255)
  30.     NEXT yy
  31. NEXT xx
  32.  
  33. FOR xx = 172 TO 329 STEP 32
  34.     FOR yy = 118.9 TO 213.05 STEP 28
  35.         LINE (xx + 2, yy + 12)-(xx + 7, yy), _RGB32(255, 255, 255)
  36.         LINE (xx + 7, yy)-(xx + 13, yy + 12), _RGB32(255, 255, 255)
  37.         LINE (xx + 13, yy + 12)-(xx, yy + 5), _RGB32(255, 255, 255)
  38.         LINE (xx, yy + 5)-(xx + 15, yy + 5), _RGB32(255, 255, 255)
  39.         LINE (xx + 15, yy + 5)-(xx + 2, yy + 12), _RGB32(255, 255, 255)
  40.         PAINT (xx + 7, yy + 2), _RGB32(255, 255, 255)
  41.         PAINT (xx + 7, yy + 6), _RGB32(255, 255, 255)
  42.         PAINT (xx + 11, yy + 10), _RGB32(255, 255, 255)
  43.         PAINT (xx + 4, yy + 10), _RGB32(255, 255, 255)
  44.         PAINT (xx + 3, yy + 6), _RGB32(255, 255, 255)
  45.         PAINT (xx + 12, yy + 6), _RGB32(255, 255, 255)
  46.     NEXT yy
  47. NEXT xx
  48.  
  49. 'Stripes
  50. FOR rs = 100 TO 230 STEP 37.2
  51.     w = w + 1
  52.     LINE (335, rs)-(612.5, rs + 18.6), _RGB32(255, 0, 0), BF
  53.     IF w > 3 THEN GOTO nex:
  54.     LINE (335, rs + 18.6)-(612.5, rs + 37.2), _RGB32(255, 255, 255), BF
  55. NEXT rs
  56. nex:
  57. w = 0
  58. FOR rs = 230 TO 341.6 STEP 37.2
  59.     r = r + 1
  60.     LINE (150, rs)-(612.5, rs + 18.6), _RGB32(255, 255, 255), BF
  61.     IF r > 3 THEN GOTO nex2:
  62.     LINE (150, rs + 18.6)-(612.5, rs + 37.2), _RGB32(255, 0, 0), BF
  63. NEXT rs
  64. nex2:
  65. r = 0
  66. FOR fy = 100 TO 341.6
  67.     FOR fx = 150 TO 612.5
  68.         t5 = t5 + 1
  69.         cf&(t5) = POINT(fx, fy)
  70.     NEXT fx
  71. NEXT fy
  72. t = 20
  73.     _LIMIT 10
  74.     'Sky
  75.     hour$ = LEFT$(TIME$, 2)
  76.     hour = VAL(hour$)
  77.     IF hour < 21 AND hour >= 6 THEN
  78.         PAINT (2, 2), _RGB32(0, 205, 255)
  79.     END IF
  80.     _PUTIMAGE , hills&, 0
  81.     'Flag Pole
  82.     FOR sz = .25 TO 10 STEP .25
  83.         CIRCLE (145, 80), sz, _RGB32(122, 128, 166)
  84.     NEXT sz
  85.     LINE (142, 80)-(147, 600), _RGB32(122, 128, 166), BF
  86.     fx2 = fx2 + 1.2
  87.     IF fx2 > 5 THEN fx2 = 1.2
  88.     FOR fy = 100 TO 341.6
  89.         FOR fx = 150 TO 612.5
  90.             t6 = t6 + 1
  91.             PSET ((SIN(fy * 0.017453 / fx2) * t) + fx, (SIN(fx * 0.017453 / fx2) * t) + fy), cf&(t6)
  92.         NEXT fx
  93.     NEXT fy
  94.     t6 = 0
  95.     IF tt = 0 THEN t = t + 1
  96.     IF t > 10 THEN tt = 1
  97.     IF tt = 1 THEN t = t - 1
  98.     IF t < -10 THEN tt = 0
  99.     a$ = INKEY$
  100.     IF a$ = CHR$(27) THEN END
  101.     IF a$ = " " THEN GOSUB hills:
  102.     _DISPLAY
  103.     CLS
  104.  
  105. hills:
  106. 'Random Hills
  107. hills& = _NEWIMAGE(_WIDTH, _HEIGHT, 32)
  108. _DEST hills&
  109. hills = INT(RND * 40) + 3
  110. FOR h = 1 TO hills
  111.     hx = INT(RND * 800) + 1
  112.     size = INT(RND * 450) + 75
  113.     cl = INT(RND * 155) + 100
  114.     shape = RND
  115.     FOR sz = .25 TO size STEP .25
  116.         CIRCLE (hx, 599), sz, _RGB32(10, cl, 20), , , shape
  117.     NEXT sz
  118.  


Offline MasterGy

  • Seasoned Forum Regular
  • Posts: 327
  • people lie, math never lies
Re: U.S. Flag
« Reply #22 on: June 16, 2020, 02:35:58 pm »

very beautiful and spectacular !! congratulations!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: U.S. Flag
« Reply #23 on: June 16, 2020, 02:37:08 pm »
+1

Wow that was fast!

I wonder why that flag looks a little jumpy, I sped up the _LIMIT, a little less jumpy but too fast.

I wonder if you make a flag image (only 1 time draw) like the hills image and lay different width sections on top of each other starting from left and going right, or take vertical lines of the flag and lay them out with slight overlaps going up and down but also going lower towards ground towards right.

Now I wonder if you got that?  ;-))


Offline SierraKen

  • Forum Resident
  • Posts: 1454
Re: U.S. Flag
« Reply #24 on: June 16, 2020, 03:35:25 pm »
Nothing overlaps except over the hills and sometimes the pole. It makes a new flag on every frame of animation. Or are you hinting at that? Yesterday I had it overlapping a tiny bit but it was a mess. lol The flag moves like that as an effect from the wind. :)

I just added the National Anthem and the hills change every 2 seconds. (Please no political posts.) I'll add the .bas and the .mp3 file to the attachments in a zip file. Enjoy. I'm also going to make a YouTube of it as well.

* US Flag by Sierraken.zip (Filesize: 1.03 MB, Downloads: 133)
« Last Edit: June 16, 2020, 04:35:04 pm by SierraKen »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: U.S. Flag
« Reply #25 on: June 16, 2020, 05:49:38 pm »
Wow you have it on YouTube! I feel like saluting!

Offline SierraKen

  • Forum Resident
  • Posts: 1454
Re: U.S. Flag
« Reply #26 on: June 16, 2020, 07:06:54 pm »
LOL Thanks :)

Offline Ashish

  • Forum Resident
  • Posts: 630
  • Never Give Up!
Re: U.S. Flag
« Reply #27 on: June 17, 2020, 12:12:26 am »
Amazing! Beautiful!
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 SierraKen

  • Forum Resident
  • Posts: 1454
Re: U.S. Flag
« Reply #28 on: June 17, 2020, 12:20:40 am »
Thanks everyone :))

Offline DANILIN

  • Forum Regular
  • Posts: 128
    • Danilin youtube
Re: U.S. Flag
« Reply #29 on: June 17, 2020, 01:05:46 pm »
Flagimation & Ezgif

 
SierraKen.gif
   
USAflag.gif




 
fldelen.gif
SierraKen.bmp
« Last Edit: June 17, 2020, 01:31:13 pm by DANILIN »
Russia looks world from future. big data is peace data.
https://youtube.com/playlist?list=PLBBTP9oVY7IagpH0g9FNUQ8JqmHwxDDDB
i never recommend anything to anyone and always write only about myself