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

Report as inappropriate.

danpost
danpost presents ...

2012/5/15

Barriers and Bars

Demonstration on collision-detection, using barriers. With example code for moving so you do not pass over them. Also includes a demonstration on how to sub-class my Bar class.

5008 views / 18 in the last 7 days

8 votes | 0 in the last 7 days

Tags: mouse demo with-source bar danpost barrier collision-detection

This scenario is a member of: Demos by danpost


open in greenfoot

There is no HTML 5 translation of this scenario available.
View legacy version (requires Java plugin)

This scenarios uses Java features that are not available for use after conversion to HTML 5. Please try the legacy version, which requires the Java plugin to be installed.

dlannidlanni

2012/5/16

Oh wow! I can't wait to have a look at the code. Thanks!
A new version of this scenario was uploaded on Fri Oct 05 11:36:39 UTC 2012 Added angled lines and adjusted movement code. Also, added a barrier thickness adjuster bar.
danpostdanpost

2012/10/5

The robot (or man) has eight-way movement; meaning that you can use two arrows keys at one time to move diagonally (like 'up' and 'left'). Even with a little resistance in the direction of movement, the robot will 'slide' along the barrier. Maximizing the thickness of the barriers (clicking on the right, outside the Barrier Thickness bar) with the robot next to a barrier may 'trap' him. Better is to press and hold inside the bar on the right side (or move the robot away from any barriers before maximizing the thickness of the barriers).
SparkySparky

2013/7/26

should i use this to learn how to make barriers?
danpostdanpost

2013/7/26

@Sparky, oftentimes new programmers find that even though they put some kind of collision checking in their code, they still have problems with the actor passing by some barriers (usually when the speed of the object is quite fast and the barrier is quite thin). Although this scenario was intended to help in that situation, it is still possible to learn collision checking by examining its code.
davemib123davemib123

2013/12/6

this is great - should have seen this before!
FloodMeisterFloodMeister

2014/10/17

Hey, this has been so useful for me but i have one thing i cant figure out which is on one side of the barrier i can get close to it and then on the other side it has a gap, do you have any solutions to this?
FloodMeisterFloodMeister

2014/10/17

sorry do not look for this. it was my amateur mistake of the image have transparent pixels sorry
A new version of this scenario was uploaded on 2017-01-20 22:43:53 UTC
A new version of this scenario was uploaded on 2017-01-20 23:19:53 UTC

See all comments

Want to leave a comment? You must first log in.

Who likes this?

TomazVDSN FloodMeister JetLennit davemib123 adamkjelstroem sparrow72 h123n dlanni