March 02, 2021, 01:10:47 PM

Author Topic: [bb] Background color chooser by n8r2k [ 1+ years ago ]  (Read 529 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bb] Background color chooser by n8r2k [ 1+ years ago ]
« on: June 29, 2017, 12:28:41 AM »
Title : Background color chooser
Author : n8r2k
Posted : 1+ years ago

Description : Press 'r' to reset. You will need pictures from the download page on <a href="http://n8r2k.deviousbytes.com/" target="_blank">http://n8r2k.deviousbytes.com/[/url] .

Code :
Code: BlitzBasic
  1. ;Set the Graphics
  2. Graphics 300,200,16,2
  3.  
  4. ;Seed the Random Generator
  5. SeedRnd MilliSecs()
  6.  
  7. ;Hide the mouse
  8. HidePointer()
  9.  
  10. ;Load all the picture files
  11. RedUp = LoadAnimImage("up.bmp",22,15,0,2)
  12. GreenUp = LoadAnimImage("up.bmp",22,15,0,2)
  13. BlueUp = LoadAnimImage("up.bmp",22,15,0,2)
  14. RedDown = LoadAnimImage("Down.bmp",22,15,0,2)
  15. GreenDown = LoadAnimImage("Down.bmp",22,15,0,2)
  16. BlueDown = LoadAnimImage("Down.bmp",22,15,0,2)
  17. red = LoadImage("red.bmp")
  18. green = LoadImage("green.bmp")
  19. blue = LoadImage("blue.bmp")
  20. ;Create the mouse img
  21. mouse = CreateImage(10,10)
  22.  
  23. ;Set the Buffer to the mouse
  24. SetBuffer ImageBuffer(mouse)
  25.  
  26. ;Set the color
  27. Color 100,100,100
  28.  
  29. ;Draw a rectangle
  30. Rect 0,0,10,10,1
  31.  
  32. ;Set the color
  33. Color 255,255,255
  34.  
  35. ;Draw a rectangle
  36. Rect 0,0,10,10,0
  37.  
  38. ;Set the Backbuffer
  39. SetBuffer BackBuffer()
  40.  
  41. ;Set random values for the rgb
  42. r = Rand(0,255)
  43. g = Rand(0,255)
  44. b = Rand(0,255)
  45.  
  46. ;Start the loop
  47. While Not KeyHit(1)
  48.  
  49. ;If user hits 'r'
  50. If KeyHit(19) Then
  51.         ;Reset the colors to 0
  52.         r = 0
  53.         g = 0
  54.         b = 0
  55.        
  56. EndIf
  57.  
  58. ;Make sure the rgb values arent out of range
  59. If r < 0 Then r = 0
  60. If r > 255 Then r = 255
  61. If g < 0 Then g = 0
  62. If g > 255 Then g = 255
  63. If b < 0 Then b = 0
  64. If b > 255 Then b = 255
  65.  
  66. ;Clear the screen
  67. Cls
  68.  
  69. ;Color the screen
  70. ClsColor r,g,b
  71.  
  72. ;Set the color
  73. Color 255 - r,255 - g,255 - b
  74.  
  75. ;Locate the 0,0 position
  76. Locate 0,0
  77.  
  78. ;Print the rgb values
  79. Print r
  80. Print g
  81. Print b
  82.  
  83. ;If the mouse is hit
  84. If MouseDown(1)
  85.         ;If the user clicked an arrow, increment the correct color the correct amount
  86.         If ImagesCollide(mouse,MouseX(),MouseY(),0,RedUp,25,0,ruf)
  87.                 ruf = 1
  88.                 r = r + 1
  89.                 rdf = 0
  90.                 guf = 0
  91.                 gdf = 0
  92.                 buf = 0
  93.                 bdf = 0
  94.         ElseIf ImagesCollide(mouse,MouseX(),MouseY(),0,RedDown,25,30,rdf)
  95.                 rdf = 1
  96.                 r = r - 1
  97.                 ruf = 0
  98.                 guf = 0
  99.                 gdf = 0
  100.                 buf = 0
  101.                 bdf = 0
  102.         ElseIf ImagesCollide(mouse,MouseX(),MouseY(),0,GreenUp,48,0,guf)
  103.                 guf = 1
  104.                 g = g + 1
  105.                 ruf = 0
  106.                 rdf = 0
  107.                 gdf = 0
  108.                 buf = 0
  109.                 bdf = 0
  110.         ElseIf ImagesCollide(mouse,MouseX(),MouseY(),0,GreenDown,48,30,gdf)
  111.                 gdf = 1
  112.                 g = g - 1
  113.                 ruf = 0
  114.                 rdf = 0
  115.                 guf = 0
  116.                 buf = 0
  117.                 bdf = 0
  118.         ElseIf ImagesCollide(mouse,MouseX(),MouseY(),0,BlueUp,71,0,buf)
  119.                 buf = 1
  120.                 b = b + 1
  121.                 ruf = 0
  122.                 rdf = 0
  123.                 guf = 0
  124.                 gdf = 0
  125.                 bdf = 0
  126.         ElseIf ImagesCollide(mouse,MouseX(),MouseY(),0,BlueDown,71,30,bdf)
  127.                 bdf = 1
  128.                 b = b - 1
  129.                 ruf = 0
  130.                 rdf = 0
  131.                 guf = 0
  132.                 gdf = 0
  133.                 buf = 0
  134.         EndIf
  135. Else ;Reset the frames
  136.         ruf = 0
  137.         rdf = 0
  138.         guf = 0
  139.         gdf = 0
  140.         buf = 0
  141.         bdf = 0
  142. EndIf  
  143.  
  144. ;Draw the images
  145. DrawImage RedUp,25,0,ruf
  146. DrawImage red,25,15
  147. DrawImage RedDown,25,30,rdf
  148. DrawImage GreenUp,48,0,guf
  149. DrawImage Green,48,15
  150. DrawImage GreenDown,48,30,gdf
  151. DrawImage BlueUp,71,0,buf
  152. DrawImage Blue,71,15
  153. DrawImage BlueDown,71,30,bdf
  154. DrawImage Mouse,MouseX(),MouseY()
  155.  
  156. ;Flip the buffers
  157. Flip
  158.  
  159. ;loop to beginning
  160. Wend


Comments : none...

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal