This site requires JavaScript, please enable it in your browser!
Greenfoot back
RM6442
RM6442 wrote ...

2012/5/18

Light in a Dark Room

1
2
3
Builderboy2005 Builderboy2005

2012/5/18

#
My suggestion would be to have the world itself simply fill the entire image with black, thus filling all holes completely. Then each object can go cut holes in it.
RM6442 RM6442

2012/5/18

#
Tried that, it didn't work out too well when there was more than one moving object.
RM6442 RM6442

2012/5/18

#
Builderboy2005 Builderboy2005

2012/5/18

#
Seems to work pretty well! There is a bit of strange offset when objects are moving though, like an edge of black. Any idea why that might be happening?
RM6442 RM6442

2012/5/18

#
Before each object starts moving it refills the hole. Then it moves and carves out a hole at a new location. When the radii overlap, one is obviously being drawn before the other, and is thus being drawn over. At least that's what I think is happening.
RM6442 RM6442

2012/5/18

#
But you were right about the processing.
Builderboy2005 Builderboy2005

2012/5/18

#
My guess is that because you are moving, you are not filling in the quite correct hole (since you have moved since you've drawn it) and so the blackness you draw doesn't quite fit into the hole you drew before.
RM6442 RM6442

2012/5/18

#
No, I've mentioned that the hole is refilled before the object moves. Essentially refill->move->carve->refill->move->carve->refill->etc. So it's not that.
Builderboy2005 Builderboy2005

2012/5/18

#
Ah I see! Yeah that makes sense now. I think your original diagnosis was correct now that I can visualize it. I definitely think having the world re-fill the image with black would be the way to go in terms of fixing this particular issue. Plus it would speed things up a bit in that each object wouldn't need to draw black circles anymore, they would just need to cut out the hole
danpost danpost

2012/5/19

#
I posted an example with code for you to look at. It is here.
You need to login to post a reply.
1
2
3