realbasic-games
[Top] [All Lists]

Delay with Keys

To: Realbasic - Games <REALbasic-Games at lists dot realsoftware dot com>
Subject: Delay with Keys
From: Eric Richards <erockus at earthlink dot net>
Date: Tue, 08 Aug 2006 10:42:54 -0500
Cc:
Delivered-to: listarchive at realsoftware dot com
Delivered-to: REALbasic-Games at lists dot realsoftware dot com
Its been a bit, so I thought I would try again.

How would I put a delay in while the key is pressed and no delay when not pressed ?

Rb tripple 5.

code Example:

Timer

Checkkey

 if bounds check
   if Grid X,Y  is not empty
       Nextitem
     else
       Delay = Delay + 1
if Delay >= levelspeed then
         Delay = 0
item.Y = item.y + 1 end if
     end if

     DrawIt(GameBuffer.graphics)
   end if
 end if



Checkkey()
if keyboard.asyncKeyDown(&h7B) then//left
  If item.X > 0 then
    if Grid(item.x-1,item.y) = -1 then
      if Grid(item.x-1,item.y+1) = -1 then
          item.X = item.X -1
      end if
    end if
  end if
elseif keyboard.asyncKeyDown(&h7c) then//right
  if item.X < 9 then
    if Grid(item.x+1,item.y)= -1 then
      if Grid(item.x+1,item.y+1)= -1 then
        item.X = item.X +1
      end if
    end if
  end if
elseif keyboard.asyncKeyDown(&h7D) then // down
  If item.y >-1 and item.Y <= 19 then //make sure we are in bounds
if Grid(item.x,item.y+1) = -1 then //make sure there isn't a piece in next spot
     item.Y = item.Y + 1
    else
      if item.Y > 19 then
        item.Y = 19
      end if
    end if
  end if
end if


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>


<Prev in Thread] Current Thread [Next in Thread>
  • Delay with Keys, Eric Richards <=