Author Topic: animation player  (Read 5352 times)

0 Members and 1 Guest are viewing this topic.

Offline mynameispaul

  • Newbie
  • Posts: 49
    • View Profile
animation player
« on: February 09, 2019, 11:49:38 am »
This program is designed to create animation by playing a series of JPEG's in sequence.

Setup:

Unzip the contents of the ZIP file into your QB64 folder
* within the ZIP you should have:
- Animation2.bas
- Animation2.ini
- sub-folders 'AniFrames' and 'AniPlayer2wallpapers'
* ZIP file includes 1 animation series ('OptimusMegatron')

Create EXE for Animation2.bas

Run Animation2.exe

At the top of the window you should see a "button" for "Catagory 1"
Below that you should see an "icon" for 'OptimusMegatron'
Click the icon and the animation should start
. + (plus) to increase playback rate (speed up)
. - (minus) to decrease playback rate (slow down)
. TAB = change playback direction (forward/reverse)
. Backspace = go back to the Selection Screen (main menu)

Notes:

If the wallpaper name specified in the config file (Animation2.ini) is not found, the program will default to using the Width and Height (ScrnWidth and ScrnHeight) and colors (BGrd BGgr and BGbl) settings. (program will warn you that it cannot find the wallpaper)

Each catagory folder must have an "icon" .PNG file (30 pixels in height).

If you change the name of a catagory folder make sure you change its icon to the same name.

Each folder of JPG files (animation frames) must have a thumbnail JPG file named '$tn'.

Program assumes all images of a series are the same Width and Height. Screen/Window size is set using the first frame in the series.

As of this release the program allows for up to 5,000 frames per series. Of course you can change this in the source code.

* I have many more animation series i can share if anyone is interested. Most are TV intros of old shows.

Again, i hope i have supplied sufficient help and instructions so you can make this work. Please let me know if more help or instructions are needed.

PaulEL
* animator.zip (Filesize: 734.52 KB, Downloads: 186)
ss.jpg
* ss.jpg (Filesize: 17.42 KB, Dimensions: 376x394, Views: 231)
example.png
* example.png (Filesize: 24.02 KB, Dimensions: 525x237, Views: 226)
« Last Edit: February 09, 2019, 12:48:32 pm by mynameispaul »

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: animation player
« Reply #1 on: February 09, 2019, 01:02:30 pm »
This one looks interesting to me on a couple of levels. QB64 with _PUTIMAGE has made this a lot easier than it was in the past. I got a jpeg viewer in 2000 from Binary Mayhem that took 100s of lines to do what _PUTIMAGE routines do in just a few lines of code. Animation inside a QB64 app would be great, but until that happens, yes, this is the way to make a "taken apart" movie file run. But what would also be neat is a pic viewer. Windows 10 has a laggy one. Seven had a better one, but it got tossed.

Anyway, I downloaded it and I'm having a look. If you (Paul) are somewhat new to QB64, I will point out some helpful things when I come across them. I see you and I both use SHELL for directory info, but QB6 has added some commands to help there, too.

For instance, you could replace your getcurrentpath sub with...

path$ = _CWD$

An error I found: Change...

GetLabelValue "settings.ini", "CountPerSec", "", CountPerSec
to...
GetLabelValue "Animation2.ini", "CountPerSec", "", CountPerSec

To get the keys to work with a zero delay, I had to change the program flow in this part of the routine as follows...

Code: QB64: [Select]
  1.     DO
  2.  
  3.         k$ = UCASE$(INKEY$)
  4.         SELECT CASE k$
  5.             CASE CHR$(27): EXIT SUB
  6.             CASE CHR$(8): EXIT SUB 'back to main menu
  7.             CASE "-"
  8.                 IF AniDelay < MaxSlowDelay THEN
  9.                     AniDelay = AniDelay + 1
  10.                 END IF
  11.             CASE "+"
  12.                 AniDelay = AniDelay - 1
  13.                 IF AniDelay < 1 THEN AniDelay = 1
  14.             CASE CHR$(9) 'change playback direction
  15.                 IF direction$ = "F" THEN
  16.                     direction$ = "R"
  17.                 ELSE
  18.                     direction$ = "F"
  19.                 END IF
  20.                 EXIT DO
  21.         END SELECT
  22.  
  23.         ''EXIT DO 'for testing
  24.  
  25.         dly = dly + 1
  26.         CalcDelayValue delay
  27.         ''LOCATE 1, 1: PRINT delay: END
  28.         ''LOCATE 1, 1: PRINT delay; dly; AniDelay
  29.         IF dly >= delay THEN EXIT DO
  30.  
  31.         ''LOCATE 1, 1: PRINT AniDelay
  32.  
  33.     LOOP
  34.  

That's because if the delay check comes before the inkey input, it just exits the do loop without checking for a key press.


Also, you can use _HIDE with SHELL as in, SHELL _HIDE CMD$ to hide the console. _DONTWAIT can also be added if you don;t want the program to wit on the SHELL command. This is helpful in those NOTEPAD shells, you remarked out, because without _DONTWAIT, you have to close Notepad to return control to your program flow.

I'll muddle my way through more of your code throughout the day and let you know how it goes for me. BTW, welcome to the forum and thank you for posting some really interesting stuff  over the past couple of days. I would love to know if you started coding with QBasic and if so, how long ago? Also, I'm not saying you need to change anything, maybe you would rather use SHELL, but just in case you didn't know about the _CWD$ command, I wanted to point it out.

Pete
« Last Edit: February 09, 2019, 02:10:48 pm by Pete »
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: animation player
« Reply #2 on: February 09, 2019, 03:23:00 pm »
Wow, this was an absolute blast! I really need to make more time for hobby programming.

I did have some difficulty getting the delays to work, so I just redid that part of the program. My revisions keep the new delay times upon bksp or esc. I loved the green delay bar, so I made sure I kept that working in tandem with my new delay variable, "newdelay". I had to make a couple of the variables SHARED (path$, DelayFile$) and took out the previous delay subs. I consolidated the save delay part by adding sub savedelay (AniDelay). It worked perfectly for me with the demo jpegs.

I loved everything about this app. Super cool greyscale skin for starters. I loved the thumbnail menu. The reverse animation was a kick! I wish most video players had as good slow-mo capabilities.

Please if anyone tries my revision, let everyone know in this thread if there is an error in my coding that prevents the app from doing what Paul intended it to do.

Paul, again, very cool and thank you so much for coding this and posting it on the forum! The code was very easy to follow and understand. Great job!

Code: QB64: [Select]
  1. '/title Animations (version 2) using thumbs
  2. '/type utility
  3. '========================================================
  4. ' Controls while playing animation
  5. '..................................................
  6. '          - = decrease animation speed
  7. '         + = increase animation speed
  8. '       TAB = change playback direction (forward/reverse)
  9. ' Backspace = back to selection screen
  10. '========================================================
  11.  
  12. _TITLE "Animations (version 2) using thumbs"
  13.  
  14. DIM SHARED UserWarned, newdelay, path$, DelayFile$
  15. DIM SHARED MenuIconsPath$, reload, BGrd, BGgr, BGbl
  16. path$ = _CWD$
  17. DelayFile$ = path$ + "\delay.dat"
  18. MenuIconsPath$ = path$ + "\AniFrames"
  19. wallpaperPath$ = path$ + "\AniPlayer2wallpapers\"
  20. DIM SHARED Catagory$(5), catagories, Cat#
  21. DIM SHARED catX(10), catY(10), catW(10), catH(10)
  22. GetCatagories
  23. DIM SHARED iconX(50), iconY(50), iconW(50), iconH(50), icon#, icons
  24. DIM SHARED IconName$(50)
  25. DIM SHARED ScrnWidth: ScrnWidth = 600
  26. DIM SHARED ScrnHeight: ScrnHeight = 300
  27. DIM SHARED MaxFrames: MaxFrames = 5000
  28. DIM SHARED FrameName$(MaxFrames), frames, direction$, AniDelay
  29.  
  30. ' value of 'MaxSlowDelay' is the largest value allowed to slow down
  31. ' an animation. Could really be any number wanted.
  32. DIM SHARED MaxSlowDelay: MaxSlowDelay = 200
  33.  
  34. DIM SHARED CountPerSec
  35. GetLabelValue "Animation2.ini", "CountPerSec", "", CountPerSec
  36.  
  37. configfile$ = "Animation2.ini"
  38. GetLabelValue configfile$, "BGrd", "", BGrd
  39. GetLabelValue configfile$, "BGgr", "", BGgr
  40. GetLabelValue configfile$, "BGbl", "", BGbl
  41.  
  42. SetTheScreen:
  43.  
  44. GetLabelValue configfile$, "ScrnWidth", "", ScrnWidth
  45. GetLabelValue configfile$, "ScrnHeight", "", ScrnHeight
  46.  
  47. DIM SHARED wallpaper$
  48. GetLabelValue configfile$, "wallpaper", wallpaper$, n
  49. wallpaper$ = wallpaperPath$ + wallpaper$
  50. CheckForFile wallpaper$, found
  51. IF found = 0 THEN
  52.     IF UserWarned = 0 THEN
  53.         CLS
  54.         PRINT "warning!   following wallpaper image not found..."
  55.         PRINT wallpaper$
  56.         PRINT "press any key.."
  57.         DO UNTIL INKEY$ <> "": LOOP
  58.         UserWarned = 1
  59.     END IF
  60.     wallpaper$ = ""
  61.     GetLabelValue configfile$, "ScrnWidth", "", ScrnWidth
  62.     GetLabelValue configfile$, "ScrnHeight", "", ScrnHeight
  63.     SCREEN _NEWIMAGE(ScrnWidth, ScrnHeight, 32)
  64.     SCREEN _NEWIMAGE(150, 150, 32)
  65.     image& = _LOADIMAGE(wallpaper$)
  66.     imgW% = _WIDTH(image&) '  get image width
  67.     imgH% = _HEIGHT(image&) ' get image height
  68.     ScrnWidth = imgW%
  69.     ScrnHeight = imgH%
  70.  
  71.  
  72. IF wallpaper$ <> "" THEN
  73.     SCREEN _NEWIMAGE(ScrnWidth, ScrnHeight, 32)
  74.     _PUTIMAGE (0, 0), image&
  75.     BGrd = 10
  76.     BGgr = 100
  77.     BGbl = 20
  78.     fill = 1
  79.     DrawBox 0, 0, ScrnWidth, ScrnHeight, BGrd, BGgr, BGbl, fill
  80.  
  81. ShowCatagories
  82. LaodIcons
  83. DrawIconBoxes
  84.  
  85. reload = 0
  86.  
  87.     DO WHILE _MOUSEINPUT ' get latest mouse information
  88.     LOOP
  89.  
  90.     x% = _MOUSEX: mx = x%
  91.     y% = _MOUSEY: my = y%
  92.     LeftClick% = _MOUSEBUTTON(1) '                 retrieve left button status
  93.     RightClick% = _MOUSEBUTTON(2) '                retrieve right button status
  94.  
  95.     IF LeftClick% = -1 THEN
  96.         IF clkd = 0 THEN
  97.             TestClickPos mx, my
  98.             IF reload THEN GOTO SetTheScreen
  99.             clkd = 1
  100.         END IF
  101.     ELSE
  102.         clkd = 0
  103.     END IF
  104.  
  105.     k$ = UCASE$(INKEY$)
  106.  
  107.     SELECT CASE k$
  108.         CASE CHR$(27): CLS: SYSTEM
  109.     END SELECT
  110.  
  111.  
  112. SUB TestClickPos (mx, my) '################################################
  113.  
  114. '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  115. '-- clicked on a icon?
  116.  
  117. FOR i = 1 TO icons
  118.  
  119.     x = iconX(i)
  120.     y = iconY(i)
  121.     w = iconW(i)
  122.     h = iconH(i)
  123.  
  124.     IF my >= y AND my <= y + h - 1 THEN
  125.         IF mx >= x AND mx <= x + w - 1 THEN
  126.             IF icon# = i THEN
  127.                 LoadAnimationFrames i
  128.                 reload = 1
  129.                 EXIT SUB
  130.             END IF
  131.             icon# = i
  132.             DrawIconBoxes
  133.             EXIT SUB
  134.         END IF
  135.     END IF
  136.  
  137.  
  138. '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  139. '--clicked on a catagory label ?
  140.  
  141. FOR i = 1 TO catagories
  142.  
  143.     x = catX(i)
  144.     y = catY(i)
  145.     w = catW(i)
  146.     h = catH(i)
  147.  
  148.     IF my >= y AND my <= y + h - 1 THEN
  149.         IF mx >= x AND mx <= x + w - 1 THEN
  150.             IF Cat# <> i THEN
  151.                 Cat# = i
  152.                 reload = 1
  153.                 EXIT SUB
  154.                 ShowCatagories
  155.             END IF
  156.         END IF
  157.     END IF
  158.  
  159.  
  160. SUB DrawIconBoxes '########################################################
  161.  
  162. FOR i = 1 TO icons
  163.  
  164.     x = iconX(i)
  165.     y = iconY(i)
  166.     w = iconW(i)
  167.     h = iconH(i)
  168.  
  169.     IF i = icon# THEN
  170.         clr& = _RGB32(0, 200, 255)
  171.     ELSE
  172.         clr& = _RGB32(BGrd, BGgr, BGbl)
  173.     END IF
  174.  
  175.     LINE (x - 2, y - 2)-(x + w + 1, y + h + 1), clr&, B
  176.     LINE (x - 3, y - 3)-(x + w + 2, y + h + 2), clr&, B
  177.  
  178.  
  179.  
  180. SUB DrawBox (x, y, w, h, Rd, Gr, Bl, fill) '###########################################
  181. clr& = _RGB32(Rd, Gr, Bl)
  182. IF fill THEN
  183.     LINE (x, y)-(x + w - 1, y + h - 1), clr&, BF
  184.     LINE (x, y)-(x + w - 1, y + h - 1), clr&, B
  185.  
  186. SUB ShowCatagories '######################################################
  187.  
  188. x = 10
  189. y = 10
  190. h = 40
  191.  
  192. w = ScrnWidth / catagories
  193.  
  194. FOR c = 1 TO catagories
  195.     img$ = MenuIconsPath$ + "\" + Catagory$(c) + ".png"
  196.     image& = _LOADIMAGE(img$)
  197.     w% = _WIDTH(image&) '                                get image width
  198.     h% = _HEIGHT(image&) '                              get image height
  199.     clr = 0
  200.     IF c = Cat# THEN clr = 255
  201.     DrawBox x - 3, y - 3, w% + 6, h% + 6, clr, clr, clr, 1
  202.  
  203.     catX(c) = x
  204.     catY(c) = y
  205.     catW(c) = w%
  206.     catH(c) = h%
  207.  
  208.     _PUTIMAGE (x, y), image&
  209.  
  210.     x = x + w% + 10
  211.  
  212.  
  213. SUB GetCatagories '######################################################
  214.  
  215. tf$ = "~cats.tmp"
  216. q$ = CHR$(34)
  217. cmd$ = "dir " + q$ + MenuIconsPath$ + q$ + " /b >" + tf$
  218.  
  219. ''SHELL _DONTWAIT "notepad ~cats.tmp": END
  220. OPEN tf$ FOR INPUT AS #1
  221.  
  222.  
  223.     LINE INPUT #1, cat$
  224.  
  225.     IF INSTR(cat$, ".") = 0 THEN
  226.         i = i + 1
  227.         PRINT i; cat$
  228.         Catagory$(i) = cat$
  229.     END IF
  230.  
  231.  
  232.  
  233. catagories = i
  234. Cat# = 1
  235.  
  236.  
  237. SUB LaodIcons '##########################################################
  238.  
  239. tf$ = "~SubCat.tmp"
  240. path$ = MenuIconsPath$ + "\" + Catagory$(Cat#) + "\"
  241. q$ = CHR$(34)
  242. cmd$ = "dir " + q$ + path$ + "*" + q$ + " /b >" + tf$
  243. ''SHELL "notepad.exe " + tf$: END
  244.  
  245. DIM image&
  246. IconSqr = 50
  247. y = 60
  248. x1 = 5
  249. x = x1
  250.  
  251. OPEN tf$ FOR INPUT AS #1
  252.  
  253.  
  254.     LINE INPUT #1, fldr$
  255.  
  256.     IF 1 = 1 THEN
  257.  
  258.         img$ = path$ + fldr$ + "\$tn.jpg"
  259.         ''PRINT img$; "<": END
  260.         image& = _LOADIMAGE(img$)
  261.         _PUTIMAGE (x, y), image&
  262.         w% = _WIDTH(image&) '                                get image width
  263.         h% = _HEIGHT(image&) '                              get image height
  264.         IF h% > tallest THEN tallest = h%
  265.         i = i + 1
  266.         iconX(i) = x
  267.         iconY(i) = y
  268.         iconW(i) = w%
  269.         iconH(i) = h%
  270.         IconName$(i) = LEFT$(img$, LEN(img$) - 4) 'trim off .XXX
  271.  
  272.         x = x + w% + 10
  273.         IF x + IconSqr >= ScrnWidth THEN
  274.             y = y + tallest + 10
  275.             x = x1
  276.             tallest = 0
  277.         END IF
  278.     END IF
  279.  
  280.  
  281.  
  282. icon# = 1
  283. icons = i
  284.  
  285.  
  286. SUB GetLabelValue (lblfile$, lbl$, v$, n) '##################################
  287.  
  288. v$ = "": n = FREEFILE: OPEN lblfile$ FOR INPUT AS #n
  289.     LINE INPUT #n, dta$: dta$ = RTRIM$(LTRIM$(dta$))
  290.     IF LEFT$(dta$, 1) = "'" THEN dta$ = ""
  291.     p = INSTR(dta$, "=")
  292.     IF p THEN
  293.         l$ = RTRIM$(LEFT$(dta$, p - 1))
  294.         IF LCASE$(l$) = LCASE$(lbl$) THEN
  295.             v$ = LTRIM$(RIGHT$(dta$, LEN(dta$) - p))
  296.             EXIT DO
  297.         END IF
  298.     END IF
  299. n = VAL(v$)
  300.  
  301. SUB LoadAnimationFrames (i) '#########################################################
  302.  
  303. ''CLS: PRINT IconName$(i): END
  304. FOR p = LEN(IconName$(i)) TO 1 STEP -1
  305.     IF MID$(IconName$(i), p, 1) = "\" THEN EXIT FOR
  306. path$ = LEFT$(IconName$(i), p - 1)
  307. '--------------------------------------------------------------
  308. FOR p = LEN(path$) TO 1 STEP -1
  309.     IF MID$(path$, p, 1) = "\" THEN EXIT FOR
  310. folder$ = RIGHT$(path$, LEN(path$) - p)
  311. '---------------------------------------------------------------
  312. '' CLS: PRINT folder$; "<": END
  313.  
  314. _TITLE "Animation : " + folder$
  315.  
  316. ''path$ = StartPath$ + "\" + Catagory$(Cat#) + "\" + folder$(i)
  317. tf$ = "~~animates.tmp"
  318. q$ = CHR$(34)
  319. cmd$ = "dir " + q$ + path$ + q$ + " /b >" + tf$
  320.  
  321. '' SHELL "notepad.exe " + tf$: END
  322.  
  323. CheckForFile DelayFile$, found
  324. 'AniDelay is a percent of CountPerSec
  325.  
  326. IF found THEN
  327.     OPEN DelayFile$ FOR INPUT AS #1
  328.     INPUT #1, AniDelay
  329.     INPUT #1, newdelay
  330.     CLOSE 1
  331.     AniDelay = 1
  332.  
  333. COLOR 7, 0
  334.  
  335. OPEN tf$ FOR INPUT AS #1
  336.  
  337. i = 0
  338.  
  339.  
  340.     LINE INPUT #1, f$
  341.  
  342.     IF LEFT$(LCASE$(f$), 4) = "$tn." THEN
  343.         f$ = "" 'this is a thumbnail image
  344.     END IF
  345.  
  346.     ft$ = LCASE$(RIGHT$(f$, 4))
  347.  
  348.     SELECT CASE ft$
  349.  
  350.         CASE ".jpg", ".png", ".bmp"
  351.             i = i + 1
  352.             FrameName$(i) = path$ + "\" + f$
  353.             'CLS :
  354.             PRINT i; FrameName$(i); "<"
  355.             IF i = MaxFrames THEN EXIT DO
  356.             'EXIT DO
  357.  
  358.     END SELECT
  359.  
  360.  
  361.  
  362. frames = i
  363.  
  364. ScrnWidth = 600
  365. ScrnHeight = 500
  366. ScreenMode = 32
  367.  
  368. SCREEN _NEWIMAGE(ScrnWidth, ScrnHeight, ScreenMode)
  369.  
  370. img$ = FrameName$(1)
  371. image& = _LOADIMAGE(img$)
  372. w% = _WIDTH(image&)
  373. h% = _HEIGHT(image&)
  374. ScrnWidth = w%
  375. ScrnHeight = h% + 15
  376. SCREEN _NEWIMAGE(ScrnWidth, ScrnHeight, ScreenMode)
  377. direction$ = "F"
  378.  
  379.     PlayTheAnimation k$
  380.     IF k$ = CHR$(8) THEN EXIT DO 'back to main menu
  381.     IF k$ = CHR$(27) THEN EXIT DO
  382.  
  383. CALL savedelay(AniDelay)
  384.  
  385. IF k$ = CHR$(27) THEN CLS: SYSTEM
  386.  
  387.  
  388. SUB CheckForFile (f$, found) '##############################################
  389. found = 0
  390. IF _FILEEXISTS(f$) THEN found = 1
  391.  
  392. SUB PlayTheAnimation (k$) '################################################
  393. ForStart = 1
  394. ForStop = frames
  395. ForStep = 1
  396.  
  397. IF direction$ = "R" THEN
  398.     ForStart = frames
  399.     ForStop = 1
  400.     ForStep = -1
  401.  
  402. FOR i = ForStart TO ForStop STEP ForStep
  403.  
  404.     img$ = FrameName$(i)
  405.     image& = _LOADIMAGE(img$)
  406.     _PUTIMAGE (0, 0), image&
  407.  
  408.     ShowDelayBar
  409.  
  410.     DO
  411.         k$ = UCASE$(INKEY$)
  412.         SELECT CASE k$
  413.             CASE CHR$(27)
  414.                 ' Update delay file.
  415.                 CALL savedelay(AniDelay)
  416.                 EXIT SUB
  417.             CASE CHR$(8)
  418.                 ' Update delay file.
  419.                 CALL savedelay(AniDelay)
  420.                 EXIT SUB 'back to main menu
  421.             CASE "-", "_"
  422.                 IF newdelay < MaxSlowDelay THEN newdelay = newdelay + 1
  423.                 IF AniDelay < MaxSlowDelay THEN
  424.                     AniDelay = AniDelay + 1
  425.                 END IF
  426.             CASE "+", "="
  427.                 AniDelay = AniDelay - 1
  428.                 IF AniDelay < 1 THEN AniDelay = 1
  429.                 IF newdelay > 0 THEN newdelay = newdelay - 1
  430.             CASE CHR$(9) 'change playback direction
  431.                 IF direction$ = "F" THEN
  432.                     direction$ = "R"
  433.                 ELSE
  434.                     direction$ = "F"
  435.                 END IF
  436.                 EXIT DO
  437.         END SELECT
  438.         ''PRINT newdelay
  439.         _DELAY newdelay / 5000: EXIT DO
  440.     LOOP
  441.  
  442.     IF k$ = CHR$(9) THEN EXIT FOR
  443.  
  444.     per = i / frames
  445.     ln = ScrnWidth * per
  446.  
  447.     x = 0
  448.     y = ScrnHeight - 13
  449.     h = 5
  450.     fill = 1
  451.  
  452.     w = ScrnWidth
  453.     Rd = 0 ' 255
  454.     Gr = 0 ' 255
  455.     Bl = 0 '' 255
  456.     'black out the progress bar
  457.     DrawBox x, y, w, h, Rd, Gr, Bl, fill
  458.  
  459.     w = ln
  460.     Rd = 255
  461.     Gr = 255
  462.     Bl = 255
  463.     'draw the progress bar
  464.     DrawBox x, y, w, h, Rd, Gr, Bl, fill
  465.  
  466.  
  467.  
  468. SUB ShowDelayBar '##########################################################
  469.  
  470. x = 0
  471. y = ScrnHeight - 5
  472. h = 5
  473. fill = 1
  474.  
  475. w = ScrnWidth
  476. Rd = 0 ' 255
  477. Gr = 0 ' 255
  478. Bl = 0 '' 255
  479. 'black out the delay value bar
  480. DrawBox x, y, w, h, Rd, Gr, Bl, fill
  481.  
  482. per = (AniDelay / MaxSlowDelay) * 100
  483. IF per >= 0 THEN 'fast
  484.     Rd = 0: Gr = 255: Bl = 0
  485. IF per >= 50 THEN 'medium
  486.     Rd = 255: Gr = 255: Bl = 0
  487. IF per >= 75 THEN 'slow
  488.     Rd = 255: Gr = 0: Bl = 0
  489.  
  490. per = per / 100
  491. w = ScrnWidth * per
  492. 'draw the delay value bar
  493. DrawBox x, y, w, h, Rd, Gr, Bl, fill
  494.  
  495.  
  496. SUB savedelay (AniDelay)
  497. OPEN DelayFile$ FOR OUTPUT AS #1
  498. WRITE #1, AniDelay
  499. WRITE #1, newdelay
  500.  

