2D games collision detection demo


#1

Deleted the inferior collision code and pic because the superior code made is being ignored . Scroll to bottom for tutorial. Coming in a few hours.


#2

Looks great.

A few things, as they come to mind...

1. As sensors, and not the hero character itself, I assume that the blocks could nominally (though not necessarily) be made to be nearly invisible, as long as collision detection still works. For example, 99% invisible. Is that what you had in mind?

2. I see that the sensors do not overlap at the corners. Is that deliberate? It seems that having them overlap could be useful in some circumstances where corner collisions have special significance.

3. I'm wondering about the overhead associated with carrying the four blocks around. I want to explore that a little, just for fun. Another scheme comes to mind, entirely inspired by your work on detecting an object's surroundings; but I want to play with it before I say much else.

4. One of the things I really like about the four-blocks approach you are sharing is that it's perfectly able to handle collisions from more than one direction simultaneously. That's goodness.

Question: Do you have a specific game in mind to try-out with this?


#3

Yes, i mentioned thinner shapes could be used for sensors. I made things big so it's easy to see and without invisibility code.
I had a puzzle game in mind,pushing blocks to trap enemies that have sensors to detect which direction they can move if they get stuck when hitting a wall or cramped space.
Also in a 2d platformer, enemies could detect when walking near the edge of a block and move the opposite way or stop or jump. I think there's lots of possibilities with having sensors. If i coded the square to move back a little when the sensors bump anything there might be less lag.


#5

Woah! This is great, I must have a look at the code! So this works with value physics? This seem like the thing I have been waiting for THT to add :yum:


#6

nooooo....
I was gonna make a tutorial on this!!!


#7

I was just exprrementing with something like this when I checked the hopscotch forums and... NOOOO SOMEONE ALREADY DONE THIS!


#8

https://c.gethopscotch.com/p/xslpjsd8f

@everyone

Now improved with the ability to push the blue square with the red square.
@oio There's no sensors now, just the players sprite that acts as a sensor
This code can save users a massive amount time not having to code for every single wall sprite when bumped/touched like the pacman game I showed and lots of other projects I've seen like that .

@crazygoat You can make a tutorial on how to make this version with the ability to push blocks as well as move-detect objects.
I'm only supplying the link to my project. I'm not that good at tutorials


#9

@Stradyvarious, intrigued by what you've been doing, I have tried several variants that may or may not interest you. Ultimately, I think the deciding factor for me is... speed.

1. So, to begin with, you shared a case having these four blocks as sensors. The potential problem for me is the "When__is touching Anything." That thing has a voracious CPU appetite.

2. So, I tried making a ring of clones be my sensors. That turned out to be more complicated than ever. Terrible.

3. I tried using eight little dots as sensors. Nope. Way slow. Then again, come to think of it, I used "when __ bumps Anything" and not "when __ is touching anything" maybe there's a speed difference?

4. I tried using a rapidly spinning (orbiting) dot as the sensor, but not the way most would probably anticipate doing it. It was actually not too bad. And it gave directional information about the collision, which is cool.

5. I tried using a thin ring character from an alternate character set around my hero object (which was a disc). I had in mind to make the ring stay centered on the disc, until the ring hit something, then the ring would stop. Then I would let the disc inside bump into the ring or the obstacle and to use math to get the impact angle. Bleah! It worked, but I could only move the disc really slowly.

I am still messing-around with this, just for fun; but I have to say, this is a case, I'm just too CPU limited to make much headway. So, I enjoy your box-pusher code. I think it works nicely, elegantly eliminating the "sensors".


#10

Thanks. I experimented a bit with an orbiting circle around a larger circle but gave up when I thought of the complex code I'd have to do.
Now I wish I could code the blue box to not go through the walls when it touches them without coding for each wall.

Your disc inside the ring sounds cool. It would be great to see that even if it's slow. I'd find the code very interesting.


#11

Your games are so cool I wish mine were that cool


#12

Thanks. I 'm enjoying finding solutions to problems now more than making games


#13

Something off topic, but do you have any experience with taking photos or video in near infrared?
I purchased some near infrared sunglasses a few months ago and everything is darker with shades of red and other colors that are different from their normal color. I bought them for a weird reason and that was to see if any Ufo's or other invisible phenomena in the near infrared spectrum could be seen with the glasses. DO you know anything about this?
@oio


#14

Yes, @Stradyvarious. In my work. I have used a FLIR systems T600 series camera for the purpose of investigating some one-of-a-kind equipment, alleged by some to project (or otherwise produce) thermal effects at a distance by means not accounted for in canonical physics. I tried some frivolous things with it as well. Maybe it was all frivolous. What do you have in mind?


#15

I know thermal imaging and night vision, but have you taken pics at near infrared outdoors with natural light/sunlight?
I read on a few sites the glasses work better on a bright day when they are held up to the sun for aprox 30 seconds before wearing. Do you know why this is? Does this somehow charge the glasses?
there's no battery in the glasses.
Also have you seen anything at night thats showed up on camera that you can't explain?


#16

I am unfamiliar with the glasses of which you speak, and could only speculate about them or about any principle upon which they are claimed to work. I would have to read the claims to offer much of a responsible opinion. I am generally pragmatic. As for the latter question, yes, but I can't justify speaking of it here. Another channel would allow some latitude. I wonder what has caught your imagination. It might be fun to create a Hopscotch game, themed on whatever you are thinking about. No? If you wish, you are welcome to send your thoughts or questions along these lines to [ help at oio-games DotThingComThing ].


#17

I just made a tutorial that had basic collision detection on scratch :stuck_out_tongue_closed_eyes: beat you by about... nvm, it says 3 days ago... you beat me by about 2 days...

Newest Y U NO NEW!!!


#18

@justanerd I didn't make a tutorial. I asked @crazygoat to make one. On scratch you can use touches color for collision detect. The collision detect code i made checks which arrow key is pressed when the square bumps anything. It's alright for pacman and other top down games, but the code doesn't detect when anything bumps into the square, only when the square bumps into anything.


#19

The app Pocket code. For android is like hopscotch, but no last touch x-y code.
It has facial recognition blocks and have the app speak what text you enter as well as to connect to drones,toys.
I'll chat more on the site you mentioned. I don't want to be a bad influence and cause something scary should someone try the idea i'll send you,


#20

Sure. Do that at your convenience. I'll look for it. The site I shared is just a portal with a help@. There is no page.

In the mean time, I'd be interested in how you put the clone point-at code to work in the coming days. Games with swarms of independently-directed clones are a completely different creature, aren't they? :slightly_smiling:


#21

I understand, but I linked the collision detection, and tried to do it and add in Gravity on hopscotch as well, so that is a something, also I totally didn't get the idea from here :wink::wink::wink::wink::wink::wink::wink: (actually I kinda did)