Author Topic: Dropping Balls  (Read 401 times)

Offline bplus

  • B = B + ware
Re: Dropping Balls
« Reply #15 on: June 10, 2018, 09:36:39 PM »
Hi Code Hunter,

The mirror effect helps explain what I first saw. I like silence too, and the song and unique sounds. Thanks for adding notes to code.


Hi V,

The hour glass is good start, ball containment seems first priority but some are being contained, I will look into what you are doing with that more closely.

The 2nd one with the numbers rotated on balls is cool and it would be really interesting if a constant but different spin were added to each ball as they move around. Nice one guys!

I have to confess, when I saw hour glass running I was thinking lottery and the ping pong balls WITH NUMBERS flying around! :D
« Last Edit: June 10, 2018, 09:40:05 PM by bplus »
B = B + ...

Offline FellippeHeitor

  • QB64 Developer
  • LET IT = BE
    • QB64.org
Re: Dropping Balls
« Reply #16 on: June 10, 2018, 09:40:24 PM »
I have to confess, when I saw hour glass running I was thinking lottery and the ping pong balls WITH NUMBERS flying around! :D

Exactly what I had in mind when I proposed it too!

Offline bplus

  • B = B + ware
Re: Dropping Balls
« Reply #17 on: June 10, 2018, 10:02:38 PM »
Hey great minds think alike!  oops... ;D

B = B + ...

Offline Ashish

  • The joy of coding is endless.
Re: Dropping Balls
« Reply #18 on: June 11, 2018, 09:16:29 AM »
@vince
That hourglass one simulation was good! 🙂
if (Me.success) {Me.improve()} else {Me.tryAgain()}


aKFrameWork - http://bit.ly/aKFrameWork
Menu System - http://bit.ly/guiMenuBar
p5.js in QB64 - http://bit.ly/p5jsbas

@KingOfCoders

Re: Dropping Balls
« Reply #19 on: June 11, 2018, 10:34:16 AM »
Hy Guys
Hy Vincent

very very fine effect in your mod/demo... but it is outlaw! :-) for gravity law surely....
see image to get into issue....

Thank's to share code

Offline bplus

  • B = B + ware
Re: Dropping Balls
« Reply #20 on: June 11, 2018, 11:33:24 AM »
Yes, I found that problem developing in my run too, the problem with modifying over and over... I had that fixed (maybe I should say balanced) in original code by altering the drop point. It also has something to do with elastic = sticky variable the lower the elastic setting the higher the stickiness.
« Last Edit: June 11, 2018, 11:37:13 AM by bplus »
B = B + ...

Re: Dropping Balls
« Reply #21 on: June 11, 2018, 02:27:02 PM »
Hy Guys
Hy Vincent

very very fine effect in your mod/demo... but it is outlaw! :-) for gravity law surely....
see image to get into issue....

Thank's to share code

Entirely bplus's and xstatic's fault. I had no part in the physics simulation.

Offline bplus

  • B = B + ware
Re: Dropping Balls
« Reply #22 on: June 11, 2018, 03:26:35 PM »
Hy Guys
Hy Vincent

very very fine effect in your mod/demo... but it is outlaw! :-) for gravity law surely....
see image to get into issue....

Thank's to share code

Entirely bplus's and xstatic's fault. I had no part in the physics simulation.

V you have changed the code since I saw it (the problem is now exaggerated! probably due to big increase in Ball Radius), don't blame me for what you do with the code.

Append: I will say also (in your defense) that it is probably quite unexpected that a change in ball radius should effect "the physic's" but this code was modified from original dropping balls to try and get as perfect a pyramid formed and to do that "the physics" was already stretched beyond real world kind (if it was ever close to start).  Also by same logic, STxAxTIC should get 0 blame for what I did with his code.

« Last Edit: June 11, 2018, 05:00:04 PM by bplus »
B = B + ...

Re: Dropping Balls
« Reply #23 on: June 11, 2018, 05:07:40 PM »
I'm joking, bplus. Tempodibasic's riveting analysis warranted the response.

Offline bplus

  • B = B + ware
Re: Dropping Balls
« Reply #24 on: June 11, 2018, 05:23:18 PM »
I'm joking, bplus. Tempodibasic's riveting analysis warranted the response.

I was hoping that! but apparently I don't have much faith in my hopes.

Well I really like the numbers on the balls and would like to see them spin independently as they move and the hour glass thing might spin off to lottery thing. (pun intended)
B = B + ...

