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

2017/5/3

Sprite Creation

BrownDwarf BrownDwarf

2017/5/3

#
I am trying to make a Tetris Game, but if I were to use sprites from online, for example for the L shaped block in Tetris, when I cut the image and set the image for an actor, it will be set as a rectangle that goes around the object. Meaning instead of cutting right around the edges, the space above that extra block that creates the L shape, is included in the object. This will make it harder to create interactions with the object. My question: is there a way to resolve this? I have tried many ways using my photo editor, but I thought maybe the solution is in Greenfoot itself?
Yehuda Yehuda

2017/5/3

#
Greenfoot includes the transparent pixels in it's collision methods. If you want you can have a look at Busch2207's Pixel-perfect collision detection.
BrownDwarf BrownDwarf

2017/5/3

#
I know. That's my problem. I need to find a way to get the transparent pixels to not be included in detection. I don't know how. The scenario you showed me was using images built into Greenfoot, these are cut perfectly. My images are form online, so I cant do this. But there must be a way to ignore the transparent pixels...
Yehuda Yehuda

2017/5/4

#
BrownDwarf wrote...
The scenario you showed me was using images built into Greenfoot, these are cut perfectly. My images are form online, so I cant do this. But there must be a way to ignore the transparent pixels...
The above can only be true in one way, which is: "My images are form online" You can use that scenario for any image you want, it seems you haven't even tried using it which gets me a little annoyed. There is no such thing as an image that is cut perfectly, if that's true then there won't be a need or a purpose for this scenario. All images have to be a rectangle even the images that get downloaded with greenfoot. The images in that scenario also have transparent pixels in them which would usually be detected by the methods from Greenfoot (the apple is round, and I don't think that alligators are perfect rectangles either), but that scenario is using a different method which checks to make sure the pixels are opaque. (If I would be speaking to you I would be almost hoarse.)
danpost danpost

2017/5/4

#
You can avoid that problem by building each piece from four simple (square) blocks. Each piece has a shape that can be described within an array. The piece actor can be made invisible (transparent image) and can control the rotation and location of its blocks. The blocks can inform the piece actor if any collisions occur during a move or rotation to cancel (undo) the action.
You need to login to post a reply.