GLBasic forum

Main forum => GLBasic - en => Topic started by: backspace on 2012-Dec-26

Title: Drawline not working with Createscreen
Post by: backspace on 2012-Dec-26
I seem to have a problem with DRAWLINE not being able to draw to a sprite created with CREATESCREEN. The DRAWRECT does work. So I am wondering if this a bug, or am I doing something wrong?

Code with the problem
Code (glbasic) Select

// Screen 0, Sprite 13
CREATESCREEN 0, 13, 256, 256

// Use screen for all output
USESCREEN 0

PRINT "Offscreen", 0,0
ALPHAMODE 0.8
DRAWRECT 254,0,5, 256, RGB(0,250,0)    // <<---- This works
DRAWLINE 256,256,512,256, RGB(0,250,0) // <<---- Does not work
   
// Switch back to the window
USESCREEN -1

// Draw the screen
DRAWSPRITE 13, 0, 0

SHOWSCREEN
MOUSEWAIT
Title: Re: Drawline not working with Createscreen
Post by: backspace on 2012-Dec-26
This is very humiliating. I had scratched my head for a long time on this one, and it is really such a silly mistake on my part. I had dimensioned the Createscreen to 256x256 instead of 512x512. So Drawline can obviously not draw to an area that does not exist. My Bad.
Title: Re: Drawline not working with Createscreen
Post by: hardyx on 2012-Dec-26
Yes, you are drawing the line outside the sprite you created. Your sprite size is 256x256, and the valid coordinates are 0 to 255 for X and the same for the Y. Programming is a fight with this little errors and you don't notice in first time. Happy coding.
Title: Re: Drawline not working with Createscreen
Post by: backspace on 2012-Dec-27
Haha. Yes it is sometimes embarrassing to make such mistakes, but its part of the process of learning. I'll get there eventually.