Best way to create a crosshair?

BlitzPlus Forums/BlitzPlus Beginners Area/Best way to create a crosshair?

Syco's post does help one understand the idea of what you're trying to do but is over 10X slower than my code. (Even uses lines instead of rects, people don't understand simplifications of code can lead to massive slowdows; i.e. x^2 is slower than x*x)

some whipped-up code to show the dif in speed.
c = 10000000

ms = MilliSecs()
For a = 1 To c
	x=x^2
Next
e =  (MilliSecs()-ms)

ms = MilliSecs()
For a = 1 To c
	x=x*x
Next
r = (MilliSecs()-ms)

Print 1.0*e/r

Input()


It is because things like ^ and Line are generalized and you are forgetting the special cases you are dealing with.


Drawing any things like plot, rect, oval, text, whatever, straight to the backbuffer is just ugly and can lead to slowdowns where images were designed to be used (repetition). My code above is nice and worrying about images that go offscreen should only be a concern for cell phone programming, etc.

Just remove the for loop that runs 1000x repeat and ull see the real speed.