Drawing a polygon

00george

  • Posts: 161
Hi im trying to make it so when the user clicks and drags a rectangle will be drawn to the size the user drags but for some reason the polygon will not show up. I posted a picture of the behaviour below.

« Last Edit: June 10, 2012, 12:51:02 pm by 00george »

Ryusui

  • Posts: 827
"Was pressed/released" is only valid once per click/release. Set/unset a boolean to indicate whether the mouse is being held down, and have the drawing routine check that instead.
In the event of a firestorm, the salad bar will remain open.

00george

  • Posts: 161
Hi I made some changes but the shape isnt a rectangle it comes out as some weird diamond shape I will post updated images above.

Ryusui

  • Posts: 827
What's wrong with the draw/fill rect blocks?

As for why you're getting an hourglass shape, that's because you're not defining your coordinates in the right order. It'll draw the vertices in the polygon in the order you provide; you've got the last two backwards.
In the event of a firestorm, the salad bar will remain open.

00george

  • Posts: 161
Um I wanted to make it so you can draw the size of the rectangle and I wasnt sure how to do this with the fill rect blocks. Edit: For some reason when drawing the polygon the rectangle comes out in strange sizes. All I want to do is make a selection rectangle like in real time stratedgy games.

« Last Edit: June 10, 2012, 01:39:06 pm by 00george »

Ryusui

  • Posts: 827
With the rect blocks, you'd calculate the width and height by subtracting the start point from the end point.

EDIT: Check out the attached game.

« Last Edit: June 10, 2012, 01:50:41 pm by Ryusui »
In the event of a firestorm, the salad bar will remain open.