<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="https://wiki.zenerves.net/skins/common/feed.css?301"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
		<id>https://wiki.zenerves.net/index.php?action=history&amp;feed=atom&amp;title=Pong</id>
		<title>Pong - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://wiki.zenerves.net/index.php?action=history&amp;feed=atom&amp;title=Pong"/>
		<link rel="alternate" type="text/html" href="https://wiki.zenerves.net/index.php?title=Pong&amp;action=history"/>
		<updated>2026-04-18T11:28:42Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.17.0</generator>

	<entry>
		<id>https://wiki.zenerves.net/index.php?title=Pong&amp;diff=40&amp;oldid=prev</id>
		<title>Admin: 1 revision</title>
		<link rel="alternate" type="text/html" href="https://wiki.zenerves.net/index.php?title=Pong&amp;diff=40&amp;oldid=prev"/>
				<updated>2011-10-14T20:49:22Z</updated>
		
		<summary type="html">&lt;p&gt;1 revision&lt;/p&gt;
&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
		&lt;tr valign='top'&gt;
		&lt;td colspan='1' style=&quot;background-color: white; color:black;&quot;&gt;← Older revision&lt;/td&gt;
		&lt;td colspan='1' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 20:49, 14 October 2011&lt;/td&gt;
		&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>https://wiki.zenerves.net/index.php?title=Pong&amp;diff=39&amp;oldid=prev</id>
		<title>Lola: Protected &quot;Pong&quot; [edit=autoconfirmed:move=autoconfirmed]</title>
		<link rel="alternate" type="text/html" href="https://wiki.zenerves.net/index.php?title=Pong&amp;diff=39&amp;oldid=prev"/>
				<updated>2011-04-10T15:48:00Z</updated>
		
		<summary type="html">&lt;p&gt;Protected &amp;quot;&lt;a href=&quot;/index.php?title=Pong&quot; title=&quot;Pong&quot;&gt;Pong&lt;/a&gt;&amp;quot; [edit=autoconfirmed:move=autoconfirmed]&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt; //&lt;br /&gt;
 // Pong for the LEGO Mindstorms NXT.&lt;br /&gt;
 //&lt;br /&gt;
 // Copyright (c) 2007, Michael Andersen (mian_/#&amp;gt;_pobox.com)&lt;br /&gt;
 //&lt;br /&gt;
 &lt;br /&gt;
 #define HEIGHT                    (64)&lt;br /&gt;
 #define WIDTH                     (100)&lt;br /&gt;
 #define PADDLE_HEIGHT             (HEIGHT/4)&lt;br /&gt;
 #define PADDLE_WIDTH              (1)&lt;br /&gt;
 #define PADDLE_MIN                (0)&lt;br /&gt;
 #define PADDLE_MAX                (HEIGHT-PADDLE_HEIGHT)&lt;br /&gt;
 &lt;br /&gt;
 #define TACHO_PADDLE_RATIO        (1)&lt;br /&gt;
 &lt;br /&gt;
 #define LOOP_PAUSE                (500)&lt;br /&gt;
 &lt;br /&gt;
 #define A_X                       (0)&lt;br /&gt;
 #define B_X                       (98)&lt;br /&gt;
 &lt;br /&gt;
 #define BALL_DX                   (4)&lt;br /&gt;
 #define BALL_DY                   (0)&lt;br /&gt;
 &lt;br /&gt;
 #define BALL_DIAMETER             (2)&lt;br /&gt;
 &lt;br /&gt;
 task main ()&lt;br /&gt;
 {&lt;br /&gt;
   int i, j;&lt;br /&gt;
 &lt;br /&gt;
   int score_a, score_b;&lt;br /&gt;
   &lt;br /&gt;
   int motor_a_now, motor_a_before, motor_a_init, a;&lt;br /&gt;
   int motor_b_now, motor_b_before, motor_b_init, b;&lt;br /&gt;
   &lt;br /&gt;
   int ball_x, ball_y, ball_dx, ball_dy, ball_angle;&lt;br /&gt;
 &lt;br /&gt;
   // initial motor positions&lt;br /&gt;
   motor_a_init = MotorTachoCount (OUT_A);&lt;br /&gt;
   motor_a_now = motor_a_init;&lt;br /&gt;
   motor_a_before = motor_a_init;&lt;br /&gt;
   motor_b_init = MotorTachoCount (OUT_B);&lt;br /&gt;
   motor_b_now = motor_b_init;&lt;br /&gt;
   motor_b_before = motor_b_init;&lt;br /&gt;
 &lt;br /&gt;
   // center paddle positions&lt;br /&gt;
   a = HEIGHT/2-PADDLE_HEIGHT/2;&lt;br /&gt;
   b = HEIGHT/2-PADDLE_HEIGHT/2;&lt;br /&gt;
   &lt;br /&gt;
   // ball position&lt;br /&gt;
   ball_x = WIDTH/2;&lt;br /&gt;
   ball_y = HEIGHT/2;&lt;br /&gt;
   // ball speed&lt;br /&gt;
   ball_dx = BALL_DX;&lt;br /&gt;
   ball_dy = BALL_DY;&lt;br /&gt;
   &lt;br /&gt;
   // scores&lt;br /&gt;
   score_a = 0;&lt;br /&gt;
   score_b = 0;&lt;br /&gt;
 &lt;br /&gt;
   while (true)&lt;br /&gt;
   {&lt;br /&gt;
     motor_a_now = MotorTachoCount (OUT_A) - motor_a_init;&lt;br /&gt;
     if (motor_a_now &amp;lt;&amp;gt; motor_a_before)&lt;br /&gt;
     {&lt;br /&gt;
       a = a + (motor_a_now - motor_a_before)/TACHO_PADDLE_RATIO;&lt;br /&gt;
       if (a &amp;lt; PADDLE_MIN) a = PADDLE_MIN;&lt;br /&gt;
       if (a &amp;gt; PADDLE_MAX) a = PADDLE_MAX;&lt;br /&gt;
     }&lt;br /&gt;
     motor_a_before = motor_a_now;&lt;br /&gt;
     &lt;br /&gt;
     motor_b_now = MotorTachoCount (OUT_B) - motor_b_init;&lt;br /&gt;
     if (motor_b_now &amp;lt;&amp;gt; motor_b_before)&lt;br /&gt;
     {&lt;br /&gt;
       b = b + (motor_b_now - motor_b_before)/TACHO_PADDLE_RATIO;&lt;br /&gt;
        if (b &amp;lt; PADDLE_MIN) b = PADDLE_MIN;&lt;br /&gt;
        if (b &amp;gt; PADDLE_MAX) b = PADDLE_MAX;&lt;br /&gt;
      }&lt;br /&gt;
      motor_b_before = motor_b_now;&lt;br /&gt;
      &lt;br /&gt;
      // new position&lt;br /&gt;
      ball_x += ball_dx;&lt;br /&gt;
      ball_y += ball_dy;&lt;br /&gt;
      &lt;br /&gt;
      // adjust for A paddle bounce (left)&lt;br /&gt;
      if (ball_x &amp;lt; 1)&lt;br /&gt;
      {&lt;br /&gt;
         if ((a &amp;lt;= ball_y) &amp;amp;&amp;amp; (ball_y &amp;lt;= (a + PADDLE_HEIGHT)))&lt;br /&gt;
         {&lt;br /&gt;
           // hit - calculate angle of return&lt;br /&gt;
           ball_dy = (ball_y - a - PADDLE_HEIGHT/2)/2; // range -4 to 4&lt;br /&gt;
           ball_dx = 4;&lt;br /&gt;
           ball_x += ball_dx;&lt;br /&gt;
        }&lt;br /&gt;
          else&lt;br /&gt;
         {&lt;br /&gt;
           // missed&lt;br /&gt;
           score_b++;&lt;br /&gt;
           &lt;br /&gt;
           // ball position&lt;br /&gt;
           ball_x = WIDTH/2;&lt;br /&gt;
           ball_y = HEIGHT/2;&lt;br /&gt;
           // ball speed&lt;br /&gt;
           ball_dx = -BALL_DX;&lt;br /&gt;
           ball_dy = BALL_DY;&lt;br /&gt;
         }&lt;br /&gt;
      }&lt;br /&gt;
 &lt;br /&gt;
      // adjust for B paddle bounce (right)&lt;br /&gt;
      if (ball_x &amp;gt; 98)&lt;br /&gt;
      {&lt;br /&gt;
         if ((b &amp;lt;= ball_y) &amp;amp;&amp;amp; (ball_y &amp;lt;= (b + PADDLE_HEIGHT)))&lt;br /&gt;
         {&lt;br /&gt;
           // hit - calculate angle of return&lt;br /&gt;
           ball_dy = (ball_y - b - PADDLE_HEIGHT/2)/2; // range -4 to 4&lt;br /&gt;
           ball_dx = -4;&lt;br /&gt;
           ball_x += ball_dx;&lt;br /&gt;
         }&lt;br /&gt;
         else&lt;br /&gt;
         {&lt;br /&gt;
           // missed&lt;br /&gt;
           score_a++;&lt;br /&gt;
 &lt;br /&gt;
           // ball position&lt;br /&gt;
           ball_x = WIDTH/2;&lt;br /&gt;
           ball_y = HEIGHT/2;&lt;br /&gt;
           // ball speed&lt;br /&gt;
           ball_dx = BALL_DX;&lt;br /&gt;
           ball_dy = BALL_DY;&lt;br /&gt;
         }&lt;br /&gt;
      } &lt;br /&gt;
 &lt;br /&gt;
     // adjust for side bounce&lt;br /&gt;
      if ((ball_y &amp;lt;= 0) || (ball_y &amp;gt; 64))&lt;br /&gt;
      {&lt;br /&gt;
         ball_y -= ball_dy;&lt;br /&gt;
         ball_dy = -ball_dy;&lt;br /&gt;
      } &lt;br /&gt;
 &lt;br /&gt;
      ClearScreen ();&lt;br /&gt;
      // paddles&lt;br /&gt;
      RectOut (A_X, a, PADDLE_WIDTH, PADDLE_HEIGHT);&lt;br /&gt;
      RectOut (B_X, b, PADDLE_WIDTH, PADDLE_HEIGHT);&lt;br /&gt;
      // net&lt;br /&gt;
      RectOut (49,3,1,8);&lt;br /&gt;
      RectOut (49,19,1,8);&lt;br /&gt;
      RectOut (49,35,1,8);&lt;br /&gt;
      RectOut (49,51,1,8);&lt;br /&gt;
      // ball&lt;br /&gt;
      //NumOut (10, LCD_LINE2, ball_x);&lt;br /&gt;
      //NumOut (10, LCD_LINE3, ball_y);&lt;br /&gt;
      //CircleOut (ball_x, ball_y, BALL_DIAMETER);&lt;br /&gt;
      RectOut (ball_x-1, ball_y-1, 1, 1);&lt;br /&gt;
      RectOut (ball_x-2, ball_y-2, 3, 3);&lt;br /&gt;
      // score&lt;br /&gt;
      NumOut (35, LCD_LINE8, score_a);&lt;br /&gt;
      NumOut (60, LCD_LINE8, score_b); &lt;br /&gt;
 &lt;br /&gt;
      for (i = 0; i &amp;lt; LOOP_PAUSE; i++);&lt;br /&gt;
    }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Snippets]]&lt;/div&gt;</summary>
		<author><name>Lola</name></author>	</entry>

	</feed>