<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>'Artificial input :P' Thread RSS Feed</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest posts from the thread 'Artificial input :P' posted on the 'Pascal' forum at Programmer's Heaven.</description>
    <language>en</language>
    <copyright>Copyright 2013 Programmers Heaven</copyright>
    <pubDate>Wed, 19 Jun 2013 20:26:56 -0700</pubDate>
    <lastBuildDate>Wed, 19 Jun 2013 20:26:56 -0700</lastBuildDate>
    <generator>Argotic Syndication Framework 2007.3.0.1, http://www.codeplex.com/Argotic</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>360</ttl>
    <image>
      <url>http://www.programmersheaven.com/images/ph.gif</url>
      <title>Programmers Heaven</title>
      <link>http://www.programmersheaven.com/</link>
      <width>88</width>
      <height>31</height>
    </image>
    <item>
      <title>Artificial input :P</title>
      <link>http://www.programmersheaven.com/mb/pasprog/422883/422883/artificial-input-p/</link>
      <description>I am making kinda game on pascal and I have faced a problem - "spaceship" should move when appropriate button is clicked, but you need to click the same button for 5 times. So I think a solution would be to make it think you pressed the same key 5 times while you do it only once, but is it possible to do?&lt;br /&gt;
&lt;br /&gt;
PS&lt;br /&gt;
&lt;br /&gt;
here's the whole code (very little yet) if you can think of a better solution :)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-size: x-small;"&gt;&lt;span style="color: Orange;"&gt;program Bevarde1;&lt;br /&gt;
uses Crt;&lt;br /&gt;
var x, y: integer;&lt;br /&gt;
    left, right, up, down: string;&lt;br /&gt;
    &lt;br /&gt;
      procedure SetKey;&lt;br /&gt;
    begin&lt;br /&gt;
        Left := ('a');&lt;br /&gt;
        Right := ('d');&lt;br /&gt;
        Up := ('w');&lt;br /&gt;
        Down := ('s');&lt;br /&gt;
    end;&lt;br /&gt;
    &lt;br /&gt;
      procedure DrawMe;&lt;br /&gt;
    begin;&lt;br /&gt;
      GoToxy(x+2, y-1);&lt;br /&gt;
      Write('I');&lt;br /&gt;
      GoToxy(x, y);&lt;br /&gt;
      Write('&amp;lt;=M=&amp;gt;');&lt;br /&gt;
      GoToxy(x+1, y+1);&lt;br /&gt;
      Write('I I');&lt;br /&gt;
    end;&lt;br /&gt;
    &lt;br /&gt;
      procedure PS;&lt;br /&gt;
    begin&lt;br /&gt;
      readkey;&lt;br /&gt;
      ClrScr;&lt;br /&gt;
      If readkey = left  then x := x - 1;&lt;br /&gt;
      If readkey = right then x := x + 1;&lt;br /&gt;
      If readkey = up    then y := y - 1;&lt;br /&gt;
      If readkey = down  then y := y + 1;&lt;br /&gt;
      DrawMe;&lt;br /&gt;
    end;&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
begin&lt;br /&gt;
&lt;br /&gt;
     SetKey;&lt;br /&gt;
   &lt;br /&gt;
   x := 38;&lt;br /&gt;
   y := 15;&lt;br /&gt;
   DrawMe;&lt;br /&gt;
&lt;br /&gt;
   while 1 = 1 do PS;&lt;br /&gt;
&lt;br /&gt;
Readln;&lt;br /&gt;
end.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/422883/422883/artificial-input-p/</guid>
      <pubDate>Wed, 30 Mar 2011 09:51:07 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>Re: Artificial input :P</title>
      <link>http://www.programmersheaven.com/mb/pasprog/422883/422884/re-artificial-input-p/#422884</link>
      <description>What's with the parentheses around the setkey values?&lt;br /&gt;
&lt;br /&gt;
:       procedure SetKey;&lt;br /&gt;
:     begin&lt;br /&gt;
:         Left := ('a');&lt;br /&gt;
:         Right := ('d');&lt;br /&gt;
:         Up := ('w');&lt;br /&gt;
:         Down := ('s');&lt;br /&gt;
:     end;&lt;br /&gt;
&lt;br /&gt;
Try this:&lt;br /&gt;
&lt;pre class="sourcecode"&gt;&lt;span style="color: Green;"&gt;   procedure SetKey;
     begin
         Left := 'a';
         Right := 'd';
         Up := 'w';
         Down := 's'
     end;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;
And then try poking these &lt;em&gt;lowercase&lt;/em&gt; keys to see if you get any movement.&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/422883/422884/re-artificial-input-p/#422884</guid>
      <pubDate>Wed, 30 Mar 2011 11:33:04 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>Re: Artificial input :P</title>
      <link>http://www.programmersheaven.com/mb/pasprog/422883/422890/re-artificial-input-p/#422890</link>
      <description>: I am making kinda game on pascal and I have faced a problem - &lt;br /&gt;
: "spaceship" should move when appropriate button is clicked, but you &lt;br /&gt;
: need to click the same button for 5 times. So I think a solution &lt;br /&gt;
: would be to make it think you pressed the same key 5 times while you &lt;br /&gt;
: do it only once, but is it possible to do?&lt;br /&gt;
: &lt;br /&gt;
: PS&lt;br /&gt;
: &lt;br /&gt;
: here's the whole code (very little yet) if you can think of a better &lt;br /&gt;
: solution :)&lt;br /&gt;
: &lt;br /&gt;
:&lt;pre class="sourcecode"&gt; 
: &lt;span style="color: Orange;"&gt;program Bevarde1;
: uses Crt;
: var x, y: integer;
:     left, right, up, down: string;
:     
:       procedure SetKey;
:     begin
:         Left := ('a');
:         Right := ('d');
:         Up := ('w');
:         Down := ('s');
:     end;
:     
:       procedure DrawMe;
:     begin;
:       GoToxy(x+2, y-1);
:       Write('I');
:       GoToxy(x, y);
:       Write('&amp;lt;=M=&amp;gt;');
:       GoToxy(x+1, y+1);
:       Write('I I');
:     end;
:     
:     &lt;span style="color: Red;"&gt;function PS:boolean&lt;/span&gt;;
      &lt;span style="color: Red;"&gt;var ch:char;&lt;/span&gt;
:     begin
:       &lt;span style="color: Red;"&gt;ch:=&lt;/span&gt;readkey;
:       ClrScr;
:       If &lt;span style="color: Red;"&gt;ch &lt;/span&gt; = left  then x := x - 1;
:       If &lt;span style="color: Red;"&gt;ch &lt;/span&gt; = right then x := x + 1;
:       If &lt;span style="color: Red;"&gt;ch &lt;/span&gt; = up    then y := y - 1;
:       If &lt;span style="color: Red;"&gt;ch &lt;/span&gt; = down  then y := y + 1;
:       DrawMe;
        &lt;span style="color: Red;"&gt;PS:=ch&amp;lt;&amp;gt;#27; { Esc to Quit}&lt;/span&gt;
:     end;
:     
:     
: begin
: 
:      SetKey;
:    
:    x := 38;
:    y := 15;
:    DrawMe;
: 
:    &lt;span style="color: Red;"&gt;while PS do; &lt;/span&gt;
: 
: Readln;
: end.&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;
: &lt;br /&gt;
&lt;br /&gt;
That's a good start, if you read through this forum then you'll find lots of examples on this subject. Here's a simple textmode game you could look at: &lt;a href="http://www.programmersheaven.com/mb/pasprog/392302/392335/simple-snake-game-and--maze-generator/?S=B10000"&gt;http://www.programmersheaven.com/mb/pasprog/392302/392335/simple-snake-game-and--maze-generator/?S=B10000&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/422883/422890/re-artificial-input-p/#422890</guid>
      <pubDate>Wed, 30 Mar 2011 19:45:58 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>Re: Artificial input :P</title>
      <link>http://www.programmersheaven.com/mb/pasprog/422883/422914/re-artificial-input-p/#422914</link>
      <description>Firstly, thanks for replies :)&lt;br /&gt;
&lt;br /&gt;
Ok, so I checked out that sample (the snake game) and I understood approximately nothing... I'm new to programming, you see... Plus - I copied the code to the pascal I use and it seems not to have some functions. Anyway, I took another route, and everything seems OK to me (even though I'm not sure what I did with the imput :D), but I get an error right away after starting the thing. Any help again?&lt;br /&gt;
&lt;br /&gt;
Oh, here's the code:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt; program TheGame;
 uses Crt;
 var x, y, x1, y1, sp, sx1, sx2, sx3, sx4, sx5, sy1, sy2, sy3, sy4, sy5, score: integer;
     left, right, up, down, sho1: string;
     ch: char;
{--------------------------------------------------------}

       procedure spawn;
     begin;
       randomize;
       sp := round (random * 64 + 5);
     end;

{--------------------------------------------------------}

       procedure DrawMe;
     begin;
       GoToxy(x+2, y-1);
       Write('I');
       GoToxy(x, y);
       Write('&amp;lt;=M=&amp;gt;');
       GoToxy(x+1, y+1);
       Write('I I');
     end;
     
{--------------------------------------------------------}
     
       procedure shoot1;
     begin
       x1 := x + 2;
       y1 := y - 1;
     end;

     
{--------------------------------------------------------}
     
       procedure SetKey;
     begin
         Left  := 'a';
         Right := 'd';
         Up    := 'w';
         Down  := 's';
         sho1  := 'g';
     end;
     
{--------------------------------------------------------}

 begin
      SetKey;
    x := 38;
    y := 15;
    DrawMe;
    
    score := 0;
    x1  := 1000;
    sx1 := 1000;
    sx2 := 1000;
    sx3 := 1000;
    sx4 := 1000;
    sx5 := 1000;
    y1  := 10;
    sy1 := 10;
    sy2 := 10;
    sy3 := 10;
    sy4 := 10;
    sy5 := 10;
    
 While 1 = 1 do begin

  {THE BULLET}
  
  if x1 &amp;lt;&amp;gt; 1000 then y1 := y1 - 1;
  if y1 = 1 then x1 := 1000;

  {IF GET SHOT}

  if x1 = sx1 then if
     y1 = sy1 then begin
     sy1 := 1;
     sx1 := 1000;
     x1 := 1000;
     score := score + 10;        end;

  if x1 = sx2 then if
     y1 = sy2 then begin
     sy2 := 1;
     sx2 := 1000;
     x1 := 1000;
     score := score + 10;        end;

  if x1 = sx3 then if
     y1 = sy3 then begin
     sy3 := 1;
     sx3 := 1000;
     x1 := 1000;
     score := score + 10;        end;

  if x1 = sx4 then if
     y1 = sy4 then begin
     sy4 := 1;
     sx4 := 1000;
     x1 := 1000;
     score := score + 10;        end;

  if x1 = sx5 then if
     y1 = sy5 then begin
     sy5 := 1;
     sx5 := 1000;
     x1 := 1000;
     score := score + 10;        end;

{SPAWNS 1 TO 5}

    if sx1 = 1000 then
  begin
    spawn;
    sx1 := sp;
    sy1 := 1;
  end else
    sy1 := sy1 + 1;
  
    if sx2 = 1000 then
  begin
    spawn;
    sx2 := sp;
    sy2 := 1;
  end else
    sy2 := sy2 + 1;
  
    if sx3 = 1000 then
  begin
    spawn;
    sx3 := sp;
    sy3 := 1;
  end else
    sy3 := sy3 + 1;
  
    if sx4 = 1000 then
  begin
    spawn;
    sx4 := sp;
    sy4 := 1;
  end else
    sy4 := sy4 + 1;
  
    if sx1 = 1000 then
  begin
    spawn;
    sx5 := sp;
    sy5 := 1;
  end else
    sy5 := sy5 + 1;

  
{OK... NOW DETECT INPUT AND APPLY IT}

  If keypressed then
    begin
       ch := readkey;
       If ch  = left   then if x &amp;gt; 3  then x := x - 1;
       If ch  = right  then if x &amp;lt; 74 then x := x + 1;
       If ch  = up     then if y &amp;gt; 3  then y := y - 1;
       If ch  = down   then if y &amp;lt; 90 then y := y + 1;
       If ch  = sho1   then shoot1;
    end;
                
{COOL, GOT COORDINATES, NOW THE DRAWING}

    If x1 &amp;lt;&amp;gt; 1000 then GoToXY(x1, y1);
    If x1 &amp;lt;&amp;gt; 1000 then Write('*');
    GoToXY(sx1, sy1);
    Write('U');
    GoToXY(sx2, sy2);
    Write('O');
    GoToXY(sx3, sy3);
    Write('Y');
    GoToXY(sx4, sy4);
    Write('H');
    GoToXY(sx5, sy5);
    Write('V');
    DrawMe;
    
{END OF FRAME}
    
    ClrScr;
    Delay(10);
  End;
 end.
&lt;/pre&gt;&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/422883/422914/re-artificial-input-p/#422914</guid>
      <pubDate>Thu, 31 Mar 2011 10:04:55 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>Re: Artificial input :P</title>
      <link>http://www.programmersheaven.com/mb/pasprog/422883/422923/re-artificial-input-p/#422923</link>
      <description>What compiler are you using ? The game, what is all about ? Explain what you're trying to achieve, time permitting will put ya on the right track. &lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/422883/422923/re-artificial-input-p/#422923</guid>
      <pubDate>Thu, 31 Mar 2011 21:22:47 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>Re: Artificial input :P</title>
      <link>http://www.programmersheaven.com/mb/pasprog/422883/422930/re-artificial-input-p/#422930</link>
      <description>Ok, so firstly I use Free Pascal 0.6.4. &lt;br /&gt;
&lt;br /&gt;
The game is pretty much like this: you control the "spaceship" and destroy objects falling from the top of screen by shooting them. Once object is destroyed, it respawns immediately in the top.&lt;br /&gt;
&lt;br /&gt;
The objects are basically coordinates. If object is not in use, I just set the x value to 1000.&lt;br /&gt;
&lt;br /&gt;
The  x   and  y   values refer to the "spaceship"&lt;br /&gt;
The  x1  and  y1  values refer to the bullet&lt;br /&gt;
The sx&lt;span style="color: Orange;"&gt;(1-5)&lt;/span&gt; and sy&lt;span style="color: Orange;"&gt;(1-5)&lt;/span&gt; refers to 5 independant falling objects.&lt;br /&gt;
&lt;br /&gt;
The whole thing I've done firstly checks for imput (even though I'm not sure will it work), then counts all coordinates and finally draws all objects that are in use. All this should repeat every 10 miliseconds.&lt;br /&gt;
&lt;br /&gt;
One more thing - The objects fall in the same speed as bullet moves, so I'll make them to fall once in about ten loops (that would be approximately 100 miliseconds).&lt;br /&gt;
&lt;br /&gt;
PS&lt;br /&gt;
&lt;br /&gt;
I'm making this game not to make it, but to gain experience in such stuff, so in the end I don't really care if I finish it sucessfully :P&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/422883/422930/re-artificial-input-p/#422930</guid>
      <pubDate>Fri, 01 Apr 2011 05:09:10 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>Re: Artificial input :P</title>
      <link>http://www.programmersheaven.com/mb/pasprog/422883/422939/re-artificial-input-p/#422939</link>
      <description>OMG. I have control of situation :) no need of help. when I finish the game I'll post it here (if you want, of coure, and if won't face any more problems).&lt;br /&gt;
&lt;br /&gt;
I'm so happy!!!&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/422883/422939/re-artificial-input-p/#422939</guid>
      <pubDate>Fri, 01 Apr 2011 09:28:48 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>Re: Artificial input :P</title>
      <link>http://www.programmersheaven.com/mb/pasprog/422883/422942/re-artificial-input-p/#422942</link>
      <description>Download the game &lt;a href="http://www.2shared.com/file/BQ7tkPss/Zaidas.html"&gt;here&lt;/a&gt; :)&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/422883/422942/re-artificial-input-p/#422942</guid>
      <pubDate>Fri, 01 Apr 2011 12:26:01 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>Re: Artificial input :P</title>
      <link>http://www.programmersheaven.com/mb/pasprog/422883/422982/re-artificial-input-p/#422982</link>
      <description>: Download the game &lt;br /&gt;
: &lt;a href="http://www.2shared.com/file/BQ7tkPss/Zaidas.html"&gt;here&lt;/a&gt; :)&lt;br /&gt;
: &lt;br /&gt;
&lt;br /&gt;
Why don't you post the source instead ? Someone may learn a thing or two...&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/422883/422982/re-artificial-input-p/#422982</guid>
      <pubDate>Sun, 03 Apr 2011 16:25:03 -0700</pubDate>
      <category>Pascal</category>
    </item>
    <item>
      <title>Re: Artificial input :P</title>
      <link>http://www.programmersheaven.com/mb/pasprog/422883/423000/re-artificial-input-p/#423000</link>
      <description>OK, &lt;a href="http://www.2shared.com/file/IMvNfDhr/v1_online.html"&gt;here's&lt;/a&gt; first I found and last versions of it (First one way more simple) :) both of them have an .exe and .pas files, so you can check the source.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/pasprog/422883/423000/re-artificial-input-p/#423000</guid>
      <pubDate>Mon, 04 Apr 2011 09:05:26 -0700</pubDate>
      <category>Pascal</category>
    </item>
  </channel>
</rss>