Results 1 to 4 of 4

Thread: Regarding a loop and drawing in console mode (etc.)

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    you might get some ideas from. I didn't test any of this:
    Code:
    velocityX:=0;
    velocityY:=0;
    repeat
      StartTime:=GetTickCount;
      Key:=SomeGetKeyFunction(); // Some function that doesn't stop waiting for press
      // return 0 or something if nothing was pressed.
    
      case Key of
        VK_LEFT: velocityX:=-1;
        VK_RIGHT: velocityX:=1;
      end;
    
      ballX:=ballX+velocityX;
      ballY:=ballY+velocityY;
      DrawScene;
    
      // If drawing and moving would take different amount of time each frame
      // then you may need to control the delay length.
      // So that it runs same speed on all computers.
      DelayTime:=50-(GetTickCount-StartTime);
      if DelayTime>0 then Delay(DelayTime);
    until Key = #27;
    This is just a quick and dirty delay solution, but it should work decently enough for some simple projects.

  2. #2
    My reply seems to be eaten up by forum software, so I'll repeat:

    Try
    Code:
    if keypressed then Key:= readKey;
    instead of just
    Code:
     Key:= readKey;
    That should fix the issue!

  3. #3
    Thanks, guys. I'm moving forward again.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •