Author Topic: Happy _PI Day!  (Read 1407 times)

0 Members and 1 Guest are viewing this topic.

Offline SierraKen

  • Forum Resident
  • Posts: 1454
Happy _PI Day!
« on: March 14, 2022, 12:18:44 pm »
Happy 3.14 _PI Day!

Here are some orbits I made today.

Code: QB64: [Select]
  1. Screen _NewImage(800, 600, 32)
  2. tilt = 60
  3.     _Limit 300
  4.     Circle (400, 200), 30, _RGB32(127, 255, 255)
  5.  
  6.     seconds = seconds + .1
  7.     If seconds > 59 Then seconds = 0
  8.     s = (60 - seconds) * 6 + 180
  9.     x = Int(Sin(s / 180 * _Pi) * 125) + 400
  10.     y = Int(Cos(s / 180 * _Pi) * 125 / tilt) + 200
  11.     Circle (x, y), 5, _RGB32(255, 0, 0)
  12.     seconds2 = seconds2 + .1
  13.     If seconds2 > 59 Then seconds2 = 0
  14.     s2 = (60 - seconds2) * 6 + 180
  15.     x2 = Int(Sin(s2 / 180 * _Pi) * 125) + 400
  16.     y2 = Int(Cos(s2 / 180 * _Pi) * 125 + tilt) + 200
  17.     Circle (x2, y2), 5, _RGB32(255, 0, 0)
  18.     seconds3 = seconds3 - .1
  19.     If seconds3 > 59 Then seconds3 = 0
  20.     s3 = (60 - seconds3) * 6 + 180
  21.     x3 = Int(Sin(s3 / 180 * _Pi) * 125) + 400
  22.     y3 = Int(Cos(s3 / 180 * _Pi) * 125 - tilt) + 200
  23.     Circle (x3, y3), 5, _RGB32(255, 0, 0)
  24.  
  25.     _Delay .002
  26.     _Display
  27.     Cls
  28.  

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: Happy _PI Day!
« Reply #1 on: March 14, 2022, 12:56:00 pm »
Oh that's today! :)

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • Steve’s QB64 Archive Forum
Re: Happy _PI Day!
« Reply #2 on: March 14, 2022, 01:08:53 pm »
Oh that's today! :)

It's not quite here yet for me on EST!  I'm waiting until 3:09:26.54 PM to celebrate!
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: Happy _PI Day!
« Reply #3 on: March 14, 2022, 01:13:16 pm »
A pie moment, with apple pie?

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
Re: Happy _PI Day!
« Reply #4 on: March 14, 2022, 02:29:06 pm »
Fun fact: The 14th of March (in your case - Pi-day) was once referred to as "The Ides of March". Ides simply referred to the first new moon of a given month, which usually fell between the 13th and 15th. In fact, the Ides of March once signified the new year, which meant celebrations and rejoicing.
Logic is the beginning of wisdom.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • Steve’s QB64 Archive Forum
Re: Happy _PI Day!
« Reply #5 on: March 14, 2022, 03:56:33 pm »
A pie moment, with apple pie?
March -- 3
14th -- .14

at

3 PM -- 15
09 --     9
and 26.54 milliseconds,

I had Boston Cream Pie in honor of Pi Day!

(Or mighty dern close to that time!  The spirit was there, even if the physics was a slag behind!)
« Last Edit: March 14, 2022, 11:47:39 pm by SMcNeill »
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Dav

  • Forum Resident
  • Posts: 792
Re: Happy _PI Day!
« Reply #6 on: March 14, 2022, 07:51:28 pm »
PI day, huh?  Now I know why the pizza place around here had pizza pie specials today.  Here’s something real freaky - my wrist watch stopped working today. It’s battery died I’m guessing.  Stopped at 3:14pm EST. Not sure if that’s a good or bad sign...

- Dav

Offline SierraKen

  • Forum Resident
  • Posts: 1454
