Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A bigger bouncing ball demo - collision with vector reflection
#11
(09-18-2024, 08:43 AM)NakedApe Wrote: Hey @sbblank. Yeh, things are a little different for us Mac users. I had the same issue with another Dav program here: 
https://qb64phoenix.com/forum/showthread...1#pid28011

Thanks... that's a heck of a nice Dav program also (after adjusting for the Mac)!
Reply
#12
Dav,

I like your Bigball Demo.

GareBear
Reply
#13
Could some of you mac users please run this code and see if SQR causes the same error there?  I've been wondering about all my graphics programs that use SQR now.

Thanks!

- Dav

Code: (Select All)
'Imageball.bas
'Draws a ball with image& on it
'By Dav for QB64

Screen _NewImage(800, 600, 32)

'Make sample texture& image to use
texture& = _NewImage(250, 250, 32)
'point to the image
_Dest texture&
'draw something there
Cls , _RGB(33, 66, 99)
For x = 0 To _Width Step 25
    For y = 0 To _Height Step 25
        Line (x, y)-Step(50, 50), _RGBA(Rnd * 255, Rnd * 255, Rnd * 255, Rnd * 255), BF
        Circle (Rnd * _Width, Rnd * _Height), 5 + Rnd * 20, _RGB(Rnd * 255, Rnd * 255, 255)
        Line (x, y)-Step(50, 50), _RGB(0, 0, 0, 0), B
    Next
Next

'go back to main screen
_Dest 0


Do
    ImageBall Rnd * _Width, Rnd * _Height, 75 + Rnd * 75, texture&
    _Limit 60
Loop Until _KeyHit

End

Sub ImageBall (x, y, size, image&)
    'puts image& on a ball.

    'To make it look better, make a temp image to match the size of the ball
    temp& = _NewImage(size * 2, size * 2, 32)
    'put the image& into temp&, stretch to fill
    _PutImage (0, 0)-(_Width(temp&), _Height(temp&)), image&, temp&
    orig& = _Source 'save current _source
    _Source temp& 'switch to temp&
    For y2 = y - size To y + size
        For x2 = x - size To x + size
            If Sqr((x2 - x) ^ 2 + (y2 - y) ^ 2) <= size Then
                clr = (size - (Sqr((x2 - x) * (x2 - x) + (y2 - y) * (y2 - y)))) / size
                c& = Point(x2 - x + size, y2 - y + size): r = _Red32(c&): g = _Green32(c&): b = _Blue32(c&)
                PSet (x2, y2), _RGB(clr * r, clr * g, clr * b)
            End If
        Next
    Next
    _FreeImage temp&
    _Source orig&
End Sub

Find my programs here in Dav's QB64 Corner
Reply
#14
Runs like a charm on my M1 and M2 Mac, @Dav. You da man - with snazzy balls.   Big Grin
Reply
#15
(09-19-2024, 04:59 PM)NakedApe Wrote: Runs like a charm on my M1 and M2 Mac, @Dav. You da man - with snazzy balls.   Big Grin

Same here on my M1 Max... nice!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  WinAPI Mouse Demo Pete 0 184 12-20-2025, 06:40 PM
Last Post: Pete
  Hyperlink Demo in SCREEN 0 Pete 2 366 11-02-2025, 07:13 PM
Last Post: madscijr
  Triangle-Based Collision Detection Herve 3 472 11-01-2025, 01:37 AM
Last Post: Unseen Machine
  Bouncing lines & boxes Dav 6 1,959 04-12-2025, 06:14 AM
Last Post: madscijr
  Sound Ball SierraKen 0 448 12-17-2024, 11:34 PM
Last Post: SierraKen

Forum Jump:


Users browsing this thread: