Jump to content

Drawing 2d Rectangle keeps jumping to 0,0?


Andy Gilbert
 Share

Recommended Posts

HI, im drawing a couple of rectangles for a simple GUI.

 

They show "levels" of dynamic values withing the game.

 

Problem im having is i keep getting "lines" going from 0,0 (top left corner) to where the rectangle cooords are? They keep jumping from showing the rectangle correctly to then lines going to 0,0?

 

Ive checked my code but cant even see how they would goto 0,0 becasue the function to draw the rect is Xpos,Ypos,width,height and my Xpos and Y pos are static values which never change, along with width too. Only "height" changes.

 

--GUI
 SetColor(Vec4(0,1,0,0.6))
  DrawRect(GraphicsWidth()-50,GraphicsHeight()-100,10,roll*100)
 DrawRect(GraphicsWidth()-90,GraphicsHeight()-100,10,0-(roll*100))

 

Why would it be doing this?

 

Thanks

Andy

The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do.

 

Leadwerks Game-Ready 3D Models:https://sellfy.com/gib3d

Link to comment
Share on other sites

HI, roll is just :

 

roll = Curve(KeyDown(KEY_LEFT) - KeyDown(KEY_RIGHT),roll,40)

 

Which when printed is long number generally below 1 like 0.0023345 (example)

 

Ive tried getting screent shots but it "flickers" from line to normal and everytime it never gets it, it isnt "all" the time, like once every 2 - 3 seconds?

 

Thanks

Andy

The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do.

 

Leadwerks Game-Ready 3D Models:https://sellfy.com/gib3d

Link to comment
Share on other sites

the DrawRect() doesnt appear to like width and height values less than 2 for whatever reason... granted a width or height value of 1 is essentially a line. so to get around it just do a simple check to determine that the value of the roll is greater than 0.02 and it should work fine...

if roll>0.02 or roll<-0.02 then
 DrawRect(gx-50,gy-100,10,roll*100)
 DrawRect(gx-90,gy-100,10,0-(roll*100))
end

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...