Author Topic: Drawline not working with Createscreen  (Read 2045 times)

Offline backspace

  • Mr. Drawsprite
  • **
  • Posts: 53
    • View Profile
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
I came, I saw, I coded.

Offline backspace

  • Mr. Drawsprite
  • **
  • Posts: 53
    • View Profile
Re: Drawline not working with Createscreen
« Reply #1 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.
I came, I saw, I coded.

Offline hardyx

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 500
    • View Profile
Re: Drawline not working with Createscreen
« Reply #2 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.
« Last Edit: 2012-Dec-26 by hardyx »

Offline backspace

  • Mr. Drawsprite
  • **
  • Posts: 53
    • View Profile
Re: Drawline not working with Createscreen
« Reply #3 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.
I came, I saw, I coded.