direction problem 
Author Message
 direction problem

Ok im writing this program. I want a pixel to move in graph mode.
when i press left i want it to move left by itself until i press right.
then i want it to
start moving to the right. i cant do it. all i can do is to stop it
where it is and then make it move again.
plz help.
and plz no assembler cause i dont even understand it. =)

/nEGotI8



Wed, 18 Jun 1902 08:00:00 GMT  
 direction problem

Quote:

> Ok im writing this program. I want a pixel to move in graph mode.
> when i press left i want it to move left by itself until i press right.
> then i want it to
> start moving to the right. i cant do it. all i can do is to stop it
> where it is and then make it move again.
> plz help.
> and plz no assembler cause i dont even understand it. =)

> /nEGotI8

If you post your code you'll have the answer in no time.

Regards,

Remco de Korte
http://www.xs4all.nl/~remcodek/



Wed, 18 Jun 1902 08:00:00 GMT  
 direction problem

Quote:

>Ok im writing this program. I want a pixel to move in graph mode.
>when i press left i want it to move left by itself until i press right.
>then i want it to
>start moving to the right. i cant do it. all i can do is to stop it
>where it is and then make it move again.
>plz help.
>and plz no assembler cause i dont even understand it. =)

>/nEGotI8

Hello!!!

I wrote a very similar program:  a "worm" that is crawling up and down the
screen that is controlled by the direction keys.  It is also of variable
length (I. E.  the worm grows in length when certain conditions are met).
If you need, you can easily change the program from worm to a single pixel.
E-mail me if you need the code.


PS.  The code was tested only on my computer (P166, W95) and I have no idea
how it will perform on other computers.



Wed, 18 Jun 1902 08:00:00 GMT  
 direction problem

Quote:

> Ok im writing this program. I want a pixel to move in graph mode.
> when i press left i want it to move left by itself until i press right.
> then i want it to
> start moving to the right. i cant do it. all i can do is to stop it
> where it is and then make it move again.
> plz help.
> and plz no assembler cause i dont even understand it. =)

General algorithm:

var
  somedir : byte; {use this for directional control}
  xp, yp : word;  {position of the pixel}

begin
  setup_up_graphics; {get into graphics mode}
  initialize vars; {pick a starting point (xp,yp) and somedir :=0}
  repeat
    key been pressed?
    if yes. . . .
      case which_key_it_was of
        up_arrow : somedir := 1;
        down_arrow : somedir := 2;
        left_arrow : somedir := 3;
        right_arrow : somedir := 4;
        space_bar : somedir := 0;
        escape : done := true;
      end; {case}
    case somedir of
      1 : move the pixel up;
      2 : move the pixel down;
      3 : move the pixel left;
      4 : move the pixel up;
    end {case}
  until done;
end;

That's about all there is to it.  The only thing is that in the second case,
you need tests to make sure the pixel doesn't go beyond the bounds of the
screen.  This help much?

Quote:
> /nEGotI8

--
Scott Earnest            | SPAM protection in effect. Remove  |





Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Help Former VB peasant looking for direction!

2. Please point me in the right database direction...

3. Point me in right direction

4. Point me in right direction

5. TPW and Winsock - Hint in right direction.

6. Please help with this problem!!ARRAY problem

7. Paradox problem on the NET - problem

8. Problems with decimals and anonther small problem

9. Memory problems (heap problems????)

10. DBGrid problem - difficult problem

11. Problem: BDE and Delphi5's ISX (Was: Re: Problem with Delphi 3 and ISX 1.11 on Windows NT / 2000)

12. KojakVGA problems (of course I could mail this to Scott Tunstall, but maybe so here knows the problem)

 

 
Powered by phpBB® Forum Software