Author Topic: Drawing problem  (Read 3956 times)

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Drawing problem
« on: December 20, 2010, 05:46:15 AM »
How do I draw a fixed line in the level, so that it appears to be part of the background?

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Drawing problem
« Reply #1 on: December 20, 2010, 06:14:25 AM »
Here is what I thought would work, but apparently does not:


Code: [Select]
function ScreenDraw()



-- left line
Line1x1 = -16000 - GetCameraX() / GetCameraScale()
Line1y1 = -16000 - GetCameraY() / GetCameraScale()
Line1x2 = -16000 - GetCameraX() / GetCameraScale()
Line1y2 = 16000 - GetCameraY() / GetCameraScale()

-- bottom line
Line2x1 = -16000 - GetCameraX() / GetCameraScale()
Line2y1 = -16000 - GetCameraY() / GetCameraScale()
Line2x2 = 16000 - GetCameraX() / GetCameraScale()
Line2y2 = -16000 - GetCameraY() / GetCameraScale()

-- right line
Line3x1 = 16000 - GetCameraX() / GetCameraScale()
Line3y1 = -16000 - GetCameraY() / GetCameraScale()
Line3x2 = 16000 - GetCameraX() / GetCameraScale()
Line3y2 = 16000 - GetCameraY() / GetCameraScale()

-- top line
Line4x1 = -16000 - GetCameraX() / GetCameraScale()
Line4y1 = 16000 - GetCameraY() / GetCameraScale()
Line4x2 = 16000 - GetCameraX() / GetCameraScale()
Line4y2 = 16000 - GetCameraY() / GetCameraScale()

DrawLine(Line1x1,Line1y1,Line1x2,Line1y2,0,0,1,1,0,1,0,1,3)
DrawLine(Line2x1,Line2y1,Line2x2,Line2y2,0,0,1,1,0,1,0,1,3)
DrawLine(Line3x1,Line3y1,Line3x2,Line3y2,0,0,1,1,0,1,0,1,3)
DrawLine(Line4x1,Line4y1,Line4x2,Line4y2,0,0,1,1,0,1,0,1,3)

end

Alex

  • Administrator
  • Ent
  • *****
  • Thank You
  • -Given: 3
  • -Receive: 14
  • Posts: 1,035
Re: Drawing problem
« Reply #2 on: December 20, 2010, 07:08:48 PM »
If you want it to be part of the background and static in the world like an asteroid or something, draw it in the LevelDraw function and use fixed world coords (not camera-relative).

The ScreenDraw function has everything in screen coordinates where 0,0 is the top left. you can use GetScreenWidth() and GetScreenHeight() to get the screen's width and height in pixels. So if you want to draw e.g. a user interface element you could use DrawBox(1, 8, 100, 100, GetScreenWidth() - 100, GetScreenHeight() - 100, r, g, b, a) where 8 is the border thickness and 1 means use the spot texture for the box. You don't need things to be camera-relative in the screen draw function.

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Drawing problem
« Reply #3 on: December 20, 2010, 09:08:09 PM »
Doh !

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Drawing problem
« Reply #4 on: December 20, 2010, 09:25:00 PM »
Ok got my primitive level-bound box in now.  :>  Thanks dude.  This will also be super-helpful for the Parallax scrolling project!