<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>1.<div>No native support in Alice 2.x to support true object collision.<div>BTW, great link about similar sized&nbsp;spherical collisions via Dr. James Vanderhyde (below).</div><div>With most objects there is a height, width, depth.</div><div>With sphere's the height,width,depth are the same and typically referred to as the radius.</div><div>Also with sphere's the object's origin is at the center making it easier to determine true collision.</div><div>Call the spherical objects ball1 and ball2.</div><div>Note: you cannot simply say when the distance between the balls is 0 then there is a collision when in fact they are exactly in the same 3-Dimensional position within each other ... so you need to add the lengths of the 2 (possibly different) radii to be the distance when a collision has occurred:</div><div>Create an event:</div><div>if (ball1.distance to (ball2) &nbsp;== (ball1.width + ball2.width))</div><div>&nbsp; &nbsp; &nbsp;collision = true</div><div><span style="font-size: 12pt;">else</span></div><div><div>&nbsp; &nbsp; &nbsp;collision = false</div></div><div><br></div><div>Note: This should be improved to not compare floating point numbers with an inequality.</div><div><div>if (ball1.distance to (ball2) &nbsp;&lt;= &nbsp;(ball1.width + ball2.width))</div><div>&nbsp; &nbsp; &nbsp;collision = true</div><div><span style="font-size: 12pt;">else</span></div><div>&nbsp; &nbsp; &nbsp;collision = false</div></div><div>&nbsp;</div><div>Note: &nbsp;The above is for 2 spheres of any size. &nbsp;If you are detecting collision amongst various spheres you will have to have a more involved collection of spheres and iterate all collisions.&nbsp;</div><div>With 2 spheres there is 1 conditional.</div><div>With 3 spheres there are 3 conditionals (1+2). &nbsp;</div><div>With 4 spheres there are 6 conditionals (1+2+3). &nbsp;</div><div><div>With 5 spheres there are 10 conditionals (1+2+3+4). &nbsp;</div></div><div>With N spheres there are (1+2+3+ ... + N-1)&nbsp;<span style="font-size: 12pt;">conditionals.</span></div><div><br></div><div>Note: This becomes more involved with non-spherical objects where the orientation of the two objects along with their components of height, width, and depth between the two objects becomes important.</div><div><br></div><div><span style="font-size: 12pt;">2.</span></div><div>Assuming you still want the cursor keys to control the movement of an object (call it personJoe) forward-back-left-right and other keys for up-down:</div><div>[a] Create a variable to control personJoe's speed (assume uniform speed in all six directions), call it distancePerCursorClick, initialize it to 0</div><div>[b]&nbsp;<span style="font-size: 12pt;">Create an event b</span><span style="font-size: 12pt;">ound</span> to the 'S' key to decrease personJoe's speed:</div><div>distancePerCursorClick =&nbsp;<span style="font-size: 12pt;">distancePerCursor</span><span style="font-size: 12pt;">Click&nbsp;- 1</span></div><div>[c]<span style="font-size: 12pt;">&nbsp;</span><span style="font-size: 12pt;">Create an event b</span><span style="font-size: 12pt;">ound</span><span style="font-size: 12pt;">&nbsp;</span><span style="font-size: 12pt;">to the 'F' key to increase personJoe's speed:</span></div><div>distancePerCursorClick&nbsp;=&nbsp;<span style="font-size: 12pt;">distancePerCursor</span><span style="font-size: 12pt;">Click&nbsp;+ 1</span></div><div>[d]&nbsp;<span style="font-size: 12pt;">Create an event for each of the six cursor keys similar to this:</span></div><div>When the up cursor is clicked</div><div><span style="font-size: 12pt;">&nbsp; &nbsp; &nbsp;move </span>personJoe<span style="font-size: 12pt;"> up by the distance&nbsp;</span>distancePerCursorClick</div><div>Note: you can package this idea anyway you want, but this is the basic&nbsp;idea.</div><div>Note: be careful that repeated clicking of the 'S' key can make the distancePerCursorClick become negative and hence your movement keys will make personJoe act&nbsp;backwards from the clicked cursor key&nbsp;</div><div><br></div><div>Not: you do not have to have uniform speed in all directions. &nbsp;In this case, create three variables:</div><div><div>distancePerUpDownCursorClick</div></div><div><div>distancePerLeftRightCursorClick</div></div><div><div>distancePerForwardBackCursorClick</div></div><div><br></div><div>--Ed Bujak</div><div><br></div><div><div><hr id="stopSpelling">From: jvanderhyde@benedictine.edu<br>To: alice-teachers@lists.andrew.cmu.edu<br>Date: Thu, 5 Sep 2013 13:28:28 +0000<br>Subject: Re: alice-teacher Collision and walking speed questions<br><br>




1. Collision detection in Alice is tricky. I have had students try several different approaches, but nothing has really worked as well as I would like. There are some tutorials you can read (I found it with a Google search):
<div><a href="http://programminginalice.wordpress.com/tag/collision-detection/" target="_blank">http://programminginalice.wordpress.com/tag/collision-detection/</a></div>
<div><br>
</div>
<div>2. I don't think there's any way to modify those existing controls, so you have to write your own controls for the player object. One non-obvious feature that will be useful is that you can right-click on events (such as "when a key is typed") and change
 it to something else ("while a key is pressed").</div>