Re: Dropping Balls
« Reply #25 on: June 13, 2018, 01:24:48 AM »
By the way, bplus, I may as well ask here. Since you make these screensaver/graphic demo type programs (as do I) in a variety of *BASICs (smallbasic, largebasic, purebasic, justbasic, etc), how do you feel about FreeBASIC?  It's pretty much the best for this sort of thing: makes small speedy exes, all the same graphics capability, cleaner syntax, and doesn't obscure advanced features, such as memory access, from the user. There's #lang "fblite" if you want it more QB-like, ie not forcing variable declaration. I suppose it doesn't have the same pull for the old DOS QB45 compatible nostalgia crowd and may not be as beginner friendly as the other BASICs but it is objectively the best.  I would certainly prefer it over QB64 for this type of thing, I wonder if you feel the same.

Offline bplus

  • B = B + ware
Re: Dropping Balls
« Reply #26 on: June 13, 2018, 10:23:44 AM »
Hi V,

I did try FB before QB64, quite a struggle to get started with it. Since I got into QB64, 50% of my FB no longer works. It is too confusing learning these 2 Basic's so similar and yet... I try running code off their forum and usually something goes wrong for me. Seems to me, QB64 has plenty of graphics devices for interesting screen stuff specially compared to what I had been using previous couple of years.

I started looking into your Hour Glass modification last night, looks like you are flipping between 2 screen pages which threw me (a technique I also found at FB instead of QB64 _DISPLAY which does the screen update in one go). But the one thing that really blew my mind was this:
Code: [Select]

SCREEN , , 1, 0 'hmm never used these before = active page 1, visual page 0
LINE (0, 0)-(800, 600), _RGB(0, 0, 0), BF '>>>>>>>>>>>>>>>>>>>>> If I comment out just this one line
a = 0
xx = 150 * SIN(2 * a)
yy = 300 * COS(a)
PSET (xx + 400, yy + 300), _RGB(100, 100, 100)
FOR a = 0 TO 2 * pi STEP 0.01
    xx = 150 * SIN(2 * a)
    yy = 300 * COS(a)
    LINE -(xx + 400, yy + 300), _RGB(100, 100, 100)
NEXT

PAINT (400, 150), _RGB(100, 100, 100)
PAINT (400, 450), _RGB(100, 100, 100)
LINE (380, 150)-(420, 450), _RGB(100, 100, 100), BF

PCOPY 1, 0  'new also to me


balls = 0
FOR yy = 50 TO 300 - 10 STEP 8
    FOR xx = 10 TO 600 - 10 STEP 8
        IF POINT(xx, yy) <> _RGB(0, 0, 0) THEN
            balls = balls + 1
            '  VVVVVVVVVVVVVVVVVVVVVV stuff here starts giving me errors, for ball array assignment???????
            r(balls) = 3
            x(balls) = xx
            y(balls) = yy
            c(balls) = 15
            dx(balls) = rand(0, 3) * rdir
            dy(balls) = 15

            rr(balls) = 255
            gg(balls) = 255
            bb(balls) = 0
        END IF
    NEXT
NEXT

SCREEN , , 0, 0


How can a simple LINE statement that basically clears the screen be so vital to ball array assignments?

Also why do the balls immediately head to the right of the screen when not contained by the Hour glass figure? Their change in direction, dx (maybe called the x vector), should not be that uniform at all.

« Last Edit: June 13, 2018, 10:37:37 AM by bplus »
B = B + ...

Re: Dropping Balls
« Reply #27 on: June 13, 2018, 03:51:10 PM »
Quote
Hi V,

I did try FB before QB64, quite a struggle to get started with it. Since I got into QB64, 50% of my FB no longer works. It is too confusing learning these 2 Basic's so similar and yet... I try running code off their forum and usually something goes wrong for me. Seems to me, QB64 has plenty of graphics devices for interesting screen stuff specially compared to what I had been using previous couple of years.

I started looking into your Hour Glass modification last night, looks like you are flipping between 2 screen pages which threw me (a technique I also found at FB instead of QB64 _DISPLAY which does the screen update in one go). But the one thing that really blew my mind was this:
Code: [Select]

SCREEN , , 1, 0 'hmm never used these before = active page 1, visual page 0
LINE (0, 0)-(800, 600), _RGB(0, 0, 0), BF '>>>>>>>>>>>>>>>>>>>>> If I comment out just this one line
a = 0
xx = 150 * SIN(2 * a)
yy = 300 * COS(a)
PSET (xx + 400, yy + 300), _RGB(100, 100, 100)
FOR a = 0 TO 2 * pi STEP 0.01
    xx = 150 * SIN(2 * a)
    yy = 300 * COS(a)
    LINE -(xx + 400, yy + 300), _RGB(100, 100, 100)
