Author Topic: Starfield 2020 - December Version  (Read 7864 times)

0 Members and 1 Guest are viewing this topic.

This topic contains a post which is marked as Best Answer. Press here if you would like to see it.

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Starfield 2020 - December Version
« on: December 07, 2020, 07:40:04 pm »
I don't believe I made one of these this year, but I know we made them last year. So I took my glowing snow idea and turned them into glowing stars. I also figured out how to start them not directly in the center like I did last year. Plus I used different sizes of stars. Feel free to use this on anything, or add anything, etc. I was mostly just goofing off. :)

Edit: I just changed the name of this to Starfield 2020 - December Version because I found an older Starfield 2020 that I made back in June.

Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(1000, 800, 32)
  2. DIM starx(800), stary(800)
  3. DIM dx(800), dy(800)
  4. DIM sz(800)
  5. _TITLE "Starfield 2020 - Dec. Version - by SierraKen"
  6. speed = 1
  7.     _LIMIT 60
  8.     a$ = INKEY$
  9.     IF a$ = CHR$(27) THEN END
  10.     stars = INT(RND * 100) + 1
  11.     IF stars > 25 THEN
  12.         s = s + 1
  13.         IF s > 750 THEN s = 1
  14.         'Set starting position.
  15.         st = INT(RND * 360)
  16.         x = (SIN(st) * 30) + 500
  17.         y = (COS(st) * 30) + 400
  18.         starx(s) = x
  19.         stary(s) = y
  20.         'Set direction to move.
  21.         dx(s) = ((x - 500) / 30)
  22.         dy(s) = ((y - 400) / 30)
  23.         'Set size.
  24.         sz(s) = RND
  25.     END IF
  26.     IF yy > 640 THEN yy = 0
  27.     FOR t = 1 TO 750
  28.         stary(t) = stary(t) + dy(t)
  29.         starx(t) = starx(t) + dx(t)
  30.         cx = starx(t): cy = stary(t)
  31.         r = sz(t) + RND
  32.         c = _RGB32(255, 255, 255)
  33.         fillCircle cx, cy, r, c
  34.     NEXT t
  35.     _DISPLAY
  36.     CLS
  37.  
  38. 'from Steve Gold standard
  39. SUB fillCircle (CX AS INTEGER, CY AS INTEGER, R AS INTEGER, C AS _UNSIGNED LONG)
  40.     DIM Radius AS INTEGER, RadiusError AS INTEGER
  41.     DIM X AS INTEGER, Y AS INTEGER
  42.     Radius = ABS(R): RadiusError = -Radius: X = Radius: Y = 0
  43.     IF Radius = 0 THEN PSET (CX, CY), C: EXIT SUB
  44.     LINE (CX - X, CY)-(CX + X, CY), C, BF
  45.     WHILE X > Y
  46.         RadiusError = RadiusError + Y * 2 + 1
  47.         IF RadiusError >= 0 THEN
  48.             IF X <> Y + 1 THEN
  49.                 LINE (CX - Y, CY - X)-(CX + Y, CY - X), C, BF
  50.                 LINE (CX - Y, CY + X)-(CX + Y, CY + X), C, BF
  51.             END IF
  52.             X = X - 1
  53.             RadiusError = RadiusError - X * 2
  54.         END IF
  55.         Y = Y + 1
  56.         LINE (CX - X, CY - Y)-(CX + X, CY - Y), C, BF
  57.         LINE (CX - X, CY + Y)-(CX + X, CY + Y), C, BF
  58.     WEND
  59.  
« Last Edit: December 08, 2020, 12:13:03 am by SierraKen »

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Starfield - December Version
« Reply #1 on: December 07, 2020, 11:52:57 pm »
I just found out that back in June I did a different Starfield 2020,  I will rename this one to "Starfield - December Version".
If you are interested to see the old one, click the link below.

https://www.qb64.org/forum/index.php?topic=2709.msg119278
« Last Edit: December 08, 2020, 12:07:53 am by SierraKen »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Starfield 2020 - December Version
« Reply #2 on: December 08, 2020, 12:12:19 am »
This is a nice one, it's labeled Starfield Simulation #2 [banned user] but looks like Fellippe's or Ashish procedures ie ' p5.js Functions

