QB64.org Forum

Active Forums => QB64 Discussion => Topic started by: Richard Frost on April 14, 2022, 10:31:33 am

Title: Small graphics programming challenge
Post by: Richard Frost on April 14, 2022, 10:31:33 am
' Small programming challenge contained at:
'

' It's a boring hour and a half of some guy creating CSS code for a simple animation to:
' 1) Have 8 icons/pictures rotating in a circle, while pulsing
' 2) when one selected, stop all rotation, the pulsing of the selected item, and
'    identify the selected item
' Use any 8 pix you've got handy, or the flags I've attached here.
Code: QB64: [Select]
  1. Data albania,britain,canada,eu,us,japan,israel,china
  2. Screen _NewImage(800, 600, 32)
  3. For i = 1 To 8
  4.     Read name$(i)
  5.     pix(i) = _LoadImage("f_" + name$(i) + ".png")
  6. td = 1 '                                         throb direction
  7.         mx = _MouseX
  8.         my = _MouseY
  9.         mb = _MouseButton(1)
  10.     Wend
  11.     Cls
  12.     hl = 0 '                                     highlight
  13.     For i = 1 To 8
  14.         r = _D2R(i * 45 + aa) '                  angle in radians
  15.         x = 400 + 200 * Cos(r)
  16.         y = 300 + 200 * Sin(r)
  17.         tt = th '                                temporary throb = current
  18.         If mb And (Abs(x - mx) < 30) And (Abs(y - my) < 30) Then ' selected
  19.             tt = 0 '                             temporary throb off
  20.             hl = 1 '                             highlight on
  21.             _PrintString (x - 26, y - 50), name$(i)
  22.         End If
  23.         _PutImage (x - 30 + tt, y - 30 + tt)-(x + 30 - tt, y + 30 - tt), pix(i), 0
  24.     Next i
  25.     _Display '                                   optional, eliminates flickering
  26.     aa = (aa - (hl = 0)) Mod 360 '               angle advance
  27.     th = th + td '                               throb
  28.     If Abs(th) = 3 Then td = -td '               throb direction
  29.  
Title: Re: Small graphics programming challenge
Post by: SMcNeill on April 14, 2022, 10:50:35 am
He stopped halfway...  I've got this on here somewhere, except my version lets you click on the circles and use them as a pop-up menu.  :P
Title: Re: Small graphics programming challenge
Post by: bplus on April 14, 2022, 10:56:54 am
Hi @Richard Frost

There is naming problem with the Flag files see attached snap
  [ This attachment cannot be displayed inline in 'Print Page' view ]  
Title: Re: Small graphics programming challenge
Post by: Richard Frost on April 14, 2022, 11:14:57 am
Attachment fixed.  Sorry for posting the message twice.  Mornings......
Title: Re: Small graphics programming challenge
Post by: bplus on April 14, 2022, 11:41:35 am
Attachment fixed.  Sorry for posting the message twice.  Mornings......

Yeah mornings, flag file names are the same.