Author Topic: Giant Red Button  (Read 1822 times)

0 Members and 1 Guest are viewing this topic.

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Giant Red Button
« on: May 10, 2020, 11:04:45 pm »
I know we can use InForm, but I decided to make my own circular red button. I was being goofy and made it into a war simulation button sorta. Click it 5 times and see what happens. The same thing happens every time you do it.
Feel free to use any of this code or change it how you wish.

Edit: I added a generic form of the Giant Red Button after this post so you can add your own code on what you want it to do.

Code: QB64: [Select]
  1. 'Press the GIANT RED BUTTON 5 times!
  2. _TITLE "GIANT RED BUTTON - Press 5 times."
  3. SCREEN _NEWIMAGE(800, 600, 32)
  4. b = 127
  5. FOR sz = .25 TO 150 STEP .25
  6.     CIRCLE (400, 300), sz, _RGB32(255, 0, 0)
  7. NEXT sz
  8.     _LIMIT 500
  9.     mouseWheel = 0
  10.         mouseX = _MOUSEX
  11.         mouseY = _MOUSEY
  12.         mouseLeftButton = _MOUSEBUTTON(1)
  13.         mouseRightButton = _MOUSEBUTTON(2)
  14.         mouseMiddleButton = _MOUSEBUTTON(3)
  15.         mouseWheel = mouseWheel + _MOUSEWHEEL
  16.         IF mouseLeftButton = -1 AND POINT(mouseX, mouseY) = _RGB32(255, 0, 0) THEN
  17.             FOR sz = 150 TO .25 STEP -.25
  18.                 b = b - 1
  19.                 IF b < 0 THEN b = 0
  20.                 CIRCLE (400, 300), sz, _RGB32(255 - b, 0, b)
  21.             NEXT sz
  22.             press = 1
  23.         END IF
  24.         IF mouseLeftButton = 0 THEN
  25.             FOR sz = .25 TO 150 STEP .25
  26.                 CIRCLE (400, 300), sz, _RGB32(255, 0, 0)
  27.             NEXT sz
  28.             b = 127
  29.             press = 0
  30.         END IF
  31.     LOOP
  32.     IF press = 1 THEN
  33.         FOR snd = 500 TO 200 STEP -5
  34.             SOUND snd, 1
  35.         NEXT snd
  36.         _DELAY 3
  37.         FOR explosion = 1 TO 50
  38.             RANDOMIZE TIMER
  39.             xx = INT(RND * 800)
  40.             yy = INT(RND * 600)
  41.             FOR sz = 1 TO 50 STEP 2
  42.                 CIRCLE (xx, yy), sz, _RGB32(155, 0, 0)
  43.             NEXT sz
  44.         NEXT explosion
  45.         SOUND 150, .5
  46.         SOUND 150, .5
  47.         SOUND 150, .5
  48.         SOUND 150, .5
  49.         press = 0
  50.         p = p + 1
  51.         IF p = 5 THEN GOTO done:
  52.     END IF
  53. done:
  54. xx2 = INT(RND * 800)
  55. yy2 = INT(RND * 600)
  56. FOR turn = 1 TO 400
  57.     xx3 = INT(RND * 800)
  58.     yy3 = INT(RND * 600)
  59.     LINE (xx2, yy2)-(xx3, yy3), _RGB32(0, 0, 0)
  60.     LINE (xx2 + 1, yy2 + 1)-(xx3 + 1, yy3 + 1), _RGB32(0, 0, 0)
  61.     LINE (xx2 + 2, yy2 + 2)-(xx3 + 2, yy3 + 2), _RGB32(0, 0, 0)
  62.     xx2 = xx3
  63.     yy2 = yy3
  64.     _DELAY .02
  65. NEXT turn
  66.  
« Last Edit: May 11, 2020, 01:18:37 pm by SierraKen »

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Giant Red Button
« Reply #1 on: May 11, 2020, 01:17:00 pm »
Here's a generic Giant Red Button where you can make it do anything you want when you click it. I added the area on where to add your own code.
For example, you can make a bunch of DATA lines and have it display a sentence of text every time you click it to make a story.

Code: QB64: [Select]
  1. 'Press the GIANT RED BUTTON
  2. _TITLE "GIANT RED BUTTON"
  3. SCREEN _NEWIMAGE(800, 600, 32)
  4. b = 127
  5. FOR sz = .25 TO 150 STEP .25
  6.     CIRCLE (400, 300), sz, _RGB32(255, 0, 0)
  7. NEXT sz
  8.     _LIMIT 500
  9.     mouseWheel = 0
  10.         mouseX = _MOUSEX
  11.         mouseY = _MOUSEY
  12.         mouseLeftButton = _MOUSEBUTTON(1)
  13.         mouseRightButton = _MOUSEBUTTON(2)
  14.         mouseMiddleButton = _MOUSEBUTTON(3)
  15.         mouseWheel = mouseWheel + _MOUSEWHEEL
  16.         IF mouseLeftButton = -1 AND POINT(mouseX, mouseY) = _RGB32(255, 0, 0) THEN
  17.             FOR sz = 150 TO .25 STEP -.25
  18.                 b = b - 1
  19.                 IF b < 0 THEN b = 0
  20.                 CIRCLE (400, 300), sz, _RGB32(255 - b, 0, b)
  21.             NEXT sz
  22.             press = 1
  23.         END IF
  24.         IF mouseLeftButton = 0 THEN
  25.             FOR sz = .25 TO 150 STEP .25
  26.                 CIRCLE (400, 300), sz, _RGB32(255, 0, 0)
  27.             NEXT sz
  28.             b = 127
  29.             press = 0
  30.         END IF
  31.     LOOP
  32.     IF press = 1 THEN
  33.         '---------------------------------------------------------------
  34.         'Add your own code here that you want the Giant Red Button to do.
  35.  
  36.  
  37.  
  38.         '----------------------------------------------------------------
  39.         press = 0
  40.     END IF
  41.  

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Giant Red Button
« Reply #2 on: May 11, 2020, 01:53:47 pm »
Maybe a little _DELAY after you redraw Button with color change when Mouse Down on it.

Since you are getting mouse wheel you could increase and decrease button radius to a min or max limit?

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Giant Red Button
« Reply #3 on: May 11, 2020, 02:23:43 pm »
Thanks bplus. It works a bit better now and I changed the color for when you click it.
I'm just changing the generic button so people can have a better one.
Changing the size of it seems to be a bit difficult, for now anyway.


Code: QB64: [Select]
  1. 'Press the GIANT RED BUTTON
  2. _TITLE "GIANT RED BUTTON"
  3. SCREEN _NEWIMAGE(800, 600, 32)
  4. b = 127
  5. FOR sz = .25 TO 150 STEP .25
  6.     CIRCLE (400, 300), sz, _RGB32(255, 0, 0)
  7. NEXT sz
  8.     _LIMIT 500
  9.     mouseWheel = 0
  10.         mouseX = _MOUSEX
  11.         mouseY = _MOUSEY
  12.         mouseLeftButton = _MOUSEBUTTON(1)
  13.         mouseRightButton = _MOUSEBUTTON(2)
  14.         mouseMiddleButton = _MOUSEBUTTON(3)
  15.         mouseWheel = mouseWheel + _MOUSEWHEEL
  16.         IF mouseLeftButton = -1 AND POINT(mouseX, mouseY) = _RGB32(255, 0, 0) THEN
  17.             FOR sz = 150 TO .25 STEP -.25
  18.                 b = b - .1
  19.                 IF b < 0 THEN b = 0
  20.                 CIRCLE (400, 300), sz, _RGB32(255 - b, 0, b)
  21.             NEXT sz
  22.             press = 1
  23.             _DELAY .02
  24.         END IF
  25.         IF mouseLeftButton = 0 THEN
  26.             FOR sz = .25 TO 150 STEP .25
  27.                 CIRCLE (400, 300), sz, _RGB32(255, 0, 0)
  28.             NEXT sz
  29.             b = 127
  30.             press = 0
  31.         END IF
  32.     LOOP
  33.     IF press = 1 THEN
  34.         '---------------------------------------------------------------
  35.         'Add your own code here that you want the Giant Red Button to do.
  36.  
  37.  
  38.  
  39.         '----------------------------------------------------------------
  40.         press = 0
  41.     END IF
  42.  
« Last Edit: May 11, 2020, 02:25:32 pm by SierraKen »

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Giant Red Button
« Reply #4 on: May 11, 2020, 02:36:37 pm »
OK I did it! People can now change the size of the button using the Mouse Wheel. :)

Code: QB64: [Select]
  1. 'Press the GIANT RED BUTTON
  2. _TITLE "GIANT RED BUTTON - Use mouse wheel to change size."
  3. SCREEN _NEWIMAGE(800, 600, 32)
  4. b = 127
  5. FOR sz = .25 TO 150 STEP .25
  6.     CIRCLE (400, 300), sz, _RGB32(255, 0, 0)
  7. NEXT sz
  8.     _LIMIT 500
  9.     mouseWheel = 0
  10.         mouseX = _MOUSEX
  11.         mouseY = _MOUSEY
  12.         mouseLeftButton = _MOUSEBUTTON(1)
  13.         mouseRightButton = _MOUSEBUTTON(2)
  14.         mouseMiddleButton = _MOUSEBUTTON(3)
  15.         mouseWheel = mouseWheel + _MOUSEWHEEL
  16.         IF mouseWheel < 0 THEN CLS: size = size + 1: mouseWheel = 0
  17.         IF mouseWheel > 0 THEN CLS: size = size - 1: mouseWheel = 0
  18.         IF size < -149 THEN size = -149
  19.         IF size > 100 THEN size = 100
  20.         IF mouseLeftButton = -1 AND POINT(mouseX, mouseY) = _RGB32(255, 0, 0) THEN
  21.             FOR sz = 150 + size TO .25 STEP -.25
  22.                 b = b - .1
  23.                 IF b < 0 THEN b = 0
  24.                 CIRCLE (400, 300), sz, _RGB32(255 - b, 0, b)
  25.             NEXT sz
  26.             press = 1
  27.             _DELAY .02
  28.         END IF
  29.         IF mouseLeftButton = 0 THEN
  30.             FOR sz = .25 TO 150 + size STEP .25
  31.                 CIRCLE (400, 300), sz, _RGB32(255, 0, 0)
  32.             NEXT sz
  33.             b = 127
  34.             press = 0
  35.         END IF
  36.     LOOP
  37.     IF press = 1 THEN
  38.         '---------------------------------------------------------------
  39.         'Add your own code here that you want the Giant Red Button to do.
  40.  
  41.  
  42.  
  43.         '----------------------------------------------------------------
  44.         press = 0
  45.     END IF
  46.  

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Giant Red Button
« Reply #5 on: May 11, 2020, 06:26:47 pm »
Thanks Ken. Now if Steve can just hack me those nuclear codes, I can combine the two programs and put an end to FreeBASIC, forever!

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

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Giant Red Button
« Reply #6 on: May 11, 2020, 08:45:31 pm »
Thanks Ken. Now if Steve can just hack me those nuclear codes, I can combine the two programs and put an end to FreeBASIC, forever!

Pete

ROFL!