Code: QB64: [Select]
  1. _TITLE "Starfield Simulation"
  2.  
  3.  
  4. CreateCanvas 600, 600
  5. WINDOW (-Width, -Height)-(Width, Height)
  6.  
  7. ' Translate the Star Class into a UDT (User Defined Type)
  8. TYPE newStar
  9.     x AS SINGLE
  10.     y AS SINGLE
  11.  
  12.     z AS SINGLE
  13.     pz AS SINGLE
  14.  
  15. ' Define how many Stars
  16. DIM SHARED starCount AS INTEGER
  17. starCount = 800
  18.  
  19. ' Setup the Stars
  20. DIM SHARED Stars(starCount) AS newStar
  21.  
  22. FOR i = 1 TO starCount
  23.     Stars(i).x = p5random(-Width, Width)
  24.     Stars(i).y = p5random(-Height, Height)
  25.  
  26.     Stars(i).z = p5random(0, Width)
  27.     Stars(i).pz = Stars(i).z
  28.  
  29. Speed = 5
  30.  
  31.     _LIMIT 60
  32.  
  33.     LINE (-_WIDTH, -_HEIGHT)-(Width - 1, Height - 1), _RGBA32(0, 0, 0, 30), BF
  34.  
  35.     FOR i = 1 TO starCount
  36.         Stars(i).z = Stars(i).z - Speed
  37.  
  38.         IF Stars(i).z < 1 THEN
  39.             Stars(i).x = p5random(-Width, Width)
  40.             Stars(i).y = p5random(-Width, Height)
  41.  
  42.             Stars(i).z = Width
  43.             Stars(i).pz = Stars(i).z
  44.         END IF
  45.  
  46.         sx = map(Stars(i).x / Stars(i).z, 0, 1, 0, Width)
  47.         sy = map(Stars(i).y / Stars(i).z, 0, 1, 0, Height)
  48.         CIRCLE (sx, sy), map(Stars(i).z, 0, Width, 2, 0)
  49.  
  50.         px = map(Stars(i).x / Stars(i).pz, 0, 1, 0, Width)
  51.         py = map(Stars(i).y / Stars(i).pz, 0, 1, 0, Height)
  52.         Stars(i).pz = Stars(i).z
  53.         LINE (px, py)-(sx, sy)
  54.     NEXT
  55.  
  56.     _DISPLAY
  57. LOOP UNTIL Done
  58.  
  59. ' p5.js Functions
  60. FUNCTION map! (value!, minRange!, maxRange!, newMinRange!, newMaxRange!)
  61.     map! = ((value! - minRange!) / (maxRange! - minRange!)) * (newMaxRange! - newMinRange!) + newMinRange!
  62.  
  63. FUNCTION p5random! (mn!, mx!)
  64.     IF mn! > mx! THEN
  65.         SWAP mn!, mx!
  66.     END IF
  67.  
  68.     p5random! = RND * (mx! - mn!) + mn!
  69.  
  70. SUB CreateCanvas (x AS INTEGER, y AS INTEGER)
  71.     ' Define the screen
  72.     Width = x
  73.     Height = y
  74.  
  75.     ' Center of the screen
  76.     CenterX = x \ 2
  77.     CenterY = y \ 2
  78.  
  79.     ' Create the screen
  80.     SCREEN _NEWIMAGE(Width, Height, 32)
  81.  
  82.  

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Starfield 2020 - December Version
« Reply #3 on: December 08, 2020, 12:23:58 am »
Woah! Thanks B+, I totally forgot about trails... hmm....

