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: Re: MIA, Ask an Expert
From: Alain LCSI <alain@xxxxxxx>
Date: Mon, 16 Jul 2007 20:32:10 -0400

Hello,

Here's one approach where t1 goes to a defined pos, and t2 does a random heading and random forward. If by any (bad)luck it is too close to t1, it will move again. This technique allows you to define how far apart the things should be at the beginning of the game (t3 steps in my example).


to setup
t1, setpos [100 100]
t2, setpos [100 100]
rt random 360
fd random 100
if (distance "t1) < 30 [setup]
end



Alain Tougas
alain@xxxxxxx
B: (514) 939-8700 poste 237



Le 07-07-16 à 19:00, askanexpert@xxxxxxxxxxxxxxxxxxxxxxxxxxxx a écrit :

This is an automatic message sent from the web form at:
http://mia.openworldlearning.org/mwforum.htm

from: Max <mnphilips@xxxxxxxxxxx>
date: Mon Jul 16 17:00:05 2007
platform: PC
version: MicroWorlds Ex

I am trying to make a Snake game where you move around to
eat stuff.  When you eat the targets, you grow a segment.

However, I need help with setting up the game.  When I set
the page with the gameplay on it up, I set one turtle to a
specific position.  I need to set another turtle to a
random position.  So finally, here's my question:

How do i make the second turtle go to a different place if
its random placement lands it right on top of the first
turtle?  Is there a way to use somewhat of a 'goto' and
'label' combo?  I will write these in my code in quotes.

Here is my code: (xcoord and ycoord are text boxes)

to start
t1, setpos [-257 -152]
'label 1'
setxcoord random 18
setycoord random 12
setxcoord xcoord * 30
setycoord ycoord * 30
setxcoord 253 - xcoord
setycoord 178 - ycoord
t2, setpos (se xcoord ycoord)
'if touching? "t1 "t2 [goto 1]'
end






  • Previous by thread: MIA, Ask an Expert
  • Next by thread: Re: MIA, Ask an Expert: different position

  • 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