NEXT

PAINT (400, 150), _RGB(100, 100, 100)
PAINT (400, 450), _RGB(100, 100, 100)
LINE (380, 150)-(420, 450), _RGB(100, 100, 100), BF

PCOPY 1, 0  'new also to me


balls = 0
FOR yy = 50 TO 300 - 10 STEP 8
    FOR xx = 10 TO 600 - 10 STEP 8
        IF POINT(xx, yy) <> _RGB(0, 0, 0) THEN
            balls = balls + 1
            '  VVVVVVVVVVVVVVVVVVVVVV stuff here starts giving me errors, for ball array assignment???????
            r(balls) = 3
            x(balls) = xx
            y(balls) = yy
            c(balls) = 15
            dx(balls) = rand(0, 3) * rdir
            dy(balls) = 15

            rr(balls) = 255
            gg(balls) = 255
            bb(balls) = 0
        END IF
    NEXT
NEXT

SCREEN , , 0, 0


How can a simple LINE statement that basically clears the screen be so vital to ball array assignments?

Also why do the balls immediately head to the right of the screen when not contained by the Hour glass figure? Their change in direction, dx (maybe called the x vector), should not be that uniform at all.



I was curious and tried it. And I got the hourglass body. Could you give me a link where this source comes from? Thanks

Code: [Select]

'SCREEN , , 1, 0 'hmm never used these before = active page 1, visual page 0

one& = _NEWIMAGE(800, 600, 32)
_DEST one&

LINE (0, 0)-(800, 600), _RGB(0, 0, 0), BF '>>>>>>>>>>>>>>>>>>>>> If I comment out just this one line
a = 0
xx = 150 * SIN(2 * a)
yy = 300 * COS(a)
PSET (xx + 400, yy + 300), _RGB(100, 100, 100)
FOR a = 0 TO 2 * _PI STEP 0.01
    xx = 150 * SIN(2 * a)
    yy = 300 * COS(a)
    LINE -(xx + 400, yy + 300), _RGB(100, 100, 100)
NEXT

PAINT (400, 150), _RGB(100, 100, 100)
PAINT (400, 450), _RGB(100, 100, 100)
LINE (380, 150)-(420, 450), _RGB(100, 100, 100), BF

PCOPY 1, 0 'standard Qbasic statement - copy videomemory source, dest


'balls = 0
TYPE balls
    r AS INTEGER
    x AS INTEGER
    y AS INTEGER
    c AS LONG
    dx AS INTEGER
    dy AS INTEGER
    rr AS _UNSIGNED _BYTE
    gg AS _UNSIGNED _BYTE
    bb AS _UNSIGNED _BYTE
END TYPE
REDIM balls(0) AS balls


FOR yy = 50 TO 300 - 10 STEP 8
    FOR xx = 10 TO 600 - 10 STEP 8
        _SOURCE one&
        IF POINT(xx, yy) <> _RGB(0, 0, 0) THEN
            balls = balls + 1
            REDIM _PRESERVE balls(balls) AS balls
            '  VVVVVVVVVVVVVVVVVVVVVV stuff here starts giving me errors, for ball array assignment???????
            balls(balls).r = 3
            balls(balls).x = xx
            balls(balls).y = yy
            balls(balls).c = 15
            balls(balls).dx = RND * 3 * rdir 'this i know not. What is it rdir?
            balls(balls).dy = 15

            balls(balls).rr = 255
            balls(balls).gg = 255
            balls(balls).bb = 0
        END IF
    NEXT
NEXT

'SCREEN , , 0, 0
SCREEN one&

I have never seen Free Basic.
« Last Edit: June 13, 2018, 03:58:22 PM by Petr »
Coding is relax (At least sometimes)

Offline bplus

  • B = B + ware
Re: Dropping Balls
« Reply #28 on: June 13, 2018, 04:58:42 PM »
Quote
I was curious and tried it. And I got the hourglass body. Could you give me a link where this source comes from? Thanks

Reply #12 of this thread is Vince mod of Dropping Balls with the Hour Glass figure.

B = B + ...

Re: Dropping Balls
« Reply #29 on: June 13, 2018, 06:22:26 PM »
Aha! Good work. Thank for reply.
Coding is relax (At least sometimes)