<div><br>
</div>
<div>James<br>
<div><span class="ecxApple-style-span" style="border-collapse:separate;border-spacing:0px;">
<div style="word-wrap:break-word;">
<span class="ecxApple-style-span" style="border-collapse:separate;color:rgb(0, 0, 0);font-family:Helvetica;font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;orphans:2;text-indent:0px;text-transform:none;white-space:normal;widows:2;word-spacing:0px;">
<div style="word-wrap:break-word;">
<div>--</div>
<div>Dr. James Vanderhyde</div>
<div>Math and Computer Science</div>
<div>Benedictine College</div>
<div><a href="mailto:jvanderhyde@benedictine.edu">jvanderhyde@benedictine.edu</a></div>
<div><a href="http://vanderhyde.us/~james/pro/" target="_blank">http://vanderhyde.us/~james/pro/</a></div>
</div>
</span></div>
<br class="ecxApple-interchange-newline">
</span><br class="ecxApple-interchange-newline">
</div>
<br>
<div>
<div>On Sep 4, 2013, at 12:46 PM, Lori Fuller &lt;<a href="mailto:lori.fuller@browardschools.com">lori.fuller@browardschools.com</a>&gt; wrote:</div>
<br class="ecxApple-interchange-newline">
<blockquote>
<div style="font-family:Helvetica;font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;orphans:2;text-align:-webkit-auto;text-indent:0px;text-transform:none;white-space:normal;widows:2;word-spacing:0px;">
<div align="left" style="text-align:left;"><font face="Times New Roman" size="+1" style="font-family:'Times New Roman';font-size:14pt;">I have an advanced student among all of my beginners... and he is working on a maze game.</font></div>
<div align="left" style="text-align:left;"><font face="Times New Roman" size="+1" style="font-family:'Times New Roman';font-size:14pt;">2 questions:</font></div>
<div align="left" style="text-align:left;"><font face="Times New Roman" size="+1" style="font-family:'Times New Roman';font-size:14pt;">1. &nbsp;&nbsp;In Alice 2.3, is it possible to set up a collision indication method? If so, where do I find information on this?</font></div>
<div align="left" style="text-align:left;"><font face="Times New Roman" size="+1" style="font-family:'Times New Roman';font-size:14pt;">2. &nbsp;Is there a way to slow down the person object walking while using the arrow keys as controllers?</font></div>
<br>
<br>
<br>
<div align="left" style="text-align:left;"><font face="Times New Roman" size="+1" style="font-family:'Times New Roman';font-size:14pt;">thanks,</font></div>
<br>
<div align="left" style="text-align:left;"><font face="Times New Roman" size="+1" style="font-family:'Times New Roman';font-size:14pt;">Lori Fuller, M.Ed.</font></div>
<div align="left" style="text-align:left;"><font face="Times New Roman" size="+1" style="font-family:'Times New Roman';font-size:14pt;">Monarch High School</font></div>
<div align="left" style="text-align:left;"><font face="Times New Roman" size="+1" style="font-family:'Times New Roman';font-size:14pt;">Career Technology Department Head</font></div>
<div align="left" style="text-align:left;"><font face="Times New Roman" size="+1" style="font-family:'Times New Roman';font-size:14pt;">Technology Coordinator</font></div>
<div align="left" style="text-align:left;"><font face="Times New Roman" size="+1" style="font-family:'Times New Roman';font-size:14pt;">Asst. Athletic Director</font></div>
<br>
<div align="left" style="text-align:left;"><font face="Times New Roman" size="+1" style="font-family:'Times New Roman';font-size:14pt;">"A posse ad esse", from possibility to actuality...</font></div>
<br>
<div align="left" style="text-align:left;"><font face="Times New Roman" size="+1" style="font-family:'Times New Roman';font-size:14pt;">Big brother is watching so watch what you put in the email!</font></div>
<br>
<div align="left" style="text-align:left;"><font face="Times New Roman" size="+1" style="font-family:'Times New Roman';font-size:14pt;">Under Florida law, e-mail addresses, and all communications, including e-mail communications, made or received in connection
 with the transaction of School Board business are public records, which must be retained as required by law and must be disclosed upon receipt of a public records request, except as may be excluded by federal or state laws. &nbsp;If you do not want your e-mail
 address released in response to a public records request, do not send electronic mail to this entity. Instead, contact this office by phone or in writing.</font></div>
<br>
<br>
_______________________________________________<br>
alice-teachers mailing list<br>
<a href="mailto:alice-teachers@lists.andrew.cmu.edu">alice-teachers@lists.andrew.cmu.edu</a><br>
<a href="https://lists.andrew.cmu.edu/mailman/listinfo/alice-teachers" target="_blank">https://lists.andrew.cmu.edu/mailman/listinfo/alice-teachers</a><br>
</div>
</blockquote>
</div>
<br>
</div>


<br>_______________________________________________ alice-teachers mailing list alice-teachers@lists.andrew.cmu.edu https://lists.andrew.cmu.edu/mailman/listinfo/alice-teachers</div></div></div>                                               </div></body>
</html>