Re: Happy _PI Day!
« Reply #7 on: March 15, 2022, 04:49:12 pm »
Here is version 2. I finally figured out how to make the 3D orbiting Moon disappear when it flies behind the planet. The trick is seeing where X is and also the fact that Y changes also in that location. The funny thing is I spent hours trying all kinds of ways but it finally came to me within minutes today. Version 2 also lets you slow down and speed up the orbits using your Mouse Wheel. Plus if you click the Left Mouse Button, it randomly positions the Moons and puts them in slightly different orbits. The vertical orbiting Moons change a lot more than the horizontal 3D Moon. I also filled up each circle with solid colors. Tell me what you think, thanks.

Code: QB64: [Select]
  1. _Title "Orbits by SierraKen - Use Mouse Wheel and Left Button - version 2"
  2. Screen _NewImage(800, 600, 32)
  3. tilt = 10
  4. delay = .004
  5. seconds2 = 30
  6.     _Limit 400
  7.     a$ = InKey$
  8.     If a$ = Chr$(27) Then End
  9.     If a$ = " " Or mouseLeftButton = -1 Then
  10.         seconds = (Rnd * 58) + 1
  11.         seconds2 = (Rnd * 58) + 1
  12.         seconds3 = (Rnd * 58) + 1
  13.         tilt = (Rnd * 49) + 10
  14.     End If
  15.  
  16.     mouseWheel = 0
  17.         mouseLeftButton = _MouseButton(1)
  18.         mouseRightButton = _MouseButton(2)
  19.         mouseMiddleButton = _MouseButton(3)
  20.         mouseWheel = mouseWheel + _MouseWheel
  21.     Loop
  22.     If mouseWheel = -1 Then delay = delay + .0001
  23.     If mouseWheel = 1 Then delay = delay - .0001
  24.     If delay > .02 Then delay = .02
  25.     If delay < .002 Then delay = .002
  26.     'Planet
  27.     For siz = .1 To 30 Step .1
  28.         Circle (400, 200), siz, _RGB32(127, 255, 255)
  29.     Next siz
  30.     '3D Orbit Moon
  31.     seconds = seconds + .1
  32.     If seconds > 59 Then seconds = 0
  33.     s = (60 - seconds) * 6 + 180
  34.     x = Int(Sin(s / 180 * _Pi) * 125) + 400
  35.     y = Int(Cos(s / 180 * _Pi) * 125 / tilt) + 200
  36.     If x > 367 And x < 430 And y <= 198 Then GoTo skip:
  37.     For siz = .1 To 5 Step .1
  38.         Circle (x, y), siz, _RGB32(255, 255, 255)
  39.     Next siz
  40.     skip:
  41.     'Moon 2
  42.     seconds2 = seconds2 + .1
  43.     If seconds2 > 59 Then seconds2 = 0
  44.     s2 = (60 - seconds2) * 6 + 180
  45.     x2 = Int(Sin(s2 / 180 * _Pi) * 125) + 400
  46.     y2 = Int(Cos(s2 / 180 * _Pi) * 125 + tilt) + 200
  47.     For siz = .1 To 5 Step .1
  48.         Circle (x2, y2), siz, _RGB32(127, 55, 255)
  49.     Next siz
  50.     'Moon 3
  51.     seconds3 = seconds3 - .1
  52.     If seconds3 > 59 Then seconds3 = 0
  53.     s3 = (60 - seconds3) * 6 + 180
  54.     x3 = Int(Sin(s3 / 180 * _Pi) * 125) + 400
  55.     y3 = Int(Cos(s3 / 180 * _Pi) * 125 - tilt) + 200
  56.     For siz = .1 To 5 Step .1
  57.         Circle (x3, y3), siz, _RGB32(116, 255, 128)
  58.     Next siz
  59.     _Delay delay
  60.     _Display
  61.     Cls
  62.  
  63.