November 28, 2020, 11:41:47 AM

Author Topic: [bb] Fast Grid Draw by Warpy [ 1+ years ago ]  (Read 376 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bb] Fast Grid Draw by Warpy [ 1+ years ago ]
« on: June 29, 2017, 12:28:39 AM »
Title : Fast Grid Draw
Author : Warpy
Posted : 1+ years ago

Description : Possibly the most useless bit of code ever, but some people might not know how to draw a grid :P

Code :
Code: BlitzBasic
  1. ;Drawgrid function!
  2. ;I don't do comments :)
  3. Function drawgrid(minx,maxx,miny,maxy,width,height,scrollx,scrolly)
  4.         x=minx+(scrollx Mod width)
  5.         While x<maxx
  6.                 Line x,miny,x,maxy
  7.                 x=x+width
  8.         Wend
  9.         y=miny+(scrolly Mod height)
  10.         While y<maxy
  11.                 Line minx,y,maxx,y
  12.                 y=y+height
  13.         Wend
  14. End Function
  15.  
  16. ;example usage
  17. Graphics 640,480,16,2
  18. SetBuffer BackBuffer()
  19.  
  20. While Not KeyHit(1)
  21.         mxs=MouseXSpeed()
  22.         mys=MouseYSpeed()
  23.         If MouseDown(1)
  24.                 scrollx=scrollx+mxs
  25.                 scrolly=scrolly+mys
  26.         EndIf
  27.         Color 150,150,150
  28.         drawgrid(0,640,0,480,10,10,scrollx,scrolly)
  29.         Color 255,255,255
  30.         oldms=ms
  31.         ms=MilliSecs()
  32.         Text 0,0,1000/(ms-oldms)
  33.         Flip
  34.         Cls
  35. Wend


Comments : none...

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal