Author Topic: QB64 code for "Spinny Cube"  (Read 8734 times)

0 Members and 1 Guest are viewing this topic.

Offline CharlieJV

  • Newbie
  • Posts: 89
    • View Profile
QB64 code for "Spinny Cube"
« on: February 26, 2022, 09:22:03 pm »

I didn't go out of my way to make the QB64 code pretty.  I just did bare minimum to get program working:

Code: QB64: [Select]
  1. ' BASIC Anywhere Machine version of Spinny Cube by Dean Belfield
  2. ' As presented in Paul Dunn's "Spinny Cube" video ([youtube]https://www.youtube.com/watch?v=bXC9qy4dGeE[/youtube])
  3. dim the as double : dim psi as double : dim phi as double
  4. the = 0.00 : psi = 0.00 : phi = 0.00
  5. dim a(8), b(8) as double
  6. xd = 0 : yd = 0 : xo = 0 : yo = 0
  7. sd = 640 : od = 480
  8. sw = 200 : sh = 200
  9. dim shape_pts(8,3), shape(6,4) as double
  10. for i = 0 to 23 : read shape_pts(int(i/3), i mod 3) : next i
  11. for i = 0 to 23 : read shape(int(i/4), i mod 4) : next i
  12. 30 the = 0 : psi = 0 : phi = 0
  13. the = the + .01 : psi = psi + .03 : phi = phi - .02
  14. _delay 0.0125 : cls
  15. 40 for i = 0 to 7
  16.     xx = shape_pts(i,0) : yy = shape_pts(i,1) : zz = shape_pts(i,2)
  17.     y = yy*cos(phi) - zz*sin(phi) : zz = yy*sin(phi) + zz*cos(phi)
  18.     x = xx*cos(the) - zz*sin(the) : zz = xx*sin(the) + zz*cos(the)
  19.     xx = x*cos(psi) - y*sin(psi) : yy = x*sin(psi) + y*cos(psi)
  20.     xx = xx + xo + xd : yy = yy + yo + yd
  21.     a(i) = sw + xx * sd / (od - zz )
  22.     b(i) = sh + yy * sd / (od - zz )
  23. for i = 0 to 5
  24.     x1 = a(shape(i,0)) : x2=a(shape(i,1)) : x3 = a(shape(i, 2)) : x4 = a(shape(i,3))
  25.     y1 = b(shape(i,0)) : y2=b(shape(i,1)) : y3 = b(shape(i, 2)) : y4 = b(shape(i,3))
  26.     if x1*(y2-y3) + x2*(y3-y1) + x3*(y1-y2) <= 0 then
  27.         line (x1, y1) - (x2, y2), 13
  28.         line (x2, y2) - (x3, y3), 13
  29.         line (x3, y3) - (x4, y4), 13
  30.         line (x4, y4) - (x1, y1), 13
  31.     end if
  32. '
  33. '
  34. '
  35. 50 data -20,20,20,20,20,20,-20,-20,20,20,-20,20,-20,20,-20,20,20,-20,-20,-20,-20,20,-20,-20
  36. 60 data 0,1,3,2,6,7,5,4,1,5,7,3,2,6,4,0,2,3,7,6,0,4,5,1
  37.  

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: QB64 code for "Spinny Cube"
« Reply #1 on: February 26, 2022, 09:33:23 pm »
Hey Paul Dunn again!

Could be handy for The 6 Sides of Cube challenge at Syntax Bomb.

Offline _vince

  • Seasoned Forum Regular
  • Posts: 422
    • View Profile
Re: QB64 code for "Spinny Cube"
« Reply #2 on: February 27, 2022, 12:13:39 pm »
Hey Paul Dunn again!

Could be handy for The 6 Sides of Cube challenge at Syntax Bomb.

wow what is syntax bomb and what is it about?

Offline CharlieJV

  • Newbie
  • Posts: 89
    • View Profile
Re: QB64 code for "Spinny Cube"
« Reply #3 on: February 27, 2022, 12:16:56 pm »
wow what is syntax bomb and what is it about?

I had just chalked that up to an inside joke that flew over my head.

Huh:  https://www.syntaxbomb.com/game-coding-competitions/code-a-game-comp-14-the-six-sides-of-qube-8840

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: QB64 code for "Spinny Cube"
« Reply #4 on: February 27, 2022, 12:31:43 pm »
wow what is syntax bomb and what is it about?

Actually it's The 6 Sides of Qube:
https://www.syntaxbomb.com/game-coding-competitions/code-a-game-comp-14-the-six-sides-of-qube-8840/

Back story: Qube is founder of the forum Syntax Bomb, allot of Blitz Basic and variations people there but all indie (? not sure)  coders welcome and games are Open Competitions. BTW Syntax Bomb became Home for SmallBASIC after Walter abandoned us po Baisc fans and closed down his forum, did it again at Friends... but that's for another day.

Qube had very unfortunate event happen before Xmas. Qube disappeared for awhile and when back told story of betrayal of trusted friend and partner. Now broke, had to sell off expensive gaming stuff. The forum was even shut down for awhile. I guess better heads prevailed and it's back. The Game competitions are the raison d'etre(reason for existence of) the forum maybe even major contributor of Qubes happiness and other core members.

So on the subject of next competition theme they started talking:
https://www.syntaxbomb.com/game-coding-competitions/time-for-another-game-comp/msg347054494/#msg347054494

PS while writing this Charlie posted sorry....  ;-))
also I apologize for possibly distracting from great code translation!
« Last Edit: February 27, 2022, 12:37:21 pm by bplus »

Offline Qwerkey

  • Forum Resident
  • Posts: 755
    • View Profile
Re: QB64 code for "Spinny Cube"
« Reply #5 on: February 27, 2022, 12:50:22 pm »
@CharlieJV This post is some QB64 code leading to an executable.  It is not, I think, a discussion on QB64.  It would be better placed in Programs.  If similar next time, put this sort of thing there if you would.
Not important, just tidy.


Offline CharlieJV

  • Newbie
  • Posts: 89
    • View Profile
Re: QB64 code for "Spinny Cube"
« Reply #6 on: February 27, 2022, 12:55:01 pm »
{snip!}
PS while writing this Charlie posted sorry....  ;-))
also I apologize for possibly distracting from great code translation!

Oh heck no, please do not apologize.  How on earth could I ever have found out about SyntaxBomb otherwise?   And a meaty backstory to boot !  Worth it.


Offline CharlieJV

  • Newbie
  • Posts: 89
    • View Profile
Re: QB64 code for "Spinny Cube"
« Reply #7 on: February 27, 2022, 12:59:34 pm »
@CharlieJV This post is some QB64 code leading to an executable.  It is not, I think, a discussion on QB64.  It would be better placed in Programs.  If similar next time, put this sort of thing there if you would.
Not important, just tidy.

I didn't see that as a fit because of comparison with SpecBAS code and BASIC Anywhere Machine code, and massaging code from those to QB64 and maybe back.

It might be a good idea to change the description of the other forum to say all demo programs.  I really can't make heads or tails of the intended purpose for that other forum.  As is, that description would be better with something much more clear/simple.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: QB64 code for "Spinny Cube"
« Reply #8 on: February 27, 2022, 02:00:19 pm »
Yeah I look at Discussion board as Talk centric and Programs QB64 Code centric unless the talk is about a code problem in which case you have to bring in code to help illustrate in Discussion Board. But then again, you might have a problem with a WIP and so it would be in Programs Board as a small part of the overall WIP.

Translations from one code or platform to another? Could go either way, are you asking for help = Discussion Board or showing off, pictures on the fridge door = Programs Board.

Hope that helps clear things up ;-))

If you really screw up you will probably hear from Odin.

Offline CharlieJV

  • Newbie
  • Posts: 89
    • View Profile
