Author Topic: Re: Starfield, or wanna-Be Starfield  (Read 907 times)

0 Members and 1 Guest are viewing this topic.

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Starfield, or wanna-Be Starfield
« on: April 22, 2019, 10:16:39 pm »
Effect seems off. Pattern too cluttered and asynchronous speeds.

Pete
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Starfield, or wanna-Be Starfield
« Reply #1 on: April 23, 2019, 08:48:55 am »
Sure, I have seen many version of this type of demo, but I never get tired of watching it... I tweaked it to 100 stars and a speed of 2. I found those setting comfortable for me... Nice job [banned user]...
Logic is the beginning of wisdom.

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Starfield, or wanna-Be Starfield
« Reply #2 on: April 23, 2019, 10:19:18 am »
Are you outta your Vulcan mind, johnno? Oh wait, that actually did make it a lot better. I re-tried it with 200 stars, and I used a speed of three. I was surprised, but even bringing the speed up to 20 ruins the effect for me, but 3 looks great and the star reduction from 500 to 200 took care of the clutter. Thanks for the tweaked variable amounts.

Pete
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Starfield, or wanna-Be Starfield
« Reply #3 on: April 23, 2019, 09:34:12 pm »
Based on both your and my results, logic would dictate that reducing the number of stars and their respective speeds, would produce a more favourable outcome.

Logic is the beginning of wisdom....
Logic is the beginning of wisdom.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Starfield, or wanna-Be Starfield
« Reply #4 on: April 24, 2019, 09:34:00 am »
And replace this line:
Code: QB64: [Select]
  1. LINE (0, 0)-(ScreenX - 1, ScreenY - 1), _RGB(0, 0, 0), BF

with this:
Code: QB64: [Select]
  1. LINE (0, 0)-(ScreenX - 1, ScreenY - 1), _RGBA32(0, 0, 0, 60), BF

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Starfield, or wanna-Be Starfield
« Reply #5 on: April 24, 2019, 11:16:49 am »
Fascinating...
Logic is the beginning of wisdom.

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Starfield, or wanna-Be Starfield
« Reply #6 on: April 24, 2019, 11:43:54 am »
It's just Mark's warp sense of humor.

Pete
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline Aurel

  • Forum Regular
  • Posts: 167
    • View Profile
Re: Starfield, or wanna-Be Starfield
« Reply #7 on: April 24, 2019, 02:52:05 pm »
i like
Quote
more favourable outcome.

he he
//////////////////////////////////////////////////////////////////
https://aurelsoft.ucoz.com
https://www.facebook.com/groups/470369984111370
//////////////////////////////////////////////////////////////////

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Starfield, or wanna-Be Starfield
« Reply #8 on: April 24, 2019, 09:53:53 pm »
Well, just me screwing around with code someone else posted, but I did enjoy putting some helm controls in it...

Press w to go to warp, i to return to impulse, and if at warp, use arrow up and down keys to increase/decrease speed. Use s for all STOP and any other key to restart. Esc to terminate. It looks nice if Alt+Enter is used to run it full screen.

@[banned user], I love the gear effect it seems to have when starting in impulse. If I were to tweak it a bit more, I'd try to add some increasing/decreasing red-blue faint color to the star trails at warp speed, and gear the increase and decrease of speeds over time.

I still don't have any projects of my own I feel like coding currently, but this was fun to fiddle around with between other projects today.

Code: QB64: [Select]
  1. _TITLE "Starfield"
  2.  
  3. DEFINT A-Z
  4.  
  5. TYPE Star
  6.     r AS SINGLE
  7.  
  8.     x AS INTEGER
  9.     y AS INTEGER
  10.     z AS INTEGER
  11.  
  12.     x2 AS INTEGER
  13.     y2 AS INTEGER
  14.  
  15.     speed AS INTEGER
  16.  
  17. DIM SHARED Stars(300) AS Star, speed, numStars
  18. numStars = 200
  19.  
  20. speed = 1
  21.  
  22. CONST ScreenX = 800
  23. CONST ScreenY = 600
  24. CONST cx = ScreenX \ 2
  25. CONST cy = ScreenY \ 2
  26.  
  27. SCREEN _NEWIMAGE(ScreenX, ScreenY, 32)
  28.  
  29. FOR Counter = 0 TO numStars - 1
  30.     InitStars (Counter)
  31.  
  32.     _LIMIT 30
  33.     IF warp% THEN LOCATE 1, 1: PRINT "Warp"; warp%; "      ";
  34.     b$ = INKEY$
  35.     IF b$ = CHR$(27) THEN EXIT DO
  36.     IF b$ = CHR$(0) + "H" AND warp% THEN b$ = "W"
  37.     IF UCASE$(b$) = "W" AND warp% < 10 THEN
  38.         warp% = warp% + 1: speed = speed + 2: Stars(Counter).speed = speed: numStars = numStars + speed / 2
  39.     END IF
  40.     IF UCASE$(b$) = "I" THEN warp% = 0: speed = 1: Stars(Counter).speed = speed
  41.     IF warp% THEN
  42.         IF b$ = CHR$(0) + "P" AND warp% > 1 THEN
  43.             warp% = warp% - 1: speed = speed - 2: Stars(Counter).speed = speed: numStars = numStars - speed / 2
  44.         END IF
  45.         LINE (0, 0)-(ScreenX - 1, ScreenY - 1), _RGBA32(0, 0, 0, 60), BF
  46.     ELSE
  47.         IF UCASE$(b$) = "S" THEN SLEEP: b$ = INKEY$: IF b$ = CHR$(27) THEN SYSTEM ELSE _DELAY .3
  48.         LINE (0, 0)-(ScreenX - 1, ScreenY - 1), _RGB(0, 0, 0), BF
  49.     END IF
  50.  
  51.     FOR Counter = 0 TO numStars - 1
  52.         IF warp% = 0 THEN LOCATE 1, 1: PRINT "Impulse Power";
  53.         Stars(Counter).z = Stars(Counter).z - Stars(Counter).speed
  54.         IF Stars(Counter).z < 1 THEN InitStars (Counter)
  55.  
  56.         Stars(Counter).x2 = 64 * (Stars(Counter).x / Stars(Counter).z)
  57.         Stars(Counter).y2 = 64 * (Stars(Counter).y / Stars(Counter).z)
  58.  
  59.         CIRCLE (cx + Stars(Counter).x2, cy + Stars(Counter).y2), Stars(Counter).r, _RGB(255, 255, 255)
  60.         PAINT (cx + Stars(Counter).x2, cy + Stars(Counter).y2), _RGB(255, 255, 255), _RGB(255, 255, 255)
  61.  
  62.         IF Stars(Counter).z < 125 THEN Stars(Counter).r = Stars(Counter).r + 0.02
  63.     NEXT
  64.  
  65.     _DISPLAY
  66.  
  67. SUB InitStars (Counter)
  68. Stars(Counter).r = 1
  69.  
  70. Stars(Counter).x = INT(RND * ScreenX) - cx
  71. Stars(Counter).y = INT(RND * ScreenY) - cy
  72. Stars(Counter).z = INT(RND * numStars) + 1
  73.  
  74. Stars(Counter).speed = speed
  75.  

Pete
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/