Here we go,  one with trails and a little bit smaller of a starting point circular area.
Thanks for the idea!


 
Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(1000, 800, 32)
  2. DIM starx(1000), stary(1000)
  3. DIM dx(1000), dy(1000)
  4. DIM sz(1000)
  5. _TITLE "Starfield 2020 - Dec. Version - by SierraKen"
  6. speed = 1
  7.     _LIMIT 100
  8.     a$ = INKEY$
  9.     IF a$ = CHR$(27) THEN END
  10.     stars = INT(RND * 100) + 1
  11.     IF stars > 25 THEN
  12.         s = s + 1
  13.         IF s > 950 THEN s = 1
  14.         'Set starting position.
  15.         st = INT(RND * 360)
  16.         x = (SIN(st) * 20) + 500
  17.         y = (COS(st) * 20) + 400
  18.         starx(s) = x
  19.         stary(s) = y
  20.         'Set direction to move.
  21.         dx(s) = ((x - 500) / 30)
  22.         dy(s) = ((y - 400) / 30)
  23.         'Set size.
  24.         sz(s) = RND
  25.     END IF
  26.     IF yy > 640 THEN yy = 0
  27.     FOR t = 1 TO 950
  28.         stary(t) = stary(t) + dy(t)
  29.         starx(t) = starx(t) + dx(t)
  30.         cx = starx(t): cy = stary(t)
  31.         r = sz(t) + RND
  32.         c = _RGB32(255, 255, 255)
  33.         fillCircle cx, cy, r, c
  34.     NEXT t
  35.     _DISPLAY
  36.     LINE (0, 0)-(_WIDTH, _HEIGHT), _RGB32(0, 0, 0, 20), BF
  37.  
  38.  
  39. 'from Steve Gold standard
  40. SUB fillCircle (CX AS INTEGER, CY AS INTEGER, R AS INTEGER, C AS _UNSIGNED LONG)
  41.     DIM Radius AS INTEGER, RadiusError AS INTEGER
  42.     DIM X AS INTEGER, Y AS INTEGER
  43.     Radius = ABS(R): RadiusError = -Radius: X = Radius: Y = 0
  44.     IF Radius = 0 THEN PSET (CX, CY), C: EXIT SUB
  45.     LINE (CX - X, CY)-(CX + X, CY), C, BF
  46.     WHILE X > Y
  47.         RadiusError = RadiusError + Y * 2 + 1
  48.         IF RadiusError >= 0 THEN
  49.             IF X <> Y + 1 THEN
  50.                 LINE (CX - Y, CY - X)-(CX + Y, CY - X), C, BF
  51.                 LINE (CX - Y, CY + X)-(CX + Y, CY + X), C, BF
  52.             END IF
  53.             X = X - 1
  54.             RadiusError = RadiusError - X * 2
  55.         END IF
  56.         Y = Y + 1
  57.         LINE (CX - X, CY - Y)-(CX + X, CY - Y), C, BF
  58.         LINE (CX - X, CY + Y)-(CX + X, CY + Y), C, BF
  59.     WEND
  60.  


Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Starfield 2020 - December Version
« Reply #4 on: December 08, 2020, 12:28:51 am »
Ken can you get them to move faster as the approach the edge ie go faster and faster out from center. Plus start with stars scattered over the whole field.

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Starfield 2020 - December Version
« Reply #5 on: December 08, 2020, 01:22:48 am »
Star fields. You just gotta love 'em....
Logic is the beginning of wisdom.

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Starfield 2020 - December Version
« Reply #6 on: December 08, 2020, 02:38:10 pm »
Great idea B+. I just did both of those. I made a countdown in the beginning of numbers counting down to 0 until it starts, which then shows the entire screen of stars. Then I also figured out how to make the stars go faster as they got further away from the center. Last night I tried to make it speed up and slow down with the up and down arrow keys, so I figured that out too today. If you want to learn how I did the speeds, look at the sp, warp, and speed() variables. Check it out! :)

Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(1000, 800, 32)
  2. DIM starx(1000), stary(1000)
  3. DIM dx(1000), dy(1000)
  4. DIM sz(1000)
  5. DIM speed(1000)
  6. _TITLE "Starfield 2020 - Dec. Version - by SierraKen - Use up and down arrow keys to control speed."
  7.  
  8.     _LIMIT 100
  9.     a$ = INKEY$
  10.     IF a$ = CHR$(27) THEN END
  11.     IF a$ = CHR$(0) + CHR$(72) THEN sp = sp + .0005: _TITLE "Warp: " + warp$
  12.     IF a$ = CHR$(0) + CHR$(80) THEN sp = sp - .0005: _TITLE "Warp: " + warp$
  13.     IF sp < 0 THEN sp = 0
  14.     IF sp > .1 THEN sp = .1
  15.     warp = (sp * 100) + 1
  16.     IF warp > 10 THEN warp = 10
  17.     warp$ = STR$(warp)
  18.     warp$ = LEFT$(warp$, 5)
  19.     stars = INT(RND * 100) + 1
  20.     IF stars > 25 THEN
  21.         start = start + 1
  22.         s = s + 1
  23.         IF s > 950 THEN s = 1
  24.         'Set starting position.
  25.         st = INT(RND * 360)
  26.         x = (SIN(st) * 20) + 500
  27.         y = (COS(st) * 20) + 400
  28.         starx(s) = x
  29.         stary(s) = y
  30.         'Set direction to move.
  31.         dx(s) = ((x - 500) / 30)
  32.         dy(s) = ((y - 400) / 30)
  33.         'Set size.
  34.         sz(s) = RND
  35.         'Set speed
  36.         speed(s) = 1
  37.     END IF
  38.     IF yy > 640 THEN yy = 0
  39.     FOR t = 1 TO 950
  40.         speed(t) = speed(t) * (1.01 + sp)
  41.         stary(t) = stary(t) + dy(t) * speed(t)
  42.         starx(t) = starx(t) + dx(t) * speed(t)
  43.         cx = starx(t): cy = stary(t)
  44.         r = sz(t) + RND
  45.         c = _RGB32(255, 255, 255)
  46.         IF start < 650 THEN
  47.             countdown = INT((650 - start) / 10)
  48.             c$ = STR$(countdown)
  49.             _PRINTSTRING (500, 400), c$
  50.             GOTO skip:
  51.         END IF
  52.         fillCircle cx, cy, r, c
  53.         skip:
  54.     NEXT t
  55.     _DISPLAY
  56.     LINE (0, 0)-(_WIDTH, _HEIGHT), _RGB32(0, 0, 0, 20), BF
  57.  
  58.  
  59. 'from Steve Gold standard
  60. SUB fillCircle (CX AS INTEGER, CY AS INTEGER, R AS INTEGER, C AS _UNSIGNED LONG)
  61.     DIM Radius AS INTEGER, RadiusError AS INTEGER
  62.     DIM X AS INTEGER, Y AS INTEGER
  63.     Radius = ABS(R): RadiusError = -Radius: X = Radius: Y = 0
  64.     IF Radius = 0 THEN PSET (CX, CY), C: EXIT SUB
  65.     LINE (CX - X, CY)-(CX + X, CY), C, BF
  66.     WHILE X > Y
  67.         RadiusError = RadiusError + Y * 2 + 1
  68.         IF RadiusError >= 0 THEN
  69.             IF X <> Y + 1 THEN
  70.                 LINE (CX - Y, CY - X)-(CX + Y, CY - X), C, BF
  71.                 LINE (CX - Y, CY + X)-(CX + Y, CY + X), C, BF
  72.             END IF
  73.             X = X - 1
  74.             RadiusError = RadiusError - X * 2
  75.         END IF
  76.         Y = Y + 1
  77.         LINE (CX - X, CY - Y)-(CX + X, CY - Y), C, BF
  78.         LINE (CX - X, CY + Y)-(CX + X, CY + Y), C, BF
  79.     WEND
  80.  

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Starfield 2020 - December Version
« Reply #7 on: December 08, 2020, 03:44:28 pm »
I just added W and S keys to it B+. I really like the new look now, thanks again.

Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(1000, 800, 32)
  2. DIM starx(1000), stary(1000)
  3. DIM dx(1000), dy(1000)
  4. DIM sz(1000)
  5. DIM speed(1000)
  6. _TITLE "Starfield 2020 - Dec. Version - by SierraKen - Use up and down arrow keys (or W and S keys) to control speed."
  7.  
  8.     _LIMIT 100
  9.     a$ = INKEY$
  10.     IF a$ = CHR$(27) THEN END
  11.     IF a$ = CHR$(0) + CHR$(72) OR a$ = "w" OR a$ = "W" THEN sp = sp + .0005: _TITLE "Warp: " + warp$
  12.     IF a$ = CHR$(0) + CHR$(80) OR a$ = "s" OR a$ = "S" THEN sp = sp - .0005: _TITLE "Warp: " + warp$
  13.     IF sp < 0 THEN sp = 0
  14.     IF sp > .1 THEN sp = .1
  15.     warp = (sp * 100) + 1
  16.     IF warp > 10 THEN warp = 10
  17.     warp$ = STR$(warp)
  18.     warp$ = LEFT$(warp$, 5)
  19.     stars = INT(RND * 100) + 1
  20.     IF stars > 25 THEN
  21.         start = start + 1
  22.         s = s + 1
  23.         IF s > 950 THEN s = 1
  24.         'Set starting position.
  25.         st = INT(RND * 360)
  26.         x = (SIN(st) * 20) + 500
  27.         y = (COS(st) * 20) + 400
  28.         starx(s) = x
  29.         stary(s) = y
  30.         'Set direction to move.
  31.         dx(s) = ((x - 500) / 30)
  32.         dy(s) = ((y - 400) / 30)
  33.         'Set size.
  34.         sz(s) = RND
  35.         'Set speed
  36.         speed(s) = 1
  37.     END IF
  38.     IF yy > 640 THEN yy = 0
  39.     FOR t = 1 TO 950
  40.         speed(t) = speed(t) * (1.01 + sp)
  41.         stary(t) = stary(t) + dy(t) * speed(t)
  42.         starx(t) = starx(t) + dx(t) * speed(t)
  43.         cx = starx(t): cy = stary(t)
  44.         r = sz(t) + RND
  45.         c = _RGB32(255, 255, 255)
  46.         IF start < 650 THEN
  47.             countdown = INT((650 - start) / 10)
  48.             c$ = STR$(countdown)
  49.             _PRINTSTRING (500, 400), c$
  50.             GOTO skip:
  51.         END IF
  52.         fillCircle cx, cy, r, c
  53.         skip:
  54.     NEXT t
  55.     _DISPLAY
  56.     LINE (0, 0)-(_WIDTH, _HEIGHT), _RGB32(0, 0, 0, 20), BF
  57.  
  58.  
  59. 'from Steve Gold standard
  60. SUB fillCircle (CX AS INTEGER, CY AS INTEGER, R AS INTEGER, C AS _UNSIGNED LONG)
  61.     DIM Radius AS INTEGER, RadiusError AS INTEGER
  62.     DIM X AS INTEGER, Y AS INTEGER
  63.     Radius = ABS(R): RadiusError = -Radius: X = Radius: Y = 0
  64.     IF Radius = 0 THEN PSET (CX, CY), C: EXIT SUB
  65.     LINE (CX - X, CY)-(CX + X, CY), C, BF
  66.     WHILE X > Y
  67.         RadiusError = RadiusError + Y * 2 + 1
  68.         IF RadiusError >= 0 THEN
  69.             IF X <> Y + 1 THEN
  70.                 LINE (CX - Y, CY - X)-(CX + Y, CY - X), C, BF
  71.                 LINE (CX - Y, CY + X)-(CX + Y, CY + X), C, BF
  72.             END IF
  73.             X = X - 1
  74.             RadiusError = RadiusError - X * 2
  75.         END IF
  76.         Y = Y + 1
  77.         LINE (CX - X, CY - Y)-(CX + X, CY - Y), C, BF
  78.         LINE (CX - X, CY + Y)-(CX + X, CY + Y), C, BF
  79.     WEND
  80.  

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Starfield 2020 - December Version
« Reply #8 on: December 08, 2020, 05:00:26 pm »
I was able to do away with the countdown completely by making a random location on the screen (except the very center) for every new star. There's no more circular pattern in the center and now it looks more realistic. :)

Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(1000, 800, 32)
  2. DIM starx(1000), stary(1000)
  3. DIM dx(1000), dy(1000)
  4. DIM sz(1000)
  5. DIM speed(1000)
  6. _TITLE "Starfield 2020 - Dec. Version - by SierraKen - Use up and down arrow keys (or W and S keys) to control speed."
  7.  
  8.     _LIMIT 100
  9.     a$ = INKEY$
  10.     IF a$ = CHR$(27) THEN END
  11.     IF a$ = CHR$(0) + CHR$(72) OR a$ = "w" OR a$ = "W" THEN sp = sp + .0005: _TITLE "Warp: " + warp$
  12.     IF a$ = CHR$(0) + CHR$(80) OR a$ = "s" OR a$ = "S" THEN sp = sp - .0005: _TITLE "Warp: " + warp$
  13.     IF sp < 0 THEN sp = 0
  14.     IF sp > .1 THEN sp = .1
  15.     warp = (sp * 100) + 1
  16.     IF warp > 10 THEN warp = 10
  17.     warp$ = STR$(warp)
  18.     warp$ = LEFT$(warp$, 5)
  19.     stars = INT(RND * 100) + 1
  20.     IF stars > 25 THEN
  21.         s = s + 1
  22.         IF s > 950 THEN s = 1
  23.         'Set starting position.
  24.         startx = RND * 490
  25.         starty = RND * 390
  26.         st = INT(RND * 360)
  27.         x = (SIN(st) * startx) + 500
  28.         y = (COS(st) * starty) + 400
  29.         starx(s) = x
  30.         stary(s) = y
  31.         'Set direction to move.
  32.         dx(s) = ((x - 500) / 30)
  33.         dy(s) = ((y - 400) / 30)
  34.         'Set size.
  35.         sz(s) = RND
  36.         'Set speed
  37.         speed(s) = .5
  38.     END IF
  39.     IF yy > 640 THEN yy = 0
  40.     FOR t = 1 TO 950
  41.         speed(t) = speed(t) * (1.005 + sp)
  42.         stary(t) = stary(t) + dy(t) * speed(t)
  43.         starx(t) = starx(t) + dx(t) * speed(t)
  44.         cx = starx(t): cy = stary(t)
  45.         r = sz(t) + RND
  46.         c = _RGB32(255, 255, 255)
  47.         fillCircle cx, cy, r, c
  48.         'skip:
  49.     NEXT t
  50.     _DISPLAY
  51.     LINE (0, 0)-(_WIDTH, _HEIGHT), _RGB32(0, 0, 0, 20), BF
  52.  
  53.  
  54. 'from Steve Gold standard
  55. SUB fillCircle (CX AS INTEGER, CY AS INTEGER, R AS INTEGER, C AS _UNSIGNED LONG)
  56.     DIM Radius AS INTEGER, RadiusError AS INTEGER
  57.     DIM X AS INTEGER, Y AS INTEGER
  58.     Radius = ABS(R): RadiusError = -Radius: X = Radius: Y = 0
  59.     IF Radius = 0 THEN PSET (CX, CY), C: EXIT SUB
  60.     LINE (CX - X, CY)-(CX + X, CY), C, BF
  61.     WHILE X > Y
  62.         RadiusError = RadiusError + Y * 2 + 1
  63.         IF RadiusError >= 0 THEN
  64.             IF X <> Y + 1 THEN
  65.                 LINE (CX - Y, CY - X)-(CX + Y, CY - X), C, BF
  66.                 LINE (CX - Y, CY + X)-(CX + Y, CY + X), C, BF
  67.             END IF
  68.             X = X - 1
  69.             RadiusError = RadiusError - X * 2
  70.         END IF
  71.         Y = Y + 1
  72.         LINE (CX - X, CY - Y)-(CX + X, CY - Y), C, BF
  73.         LINE (CX - X, CY + Y)-(CX + X, CY + Y), C, BF
  74.     WEND
  75.  

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Starfield 2020 - December Version
« Reply #9 on: December 08, 2020, 05:03:58 pm »
Coming along nicely! :)

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Starfield 2020 - December Version
« Reply #10 on: December 08, 2020, 05:33:36 pm »
:) I just added _FULLSCREEN mode off and on using the Space Bar. I did it because I'm going to try and make a YouTube video of it. Full Screen makes it show really awesome.

Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(1000, 800, 32)
  2. DIM starx(1000), stary(1000)
  3. DIM dx(1000), dy(1000)
  4. DIM sz(1000)
  5. DIM speed(1000)
  6. _TITLE "Starfield 2020 - Dec. Ver. by SierraKen - Up and down arrow keys (or W and S keys) for speed. Space Bar switches back and forth to Full Screen. Esc to quit."
  7.  
  8.     _LIMIT 100
  9.     a$ = INKEY$
  10.     IF a$ = CHR$(27) THEN END
  11.     IF a$ = CHR$(0) + CHR$(72) OR a$ = "w" OR a$ = "W" THEN sp = sp + .0005: _TITLE "Warp: " + warp$
  12.     IF a$ = CHR$(0) + CHR$(80) OR a$ = "s" OR a$ = "S" THEN sp = sp - .0005: _TITLE "Warp: " + warp$
  13.     IF a$ = " " THEN f = f + 1
  14.     IF f = 1 THEN _FULLSCREEN
  15.     IF f = 2 THEN _FULLSCREEN OFF: f = 0
  16.     IF sp < 0 THEN sp = 0
  17.     IF sp > .1 THEN sp = .1
  18.     warp = (sp * 100) + 1
  19.     IF warp > 10 THEN warp = 10
  20.     warp$ = STR$(warp)
  21.     warp$ = LEFT$(warp$, 5)
  22.     stars = INT(RND * 100) + 1
  23.     IF stars > 25 THEN
  24.         s = s + 1
  25.         IF s > 950 THEN s = 1
  26.         'Set starting position.
  27.         startx = RND * 490
  28.         starty = RND * 390
  29.         st = INT(RND * 360)
  30.         x = (SIN(st) * startx) + 500
  31.         y = (COS(st) * starty) + 400
  32.         starx(s) = x
  33.         stary(s) = y
  34.         'Set direction to move.
  35.         dx(s) = ((x - 500) / 30)
  36.         dy(s) = ((y - 400) / 30)
  37.         'Set size.
  38.         sz(s) = RND
  39.         'Set speed
  40.         speed(s) = .5
  41.     END IF
  42.     IF yy > 640 THEN yy = 0
  43.     FOR t = 1 TO 950
  44.         speed(t) = speed(t) * (1.005 + sp)
  45.         stary(t) = stary(t) + dy(t) * speed(t)
  46.         starx(t) = starx(t) + dx(t) * speed(t)
  47.         cx = starx(t): cy = stary(t)
  48.         r = sz(t) + RND
  49.         c = _RGB32(255, 255, 255)
  50.         fillCircle cx, cy, r, c
  51.         'skip:
  52.     NEXT t
  53.     _DISPLAY
  54.     LINE (0, 0)-(_WIDTH, _HEIGHT), _RGB32(0, 0, 0, 20), BF
  55.  
  56.  
  57. 'from Steve Gold standard
  58. SUB fillCircle (CX AS INTEGER, CY AS INTEGER, R AS INTEGER, C AS _UNSIGNED LONG)
  59.     DIM Radius AS INTEGER, RadiusError AS INTEGER
  60.     DIM X AS INTEGER, Y AS INTEGER
  61.     Radius = ABS(R): RadiusError = -Radius: X = Radius: Y = 0
  62.     IF Radius = 0 THEN PSET (CX, CY), C: EXIT SUB
  63.     LINE (CX - X, CY)-(CX + X, CY), C, BF
  64.     WHILE X > Y
  65.         RadiusError = RadiusError + Y * 2 + 1
  66.         IF RadiusError >= 0 THEN
  67.             IF X <> Y + 1 THEN
  68.                 LINE (CX - Y, CY - X)-(CX + Y, CY - X), C, BF
  69.                 LINE (CX - Y, CY + X)-(CX + Y, CY + X), C, BF
  70.             END IF
  71.             X = X - 1
  72.             RadiusError = RadiusError - X * 2
  73.         END IF
  74.         Y = Y + 1
  75.         LINE (CX - X, CY - Y)-(CX + X, CY - Y), C, BF
  76.         LINE (CX - X, CY + Y)-(CX + X, CY + Y), C, BF
  77.     WEND
  78.  


Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Starfield 2020 - December Version
« Reply #11 on: December 08, 2020, 06:12:59 pm »
Here is the YouTube of it I just made. I speed up and then slow back down. The video is 1 minute and 10 seconds long.


