Checking for Collisions: Alternative Method Erin Taylor Under the Direction of Susan Rodger July 2015 Duke University.

Slides:



Advertisements
Similar presentations
Visual Lists By Chris Brown under Prof. Susan Rodger Duke University July 2012.
Advertisements

Space Man Sam: Grammar Mistakes By Aleis Murphy Duke University, Under the direction of Professor Susan Rodger July 2010.
Repetition everywhere – comparing while in a method and as an event Susan Rodger Duke University July 2010 modified July 2011.
Princess & Dragon – Version 2 By Michael Hoyle under the direction of Professor Susan Rodger Duke University July 2012 Part 3: Billboards, Events, Sounds,
Getting Started With Alice By Ruthie Tucker under the direction of Prof. Susan Rodger Duke University, July
Skater World: Part One By Deborah Nelson Duke University Under the direction of Professor Susan Rodger May 29,
Coloring Randomly: Random Selection in Alice By Jenna Hayes under the direction of Professor Susan Rodger Duke University July 2008.
How Tall Are You? Introducing Functions By Jenna Hayes under the direction of Professor Susan Rodger Duke University July 2008 Updates made June 2014 by.
Using Functions in Alice By Jenna Hayes Under the direction of Professor Susan Rodger Duke University July 2008.
Princess & Dragon Part 2: Teaching a Dragon to Fly—Methods & Properties By Elizabeth Liang under the direction of Professor Susan Rodger Duke University.
Lets Play Catch! Keeping Score in Alice By Francine Wolfe Duke University Professor Susan Rodger May 2010.
Asteroids! Michael Marion under Prof. Susan Rodger Duke University July2012.
Using Functions in Alice By Jenna Hayes Under the direction of Professor Susan Rodger Duke University July 2008.
Lights Camera Action! Part 3: BDE Events By Deborah Nelson under the direction of Professor Susan Rodger Duke University July 2008.
Wizard Game: Class-Level Variables in Alice By Jenna Hayes Under the direction of Professor Susan Rodger Duke University, July
Alice Learning to program: Part 1 Scene Setup and Starting Animation by Ruthie Tucker and Jenna Hayes Under the direction of Professor Susan Rodger Duke.
Calvin and Hobbes Teach Properties and Functions Created by Daniel MacDonald under the direction of Professor Susan Rodger Duke University June 2013.
Alice Learning to program: Part Two by Ruthie Tucker and Jenna Hayes Under the direction of Professor Susan Rodger Duke University, July 2008.
Princess & Dragon Part 4: Breathing Fire—Adding Effects to Alice By Elizabeth Liang under the direction of Professor Susan Rodger Duke University June.
Shorter of two objects and changing color Functions, events and setting the color Susan Rodger, Duke University June 2008.
Checking for Collisions Ellen Yuan Under the direction of Professor Susan Rodger at Duke University June 2014.
Working with Numbers in Alice - Converting to integers and to strings - Rounding numbers. - Truncating Numbers Samantha Huerta under the direction of Professor.
by Chris Brown under Prof. Susan Rodger Duke University June 2012
Getting Started With Alice By Ruthie Tucker under the direction of Prof. Susan Rodger Duke University, July
Making a Boat Racing Game in Alice By Jenna Hayes Under the direction of Professor Susan Rodger Duke University, July 2010.
Skater World: Part Two By Deborah Nelson Duke University Under the direction of Professor Susan Rodger June
Shorter of two objects and changing color V2 Functions, events and setting the color in sequence and randomly This is a modification of the Changing Color.
Changing Camera Views! Part 2: Simple Scene Change & Lighting Fixes By Bella Onwumbiko under the direction of Professor Susan Rodger Duke University July.
3–D Helium Molecule Tutorial Alice Project Duke University Professor Susan H. Rodger Gaetjens Lezin June 2008.
Alice Pong Recreating Pong in Alice By Elizabeth Liang under the direction of Professor Susan Rodger Duke University June 2010.
Changing Color, Using Text Objects, and Random Selection in Alice By Jenna Hayes Under the direction of Professor Susan Rodger Duke University, July 2008.
Teaching a character to walk in more than one world: Parameters and Inheritance. By Lana Dyck under the direction of Professor Susan Rodger Duke University.
By Deborah Nelson Duke University Professor Susan Rodger July 13, 2008.
Lists Tutorial By Deborah Nelson Duke University Professor Susan Rodger July 13, 2008.
A Simple Quiz: Ask User Functions. By Lana Dyck under the direction of Professor Susan Rodger Duke University June 2009, added Part 2 July 2011.
An Introduction to Alice (Short Version) – Extras! Yossra Hamid Under the Supervision of Professor Susan Rodger Duke University, June 2014 This is a continuation.
Piñata Game: Keeping Score in Alice By Maggie Bashford Professor Susan Rodger Duke University July
Skater World: Part Two By Deborah Nelson Duke University Under the direction of Professor Susan Rodger June 1,
Alice Learning to program: Part Two Writing Your Own Methods by Ruthie Tucker and Jenna Hayes Under the direction of Professor Susan Rodger Duke University,
Bunny Eat Broccoli Repetition – Simple loops and Conditional loops Susan Rodger Duke University July 2011.
Making Billboards By Deborah Nelson Duke University, Under the direction of Professor Susan Rodger, July 14, 2008.
Balancing the scales: Inequalities By Melissa Dalis Professor Susan Rodger Duke University June 2011.
Simple Collision Detection By David Yan Under the direction of Professor Susan Rodger and Chari Distler Duke University, June 2015.
Ready, SET, go! By Melissa Dalis Professor Susan Rodger Duke University July 2011.
Tutorial on Kangaroo visiting his animal friends - parameters, events Susan Rodger Duke University June 2009.
Changing Camera Views! Part 1: Set Point of View to By Bella Onwumbiko under the direction of Professor Susan Rodger Duke University July 2013 Updates.
Skater World: Part Three By Deborah Nelson Duke University Under the direction of Professor Susan Rodger June 2009.
An Introduction to Alice By Jenna Hayes under the direction of Professor Susan Rodger Duke University, June 2009 Updated June 2014 by Ellen Yuan.
BDE tutorial By Deborah Nelson Duke University Under the direction of Professor Susan Rodger July 13, 2008.
Repetition everywhere – comparing while in a method and as an event Susan Rodger Duke University July 2010.
Illuminating Computer Science CCIT 4-6Sep
Creating a Fancier Chicken to use in several worlds - Inheritance Susan Rodger Duke University June 2009.
Headshots in Alice Duke University Professor Susan H. Rodger Gaetjens Lezin July 2008.
Princess & Dragon Part 3: A Knight Comes Riding In—Cameras & Events By Elizabeth Liang under the direction of Professor Susan Rodger Duke University June.
How Tall Are You? Introducing Functions for Alice 3 By Jenna Hayes under the direction of Professor Susan Rodger Duke University July 2008 Updates made.
The Essentials of Alice By Jenna Hayes under the direction of Professor Susan Rodger Duke University May 2009.
Tutorial on Bunny visiting his animal friends - parameters, events for Alice 3 Susan Rodger Duke University June 2009 Updated by Yossra Hamid on October.
An Introduction to Alice (Short Version)
Professor Susan Rodger
Bunny Eat Broccoli Repetition – Simple loops and Conditional loops
Changing Color, Using Text Objects, and Random Selection in Alice
Let's Race! Typing on the Home Row
Vehicles and Conditionals
Checking for Collisions: Using Functions in Alice
An Introduction to Alice
How Tall Are You? Introducing Functions
Getting Started With Alice
Headshots in Alice Duke University Professor Susan H. Rodger
Restricting Events Creating Conditional Events in Alice By Henry Qin
Presentation transcript:

Checking for Collisions: Alternative Method Erin Taylor Under the Direction of Susan Rodger July 2015 Duke University

Motivation In the Simple Collision Detection tutorial we used the center of buildings to determine when the humvee was going to collide with them This method worked, but was ineffective for preventing collisions with corners of buildings This method was particularly ineffective for the townhouse, whose center was up high In this tutorial, we’ll try out a different way to check for collisions

Getting Set Up Open up a new Alice world, choose the sand layout Add in the townHouse object from the buildings folder and the Humvee object from the vehicles folder

Adding in Cubes Instead of using the center of the building to check if our humvee is about to collide with it, we’re going to place a series of cubes around the perimeter and check if the humvee is about to hit any of those So, go into the shapes folder and begin to add in cubes around the perimeter of the building The number of cubes you need will depend on whether you resized your building and how you place them.

Adding in Cubes It might be difficult to correctly place the cubes You can switch from single view to quad view for more precise placement. Start with the corners, placing the cube partly inside of the building

Adding in Cubes Go ahead and add in cubes all around the side, your top view should look something like this: Don’t forget to put a cube in the stairs!

Adding Cubes Once you’ve added all of your cubes, you need to do two things: – You don’t want to see the cubes when you run the world, so go to their properties > is showing and set it equal to false – If you move the townhouse then you want the cubes to stay in place and move with it, so go to the cube’s properties and set the vehicle to the townhouse Do this for every cube in your world

Creating a list Next go to world > properties > create new variable Now create a list and add all of your cubes to it so we can use it in our code

Writing world.collision Go to the world > methods tab and create a new method and call it “collision” We will use this method to check if the humvee is about to collide with any of the cubes and if it is, then we will move the humvee back

Writing world.collision First drag up an if/else block and select true Then open up the humvee’s functions and find humvee is within threshold of object Drag this on top of the true, you can choose 5 for the threshold and a cube for the object

Writing world.collision 5 meters was picked arbitrarily, so we want a more precise measurement Locate the humvee’s width in the humvee > function tab and drag it over the 5 meters Then click the arrow beside the width, go to math, and then divide the width by 2

Writing world.collision Now click the drop down arrow in front of the word “of” and choose math and add and then just pick 1

Writing world.collision We want to replace the 1 with the cube’s width divided by 2 First go to cube > function and drag in cube’s width Then click the arrow beside the width and find math, and then divide by 2. Your finished statement should look like this:

Writing world.collision Now after the if statement we want the humvee to move back, so drag in a humvee > move > backwards > 5 meters Set the duration equal to.1 so this happens quickly

Writing world.collision Right now this will only work with one cube, but we want it to work with every cube so we will use the list we created First drag in a for all together and choose for it to go through your cube list

Writing world.collision Drag in the entire if statement into the for all together block Replace every instance of cube with item_from_cubes

Finshed world.collision Your finished method should look like this:

Creating an Event In your event space, right click on the event “when the world starts” Choose change to > while the world is running

Creating an Event Change the beside the during to to call the world.collide method that we just wrote

Adding a Final Event We want to be able to move our Humvee around the world using the arrow keys. In your event space, select Create new event > Let the arrow keys move subject Select the humvee object when the event appears

Finishing world We also want the camera to follow the humvee, so go to camera > properties > vehicle and choose humvee > the entire humvee For this to work correctly make sure the humvee is facing away from the camera towards the townhouse, you may need to reposition your objects

Finished world Now you can play your world and see how the humvee jumps back from the townhouse This method works better than using an object’s center, but is more tedious and requires many more objects