Author Topic: Re: a coding challenge from the coding train  (Read 2668 times)

0 Members and 1 Guest are viewing this topic.

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: a coding challenge from the coding train
« Reply #30 on: April 03, 2019, 05:57:48 pm »
@Bplus
? what do you mean?

Left & Right Arrows = do nothing
Up &Down Arrows = Increase/Decrease Worp

 but at Worp 0  the Enterprise is stopped in the sky among the stars.... No normal speed?
:-O what will Captain Kirk think of this ?
Programming isn't difficult, only it's  consuming time and coffee

Offline david_uwi

  • Newbie
  • Posts: 71
    • View Profile
Re: a coding challenge from the coding train
« Reply #31 on: April 04, 2019, 07:53:51 am »
Yes like pete I remember doing this in QB4.5 screen 12. I've found my program from 2006. I've had to put in a delay loop as it was going too fast.
Code: QB64: [Select]
  1. DEFLNG B, G, R
  2. DATA 0,0,0,16,16,16,20,20,20,24,24,24,28,28,28,32,32,32,36,36,36
  3. DATA 40,40,40,44,44,44,48,48,48,56,56,56,63,63,63
  4. FOR i = 0 TO 11
  5.     READ b, g, r
  6.     PALETTE i, b * 65536 + g * 256 + r
  7. 'INPUT "# of stars"; ns
  8. ns = 1000
  9. DIM x(ns), y(ns), n(ns)
  10. FOR i = 1 TO ns
  11.     x(i) = RND * 640
  12.     y(i) = RND * 480
  13.     n(i) = RND * 50
  14.     FOR k = 1 TO ns
  15.         n(k) = n(k) + 1
  16.         m = INT(n(k) / 42)
  17.         IF m > 3 THEN m = 3
  18.         c = INT(n(k) / 5) + 1
  19.         IF c > 11 THEN c = 11
  20.         FOR j = -m TO m
  21.             FOR i = ABS(j) - m TO m - ABS(j)
  22.                 PSET (x(k) + i, y(k) + j), 0
  23.             NEXT i
  24.         NEXT j
  25.         n(k) = n(k) + 1
  26.         yi = 240 - y(k)
  27.         xi = 320 - x(k)
  28.         yi = SGN(yi) * ABS(yi) ^ 1.2
  29.         xi = SGN(xi) * ABS(xi) ^ 1.2
  30.         x(k) = x(k) - xi * .03: y(k) = y(k) - yi * .03
  31.         FOR j = -m TO m
  32.             FOR i = ABS(j) - m TO m - ABS(j)
  33.                 PSET (x(k) + i, y(k) + j), c
  34.             NEXT i
  35.         NEXT j
  36.         IF y(k) < -20 OR y(k) > 500 OR x(k) < -60 OR x(k) > 700 THEN
  37.             x(k) = 160 + (RND * 320)
  38.             y(k) = RND * 240 + 120
  39.             n(k) = 0
  40.         END IF
  41.     NEXT k
  42.     FOR i9 = 1 TO 3000000: NEXT i9 'delay loop

FellippeHeitor

  • Guest
Re: a coding challenge from the coding train
« Reply #32 on: April 04, 2019, 08:03:44 am »
Instead of a FOR delay, use _DELAY or, preferably, _LIMIT:

Code: QB64: [Select]
  1. _LIMIT 30 'block will run at ~30fps