Author Topic: Dice Roller, Ping Pong, Conversion Calculator, Timer, List Aphabetizer  (Read 7284 times)

0 Members and 1 Guest are viewing this topic.

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
I have 5 QB64 programs on my little website so far. Only the code is there so you can copy/paste it to your own. They are: Dice Roller (without graphics), Ping Pong (like Pong but a little harder), Conversion Calculator (converts KM<>Miles, Gallons <> Liters, Fahrenheit <> Celsius, MPH <> KM/h), a simple count up or count down Timer, and a List Alphabetizer. All of mine are for a Microsoft Windows computer. The code can be found here: http://ken.x10host.com/qb64/                Thanks! - Ken G.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Hi Kenneth,

Welcome to the forum.

I tried your Ping Pong. That paddle action sucks! and it is disconcerting to see the ball go through the paddle.

I fixed both:
Code: QB64: [Select]
  1. 'Updated by Kenneth on May 27, 2019.
  2. _TITLE "PING PONG"
  3. begin:
  4. PRINT "               PING PONG"
  5. PRINT "By Kenneth G."
  6. PRINT "Use the up and down arrow keys to move"
  7. PRINT "the left paddle. If the ball passes the"
  8. PRINT "computer's paddle, you get a point."
  9. PRINT "Whoever gets 10 points first wins."
  10. PRINT "Use the right and left arrow keys to"
  11. PRINT "stop your paddle."
  12. PRINT "Press Esc to end anytime."
  13. INPUT "(F)ast, (M)edium, (S)low, (Q)uit:"; sp$
  14. IF sp$ = "F" OR sp$ = "f" OR sp$ = "FAST" OR sp$ = "fast" OR sp$ = "Fast" THEN sd = 30
  15. IF sp$ = "M" OR sp$ = "m" OR sp$ = "MEDIUM" OR sp$ = "medium" OR sp$ = "Medium" THEN sd = 20
  16. IF sp$ = "S" OR sp$ = "s" OR sp$ = "SLOW" OR sp$ = "slow" OR sp$ = "Slow" THEN sd = 10
  17. IF sp$ = "Q" OR sp$ = "q" OR sp$ = "QUIT" OR sp$ = "quit" OR sp$ = "Quit" THEN CLEAR: END
  18. IF sd = 0 THEN sd = 10
  19. INPUT "Press enter to start."; st$
  20. start:
  21. x = 10: y = 100
  22. x2 = 305: y2 = 100
  23. a = 140: b = 100
  24. d = 0: po1 = 0: po2 = 0
  25. l = 1: r = 0
  26. dr$ = ""
  27. ky:
  28. LOCATE 1, 1: PRINT "You:"; p: LOCATE 1, 25: PRINT "Computer:"; p2
  29. a$ = INKEY$
  30. LINE (x, y)-(x + 2, y + 15), 0, BF
  31. IF a$ = CHR$(0) + CHR$(72) THEN y = y - 10 ': dr$ = "up"
  32. IF a$ = CHR$(0) + CHR$(80) THEN y = y + 10 ' : dr$ = "down"
  33. IF a$ = CHR$(0) + CHR$(75) THEN dr$ = "stop"
  34. IF a$ = CHR$(0) + CHR$(77) THEN dr$ = "stop"
  35. IF a$ = CHR$(27) THEN CLEAR: END
  36. IF dr$ = "up" THEN y = y - 5
  37. IF dr$ = "down" THEN y = y + 5
  38. IF y < 10 THEN y = 10
  39. IF y > 170 THEN y = 170
  40. LINE (x, y)-(x + 2, y + 15), 4, BF
  41. ball:
  42. CIRCLE (a, b), 3, 0
  43. IF a > x2 - 6 THEN l = 1: r = 0: RANDOMIZE TIMER: d = INT(RND * 10) - 5: PLAY "l30c"
  44. IF a < x + 6 THEN r = 1: l = 0: RANDOMIZE TIMER: d = INT(RND * 10) - 5: PLAY "l30c"
  45. IF l = 1 THEN a = a - 5: b = b + d
  46. IF r = 1 THEN a = a + 5: b = b + d
  47. IF b < 20 THEN RANDOMIZE TIMER: d = INT(RND * 5) + 1
  48. IF b > 170 THEN RANDOMIZE TIMER: d = INT(RND * 5) - 5
  49. IF b > y + 16 OR b < y - 1 THEN po1 = 1
  50. IF b > y2 + 16 OR b < y2 - 1 THEN po2 = 1
  51. GOTO chk
  52. ball2:
  53. CIRCLE (a, b), 3, 15
  54. computer:
  55. LINE (x2, y2)-(x2 + 2, y2 + 15), 4, BF
  56. IF l = 1 THEN GOTO tim:
  57. LINE (x2, y2)-(x2 + 2, y2 + 15), 0, BF
  58. IF d < 0 THEN y2 = y2 - 6
  59. IF d > 0 THEN y2 = y2 + 6
  60. IF b < y2 THEN y2 = y2 - 7
  61. IF b > y2 + 15 THEN y2 = y2 + 7
  62. IF y2 < 10 THEN dr2$ = "down"
  63. IF y2 > 170 THEN dr2$ = "up"
  64. IF dr2$ = "down" THEN
  65.     rad = INT(RND * 3) + 2
  66.     y2 = y2 + rad
  67. IF dr2$ = "up" THEN
  68.     rad = INT(RND * 3) + 2
  69.     y2 = y2 - rad
  70. LINE (x2, y2)-(x2 + 2, y2 + 15), 4, BF
  71. tim:
  72. GOTO ky:
  73. chk:
  74. IF a > x2 + 2 AND po2 = 1 THEN p = p + 1
  75. IF a < x - 2 AND po1 = 1 THEN p2 = p2 + 1
  76. IF p = 10 THEN
  77.     LOCATE 1, 1: PRINT "You:"; p: LOCATE 1, 25: PRINT "Computer:"; p2
  78.     PRINT "YOU WIN"
  79.     PRINT
  80.     PRINT
  81.     INPUT "Press enter to go to main menu."; mm$
  82.     GOTO begin:
  83. IF p2 = 10 THEN
  84.     LOCATE 1, 1: PRINT "You:"; p: LOCATE 1, 25: PRINT "Computer:"; p2
  85.     PRINT "COMPUTER WINS"
  86.     PRINT
  87.     PRINT
  88.     INPUT "Press enter to go to main menu."; mm$
  89.     GOTO begin:
  90. IF a > x2 + 2 AND po2 = 1 THEN GOTO start
  91. IF a < x - 2 AND po1 = 1 THEN GOTO start
  92. po2 = 0
  93. po1 = 0
  94. GOTO ball2
  95.  
  96.  

BTW does the computer ever miss? :D
« Last Edit: June 19, 2019, 11:10:58 pm by bplus »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Here is my Infinite Pong the Movie:
Code: QB64: [Select]
  1. _TITLE "Infinite Pong the Movie.bas for QB64 B+ 2018-09-16"
  2. p1y = 1: p2y = 25 'paddle y
  3. bx = 30: by = 10: bdx = 2: bdy = 1 'ball x, y, dx, dy
  4.     CLS
  5.     FOR row = 2 TO 24
  6.         LOCATE row, 5: PRINT "|";
  7.         LOCATE row, 75: PRINT "|";
  8.     NEXT
  9.     p1x = bx - 5: _PRINTSTRING (p1x, p1y), "1111111111" ' draw paddle 1
  10.     p2x = bx - 5: _PRINTSTRING (p2x, p2y), "2222222222" ' draw paddle 2
  11.     IF bx + bdx < 6 THEN bdx = bdx * -1 + INT(RND * 3) - 1
  12.     IF bx + bdx > 74 THEN bdx = bdx * -1 + INT(RND * 3) - 1
  13.     IF by + bdy < 2 THEN bdy = bdy * -1: bdx = bdx + INT(RND * 3) - 1
  14.     IF by + bdy > 24 THEN bdy = bdy * -1: bdx = bdx + INT(RND * 3) - 1
  15.     bx = bx + bdx: by = by + bdy
  16.     _PRINTSTRING (bx, by), "O"
  17.     _LIMIT 10
  18.  
  19.  

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Thanks. Yeah I've known the ball can go through the paddle at certain times, but I couldn't figure out how to fix it. I tried your code and for some reason the ball always bounces off the walls and nobody ever gets a point. But I really like your Pong the Movie! Pretty good for not too much code you made. Also, I want to keep my paddle always moving unless the user presses the right or left arrow key, which stops your paddle. Yeah it's really hard, I've only beaten it once or twice out of many tries. The computer sometimes misses if you play enough. Also, the highest speed is usually in the user's favor for some reason. I made about 90% of this program back in 1996 so who knows what I was thinking, but I think it's kinda cool so that's why I plopped it on my website. lol Thanks for the critique though, I appreciate it.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Hi Kenneth,

I did work on your game some more, if you like paddles always moving sorry :) but ball looks like it's bouncing pretty close to correct places and I handicapped the computer a bit.

Code: QB64: [Select]
  1. 'Updated by Kenneth on May 27, 2019.
  2. _TITLE "PING PONG"
  3. begin:
  4. PRINT "               PING PONG"
  5. PRINT "By Kenneth G."
  6. PRINT "Use the up and down arrow keys to move"
  7. PRINT "the left paddle. If the ball passes the"
  8. PRINT "computer's paddle, you get a point."
  9. PRINT "Whoever gets 10 points first wins."
  10. PRINT "Press Esc to end anytime."
  11. INPUT "(F)ast, (M)edium, (S)low, (Q)uit:"; sp$
  12. IF sp$ = "F" OR sp$ = "f" OR sp$ = "FAST" OR sp$ = "fast" OR sp$ = "Fast" THEN sd = 30
  13. IF sp$ = "M" OR sp$ = "m" OR sp$ = "MEDIUM" OR sp$ = "medium" OR sp$ = "Medium" THEN sd = 20
  14. IF sp$ = "S" OR sp$ = "s" OR sp$ = "SLOW" OR sp$ = "slow" OR sp$ = "Slow" THEN sd = 10
  15. IF sp$ = "Q" OR sp$ = "q" OR sp$ = "QUIT" OR sp$ = "quit" OR sp$ = "Quit" THEN CLEAR: END
  16. IF sd = 0 THEN sd = 10
  17. INPUT "Press enter to start."; st$
  18. start:
  19. x = 10: y = 100
  20. x2 = 305: y2 = 100
  21. a = 140: b = 100
  22. d = 0: po1 = 0: po2 = 0
  23. l = 1: r = 0
  24. dr$ = ""
  25.     'LINE (0, 15)-(400, 15), 3
  26.     'LINE (0, 176)-(400, 176), 3
  27.     CLS
  28.     LINE (10, 15)-(305, 176), 1, BF
  29.     LOCATE 1, 5: PRINT "You:"; p: LOCATE 1, 25: PRINT "Computer:"; p2
  30.     a$ = INKEY$
  31.     IF a$ = CHR$(27) THEN CLEAR: END
  32.  
  33.     'your paddle
  34.     'LINE (x, y)-(x + 2, y + 15), 0, BF 'why 2 times black out old redrw new
  35.     IF a$ = CHR$(0) + CHR$(72) THEN y = y - 10
  36.     IF a$ = CHR$(0) + CHR$(80) THEN y = y + 10
  37.     IF y < 10 THEN y = 10
  38.     IF y > 170 THEN y = 170
  39.     LINE (x, y)-(x + 2, y + 15), 4, BF
  40.  
  41.     ball:
  42.     'CIRCLE (a, b), 3, 0 'black out
  43.     'IF a > x2 - 6 THEN l = 1: r = 0:  d = INT(RND * 10) - 5: PLAY "l30c"
  44.     'IF a = x + 5 AND po1 THEN r = 1: l = 0:  d = INT(RND * 10) - 5: PLAY "l30c"
  45.  
  46.     'the ball is always moving left or right in inc of 5
  47.     IF l = 1 THEN a = a - 5: b = b + d
  48.     IF r = 1 THEN a = a + 5: b = b + d
  49.  
  50.     IF a = x + 5 THEN
  51.         IF b < y + 16 AND b > y - 1 THEN 'paddle hit ball   send it back
  52.             r = 1
  53.             l = 0
  54.             d = INT(RND * 10) - 5: PLAY "l30c"
  55.         END IF
  56.     END IF
  57.  
  58.     IF b < 20 THEN d = RND * 5 + 1
  59.     IF b > 170 THEN d = RND * 5 - 5
  60.     IF b > y + 16 OR b < y - 1 THEN po1 = 1 'ball misses paddle on
  61.     IF b > y2 + 16 OR b < y2 - 1 THEN po2 = 1
  62.     IF a = x2 - 5 THEN
  63.         IF b < y2 + 16 AND b > y2 - 1 THEN 'paddle hit ball   send it back
  64.             r = 0
  65.             l = 1
  66.             d = INT(RND * 10) - 5: PLAY "l30c"
  67.         END IF
  68.     END IF
  69.     IF a < x + 5 AND po1 = 1 THEN p2 = p2 + 1 'ball misses paddle on x spot
  70.     IF a >= x2 AND po2 = 1 THEN p = p + 1
  71.     IF p = 10 THEN
  72.         LOCATE 1, 1: PRINT "You:"; p: LOCATE 1, 25: PRINT "Computer:"; p2
  73.         PRINT "YOU WIN, ";
  74.         INPUT "Press enter."; mm$
  75.         GOTO begin:
  76.     END IF
  77.     IF p2 = 10 THEN
  78.         LOCATE 1, 1: PRINT "You:"; p: LOCATE 1, 25: PRINT "Computer:"; p2
  79.         PRINT "COMPUTER WINS, ";
  80.         INPUT "Press enter."; mm$
  81.         GOTO begin:
  82.     END IF
  83.     IF a >= x2 AND po2 = 1 THEN GOTO start
  84.     IF a <= x AND po1 = 1 THEN GOTO start
  85.     po2 = 0
  86.     po1 = 0
  87.     CIRCLE (a, b), 3, 15
  88.  
  89.     computer:
  90.     LINE (x2, y2)-(x2 + 2, y2 + 15), 4, BF
  91.     IF l = 1 THEN GOTO tim:
  92.     'LINE (x2, y2)-(x2 + 2, y2 + 15), 0, BF
  93.     IF d < 0 THEN y2 = y2 - 6
  94.     IF d > 0 THEN y2 = y2 + 6
  95.     IF RND < .90 THEN '<<<<<<<<<<<<<<<<<<<<<<< sorry computer you are too perfect
  96.         IF b < y2 THEN y2 = y2 - 7
  97.         IF b > y2 + 15 THEN y2 = y2 + 7
  98.     END IF
  99.     IF y2 < 10 THEN dr2$ = "down"
  100.     IF y2 > 170 THEN dr2$ = "up"
  101.     IF dr2$ = "down" THEN
  102.         RANDOMIZE TIMER
  103.         rad = INT(RND * 3) + 2
  104.         y2 = y2 + rad
  105.     END IF
  106.     IF dr2$ = "up" THEN
  107.         RANDOMIZE TIMER
  108.         rad = INT(RND * 3) + 2
  109.         y2 = y2 - rad
  110.     END IF
  111.     LINE (x2, y2)-(x2 + 2, y2 + 15), 4, BF
  112.     tim:
  113.     _DISPLAY
  114.     _LIMIT sd
  115.  
  116.  

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
WOW Thanks!!! I added credit to you in the game too and in the top code remark. I will add it to my website sometime later today most likely. I did notice one small problem which also happened before you worked on it, is that the ball also sometimes goes through the computer's paddle. I'm not sure if that is intentional or not, like if we want to make it easier to play on the user's part. If you want, you can keep working on it and I will just update the website again if you make another version. I'm going to also call this: Ping Pong 2.

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
I got your name on the updated version on the program and on the website, thanks again.
http://ken.x10host.com/qb64/

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
I just found a way to stop the ball from going through the Computer's paddle. Once in awhile it will still stop before the paddle but I'm not going to worry about that. What I did was change Line 68 to this: IF a > x2 - 5 AND a < x2 + 2 THEN       
I updated the new code to the website.

Offline OldMoses

  • Seasoned Forum Regular
  • Posts: 469
    • View Profile
I'm going to have to scrutinize your computer "player" algorithm. I've never written anything that put a computer as an opponent. All I've concentrated on was number crunchers, so I don't have a clue how to go about it.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
For contrast and curiosity, I wrote up a Ping Pong Game totally structured such that ... well look! :-))

Oh, also if you are a constant paddle mover, no problem because this paddle runs off mouse.

Code: QB64: [Select]
  1. _TITLE "Ping Pong" 'try a modern structured approach 2019-06-20 by B+
  2. CONST xmax = 800, ymax = 600
  3. SCREEN _NEWIMAGE(xmax, ymax, 32)
  4. _SCREENMOVE 300, 40
  5.  
  6. TYPE XYType
  7.     x AS SINGLE
  8.     y AS SINGLE
  9. TYPE Rectangle
  10.     xy AS XYType
  11.     w AS SINGLE
  12.     h AS SINGLE
  13.     clr AS _UNSIGNED LONG
  14.     xy AS XYType
  15.     dx AS SINGLE
  16.     dy AS SINGLE
  17.     r AS INTEGER
  18.     clr AS _UNSIGNED LONG
  19. TYPE player
  20.     id AS STRING
  21.     pdl AS Rectangle
  22.     pts AS INTEGER
  23. TYPE game
  24.     human AS player
  25.     computer AS player
  26.     ball AS circle
  27.     table AS Rectangle
  28. DIM SHARED g AS game '<<< all game data is in here
  29. initGame
  30. playGame
  31.  
  32. SUB initGame 'most of thses remain constant                                         start with table
  33.     g.table.xy.x = 50: g.table.xy.y = 150: g.table.w = 700: g.table.h = 400: g.table.clr = &HFF005038
  34.     g.computer.id = "Computer": g.computer.pts = 0 '                            computer on the left
  35.     g.computer.pdl.w = 15: g.computer.pdl.h = 40: g.computer.pdl.clr = &HFF0000FF
  36.     g.computer.pdl.xy.x = g.table.xy.x - g.computer.pdl.w
  37.     g.human.id = "Human": g.human.pts = 0 '                                      player on the right
  38.     g.human.pdl.w = 15: g.human.pdl.h = 40: g.human.pdl.clr = &HFFFF0000
  39.     g.human.pdl.xy.x = g.table.xy.x + g.table.w '                                      player paddle
  40.     g.ball.r = 5: g.ball.clr = &HFFFFFFFF '                                                     ball
  41.  
  42. SUB playGame
  43.     DIM my, inbounds
  44.     DO
  45.         getBallRolling
  46.         inbounds = 1
  47.         WHILE inbounds
  48.             WHILE _MOUSEINPUT: WEND '                                                              update human paddle
  49.             my = _MOUSEY
  50.             IF my > g.table.xy.y AND my <= g.table.xy.y + g.table.h THEN
  51.                 g.human.pdl.xy.y = my - g.human.pdl.h / 2
  52.             END IF
  53.             IF RND < .3 THEN '                                                                 update computer paddle
  54.                 g.computer.pdl.xy.y = g.ball.xy.y - g.computer.pdl.h / 2
  55.             END IF
  56.             g.ball.xy.x = g.ball.xy.x + g.ball.dx: g.ball.xy.y = g.ball.xy.y + g.ball.dy '  update ball
  57.             'past the table edge? or paddle edge
  58.             IF g.ball.xy.x - g.ball.r <= g.table.xy.x THEN '                                ball paste left edge
  59.                 IF g.ball.xy.y + g.ball.r >= g.computer.pdl.xy.y AND g.ball.xy.y - g.ball.r <= g.computer.pdl.xy.y + g.computer.pdl.h THEN
  60.                     g.ball.dx = -g.ball.dx
  61.                 ELSE
  62.                     inbounds = 0: g.human.pts = g.human.pts + 1
  63.                 END IF
  64.             ELSEIF g.ball.xy.x + g.ball.r >= g.table.xy.x + g.table.w THEN '                ball paste right edge
  65.                 IF g.ball.xy.y + g.ball.r >= g.human.pdl.xy.y AND g.ball.xy.y - g.ball.r <= g.human.pdl.xy.y + g.human.pdl.h THEN
  66.                     g.ball.dx = -g.ball.dx
  67.                 ELSE
  68.                     inbounds = 0: g.computer.pts = g.computer.pts + 1
  69.                 END IF
  70.             ELSEIF g.ball.xy.y - g.ball.r <= g.table.xy.y THEN '                                          top edge
  71.                 g.ball.dy = -g.ball.dy
  72.             ELSEIF g.ball.xy.y + g.ball.r >= g.table.xy.y + g.table.h THEN '                            bottom edge
  73.                 g.ball.dy = -g.ball.dy
  74.             END IF
  75.             drawGame
  76.             _DISPLAY
  77.             _LIMIT 60
  78.         WEND
  79.         _DELAY .5
  80.     LOOP UNTIL g.human.pts = 21 OR g.computer.pts = 21
  81.  
  82. SUB getBallRolling
  83.     DIM d, s$, tstart, my
  84.     g.computer.pdl.xy.y = g.table.xy.y + (g.table.h - g.computer.pdl.h) / 2 '       center paddles y
  85.     g.human.pdl.xy.y = g.table.xy.y + (g.table.h - g.human.pdl.h) / 2
  86.     g.ball.dy = 4 + RND
  87.     g.ball.dx = (g.ball.dy + 1 + RND)
  88.     IF RND < .5 THEN d = -1 ELSE d = 1 '                              ball movement absolutely  more dx than dy
  89.     g.ball.dy = g.ball.dy * d
  90.     IF RND < .5 THEN d = -1 ELSE d = 1
  91.     g.ball.dx = g.ball.dx * d
  92.     IF d < 0 THEN '                                                      ball table center
  93.         g.ball.xy.x = g.table.xy.x + .9 * g.table.w
  94.     ELSE
  95.         g.ball.xy.x = g.table.xy.x + .1 * g.table.w
  96.     END IF
  97.     g.ball.xy.y = g.table.xy.y + g.table.h / 2
  98.     tstart = TIMER(.001)
  99.     WHILE TIMER(.001) - tstart < 1.500 ' <<<<<<<<<<<<<<<< This allows player to get es paddle alligned with mouse
  100.         WHILE _MOUSEINPUT: WEND
  101.         my = _MOUSEY
  102.         IF my > g.table.xy.y AND my <= g.table.xy.y + g.table.h THEN '    update human paddle
  103.             g.human.pdl.xy.y = my - g.human.pdl.h / 2
  104.         END IF
  105.         drawGame
  106.         s$ = "Get ready for random serve..."
  107.         COLOR , g.table.clr
  108.         _PRINTSTRING (g.table.xy.x + (g.table.w - 8 * LEN(s$)) / 2, g.table.xy.y + g.table.h / 2 - 8), s$
  109.         COLOR , &HFF000000
  110.         _DISPLAY
  111.         _LIMIT 60
  112.     WEND
  113.  
  114. SUB drawGame
  115.     DIM s$
  116.     CLS
  117.     _PRINTSTRING (g.table.xy.x + 120, g.table.xy.y / 2 - 4), g.computer.id + ":" + STR$(g.computer.pts) '              score
  118.     s$ = g.human.id + ":" + STR$(g.human.pts)
  119.     _PRINTSTRING (g.table.xy.x + g.table.w - 8 * LEN(s$) - 120, g.table.xy.y / 2 - 4), s$
  120.     LINE (g.table.xy.x, g.table.xy.y)-STEP(g.table.w, g.table.h), g.table.clr, BF '                                    table
  121.     LINE (g.computer.pdl.xy.x, g.computer.pdl.xy.y)-STEP(g.computer.pdl.w, g.computer.pdl.h), g.computer.pdl.clr, BF ' computer paddle
  122.     LINE (g.human.pdl.xy.x, g.human.pdl.xy.y)-STEP(g.human.pdl.w, g.human.pdl.h), g.human.pdl.clr, BF '                human paddle
  123.     fcirc g.ball.xy.x, g.ball.xy.y, g.ball.r, g.ball.clr
  124.  
  125. SUB fcirc (CX AS INTEGER, CY AS INTEGER, R AS INTEGER, C AS _UNSIGNED LONG)
  126.     DIM Radius AS INTEGER, RadiusError AS INTEGER
  127.     DIM X AS INTEGER, Y AS INTEGER
  128.     Radius = ABS(R): RadiusError = -Radius: X = Radius: Y = 0
  129.     IF Radius = 0 THEN PSET (CX, CY), C: EXIT SUB
  130.     LINE (CX - X, CY)-(CX + X, CY), C, BF
  131.     WHILE X > Y
  132.         RadiusError = RadiusError + Y * 2 + 1
  133.         IF RadiusError >= 0 THEN
  134.             IF X <> Y + 1 THEN
  135.                 LINE (CX - Y, CY - X)-(CX + Y, CY - X), C, BF
  136.                 LINE (CX - Y, CY + X)-(CX + Y, CY + X), C, BF
  137.             END IF
  138.             X = X - 1
  139.             RadiusError = RadiusError - X * 2
  140.         END IF
  141.         Y = Y + 1
  142.         LINE (CX - X, CY - Y)-(CX + X, CY - Y), C, BF
  143.         LINE (CX - X, CY + Y)-(CX + X, CY + Y), C, BF
  144.     WEND
  145.  
  146.  

Unfortunately when I hide the mouse, my x alignment drifts off and so movement gets stuck all too often.
« Last Edit: June 20, 2019, 05:52:13 pm by bplus »

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Thanks Ron!

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Interesting bplus, I might take a look at that. Using the mouse reminds me of a week or 2 ago when I made a Paint program. I used examples on this website and it lets you paint with the mouse and even choose from the Windows color selection window. It even prints the picture and saves as JPG. Plus I added circles, squares, and fill-in. I really liked it until I found out that it might not work on a lot of Windows computers. And I have no idea why. It's why I don't have it on my website. But if anyone is interested in seeing that code, just tell me. Would love to hear any opinions and what I might have done wrong.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Hi Kenneth,

If you or anyone can figure a way to keep the mouse from getting stuck in my Ping Pong version I would be eternally grateful. With arrow keys you don't have to worry about paddle getting off track but with mouse I drift sometimes all the way off the left side of the screen! and yet showing the mouse gets distracting.

Should be able to do everything you described for Paint program with QB64 specially easy for Windows. Steve has nifty code for saving images to image file formats. We can draw and fill any shape including tilted ellipse though N-gons might be tricky.

You say you have code? I say I'd be interested :D I am very curious what might not work in Windows, ah the saving to file format might be different and I don't know about printing an image.

We have started image editor here some time ago for modifying images, I think that is similar to Paint program except the pixels are blown up to squares.

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
All I can think of to possibly help you with your mouse problem is to require people to hold down the left mouse button at the same time as moving it. That will give people the chance to move the mouse anywhere they want without moving the paddle.

Well, here is the code to my Paint program. It also uses bloated boxes for the "pixels" but you can load any JPG with it first to edit. Another problem I have with it is that you have to draw pretty slowly to make your lines connect. But I still like it. It runs fine on my Windows 10 Home Edition computer. It might have just been that particular person's computer that had problems, I have no idea. You will probably laugh in how scattered the code is, I still program like I did in the 90's. LOL The biggest thing I like about this program is that it uses the ENTIRE screen to paint, no words, boxes, anything, just your canvas. :) But like I said, draw slow. And also make sure and read the 2 pages of instructions that start out.

Code: QB64: [Select]
  1. 'This program took on a life of its own starting from a basic mouse
  2. 'drawing program to then saving it as its own type of data file to
  3. 'then BMP pictures and now JPG pictures.
  4. 'Then other things were added such as rays, orbits, paint fill ins,
  5. 'boxes, printer support, Windows color picker, and editing.
  6. 'This program was made using QB64 and will always be Freeware.
  7. 'Paint PIxels was made by Kenneth G. with some help from
  8. 'the QB64 website Wiki pages.
  9. 'I want to thank the people who made and take care of the QB64 website
  10. 'and computer language. I have wanted to make a program like this for
  11. 'a very long time.
  12. 'It took 1 week to make this program and finished on June 5, 2019.
  13. 'Feel free to use any of its code below for your own creations but
  14. 'please don't copy more than half of it and sell it. Thank you.
  15. 'Just remember, there are much better graphics programs out there
  16. 'that can do much more than this can, but to me this is my pride and joy.
  17. 'One big thing I like a lot about this program is that it uses the
  18. 'entire computer screen to draw with. Also remember, I am no professional,
  19. 'just a guy who has loved BASIC programming for over 30 years.
  20. '
  21. 'Technical Notes:
  22. 'This program uses around 55 MB RAM and 1% of the CPU on my semi-new computer.
  23. 'Use at your own risk. I hold no responsibility for any problems whatsoever.
  24.  
  25. 'Here is the code needed for the Color Picker. The Function code
  26. 'is also at the end of this program.
  27. CONST CC_RGBINIT = &H1& ' Sets the initial color (don't know how to set it)
  28. CONST CC_FULLOPEN = &H2& ' Opens all dialog sections such as the custom color selector
  29. CONST CC_PREVENTFULLOPEN = &H4& ' Prevents the user from opening the custom color selector
  30. CONST CC_SHOWHELP = &H8& ' Shows the help button (USELESS!)
  31. '----------------------------------------------------------------------------------------
  32. TYPE COLORDIALOGTYPE
  33.     lStructSize AS LONG ' Length of this TYPE structure
  34.     hwndOwner AS LONG 'Dialog owner's handle
  35.     hInstance AS LONG '  ?
  36.     rgbResult AS LONG ' The RGB color the user selected
  37.     lpCustColors AS _OFFSET ' Pointer to an array of 16 custom colors (will be changed by user)
  38.     flags AS LONG ' Dialog flags
  39.     lCustData AS LONG ' Custom data
  40.     lpfnHook AS LONG ' Hook
  41.     lpTemplateName AS _OFFSET ' Custom template
  42. DIM ColorString AS STRING * 64
  43.  
  44. _LIMIT 500
  45. start:
  46. _TITLE "Paint Pixels"
  47. WIDTH 40, 43
  48. _SCREENMOVE 400, 200
  49. PRINT "         Paint Pixels"
  50. PRINT "         By Ken G."
  51. PRINT "This is a little program that you"
  52. PRINT "can draw using your mouse and"
  53. PRINT "save the picture and load it."
  54. PRINT "You also can make lines (Rays),"
  55. PRINT "circles (Orbits), and fill in the"
  56. PRINT "same color. You also can print to"
  57. PRINT "your USB printer as well as edit"
  58. PRINT "an old picture file."
  59. PRINT "It saves under .jpg files which can"
  60. PRINT "be used with most other programs."
  61. PRINT "Press the Space Bar to"
  62. PRINT "skip instructions."
  63. PRINT "Press Esc to end program."
  64. PRINT "Press any other key to continue."
  65. gggo:
  66. ecc$ = INKEY$
  67. IF ecc$ = " " THEN GOTO start2:
  68. IF ecc$ = CHR$(27) THEN END
  69. IF ecc$ = "" THEN GOTO gggo:
  70. PRINT "       Instructions"
  71. PRINT "(S)ave (L)oad (H)ome"
  72. PRINT "(R)ay coordinates for line."
  73. PRINT "Press R once to start line"
  74. PRINT "and again to finish it."
  75. PRINT "(O)rbit coordinates for circles."
  76. PRINT "Press O once to start circle."
  77. PRINT "and again to finish it."
  78. PRINT "The size of the circle depends"
  79. PRINT "on the length difference"
  80. PRINT "between where you pressed O"
  81. PRINT "both times. The center of the circle"
  82. PRINT "will be the first place you pressed O."
  83. PRINT "(P)rints the picture on"
  84. PRINT "your printer. It will not work"
  85. PRINT "if you choose a black background"
  86. PRINT "because of heavy ink or toner use."
  87. PRINT "To go around that, choose a white"
  88. PRINT "background and on the color picker"
  89. PRINT "window, choose black and press F"
  90. PRINT "to fill entire window."
  91. PRINT "The paper printed outcome will NOT"
  92. PRINT "be proportionate to the screen."
  93. PRINT "Esc to end program."
  94. PRINT "Space Bar clears the screen."
  95. PRINT "Left Mouse Button draws."
  96. PRINT "Right Mouse Button erases."
  97. PRINT "There is no Undo feature on"
  98. PRINT "this program."
  99. PRINT "Press Esc to end program or"
  100. PRINT "any other key to continue."
  101. ggggo:
  102. ecc2$ = INKEY$
  103. IF ecc2$ = CHR$(27) THEN END
  104. IF ecc2$ = "" THEN GOTO ggggo:
  105. PRINT "    Instructions Page 2"
  106. PRINT "(C)olor changes colors."
  107. PRINT "A window will popup to use"
  108. PRINT "your mouse to choose a color."
  109. PRINT "This will also happen when you"
  110. PRINT "first start your painting."
  111. PRINT "(F)ill fills in a color between"
  112. PRINT "the lines of the same color only."
  113. PRINT "Also close any gaps or it will"
  114. PRINT "fill the whole screen."
  115. PRINT "(B)oxes makes a box."
  116. PRINT "First press B once to start the"
  117. PRINT "box corner, then press B again"
  118. PRINT "to set the 2nd corner and size"
  119. PRINT "diagonally from the first one."
  120. PRINT "Paint slowly to leave out gaps."
  121. PRINT "When you press S to save,"
  122. PRINT "the program will create a temp.jpg"
  123. PRINT "of the screen and when asking you"
  124. PRINT "for a file name, it will rename temp.jpg"
  125. PRINT "to your chosen name."
  126. PRINT "Press Esc to end program or"
  127. PRINT "any other key to start."
  128. gggggo:
  129. s$ = INKEY$
  130. IF s$ = "" THEN GOTO gggggo:
  131. IF s$ = CHR$(27) THEN END
  132. start2:
  133. begin = 1
  134. PRINT "Background Color"
  135. PRINT "(B)lack (W)hite"
  136. PRINT "Or Esc to end program."
  137. start3:
  138. bcolor$ = INKEY$
  139. IF bcolor$ = CHR$(27) THEN END
  140. IF bcolor$ = "" THEN GOTO start3:
  141. IF bcolor$ = "w" OR bcolor$ = "W" THEN
  142.     s& = _NEWIMAGE(640, 480, 32)
  143.     SCREEN s&
  144.     LINE (0, 0)-(640, 480), _RGB(255, 255, 255), BF
  145.     GOTO more2:
  146. IF bcolor$ = "B" OR bcolor$ = "b" THEN
  147.     s& = _NEWIMAGE(640, 480, 32)
  148.     SCREEN s&
  149.     CLS
  150.     GOTO more2:
  151. GOTO start3:
  152. more2:
  153. begin = 1
  154. GOSUB chosencolor:
  155. '---------------------------------------------------
  156. 'Here is the main loop of the program when painting.
  157. '---------------------------------------------------
  158.     _LIMIT 500
  159.         mouseX = _MOUSEX
  160.         mouseY = _MOUSEY
  161.         mouseLeftButton = _MOUSEBUTTON(1)
  162.         mouseRightButton = _MOUSEBUTTON(2)
  163.         mouseMiddleButton = _MOUSEBUTTON(3)
  164.     LOOP
  165.     IF mouseLeftButton = -1 THEN
  166.         LINE (mouseX, mouseY)-(mouseX + 1, mouseY + 1), clr~&, BF
  167.     END IF
  168.     IF mouseRightButton = -1 THEN
  169.         LINE (mouseX, mouseY)-(mouseX + 1, mouseY + 1), 0, BF
  170.     END IF
  171.     a$ = INKEY$
  172.     'Here is when someone whipes the screen blank with the space bar.
  173.     IF a$ = " " THEN GOTO start2:
  174.     IF a$ = CHR$(27) THEN END
  175.     IF a$ = "s" OR a$ = "S" THEN GOTO saving:
  176.     IF a$ = "l" OR a$ = "L" THEN GOSUB loading:
  177.     IF a$ = "h" OR a$ = "H" THEN GOTO start:
  178.     'Here is code needed to call up the Windows Color Picker.
  179.     'It also uses the code on top of this program and the Function at the end
  180.     'of this program.
  181.     IF a$ = "c" OR a$ = "C" THEN
  182.         chosencolor:
  183.         'Color Dialog flag constants (use + or OR to use more than 1 flag)
  184.         ColorString = "FFFFFFFFFF" 'not sure how this works?
  185.         DECLARE DYNAMIC LIBRARY "comdlg32"
  186.             FUNCTION ChooseColorA& (DIALOGPARAMS AS COLORDIALOGTYPE) ' Yet the also famous color dialog box
  187.         END DECLARE
  188.         DECLARE LIBRARY
  189.             FUNCTION FindWindow& (BYVAL ClassName AS _OFFSET, WindowName$) ' To get hWnd handle
  190.         END DECLARE
  191.         ' SCREEN _NEWIMAGE(640, 480, 12) '32 or 16 or 256 color screen modes
  192.         _TITLE "Paint Pixels" 'set Title of program
  193.         hWnd& = FindWindow(0, "Paint Pixels" + CHR$(0)) 'get window handle using _TITLE string
  194.         clr~& = ChooseColor&(_RGB32(0, 0, 0), ColorString$, Cancel, CC_FULLOPEN, hWnd&)
  195.         IF begin = 1 THEN begin = 0: RETURN
  196.     END IF
  197.     'Here is the Ray Lines code.
  198.     IF a$ = "r" OR a$ = "R" THEN
  199.         ck = ck + 1
  200.         IF ck > 1 THEN GOTO ray:
  201.         xxx = mouseX: yyy = mouseY
  202.         LINE (mouseX, mouseY)-(mouseX + 1, mouseY + 1), clr~&, BF
  203.         GOTO firstray:
  204.         ray:
  205.         LINE (mouseX, mouseY)-(xxx, yyy), clr~&
  206.         xxx = 0: yyy = 0
  207.         ck = 0
  208.         firstray:
  209.     END IF
  210.     'Here is the Orbit Circles code.
  211.     IF a$ = "o" OR a$ = "O" THEN
  212.         ck2 = ck2 + 1
  213.         IF ck2 > 1 THEN GOTO orbit:
  214.         xxx2 = mouseX: yyy2 = mouseY
  215.         GOTO firstorbit:
  216.         orbit:
  217.         IF mouseX < xxx2 THEN size = xxx2 - mouseX
  218.         IF mouseX > xxx2 THEN size = mouseX - xxx2
  219.         IF mouseY < yyy2 THEN size2 = yyy2 - mouseY
  220.         IF mouseY > yyy2 THEN size2 = mouseY - yyy2
  221.         size3 = INT((size + size2) / 2)
  222.         CIRCLE (xxx2, yyy2), size3, clr~&
  223.         xxx2 = 0: yyy2 = 0
  224.         size = 0: size2 = 0: size3 = 0
  225.         ck2 = 0
  226.         firstorbit:
  227.     END IF
  228.     'Here is the Fill-in code.
  229.     IF a$ = "f" OR a$ = "F" THEN
  230.         PAINT (mouseX, mouseY), clr~&
  231.     END IF
  232.     'Here is the Boxes code.
  233.     IF a$ = "b" OR a$ = "B" THEN
  234.         ck3 = ck3 + 1
  235.         IF ck3 > 1 THEN GOTO box:
  236.         xxx3 = mouseX: yyy3 = mouseY
  237.         GOTO firstbox:
  238.         box:
  239.         LINE (mouseX, mouseY)-(xxx3 + 1, yyy3 + 1), clr~&, B
  240.         xxx3 = 0: yyy3 = 0
  241.         ck3 = 0
  242.         firstbox:
  243.     END IF
  244.     'Here is the Printing of the picture.
  245.     IF a$ = "p" OR a$ = "P" THEN
  246.         IF bcolor$ = "w" OR bcolor$ = "W" THEN
  247.             j& = _COPYIMAGE(0)
  248.             _DELAY .25
  249.             INPUT "Print on printer (Y/N)?", i$ 'print screen page on printer
  250.             CLS
  251.             SCREEN j&
  252.             _DELAY .25
  253.             IF UCASE$(i$) = "Y" THEN _PRINTIMAGE j&
  254.             _DELAY 2
  255.             j& = 0
  256.         END IF
  257.     END IF
  258.  
  259. 'Saving
  260. 'This section first saves your picture as temp.jpg and then
  261. 'asks you a name for your picture and then renames temp.jpg to your name.
  262. saving:
  263. 'Now we call up the SUB to save the image to JPG.
  264. SaveImage 0, "temp.jpg"
  265. _DELAY .25
  266. PRINT "            Saving"
  267. PRINT "Your jpg file will be saved in the"
  268. PRINT "same directory as this program is."
  269. PRINT "It can be used with almost any"
  270. PRINT "other graphics program or website."
  271. PRINT "It is saved using:"
  272. PRINT "width: 640  height: 480 pixels."
  273. PRINT "Type a name to save your picture"
  274. PRINT "and press the Enter key. Do not"
  275. PRINT "add .jpg at the end, the program"
  276. PRINT "will do it automatically."
  277. PRINT "Also do not use the name temp"
  278. PRINT "because the program uses that name"
  279. PRINT "and it would be erased the next time"
  280. PRINT "you save a picture."
  281. PRINT "Example: MyPic"
  282. PRINT "Quit and Enter key ends program."
  283. INPUT "->"; nm$
  284. IF nm$ = "Quit" OR nm$ = "quit" OR nm$ = "QUIT" THEN END
  285. nm$ = nm$ + ".jpg"
  286. 'Checking to see if the file already exists on your computer.
  287. theFileExists = _FILEEXISTS(nm$)
  288. IF theFileExists = -1 THEN
  289.     PRINT "File Already Exists"
  290.     PRINT "Saving will delete your old"
  291.     PRINT "jpg picture."
  292.     PRINT "Would you like to still do it?"
  293.     PRINT "(Y/N). Esc ends program."
  294.     llloop:
  295.     _LIMIT 10
  296.     ag2$ = INKEY$
  297.     IF ag2$ = "" THEN GOTO llloop:
  298.     IF ag2$ = "y" OR ag$ = "Y" THEN GOTO saving2:
  299.     IF ag2$ = CHR$(27) THEN END
  300.     GOTO saving:
  301. saving2:
  302. NAME "temp.jpg" AS nm$
  303.  
  304. nm$ = ""
  305. FOR snd = 100 TO 700 STEP 100
  306.     SOUND snd, 2
  307. NEXT snd
  308. GOTO start:
  309. loading: 'This section loads your picture from your computer.
  310. PRINT "           Loading"
  311. PRINT "Do not add .jpg at the end."
  312. PRINT "The jpg picture must be in the same"
  313. PRINT "directory as this program is."
  314. PRINT "Type the name of your picture file"
  315. PRINT "here and press the Enter key."
  316. PRINT "Example: MyPic"
  317. PRINT "Quit and Enter key ends program."
  318. INPUT "->"; nm$
  319. IF nm$ = "Quit" OR nm$ = "quit" OR nm$ = "QUIT" THEN END
  320. nm$ = nm$ + ".jpg"
  321. theFileExists = _FILEEXISTS(nm$)
  322. IF theFileExists = 0 THEN
  323.     PRINT "File Does Not Exist."
  324.     PRINT "Would you like to try again (Y/N)"
  325.     PRINT "Esc ends program."
  326.     _LIMIT 10
  327.     llloop2:
  328.     ag$ = INKEY$
  329.     IF ag$ = "" THEN GOTO llloop2:
  330.     IF ag$ = "y" OR ag$ = "Y" THEN GOTO loading:
  331.     IF ag$ = CHR$(27) THEN END
  332.     GOTO start:
  333. l = 0
  334. i& = _LOADIMAGE(nm$, 32)
  335. 'j& = _COPYIMAGE(0)
  336. FOR snd2 = 100 TO 700 STEP 100
  337.     SOUND snd2, 2
  338. NEXT snd2
  339. s& = i&
  340. i& = 0
  341.  
  342. 'Here is the function for the Windows Color Picker,
  343. FUNCTION ChooseColor& (InitialColor&, CustomColors$, Cancel, Flags&, hWnd&)
  344.     ' Parameters:
  345.     ' InitialColor& - The initial color used, will take effect if CC_RGBINIT flag is specified
  346.     ' CustomColors$ - A 64-byte string where the user's custom colors will be stored (4 bytes per color in RGB0 format).
  347.     ' Cancel - Variable where the cancel flag will be stored.
  348.     ' Flags& - Dialog flags
  349.     ' hWnd& - Your program's window handle that should be aquired by the FindWindow function.
  350.     DIM ColorCall AS COLORDIALOGTYPE
  351.     ColorCall.rgbResult = _RGB32(_BLUE32(InitialColor&), _GREEN32(InitialColor&), _RED32(InitialColor&))
  352.     ColorCall.lStructSize = LEN(ColorCall)
  353.     ColorCall.hwndOwner = hWnd&
  354.     ColorCall.flags = Flags&
  355.     ColorCall.lpCustColors = _OFFSET(CustomColors$)
  356.     ' Do dialog call
  357.     Result = ChooseColorA(ColorCall)
  358.     IF Result THEN
  359.         rgbResult& = ColorCall.rgbResult
  360.         ' Swap RED and BLUE color intensity values using _RGB
  361.         ChooseColor& = _RGB(_BLUE32(rgbResult&), _GREEN32(rgbResult&), _RED32(rgbResult&))
  362.     ELSE
  363.         Cancel = -1
  364.     END IF
  365.  
  366. 'Here is the SUB needed to save the image to JPG.
  367. 'It also can be used for BMP pictures on your own program.
  368. SUB SaveImage (image AS LONG, filename AS STRING)
  369.     bytesperpixel& = _PIXELSIZE(image&)
  370.     IF bytesperpixel& = 0 THEN PRINT "Text modes unsupported!": END
  371.     IF bytesperpixel& = 1 THEN bpp& = 8 ELSE bpp& = 24
  372.     x& = _WIDTH(image&)
  373.     y& = _HEIGHT(image&)
  374.     b$ = "BM????QB64????" + MKL$(40) + MKL$(x&) + MKL$(y&) + MKI$(1) + MKI$(bpp&) + MKL$(0) + "????" + STRING$(16, 0) 'partial BMP header info(???? to be filled later)
  375.     IF bytesperpixel& = 1 THEN
  376.         FOR c& = 0 TO 255 ' read BGR color settings from JPG image + 1 byte spacer(CHR$(0))
  377.             cv& = _PALETTECOLOR(c&, image&) ' color attribute to read.
  378.             b$ = b$ + CHR$(_BLUE32(cv&)) + CHR$(_GREEN32(cv&)) + CHR$(_RED32(cv&)) + CHR$(0) 'spacer byte
  379.         NEXT
  380.     END IF
  381.     MID$(b$, 11, 4) = MKL$(LEN(b$)) ' image pixel data offset(BMP header)
  382.     lastsource& = _SOURCE
  383.     _SOURCE image&
  384.     IF ((x& * 3) MOD 4) THEN padder$ = STRING$(4 - ((x& * 3) MOD 4), 0)
  385.     FOR py& = y& - 1 TO 0 STEP -1 ' read JPG image pixel color data
  386.         r$ = ""
  387.         FOR px& = 0 TO x& - 1
  388.             c& = POINT(px&, py&) 'POINT 32 bit values are large LONG values
  389.             IF bytesperpixel& = 1 THEN r$ = r$ + CHR$(c&) ELSE r$ = r$ + LEFT$(MKL$(c&), 3)
  390.         NEXT px&
  391.         d$ = d$ + r$ + padder$
  392.     NEXT py&
  393.     _SOURCE lastsource&
  394.     MID$(b$, 35, 4) = MKL$(LEN(d$)) ' image size(BMP header)
  395.     b$ = b$ + d$ ' total file data bytes to create file
  396.     MID$(b$, 3, 4) = MKL$(LEN(b$)) ' size of data file(BMP header)
  397.     IF LCASE$(RIGHT$(filename$, 4)) <> ".jpg" THEN ext$ = ".jpg"
  398.     f& = FREEFILE
  399.     OPEN filename$ + ext$ FOR OUTPUT AS #f&: CLOSE #f& ' erases an existing file
  400.     OPEN filename$ + ext$ FOR BINARY AS #f&
  401.     PUT #f&, , b$
  402.     CLOSE #f&
  403.  
« Last Edit: June 21, 2019, 12:37:09 am by SierraKen »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Thanks Kenneth,

I see QB64 has compile error:
Quote
In file included from qbx.cpp:2171:
..\\temp\\main.txt: In function 'void QBMAIN(void*)':
..\\temp\\main.txt:1224:112: error: cast from 'HWND' {aka 'HWND__*'} to 'int' loses precision [-fpermissive]
 *__LONG_HWND=(  int32  )FindWindow(NULL,(char*)(qbs_add(qbs_new_txt_len("Paint Pixels",12),func_chr( 0 )))->chr);
                                                                                                                ^
compilation terminated due to -Wfatal-errors.

Probably this is problem:
Code: QB64: [Select]
  1.         DECLARE LIBRARY
  2.             FUNCTION FindWindow& (BYVAL ClassName AS _OFFSET, WindowName$) ' To get hWnd handle
  3.         END DECLARE

I will look over code tomorrow.

BTW I have great Air Hockey game because mouse wouldn't stay on track for Ping Pong. ;-))
« Last Edit: June 21, 2019, 12:48:32 am by bplus »