CSC 171 Lecture Notes - Lecture 9: Collision Detection, Outer Perimeter

46 views5 pages
24 Feb 2017
School
Course

Document Summary

For loops ***probably the most important: know the three parts. Strings: how to declare, use, and add them together. Modulo (%) based operations: (5*4)%3 > the answer is 2 because 2 is the remainder. Nothing directly from chapter 2, nothing from textbook: x+=y, math. round(x/2. 0) 3. (x*4)%3: string s = there are +integer. tostring(x*2)+ apples here , 2 + math. round(y*0. 4) Code examples: write a nested loop to layout a ower garden in a 10x10x10 world in a checkered pattern. Collision detection: nd out if two objects are occupying the same space at the same time. Greenfoot has many ways of supporting this: 1. istouching(someclass) is a boolean method that checks to see if current actor is touching some other class someclass if (istouching(enemy. class)) { If you"re inside the bullet class and you want the bullet to go away, you"d put this code into the bullet class.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related textbook solutions