Discuss Scratch
- Discussion Forums
- » Advanced Topics
- » Touching blocks outside Scratch
- skeletonxf
-
33 posts
Touching blocks outside Scratch
Recently I've started using http://love2d.org/ to run my Lua code so that I can start to make games that can still well run on my 7 year old computer. While it's going to be a long time before I can grasp the more complex details of text based languages that's not what I'm asking about today.
A key problem I ran in to very quickly was how was I going to sense things touching each other now I didn't have those handy blocks.
I'm not expecting a huge function or something to be provided, but so far the closest I can get to ‘sensing’ when things are touching each other is by assuming that they are square and using their x and y positions, which of course can't be done forever with less regular shapes
Any insight into how these Scratch blocks work would be very useful as I start to need to sense non-regularly shaped stuff touching each other.
Thank you
A key problem I ran in to very quickly was how was I going to sense things touching each other now I didn't have those handy blocks.
I'm not expecting a huge function or something to be provided, but so far the closest I can get to ‘sensing’ when things are touching each other is by assuming that they are square and using their x and y positions, which of course can't be done forever with less regular shapes
Any insight into how these Scratch blocks work would be very useful as I start to need to sense non-regularly shaped stuff touching each other.
Thank you
- joefarebrother
-
500+ posts
Touching blocks outside Scratch
If you know enough JavaScript (how the canvas works in particular) the Snap! source code might be helpful.
Click on the snap logo to download the source. Morphic.js is the one that contains the definition of isTouching()
Click on the snap logo to download the source. Morphic.js is the one that contains the definition of isTouching()
- skeletonxf
-
33 posts
Touching blocks outside Scratch
Gosh. I figured it wouldn't be a few lines of code but :O
I do vaguely know JavaScript and I'll try to read through that morphic.js though it may take me some time.
Edit: No way can I follow all of that but thanks for the effort
Thanks also for that github collision thing, being able to just use it rather than having to code my own should be nice, although how exactly do I go from a .zip to making love2d accept the Lua module?
Ha ha, never mind, I found it. Thanks to both of you, really helped me out.
I do vaguely know JavaScript and I'll try to read through that morphic.js though it may take me some time.
Edit: No way can I follow all of that but thanks for the effort
Thanks also for that github collision thing, being able to just use it rather than having to code my own should be nice, although how exactly do I go from a .zip to making love2d accept the Lua module?
Ha ha, never mind, I found it. Thanks to both of you, really helped me out.
Last edited by skeletonxf (Oct. 1, 2013 17:07:18)
- Discussion Forums
- » Advanced Topics
-
» Touching blocks outside Scratch