Home
Project Folders
Teacher Resources
Student Resources
How Do I?
Literacy
MWForum
Site Map
Search
Our Team

MWForum Message [Date Index] [Threads] [Authors] [Attachments] [Subscribe]

[Thread Prev] [Thread Next]

To: MWForum@xxxxxxxxxxxxxxxxxxxxxxxxxxxx
Subject: Coding breakout paddle
From: "Doug Alexander" <dalexander@xxxxxxxxxxxxxxxxx>
Date: Wed, 14 Nov 2007 15:24:16 -0500

A student and I are attempting to code a breakout game, but we're running
into a couple of issues with the bouncing code.

With the paddle, we've divided it into three sections, each one a turtle -
left, center, and right. The left and right paddles need to reverse the
ball's heading plus angle it a bit more toward the horizontal, while the
center does a standard reflection of the heading. However, we want to test
the ball's heading when it hits the left paddle (for example) so that if
it's approaching on a heading of 95-180, it gets reversed back toward the
wall and then some, but if it approaches from the right or too shallowly
from the left, it just reflects. The code we have looks like:

to bounceLeftPaddle
make "ballheading heading
ifelse and (greater? ballheading 95) (less? ballheading 180)
[ball, seth 90 - (ballheading - 350)]
[ball, seth 90 - (ballheading - 45)]
end

Trouble is, saving the ball's heading to a variable "ballHeading" isn't
working. What's the right syntax? Do you think this approach could be
improved altogether?

Thanks,

Doug
--
Doug Alexander
Director of Academic Technology
Lincoln School
401-331-9696 x3137


  • Previous by thread: MIA, Ask an Expert: how to t1 in superProcedure
  • Next by thread: RE: Coding breakout paddle

  • To save an attachment to your computer, PC users should right-click (Mac users, click and hold the mouse button) on the link and then choose 'save target as' from the pop-up menu. A window will then pop up in which you can choose a location for the file.


    © copyright 2001 - 2008