Note: Anyone who downloads Paul's code with my revisons here will need to download Paul's original ZIO file to get the ini and folders with animation jpegs.

Pete
« Last Edit: February 09, 2019, 03:32:06 pm by Pete »
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline mynameispaul

  • Newbie
  • Posts: 49
    • View Profile
Re: animation player
« Reply #3 on: February 09, 2019, 05:05:11 pm »
OK...
First, the files 'CountPerSecUpdt.bas' and 'settings.ini' should have been supplied at the beginning.
The settings.ini file is a kinda of global settings file to be used by multiple programs. In this case the value for 'CountPerSec' is used by the animation program so that theoretically the animations should play at about the same speed even when run on a different pc with a different processing speed. This is done by running the CountPerSecUpdt program which basically just counts up as much as it can for 1 second (multiple times). Then the animation program get a specified percent of that Count Per Second value. Will count higher on a faster pc but count lower on a slower pc, but will always the same percent value for the program. Make sense?? (hopefully)
So anyways, copy the CountPerSecUpdt.bas to your QB64 folder and run it. Let it run a few times so it can get an average count per second. Then press any key to exit the program. It will save the average count per second to the settings.ini file.

Second, run the animation program (I have uploaded an updated version, using the _CWD$ command).

* each animation folder gets its own delay file after you run the animation and then go back to the selection screen.
* Animation2.bas (Filesize: 14.62 KB, Downloads: 150)
* CountPerSecUpdt.bas (Filesize: 1.43 KB, Downloads: 148)
* settings.ini (Filesize: 0.22 KB, Downloads: 153)

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: animation player
« Reply #4 on: February 09, 2019, 05:20:15 pm »
Ah, some files were missing. Well Paul, what do you think about switching to _delay? From my understanding, it is a timer function, so it is independent of CPU speeds and should be the same on any system. If it works for you, that would simplify the app, which could be run with just the original files included in the original post.

