Author Topic: Moving Water Waves  (Read 3720 times)

0 Members and 1 Guest are viewing this topic.

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Moving Water Waves
« Reply #15 on: June 08, 2020, 12:13:06 pm »
LOL Thanks Johno. :)

Offline euklides

  • Forum Regular
  • Posts: 128
    • View Profile
Re: Moving Water Waves
« Reply #16 on: June 08, 2020, 12:23:51 pm »
Very nice. And you can add random, like this...

SCREEN _NEWIMAGE(800, 600, 32)
t = 20
RANDOMIZE TIMER
b = 174
xx = 250
DO
    _LIMIT 500
    IF xx + xx > 1200 THEN xx = 250
    FOR yy = 300 TO 700 'STEP 5 * RND + 1
        FOR x = 0 TO 500
            PSET (x + xx, (SIN(x * 0.1017453 * RND) * t) + yy), _RGB32(25, 50, b)
            PSET (x + xx + 360, (SIN(x * 0.017453) * t) + yy + RND), _RGB32(45, 40, b)
        NEXT x
    NEXT yy
    FOR yy = 300 TO 700 STEP (9 * RND + 2)
        FOR x = xx - 1300 TO xx
            PSET (x + xx, (SIN(x * 0.017453 * RND) * t) + yy), _RGB32(25, 30 * RND + 5, b)
            PSET (x + xx + 360, (SIN(x * 0.017453) * t) + yy), _RGB32(25, 75 * RND + 9, b)
        NEXT x
    NEXT yy
    IF tt = 0 THEN t = t + 2: b = b + 2
    IF t > 80 THEN tt = 1
    IF tt = 1 THEN t = t - 2: b = b - 2
    IF t < -80 THEN tt = 0
    xx = xx + 10
    _DISPLAY
    'CLS:  'no CLS...

LOOP WHILE INKEY$ <> CHR$(27)
Why not yes ?

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Moving Water Waves
« Reply #17 on: June 08, 2020, 12:33:21 pm »
Yeah that's another way to offset the waves :)

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Moving Water Waves
« Reply #18 on: June 08, 2020, 12:41:43 pm »
Pretty cool Euklides! I just tried it on my newer version and it didn't come out good lol. But I kept yours as your mod. :)

Offline _vince

  • Seasoned Forum Regular
  • Posts: 422
    • View Profile
Re: Moving Water Waves
« Reply #19 on: June 08, 2020, 02:46:39 pm »
Nice work, Ken. reminiscent of a young bplus.

The SIN formula can be easily understood, try changing variables a and b in the following example:
variable 'a' is the height of the wave
variable 'b' is the 'width' of one cycle of the wave, in this case both in pixels

Code: QB64: [Select]
  1. a = 100
  2. b = 320
  3.  
  4.  
  5. PSET (0, 240)
  6. FOR x = 0 TO 640
  7.     y = a * SIN(2 * _PI * x / b)
  8.  
  9.     LINE -(x, 240 - y)
  10.  

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Moving Water Waves
« Reply #20 on: June 08, 2020, 07:13:17 pm »
Quote
Nice work, Ken. reminiscent of a young bplus.

LOL! Yes in my younger days I showed you this:

Code: QB64: [Select]
  1. _TITLE "Ocean view" 'b+ 2020-01-11 from old, old sdlbasic 2015-07-02
  2. CONST sw = 640, sh = 480
  3. SCREEN _NEWIMAGE(sw, sh, 32)
  4. FOR i = 0 TO sh / 2
  5.     LINE (0, i)-(sw, i), _RGB32(40, 60, 2 * i / sh * 148 + 80)
  6. FOR y = sh / 2 TO sh
  7.     FOR x = 0 TO sw
  8.         COLOR _RGB32(RND * 40, RND * 60 + 100, RND * 55 + 120)
  9.         PSET (x, y)
  10.     NEXT
  11. WHILE _KEYDOWN(27) = 0
  12.     z = RND * sh / 2
  13.     wh = z / (sh / 2) * 15
  14.     wf = 10 - 10 * (z / (sh / 2))
  15.     wo = z MOD 2
  16.     COLOR _RGB32(RND * 40, RND * 60 + 100, RND * 55 + 120)
  17.     FOR x = 0 TO sw
  18.         y = sh / 2 + z + wh * COS(_D2R(wf * x + 180 * wo))
  19.         LINE (x, y)-STEP(0, 0), , BF
  20.     NEXT
  21.     _DISPLAY
  22.     _LIMIT 60

