CSC 171 Lecture 12: mar 9

42 views3 pages
9 Mar 2017
School
Course

Document Summary

Keyboard detection what key is being pressed down: iskeydown( [name of key] ) // returns boolean true or false public void act(){ if (greenfoot. iskeydown( left )) turn(-3); what key was pressed before, getkey() // returns the last key pressed (a string) For mouse detection, greenfoot has created its own mouse method called. !1: static boolean mousemoved(java. lang. object obj) //true if mouse has been moved on the given object. Building a tron game always moving leaves a trail of where it"s been int previousx = 0; int previousy = 0; act() addobject(previousx,previousy) previousx = getx(); previousy = gety(); getworld(). addobject(getx(),gety(),dot()); move(1); if (iskeydown( left )) { turn(-90); if (iskeydown( right )) { turn(90); For the most part, no questions will be taken from past quizzes. Always loop inside a loop: will be asked to ll a pattern of lowers in a 12x12 block world.

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

Related Documents

Related Questions