Pete
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline mynameispaul

  • Newbie
  • Posts: 49
    • View Profile
Re: animation player
« Reply #5 on: February 09, 2019, 05:40:34 pm »
I will give it a try and report back.

Offline mynameispaul

  • Newbie
  • Posts: 49
    • View Profile
Re: animation player
« Reply #6 on: February 09, 2019, 06:48:26 pm »
OK, updated Animation2.bas with option to use the old delay process (using CountPerSec) or using the _DELAY function.
Add the following lines of code to Animation2.ini

'If you want the program to use the CountPerSec field value from settings.ini
'  set the following field value to 1
'Else
'  set it to 0 (program will use the _DELAY function)
'  program acts a little different when using this option
UseCountPerSec = 1

I personally prefer to the CountPerSec process. the _Delay function is ok. But what I don't like about it is that the _DELAY function basically pauses the entire program..while its paused the program from runnin, the program is not acting on any input from the user. Does not look like it to me anyways. I use the delay loop (which uses the CountPerSec) so that while the program is 'paused' showing a frame its also monitoring for input from the user.
So anyway, I've modified the program so its up to the user to decide which way they prefer.
...or modify the program however you want...doesn't really matter to me.
* Animation2.bas (Filesize: 14.99 KB, Downloads: 163)

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: animation player
« Reply #7 on: February 09, 2019, 07:29:35 pm »
Pete's code worked, is there only one animation? (I haven't tried latest.)