Marked as best answer by SierraKen on December 11, 2020, 08:50:05 am

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Starfield 2020 - December Version
« Reply #12 on: December 11, 2020, 01:49:51 pm »
I found a way to make this look even better. Check it out.

Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(1000, 800, 32)
  2. DIM starx(1000), stary(1000)
  3. DIM dx(1000), dy(1000)
  4. DIM sz(1000)
  5. DIM speed(1000)
  6. _TITLE "Starfield 2020 - Dec. Ver. by SierraKen - Up and down arrow keys (or W and S keys) for speed. Space Bar switches back and forth to Full Screen. Esc to quit."
  7.  
  8.     _LIMIT 100
  9.     a$ = INKEY$
  10.     IF a$ = CHR$(27) THEN END
  11.     IF a$ = CHR$(0) + CHR$(72) OR a$ = "w" OR a$ = "W" THEN sp = sp + .0005: _TITLE "Warp: " + warp$
  12.     IF a$ = CHR$(0) + CHR$(80) OR a$ = "s" OR a$ = "S" THEN sp = sp - .0005: _TITLE "Warp: " + warp$
  13.     IF a$ = " " THEN f = f + 1
  14.     IF f = 1 THEN _FULLSCREEN
  15.     IF f = 2 THEN _FULLSCREEN OFF: f = 0
  16.     IF sp < 0 THEN sp = 0
  17.     IF sp > .1 THEN sp = .1
  18.     warp = (sp * 100) + 1
  19.     IF warp > 10 THEN warp = 10
  20.     warp$ = STR$(warp)
  21.     warp$ = LEFT$(warp$, 5)
  22.     stars = INT(RND * 100) + 1
  23.     IF stars > 25 THEN
  24.         s = s + 1
  25.         IF s > 950 THEN s = 1
  26.         'Set starting position.
  27.         startx = RND * 490
  28.         starty = RND * 390
  29.         st = INT(RND * 360)
  30.         x = (SIN(st) * startx) + 500
  31.         y = (COS(st) * starty) + 400
  32.         starx(s) = x
  33.         stary(s) = y
  34.         'Set direction to move.
  35.         dx(s) = ((x - 500) / 30)
  36.         dy(s) = ((y - 400) / 30)
  37.         'Set size.
  38.         sz(s) = RND
  39.         'Set speed
  40.         speed(s) = .1
  41.     END IF
  42.     IF yy > 640 THEN yy = 0
  43.     FOR t = 1 TO 950
  44.         speed(t) = speed(t) * (1.05 + sp)
  45.         stary(t) = stary(t) + dy(t) * speed(t)
  46.         starx(t) = starx(t) + dx(t) * speed(t)
  47.         cx = starx(t): cy = stary(t)
  48.         r = sz(t) + .5
  49.         c = _RGB32(255, 255, 255)
  50.         fillCircle cx, cy, r, c
  51.         'skip:
  52.     NEXT t
  53.     _DISPLAY
  54.     LINE (0, 0)-(_WIDTH, _HEIGHT), _RGB32(0, 0, 0, 20), BF
  55.  
  56.  
  57. 'from Steve Gold standard
  58. SUB fillCircle (CX AS INTEGER, CY AS INTEGER, R AS INTEGER, C AS _UNSIGNED LONG)
  59.     DIM Radius AS INTEGER, RadiusError AS INTEGER
  60.     DIM X AS INTEGER, Y AS INTEGER
  61.     Radius = ABS(R): RadiusError = -Radius: X = Radius: Y = 0
  62.     IF Radius = 0 THEN PSET (CX, CY), C: EXIT SUB
  63.     LINE (CX - X, CY)-(CX + X, CY), C, BF
  64.     WHILE X > Y
  65.         RadiusError = RadiusError + Y * 2 + 1
  66.         IF RadiusError >= 0 THEN
  67.             IF X <> Y + 1 THEN
  68.                 LINE (CX - Y, CY - X)-(CX + Y, CY - X), C, BF
  69.                 LINE (CX - Y, CY + X)-(CX + Y, CY + X), C, BF
  70.             END IF
  71.             X = X - 1
  72.             RadiusError = RadiusError - X * 2
  73.         END IF
  74.         Y = Y + 1
  75.         LINE (CX - X, CY - Y)-(CX + X, CY - Y), C, BF
  76.         LINE (CX - X, CY + Y)-(CX + X, CY + Y), C, BF
  77.     WEND
  78.  
  79.  

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: Starfield 2020 - December Version
« Reply #13 on: December 11, 2020, 02:08:47 pm »
Hi, you made it very nice. Am I guessing this is some preparation for a program to celebrate the new year?

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Starfield 2020 - December Version
« Reply #14 on: December 11, 2020, 04:50:21 pm »
Petr, I didn't think of any of that, except I do have an idea for this... but we'll see... :)