Author Topic: Small graphics programming challenge  (Read 6977 times)

0 Members and 1 Guest are viewing this topic.

Offline Richard Frost

  • Seasoned Forum Regular
  • Posts: 316
  • Needle nardle noo. - Peter Sellers
    • View Profile
Small graphics programming challenge
« 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.  
It works better if you plug it in.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Small graphics programming challenge
« Reply #1 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
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Small graphics programming challenge
« Reply #2 on: April 14, 2022, 10:56:54 am »
Hi @Richard Frost

There is naming problem with the Flag files see attached snap
  [ You are not allowed to view this attachment ]  

Offline Richard Frost

  • Seasoned Forum Regular
  • Posts: 316
  • Needle nardle noo. - Peter Sellers
    • View Profile
Re: Small graphics programming challenge
« Reply #3 on: April 14, 2022, 11:14:57 am »
Attachment fixed.  Sorry for posting the message twice.  Mornings......
It works better if you plug it in.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Small graphics programming challenge
« Reply #4 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.