Project Folders
Teacher Resources
Student Resources
How Do I?
Site Map
Our Team

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

[Thread Prev] [Thread Next]

To: "MicroWorlds Forum" <mwforum@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>, swanson6748g@xxxxxxxxxxxxxx
Subject: Re: MIA, Ask an Expert: Pong/Follow
From: "Daniel Ajoy" <da.ajoy@xxxxxxxxx>
Date: Mon, 20 Sep 2010 11:33:35 -0500

On Mon, 20 Sep 2010 09:48:33 -0500, <askanexpert@xxxxxxxxxxxxxxxxxxxxxxxxxxxx> 

> from: <swanson6748g@xxxxxxxxxxxxxx>
> date: Mon Sep 20 08:48:32 2010
> platform: PC
> version: MicroWorlds Ex
> I am currently in the process of creating a Pong-like game, with a 
> computer-controlled paddle that follows the ball with not-exact accuracy. For 
> example, if the ball moves up 4, the paddle only moves up 3, instead of 
> insantly teleporting to the position. However, it seems the if function (might 
> not be considered a function, I am too used to using lua) does not like the 
> turtle's ycor as a value to work off of.
> Script in question:
> to follow
> wait 0.1
> if t2's last ycor < last ycor [sety ycor + 1]
> if t3's "ycor > ycor = true [sety ycor + 1]
> end

It is more a problem of operation precedence. Your "if" command is being 
parsed this way:

(if (t2's (last (ycor < (last ycor)))) [sety ycor + 1])

This part:

last ycor < last ycor

should at least be:

(last ycor) < last ycor

Notice that "ycor" is a number and a word:

show ycor

So "last ycor" means: the last digit or character in the ycor number:

show ycor

show last ycor

OpenWorld Learning

  • Previous by thread: MIA, Ask an Expert: Pong/Follow
  • Next by thread: MIA, Ask an Expert: Button

  • 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