Offline +KZ

  • Newbie
  • Posts: 21
  • an ugly avatar :)
    • View Profile
Re: Moving Water Waves
« Reply #21 on: June 08, 2020, 08:16:45 pm »
I found a neat ocean waves mp3 sound and added the code to automatically play it when you run the program. So here are Ocean.mp3 and Ken's Water Waves.bas files. Put both files in the same directory.

I had trouble compiling the downloadable version of the program (From quoted post), then someone told me to give the file a shorter name, removing the apostrophe  '  ...

it now work, but for prevent more trouble please fix that file name
google translate :0

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Moving Water Waves
« Reply #22 on: June 08, 2020, 08:20:05 pm »
I had trouble compiling the downloadable version of the program (From quoted post), then someone told me to give the file a shorter name, removing the apostrophe  '  ...

it now work, but for prevent more trouble please fix that file name

You're not one of those crazy Linux users who thinks if it does not work in Linux then it's no good ;-))

It is true, we would like all QB64 programs to work just the same on Windows all versions, Linux all varieties, Mac all flavors, Raspberry Pi as berry's and the Wang 2000 of course!
« Last Edit: June 08, 2020, 08:24:03 pm by bplus »

Offline +KZ

  • Newbie
  • Posts: 21
  • an ugly avatar :)
    • View Profile
Re: Moving Water Waves
« Reply #23 on: June 08, 2020, 08:23:08 pm »
You're not one of those crazy Linux users who thinks if it does not work in Linux then it's no good ;-))

no

also, that sounds like "If it doesn't work on my pc then this is trash >:P" :P
« Last Edit: June 08, 2020, 08:24:36 pm by +KZ »
google translate :0

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Moving Water Waves
« Reply #24 on: June 08, 2020, 08:26:09 pm »
LOL good!

I do hear that Linux is pretty particular when it comes to file names.

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Moving Water Waves
« Reply #25 on: June 08, 2020, 08:43:56 pm »
Thanks everyone! LOL younger days. :) Vince, I'll check out that math, thanks! Bplus, I'll check yours out in a minute.

KZ, I have to have "Ocean.mp3" with apostrophes on my Windows 10 computer or it won't work. I don't know what is going on with yours. I do know that Ocean.mp3 has to be in the same directory as the program itself or it won't work. The mp3 file does not combined with the .exe file to make one file, it has to use both. From what I know anyway. But thanks for trying it out at least!

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Moving Water Waves
« Reply #26 on: June 08, 2020, 08:46:17 pm »
Bplus yours is pretty cool! I like the depth perception. Mine is very up front and yours goes way, way out there. :)

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Moving Water Waves
« Reply #27 on: June 08, 2020, 08:50:20 pm »
@SierraKen, oh it was the title "Ken's Water Waves.bas" title that was the trouble, the ' character. Heck I was surprised that even works in Windows!

Offline +KZ

  • Newbie
  • Posts: 21
  • an ugly avatar :)
    • View Profile
Re: Moving Water Waves
« Reply #28 on: June 08, 2020, 10:49:14 pm »
@SierraKen, oh it was the title "Ken's Water Waves.bas" title that was the trouble, the ' character. Heck I was surprised that even works in Windows!


Lel
google translate :0

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Moving Water Waves
« Reply #29 on: June 09, 2020, 11:58:15 am »
Wow I had no idea, thanks for telling me guys. I removed it from that post and put the newer one in its place. The funny thing is that almost all my QB64 programs I've made start with "Ken's". LOL But I won't do that from now on. lol