Offline mynameispaul

  • Newbie
  • Posts: 49
    • View Profile
Re: animation player
« Reply #8 on: February 09, 2019, 08:10:17 pm »
If his works then use his.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: animation player
« Reply #9 on: February 09, 2019, 08:33:52 pm »
The reason I ask if there was another animation is that I see stuff being setup for cat. So I was expecting something with a cat. Maybe Pete snuck that in?

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: animation player
« Reply #10 on: February 09, 2019, 11:09:47 pm »
Mark: I presume Cat is short for category. Paul put that in there.

Paul: I agree that programs are better if they always keep the flow going. I had a clock in all my office software, and all user input passed through the clock sub, without delays. Timers were fluid. Now for this application the delays are so minimal I really don't think it matters, but with some adjustments, the timer function can be use. I included two in this rendition, along with the _delay. To anyone who tries it, just change the remarks to the one you want to use.

I also changed the name of one sub, because it was a typo; so LaodIcons is now properly named LoadIcons. I could have left it alone... but then the twitch wouldn't have abated without considerable doses of several psychogenic medications.

Oh, I also added _EXIT so a user can click the "X" and still save the last delay.

What I need to do next is study and learn some stuff from the animation code to make a photo viewer app inside an app. Not bad for a SCREEN 0 junkie like me!

Pete