Re: QB64 code for "Spinny Cube"
« Reply #9 on: February 27, 2022, 03:12:35 pm »
Yeah I look at Discussion board as Talk centric and Programs QB64 Code centric unless the talk is about a code problem in which case you have to bring in code to help illustrate in Discussion Board. But then again, you might have a problem with a WIP and so it would be in Programs Board as a small part of the overall WIP.

Translations from one code or platform to another? Could go either way, are you asking for help = Discussion Board or showing off, pictures on the fridge door = Programs Board.

Hope that helps clear things up ;-))

If you really screw up you will probably hear from Odin.

I don't think there is a soul who could do any better.  (The spirit of that is not clear in the descriptions.)

However, it is too much effort figuring out which forum I go to for posting something.

When the very first forum says "All things QB64 here", I figure the description means it.  So I jump in.

The list of forums and descriptions need some TLC for guiding folk to the right place.  Although I don't think "no brainer" choices can ever be achieved, it is far from no-brainer now.

If I have to get directions for every time I post something, or if I have to go deer in the headlights thinking maybe it should go here or there, I'm either not going to post anything at all or roll the dice (and ignore any directions after rolling the dice.)  I am too old and life is way too short to be bothered trying to make heads or tails of things.

Aside: cognitively disabilities over here, so I really desperately need clear organization of things, although that can be a real crap shoot because I do process things very (like: way way out there) differently.  Kind of why I dropped out of the idea of helping with the wiki.  The "do's" and "don't's" are not obvious, and reminders add to cognitive overload.

For example: "all things QB64" seemed right, Programs not so much, and if Programs, then I think: wouldn't "Samples" make more sense?

Paralysis by analysis, I'd rather not.  Man, that's already a 24x7 thing for me, unless I go bubble boy and keep to myself.  That does get lonely, though.  Yet safe.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: QB64 code for "Spinny Cube"
« Reply #10 on: February 27, 2022, 03:57:55 pm »
edit:
Oh I see where you are getting "All Things QB64" that just means don't talk about things unrelated to QB64, eg problems with your mistress or that orange politician.

Well if you become totally paralyzed try checking with Fellippe, he happens to know Odin's thinking or Qwerkey LOL!
« Last Edit: February 27, 2022, 04:06:19 pm by bplus »

Offline CharlieJV

  • Newbie
  • Posts: 89
    • View Profile
Re: QB64 code for "Spinny Cube"
« Reply #11 on: February 27, 2022, 05:18:39 pm »
edit:
Oh I see where you are getting "All Things QB64" that just means don't talk about things unrelated to QB64, eg problems with your mistress or that orange politician.

Pff, as long as it is "all things QB64 and the first choice, I'll be going to it every time.

Now I'm going to be wishing for QB64-related posts that are somehow intertwingled with captivating stories of mistresses.  Having to look it up, I'm thinking funny the male version of mistress is called a mister.  That's just weird.  Totally QB64-related ...

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: QB64 code for "Spinny Cube"
« Reply #12 on: February 27, 2022, 05:32:50 pm »
OK now don't think of QB64 stuff. Anything but QB64. LOL

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: QB64 code for "Spinny Cube"
« Reply #13 on: February 27, 2022, 06:02:02 pm »
Having to look it up, I'm thinking funny the male version of mistress is called a mister.

Mister isn't a male mistress.  The word you're looking for is either a paramour, or else an inamorato.  Or, the the southern US, you'd call them a "dandy beau".  ;)
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline CharlieJV

  • Newbie
  • Posts: 89
    • View Profile
Re: QB64 code for "Spinny Cube"
« Reply #14 on: February 27, 2022, 08:23:33 pm »
Mister isn't a male mistress.  The word you're looking for is either a paramour, or else an inamorato.  Or, the the southern US, you'd call them a "dandy beau".  ;)

+ 1

Bad mistake by moi after reading:  According to morphology, 'mister' is the male form of 'mistress', just as 'waiter' is that of 'waitress'. However, the sense of 'mistress' changed from something like 'lady' to 'a sexually related women of a married man', while 'mister' (Mr.) remains a general word refering to any an adult man.

And for the giggles, although I don't know how I feel about it: misteress

This needs an algorithm ...