Code: QB64: [Select]
  1. '/title Animations (version 2) using thumbs
  2. '/type utility
  3. '========================================================
  4. ' Controls while playing animation
  5. '..................................................
  6. '          - = decrease animation speed
  7. '         + = increase animation speed
  8. '       TAB = change playback direction (forward/reverse)
  9. ' Backspace = back to selection screen
  10. '========================================================
  11.  
  12. _TITLE "Animations (version 2) using thumbs"
  13.  
  14. DIM SHARED UserWarned, newdelay%, newdelay!, t#, path$, DelayFile$
  15. DIM SHARED MenuIconsPath$, reload, BGrd, BGgr, BGbl
  16. path$ = _CWD$
  17. DelayFile$ = path$ + "\delay.dat"
  18. MenuIconsPath$ = path$ + "\AniFrames"
  19. wallpaperPath$ = path$ + "\AniPlayer2wallpapers\"
  20. DIM SHARED Catagory$(5), catagories, Cat#
  21. DIM SHARED catX(10), catY(10), catW(10), catH(10)
  22. GetCatagories
  23. DIM SHARED iconX(50), iconY(50), iconW(50), iconH(50), icon#, icons
  24. DIM SHARED IconName$(50)
  25. DIM SHARED ScrnWidth: ScrnWidth = 600
  26. DIM SHARED ScrnHeight: ScrnHeight = 300
  27. DIM SHARED MaxFrames: MaxFrames = 5000
  28. DIM SHARED FrameName$(MaxFrames), frames, direction$, AniDelay
  29.  
  30. ' value of 'MaxSlowDelay' is the largest value allowed to slow down
  31. ' an animation. Could really be any number wanted.
  32. DIM SHARED MaxSlowDelay: MaxSlowDelay = 200
  33.  
  34. DIM SHARED CountPerSec
  35. GetLabelValue "Animation2.ini", "CountPerSec", "", CountPerSec
  36.  
  37. configfile$ = "Animation2.ini"
  38. GetLabelValue configfile$, "BGrd", "", BGrd
  39. GetLabelValue configfile$, "BGgr", "", BGgr
  40. GetLabelValue configfile$, "BGbl", "", BGbl
  41.  
  42. SetTheScreen:
  43.  
  44. GetLabelValue configfile$, "ScrnWidth", "", ScrnWidth
  45. GetLabelValue configfile$, "ScrnHeight", "", ScrnHeight
  46.  
  47. DIM SHARED wallpaper$
  48. GetLabelValue configfile$, "wallpaper", wallpaper$, n
  49. wallpaper$ = wallpaperPath$ + wallpaper$
  50. CheckForFile wallpaper$, found
  51. IF found = 0 THEN
  52.     IF UserWarned = 0 THEN
  53.         CLS
  54.         PRINT "warning!   following wallpaper image not found..."
  55.         PRINT wallpaper$
  56.         PRINT "press any key.."
  57.         DO UNTIL INKEY$ <> "": LOOP
  58.         UserWarned = 1
  59.     END IF
  60.     wallpaper$ = ""
  61.     GetLabelValue configfile$, "ScrnWidth", "", ScrnWidth
  62.     GetLabelValue configfile$, "ScrnHeight", "", ScrnHeight
  63.     SCREEN _NEWIMAGE(ScrnWidth, ScrnHeight, 32)
  64.     SCREEN _NEWIMAGE(150, 150, 32)
  65.     image& = _LOADIMAGE(wallpaper$)
  66.     imgW% = _WIDTH(image&) '  get image width
  67.     imgH% = _HEIGHT(image&) ' get image height
  68.     ScrnWidth = imgW%
  69.     ScrnHeight = imgH%
  70.  
  71.  
  72. IF wallpaper$ <> "" THEN
  73.     SCREEN _NEWIMAGE(ScrnWidth, ScrnHeight, 32)
  74.     _PUTIMAGE (0, 0), image&
  75.     BGrd = 10
  76.     BGgr = 100
  77.     BGbl = 20
  78.     fill = 1
  79.     DrawBox 0, 0, ScrnWidth, ScrnHeight, BGrd, BGgr, BGbl, fill
  80.  
  81. ShowCatagories
  82. LoadIcons
  83. DrawIconBoxes
  84.  
  85. reload = 0
  86.  
  87.     DO WHILE _MOUSEINPUT ' get latest mouse information
  88.     LOOP
  89.  
  90.     x% = _MOUSEX: mx = x%
  91.     y% = _MOUSEY: my = y%
  92.     LeftClick% = _MOUSEBUTTON(1) '                 retrieve left button status
  93.     RightClick% = _MOUSEBUTTON(2) '                retrieve right button status
  94.  
  95.     IF LeftClick% = -1 THEN
  96.         IF clkd = 0 THEN
  97.             TestClickPos mx, my
  98.             IF reload THEN GOTO SetTheScreen
  99.             clkd = 1
  100.         END IF
  101.     ELSE
  102.         clkd = 0
  103.     END IF
  104.  
  105.     k$ = UCASE$(INKEY$)
  106.  
  107.     SELECT CASE k$
  108.         CASE CHR$(27): CLS: SYSTEM
  109.     END SELECT
  110.  
  111.  
  112. SUB TestClickPos (mx, my) '################################################
  113.  
  114. '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  115. '-- clicked on a icon?
  116.  
  117. FOR i = 1 TO icons
  118.  
  119.     x = iconX(i)
  120.     y = iconY(i)
  121.     w = iconW(i)
  122.     h = iconH(i)
  123.  
  124.     IF my >= y AND my <= y + h - 1 THEN
  125.         IF mx >= x AND mx <= x + w - 1 THEN
  126.             IF icon# = i THEN
  127.                 LoadAnimationFrames i
  128.                 reload = 1
  129.                 EXIT SUB
  130.             END IF
  131.             icon# = i
  132.             DrawIconBoxes
  133.             EXIT SUB
  134.         END IF
  135.     END IF
  136.  
  137.  
  138. '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  139. '--clicked on a catagory label ?
  140.  
  141. FOR i = 1 TO catagories
  142.  
  143.     x = catX(i)
  144.     y = catY(i)
  145.     w = catW(i)
  146.     h = catH(i)
  147.  
  148.     IF my >= y AND my <= y + h - 1 THEN
  149.         IF mx >= x AND mx <= x + w - 1 THEN
  150.             IF Cat# <> i THEN
  151.                 Cat# = i
  152.                 reload = 1
  153.                 EXIT SUB
  154.                 ShowCatagories
  155.             END IF
  156.         END IF
  157.     END IF
  158.  
  159.  
  160. SUB DrawIconBoxes '########################################################
  161.  
  162. FOR i = 1 TO icons
  163.  
  164.     x = iconX(i)
  165.     y = iconY(i)
  166.     w = iconW(i)
  167.     h = iconH(i)
  168.  
  169.     IF i = icon# THEN
  170.         clr& = _RGB32(0, 200, 255)
  171.     ELSE
  172.         clr& = _RGB32(BGrd, BGgr, BGbl)
  173.     END IF
  174.  
  175.     LINE (x - 2, y - 2)-(x + w + 1, y + h + 1), clr&, B
  176.     LINE (x - 3, y - 3)-(x + w + 2, y + h + 2), clr&, B
  177.  
  178.  
  179.  
  180. SUB DrawBox (x, y, w, h, Rd, Gr, Bl, fill) '###########################################
  181. clr& = _RGB32(Rd, Gr, Bl)
  182. IF fill THEN
  183.     LINE (x, y)-(x + w - 1, y + h - 1), clr&, BF
  184.     LINE (x, y)-(x + w - 1, y + h - 1), clr&, B
  185.  
  186. SUB ShowCatagories '######################################################
  187.  
  188. x = 10
  189. y = 10
  190. h = 40
  191.  
  192. w = ScrnWidth / catagories
  193.  
  194. FOR c = 1 TO catagories
  195.     img$ = MenuIconsPath$ + "\" + Catagory$(c) + ".png"
  196.     image& = _LOADIMAGE(img$)
  197.     w% = _WIDTH(image&) '                                get image width
  198.     h% = _HEIGHT(image&) '                              get image height
  199.     clr = 0
  200.     IF c = Cat# THEN clr = 255
  201.     DrawBox x - 3, y - 3, w% + 6, h% + 6, clr, clr, clr, 1
  202.  
  203.     catX(c) = x
  204.     catY(c) = y
  205.     catW(c) = w%
  206.     catH(c) = h%
  207.  
  208.     _PUTIMAGE (x, y), image&
  209.  
  210.     x = x + w% + 10
  211.  
  212.  
  213. SUB GetCatagories '######################################################
  214.  
  215. tf$ = "~cats.tmp"
  216. q$ = CHR$(34)
  217. cmd$ = "dir " + q$ + MenuIconsPath$ + q$ + " /b >" + tf$
  218.  
  219. ''SHELL _DONTWAIT "notepad ~cats.tmp": END
  220. OPEN tf$ FOR INPUT AS #1
  221.  
  222.  
  223.     LINE INPUT #1, cat$
  224.  
  225.     IF INSTR(cat$, ".") = 0 THEN
  226.         i = i + 1
  227.         PRINT i; cat$
  228.         Catagory$(i) = cat$
  229.     END IF
  230.  
  231.  
  232.  
  233. catagories = i
  234. Cat# = 1
  235.  
  236.  
  237. SUB LoadIcons '##########################################################
  238.  
  239. tf$ = "~SubCat.tmp"
  240. path$ = MenuIconsPath$ + "\" + Catagory$(Cat#) + "\"
  241. q$ = CHR$(34)
  242. cmd$ = "dir " + q$ + path$ + "*" + q$ + " /b >" + tf$
  243. ''SHELL "notepad.exe " + tf$: END
  244.  
  245. DIM image&
  246. IconSqr = 50
  247. y = 60
  248. x1 = 5
  249. x = x1
  250.  
  251. OPEN tf$ FOR INPUT AS #1
  252.  
  253.  
  254.     LINE INPUT #1, fldr$
  255.  
  256.     IF 1 = 1 THEN
  257.  
  258.         img$ = path$ + fldr$ + "\$tn.jpg"
  259.         ''PRINT img$; "<": END
  260.         image& = _LOADIMAGE(img$)
  261.         _PUTIMAGE (x, y), image&
  262.         w% = _WIDTH(image&) '                                get image width
  263.         h% = _HEIGHT(image&) '                              get image height
  264.         IF h% > tallest THEN tallest = h%
  265.         i = i + 1
  266.         iconX(i) = x
  267.         iconY(i) = y
  268.         iconW(i) = w%
  269.         iconH(i) = h%
  270.         IconName$(i) = LEFT$(img$, LEN(img$) - 4) 'trim off .XXX
  271.  
  272.         x = x + w% + 10
  273.         IF x + IconSqr >= ScrnWidth THEN
  274.             y = y + tallest + 10
  275.             x = x1
  276.             tallest = 0
  277.         END IF
  278.     END IF
  279.  
  280.  
  281.  
  282. icon# = 1
  283. icons = i
  284.  
  285.  
  286. SUB GetLabelValue (lblfile$, lbl$, v$, n) '##################################
  287.  
  288. v$ = "": n = FREEFILE: OPEN lblfile$ FOR INPUT AS #n
  289.     LINE INPUT #n, dta$: dta$ = RTRIM$(LTRIM$(dta$))
  290.     IF LEFT$(dta$, 1) = "'" THEN dta$ = ""
  291.     p = INSTR(dta$, "=")
  292.     IF p THEN
  293.         l$ = RTRIM$(LEFT$(dta$, p - 1))
  294.         IF LCASE$(l$) = LCASE$(lbl$) THEN
  295.             v$ = LTRIM$(RIGHT$(dta$, LEN(dta$) - p))
  296.             EXIT DO
  297.         END IF
  298.     END IF
  299. n = VAL(v$)
  300.  
  301. SUB LoadAnimationFrames (i) '#########################################################
  302. ''CLS: PRINT IconName$(i): END
  303. FOR p = LEN(IconName$(i)) TO 1 STEP -1
  304.     IF MID$(IconName$(i), p, 1) = "\" THEN EXIT FOR
  305. path$ = LEFT$(IconName$(i), p - 1)
  306. '--------------------------------------------------------------
  307. FOR p = LEN(path$) TO 1 STEP -1
  308.     IF MID$(path$, p, 1) = "\" THEN EXIT FOR
  309. folder$ = RIGHT$(path$, LEN(path$) - p)
  310. '---------------------------------------------------------------
  311. '' CLS: PRINT folder$; "<": END
  312.  
  313. _TITLE "Animation : " + folder$
  314.  
  315. ''path$ = StartPath$ + "\" + Catagory$(Cat#) + "\" + folder$(i)
  316. tf$ = "~~animates.tmp"
  317. q$ = CHR$(34)
  318. cmd$ = "dir " + q$ + path$ + q$ + " /b >" + tf$
  319.  
  320. '' SHELL "notepad.exe " + tf$: END
  321.  
  322. CheckForFile DelayFile$, found
  323. 'AniDelay is a percent of CountPerSec
  324.  
  325. IF found THEN
  326.     OPEN DelayFile$ FOR INPUT AS #1
  327.     INPUT #1, AniDelay
  328.     INPUT #1, newdelay%
  329.     newdelay! = newdelay% / 1000
  330.     CLOSE 1
  331.     AniDelay = 1
  332.  
  333. COLOR 7, 0
  334.  
  335. OPEN tf$ FOR INPUT AS #1
  336.  
  337. i = 0
  338.  
  339.  
  340.     LINE INPUT #1, f$
  341.  
  342.     IF LEFT$(LCASE$(f$), 4) = "$tn." THEN
  343.         f$ = "" 'this is a thumbnail image
  344.     END IF
  345.  
  346.     ft$ = LCASE$(RIGHT$(f$, 4))
  347.  
  348.     SELECT CASE ft$
  349.  
  350.         CASE ".jpg", ".png", ".bmp"
  351.             i = i + 1
  352.             FrameName$(i) = path$ + "\" + f$
  353.             'CLS :
  354.             PRINT i; FrameName$(i); "<"
  355.             IF i = MaxFrames THEN EXIT DO
  356.             'EXIT DO
  357.  
  358.     END SELECT
  359.  
  360.  
  361.  
  362. frames = i
  363.  
  364. ScrnWidth = 600
  365. ScrnHeight = 500
  366. ScreenMode = 32
  367.  
  368. SCREEN _NEWIMAGE(ScrnWidth, ScrnHeight, ScreenMode)
  369.  
  370. img$ = FrameName$(1)
  371. image& = _LOADIMAGE(img$)
  372. w% = _WIDTH(image&)
  373. h% = _HEIGHT(image&)
  374. ScrnWidth = w%
  375. ScrnHeight = h% + 15
  376. SCREEN _NEWIMAGE(ScrnWidth, ScrnHeight, ScreenMode)
  377. direction$ = "F"
  378.  
  379.     PlayTheAnimation k$
  380.     IF k$ = CHR$(8) THEN EXIT DO 'back to main menu
  381.     IF k$ = CHR$(27) THEN EXIT DO
  382.  
  383. CALL savedelay(AniDelay)
  384.  
  385. IF k$ = CHR$(27) THEN CLS: SYSTEM
  386.  
  387.  
  388. SUB CheckForFile (f$, found) '##############################################
  389. found = 0
  390. IF _FILEEXISTS(f$) THEN found = 1
  391.  
  392. SUB PlayTheAnimation (k$) '################################################
  393. ForStart = 1
  394. ForStop = frames
  395. ForStep = 1
  396.  
  397. IF direction$ = "R" THEN
  398.     ForStart = frames
  399.     ForStop = 1
  400.     ForStep = -1
  401.  
  402. FOR i = ForStart TO ForStop STEP ForStep
  403.  
  404.     img$ = FrameName$(i)
  405.     image& = _LOADIMAGE(img$)
  406.     _PUTIMAGE (0, 0), image&
  407.  
  408.     ShowDelayBar
  409.     t# = TIMER
  410.     DO
  411.         quit = _EXIT
  412.         IF quit THEN
  413.             CALL savedelay(AniDelay)
  414.             SYSTEM
  415.         END IF
  416.  
  417.         k$ = INKEY$
  418.  
  419.         SELECT CASE k$
  420.             CASE CHR$(27)
  421.                 ' Update delay file.
  422.                 CALL savedelay(AniDelay)
  423.                 EXIT SUB
  424.             CASE CHR$(8)
  425.                 ' Update delay file.
  426.                 CALL savedelay(AniDelay)
  427.                 EXIT SUB 'back to main menu
  428.             CASE "-", "_"
  429.                 IF newdelay% < MaxSlowDelay THEN
  430.                     newdelay% = newdelay% + 1
  431.                     newdelay! = newdelay% / 1000
  432.                 END IF
  433.                 IF AniDelay < MaxSlowDelay THEN
  434.                     AniDelay = AniDelay + 1
  435.                 END IF
  436.             CASE "+", "="
  437.                 AniDelay = AniDelay - 1
  438.                 IF AniDelay < 1 THEN AniDelay = 1
  439.                 IF newdelay% > 0 THEN
  440.                     newdelay% = newdelay% - 1
  441.                     newdelay! = newdelay% / 1000
  442.                 END IF
  443.             CASE CHR$(9) 'change playback direction
  444.                 IF direction$ = "F" THEN
  445.                     direction$ = "R"
  446.                 ELSE
  447.                     direction$ = "F"
  448.                 END IF
  449.                 EXIT DO
  450.         END SELECT
  451.  
  452.         ' Three delay options.
  453.         ''_DELAY newdelay% / 5000
  454.         ''IF ABS(TIMER - t#) > newdelay! THEN EXIT DO ' (Can be Substituted for the call sub below if a midnite delay is not a big deal.)
  455.         CALL timerdelay(flag%): IF flag% THEN flag% = 0: EXIT DO
  456.     LOOP
  457.  
  458.     IF k$ = CHR$(9) THEN EXIT FOR
  459.  
  460.     per = i / frames
  461.     ln = ScrnWidth * per
  462.  
  463.     x = 0
  464.     y = ScrnHeight - 13
  465.     h = 5
  466.     fill = 1
  467.  
  468.     w = ScrnWidth
  469.     Rd = 0 ' 255
  470.     Gr = 0 ' 255
  471.     Bl = 0 '' 255
  472.     'black out the progress bar
  473.     DrawBox x, y, w, h, Rd, Gr, Bl, fill
  474.  
  475.     w = ln
  476.     Rd = 255
  477.     Gr = 255
  478.     Bl = 255
  479.     'draw the progress bar
  480.     DrawBox x, y, w, h, Rd, Gr, Bl, fill
  481.  
  482.  
  483.  
  484. SUB ShowDelayBar '##########################################################
  485.  
  486. x = 0
  487. y = ScrnHeight - 5
  488. h = 5
  489. fill = 1
  490.  
  491. w = ScrnWidth
  492. Rd = 0 ' 255
  493. Gr = 0 ' 255
  494. Bl = 0 '' 255
  495. 'black out the delay value bar
  496. DrawBox x, y, w, h, Rd, Gr, Bl, fill
  497.  
  498. per = (AniDelay / MaxSlowDelay) * 100
  499. IF per >= 0 THEN 'fast
  500.     Rd = 0: Gr = 255: Bl = 0
  501. IF per >= 50 THEN 'medium
  502.     Rd = 255: Gr = 255: Bl = 0
  503. IF per >= 75 THEN 'slow
  504.     Rd = 255: Gr = 0: Bl = 0
  505.  
  506. per = per / 100
  507. w = ScrnWidth * per
  508. 'draw the delay value bar
  509. DrawBox x, y, w, h, Rd, Gr, Bl, fill
  510.  
  511.  
  512. SUB savedelay (AniDelay)
  513. OPEN DelayFile$ FOR OUTPUT AS #1
  514. WRITE #1, AniDelay
  515. WRITE #1, newdelay%
  516.  
  517.  
  518. SUB timerdelay (flag%)
  519.     t# = t# - 86400 'Midnite adjustment
  520.     IF TIMER - t# > newdelay! THEN flag% = -1

Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: animation player
« Reply #11 on: February 09, 2019, 11:20:31 pm »
Quote
Mark: I presume Cat is short for category. Paul put that in there.

LOL well yes that explains that!

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: animation player
« Reply #12 on: February 09, 2019, 11:26:08 pm »
There are some similarities. Take for instance a Cat 5 hurricane. Similar, but everyone knows 5 cats do a lot more damage to your home than a 180 mile an hour wind.

Pete
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/