| Game Attack Key 
 
	 
	
		| Author | Message |   
		| Spence607 
 
  
 
 
 | 
			
				|  Posted: Wed Dec 10, 2008 4:18 pm    Post subject: Game Attack Key |  |   
				| 
 |  
				| I have worked out most of the bugs in my game so far.. this I can't seem to figure out, frankly I don't even know if it is possible. I'm using KeyDown for my inputs and I would like to make it so if the attack key is held down it will only count as being pressed once... otherwise my game is going to be rather easy.. all you have to do is hold the attack key. Does anyone know of a way to stop this? 
 Here's my game so far:
 
 
 	  | Turing: |  	  | 
% --------------------------
%|Wanderer of the Dark Realm|
%|    By Spencer Sherman    |
% --------------------------
var font : int
var  font2 : int
var  keys : array char of boolean
% ----------------------------------
%|Player Move/Attack/Health Position|
% ----------------------------------
var  plmov : int := 0
var  platt : int := 0
var  plhel : int := 0
var  plswu : boolean := false
var  plswd : boolean := false
var  plswr : boolean := false
var  plswl : boolean := false
% -----------------------
%|Player X/Y/Height/Width|
% -----------------------
var  plx := 400
var  ply := 200
var  plx2 := 420
var  ply2 := 220
% -----------------------
%|Map 1 Goblin 1 Variable|
% -----------------------
var  gobx := 5
var  goby := 5
var  gobx2 := 5
var  goby2 := 5
var  gobhx := 1
var  gobhy := 766
var  gobhx2 := 250
var  gobhy2 := 756
% -------------
%|Screen Config|
% -------------
setscreen ("offscreenonly")
setscreen ("graphics:1024;768")
% -----
%|Fonts|
% ----- 
font := Font.New ("arial:10:bold,italic") 
font2 := Font.New ("arial:10:bold")
% -----
%|Music|
% -----
process  Background
    loop
        Music.PlayFile ("Background.mp3")
    end loop
end  Background
% -------------------
%|Draw Map 1 Goblin 1|
% -------------------
procedure  DrawMap1Goblin1
    % ----
    %|Name|
    % ----
    Draw.Text ("Goblin 1",  gobx + 27 , goby + 222 , font, white)
    % ----
    %|Body|
    % ----
    Draw.FillBox ( gobx + 45 , goby + 195 , gobx2 + 65 , goby2 + 210 , brown)
    Draw.Box ( gobx + 45 , goby + 195 , gobx2 + 65 , goby2 + 210 , black)
    % ----
    %|Head|
    % ----
    Draw.FillBox ( gobx + 50 , goby + 200 , gobx2 + 60 , goby2 + 210 , green)
    Draw.Box ( gobx + 50 , goby + 200 , gobx2 + 60 , goby2 + 210 , black)
    % --------
    %|Left Ear|
    % --------
    Draw.FillBox ( gobx + 45 , goby + 205 , gobx2 + 50 , goby2 + 215 , green)
    Draw.Box ( gobx + 45 , goby + 205 , gobx2 + 50 , goby2 + 215 , black)
    % ---------
    %|Right Ear|
    % ---------
    Draw.FillBox ( gobx + 60 , goby + 205 , gobx2 + 65 , goby2 + 215 , green)
    Draw.Box ( gobx + 60 , goby + 205 , gobx2 + 65 , goby2 + 215 , black)
    % --------
    %|Left Arm|
    % --------
    Draw.FillBox ( gobx + 40 , goby + 190 , gobx2 + 45 , goby2 + 205 , green)
    Draw.Box ( gobx + 40 , goby + 190 , gobx2 + 45 , goby2 + 205 , black)
    Draw.FillBox ( gobx + 40 , goby + 190 , gobx2 + 45 , goby2 + 195 , brown)
    Draw.Box ( gobx + 40 , goby + 190 , gobx2 + 45 , goby2 + 195 , black)
    Draw.Line ( gobx + 43 , goby + 190 , gobx2 + 43 , goby2 + 193 , black)
    % ---------
    %|Right Arm|
    % ---------
    Draw.FillBox ( gobx + 65 , goby + 190 , gobx2 + 70 , goby2 + 205 , green)
    Draw.Box ( gobx + 65 , goby + 190 , gobx2 + 70 , goby2 + 205 , black)
    Draw.FillBox ( gobx + 65 , goby + 190 , gobx2 + 70 , goby2 + 195 , brown)
    Draw.Box ( gobx + 65 , goby + 190 , gobx2 + 70 , goby2 + 195 , black)
    Draw.Line ( gobx + 67 , goby + 190 , gobx2 + 67 , goby2 + 193 , black)
    % ---------
    %|Left Foot|
    % ---------
    Draw.FillBox ( gobx + 48 , goby + 190 , gobx2 + 53 , goby2 + 195 , green)
    Draw.Box ( gobx + 48 , goby + 190 , gobx2 + 53 , goby2 + 195 , black)
    % ----------
    %|Right Foot|
    % ----------
    Draw.FillBox ( gobx + 58 , goby + 190 , gobx2 + 63 , goby2 + 195 , green)
    Draw.Box ( gobx + 58 , goby + 190 , gobx2 + 63 , goby2 + 195 , black)
end  DrawMap1Goblin1
% ------------------------------
%|Map 1 Goblin 1 Health Bar Full|
% ------------------------------
procedure  DrawMap1Goblin1Health
    Draw.FillBox ( gobhx, gobhy, gobhx2, gobhy2, 12)
    Draw.Box ( gobhx, gobhy, 250 , gobhy2, white)
end  DrawMap1Goblin1Health
% -----------------
%|Player Procedures|
% -----------------
% --------------
%|Draw Player Up|
% --------------
procedure  PlayerMoveUp
    % ----
    %|Helm|
    % ----
    Draw.FillBox ( plx, ply, plx2, ply2, grey)
    Draw.Box ( plx, ply, plx2, ply2, black)
    % ---------
    %|Left Foot|
    % ---------
    Draw.FillBox ( plx + 4 , ply + 20 , plx2 - 11 , ply2 + 5 , grey)
    Draw.Box ( plx + 4 , ply + 20 , plx2 - 11 , ply2 + 5 , black)
    % ---------
    %|Right Foot|
    % ---------
    Draw.FillBox ( plx + 11 , ply + 20 , plx2 - 4 , ply2 + 5 , grey)
    Draw.Box ( plx + 11 , ply + 20 , plx2 - 4 , ply2 + 5 , black)
    % --------
    %|Left Arm|
    % --------
    Draw.FillBox ( plx - 5 , ply + 2 , plx2 - 20 , ply2 + 10 , grey)
    Draw.Box ( plx - 5 , ply + 2 , plx2 - 20 , ply2 + 10 , black)
    Draw.Line ( plx - 5 , ply + 25 , plx2 - 20 , ply2 + 5 , black)
    % ---------
    %|Right Arm|
    % ---------
    Draw.FillBox ( plx + 20 , ply + 2 , plx2 + 5 , ply2 + 10 , grey)
    Draw.Box ( plx + 20 , ply + 2 , plx2 + 5 , ply2 + 10 , black)
    Draw.Line ( plx + 20 , ply + 25 , plx2 + 5 , ply2 + 5 , black)
    % --------------
    %|Helm Left Horn|
    % --------------
    Draw.Line ( plx, ply, plx2 - 20 , ply2, black)
    Draw.FillBox ( plx - 10 , ply + 6 , plx2 - 25 , ply2 - 6 , brown)
    Draw.Box ( plx - 10 , ply + 6 , plx2 - 25 , ply2 - 6 , black)
    Draw.FillBox ( plx - 13 , ply + 8 , plx2 - 30 , ply2 - 8 , brown)
    Draw.Box ( plx - 13 , ply + 8 , plx2 - 30 , ply2 - 8 , black)
    Draw.Box ( plx, ply, plx2, ply2, black)
    Draw.FillBox ( plx - 5 , ply + 5 , plx2 - 15 , ply2 - 5 , brown)
    Draw.Box ( plx - 5 , ply + 5 , plx2 - 15 , ply2 - 5 , black)
    Draw.Line ( plx, ply, plx2 - 20 , ply2, black)
    % ---------------
    %|Helm Right Horn|
    % ---------------
    Draw.Line ( plx + 20 , ply, plx2, ply2, black)
    Draw.FillBox ( plx + 25 , ply + 6 , plx2 + 10 , ply2 - 6 , brown)
    Draw.Box ( plx + 25 , ply + 6 , plx2 + 10 , ply2 - 6 , black)
    Draw.FillBox ( plx + 30 , ply + 8 , plx2 + 13 , ply2 - 8 , brown)
    Draw.Box ( plx + 30 , ply + 8 , plx2 + 13 , ply2 - 8 , black)
    Draw.Box ( plx, ply, plx2, ply2, black)
    Draw.FillBox ( plx + 15 , ply + 5 , plx2 + 5 , ply2 - 5 , brown)
    Draw.Box ( plx + 15 , ply + 5 , plx2 + 5 , ply2 - 5 , black)
    Draw.Line ( plx + 20 , ply, plx2, ply2, black)
end  PlayerMoveUp
% ----------------
%|Draw Player Down|
% ----------------
procedure  PlayerMoveDown
    % ----
    %|Helm|
    % ----
    Draw.FillBox ( plx, ply, plx2, ply2, grey)
    Draw.Box ( plx, ply, plx2, ply2, black)
    % ---------
    %|Left Foot|
    % ---------
    Draw.FillBox ( plx + 4 , ply - 5 , plx2 - 11 , ply2 - 20 , grey)
    Draw.Box ( plx + 4 , ply - 5 , plx2 - 11 , ply2 - 20 , black)
    % ---------
    %|Right Foot|
    % ---------
    Draw.FillBox ( plx + 11 , ply - 5 , plx2 - 4 , ply2 - 20 , grey)
    Draw.Box ( plx + 11 , ply - 5 , plx2 - 4 , ply2 - 20 , black)
    % --------
    %|Left Arm|
    % --------
    Draw.FillBox ( plx - 5 , ply - 10 , plx2 - 20 , ply2 - 2 , grey)
    Draw.Box ( plx - 5 , ply - 10 , plx2 - 20 , ply2 - 2 , black)
    Draw.Line ( plx - 5 , ply - 5 , plx2 - 20 , ply2 - 25 , black)
    % ---------
    %|Right Arm|
    % ---------
    Draw.FillBox ( plx + 20 , ply - 10 , plx2 + 5 , ply2 - 2 , grey)
    Draw.Box ( plx + 20 , ply - 10 , plx2 + 5 , ply2 - 2 , black)
    Draw.Line ( plx + 20 , ply - 5 , plx2 + 5 , ply2 - 25 , black)
    % --------------
    %|Helm Left Horn|
    % --------------
    Draw.Line ( plx, ply, plx2 - 20 , ply2, black)
    Draw.FillBox ( plx - 10 , ply + 6 , plx2 - 25 , ply2 - 6 , brown)
    Draw.Box ( plx - 10 , ply + 6 , plx2 - 25 , ply2 - 6 , black)
    Draw.FillBox ( plx - 13 , ply + 8 , plx2 - 30 , ply2 - 8 , brown)
    Draw.Box ( plx - 13 , ply + 8 , plx2 - 30 , ply2 - 8 , black)
    Draw.Box ( plx, ply, plx2, ply2, black)
    Draw.FillBox ( plx - 5 , ply + 5 , plx2 - 15 , ply2 - 5 , brown)
    Draw.Box ( plx - 5 , ply + 5 , plx2 - 15 , ply2 - 5 , black)
    Draw.Line ( plx, ply, plx2 - 20 , ply2, black)
    % ---------------
    %|Helm Right Horn|
    % ---------------
    Draw.Line ( plx + 20 , ply, plx2, ply2, black)
    Draw.FillBox ( plx + 25 , ply + 6 , plx2 + 10 , ply2 - 6 , brown)
    Draw.Box ( plx + 25 , ply + 6 , plx2 + 10 , ply2 - 6 , black)
    Draw.FillBox ( plx + 30 , ply + 8 , plx2 + 13 , ply2 - 8 , brown)
    Draw.Box ( plx + 30 , ply + 8 , plx2 + 13 , ply2 - 8 , black)
    Draw.Box ( plx, ply, plx2, ply2, black)
    Draw.FillBox ( plx + 15 , ply + 5 , plx2 + 5 , ply2 - 5 , brown)
    Draw.Box ( plx + 15 , ply + 5 , plx2 + 5 , ply2 - 5 , black)
    Draw.Line ( plx + 20 , ply, plx2, ply2, black)
end  PlayerMoveDown
% -----------------
%|Draw Player Right|
% -----------------
procedure  PlayerMoveRight
    % ----
    %|Helm|
    % ----
    Draw.FillBox ( plx, ply, plx2, ply2, grey)
    Draw.Box ( plx, ply, plx2, ply2, black)
    % ---------
    %|Left Foot|
    % ---------
    Draw.FillBox ( plx + 20 , ply + 4 , plx2 + 5 , ply2 - 11 , grey)
    Draw.Box ( plx + 20 , ply + 4 , plx2 + 5 , ply2 - 11 , black)
    % ---------
    %|Right Foot|
    % ---------
    Draw.FillBox ( plx + 20 , ply + 11 , plx2 + 5 , ply2 - 4 , grey)
    Draw.Box ( plx + 20 , ply + 11 , plx2 + 5 , ply2 - 4 , black)
    % --------
    %|Left Arm|
    % --------
    Draw.FillBox ( plx + 2 , ply + 20 , plx2 + 10 , ply2 + 5 , grey)
    Draw.Box ( plx + 2 , ply + 20 , plx2 + 10 , ply2 + 5 , black)
    Draw.Line ( plx + 25 , ply + 20 , plx2 + 5 , ply2 + 5 , black)
    % ---------
    %|Right Arm|
    % ---------
    Draw.FillBox ( plx + 2 , ply - 5 , plx2 + 10 , ply2 - 20 , grey)
    Draw.Box ( plx + 2 , ply - 5 , plx2 + 10 , ply2 - 20 , black)
    Draw.Line ( plx + 25 , ply - 5 , plx2 + 5 , ply2 - 20 , black)
    % --------------
    %|Helm Left Horn|
    % --------------
    Draw.Line ( plx, ply, plx2, ply2 - 20 , black)
    Draw.FillBox ( plx + 6 , ply - 10 , plx2 - 6 , ply2 - 25 , brown)
    Draw.Box ( plx + 6 , ply - 10 , plx2 - 6 , ply2 - 25 , black)
    Draw.FillBox ( plx + 8 , ply - 13 , plx2 - 8 , ply2 - 30 , brown)
    Draw.Box ( plx + 8 , ply - 13 , plx2 - 8 , ply2 - 30 , black)
    Draw.Box ( plx, ply, plx2, ply2, black)
    Draw.FillBox ( plx + 5 , ply - 5 , plx2 - 5 , ply2 - 15 , brown)
    Draw.Box ( plx + 5 , ply - 5 , plx2 - 5 , ply2 - 15 , black)
    Draw.Line ( plx, ply, plx2, ply2 - 20 , black)
    % ---------------
    %|Helm Right Horn|
    % ---------------
    Draw.Line ( plx, ply + 20 , plx2, ply2, black)
    Draw.FillBox ( plx + 6 , ply + 25 , plx2 - 6 , ply2 + 10 , brown)
    Draw.Box ( plx + 6 , ply + 25 , plx2 - 6 , ply2 + 10 , black)
    Draw.FillBox ( plx + 8 , ply + 30 , plx2 - 8 , ply2 + 13 , brown)
    Draw.Box ( plx + 8 , ply + 30 , plx2 - 8 , ply2 + 13 , black)
    Draw.Box ( plx, ply, plx2, ply2, black)
    Draw.FillBox ( plx + 5 , ply + 15 , plx2 - 5 , ply2 + 5 , brown)
    Draw.Box ( plx + 5 , ply + 15 , plx2 - 5 , ply2 + 5 , black)
    Draw.Line ( plx, ply + 20 , plx2, ply2, black)
end  PlayerMoveRight
% ----------------
%|Draw Player Left|
% ----------------
procedure  PlayerMoveLeft
    % ----
    %|Helm|
    % ----
    Draw.FillBox ( plx, ply, plx2, ply2, grey)
    Draw.Box ( plx, ply, plx2, ply2, black)
    % ----------
    %|Right Foot|
    % ----------
    Draw.FillBox ( plx - 5 , ply + 11 , plx2 - 20 , ply2 - 4 , grey)
    Draw.Box ( plx - 5 , ply + 11 , plx2 - 20 , ply2 - 4 , black)
    % ---------
    %|Left Foot|
    % ---------
    Draw.FillBox ( plx - 5 , ply + 4 , plx2 - 20 , ply2 - 11 , grey)
    Draw.Box ( plx - 5 , ply + 4 , plx2 - 20 , ply2 - 11 , black)
    % ---------
    %|Right Arm|
    % ---------
    Draw.FillBox ( plx - 10 , ply - 5 , plx2 - 2 , ply2 - 20 , grey)
    Draw.Box ( plx - 10 , ply - 5 , plx2 - 2 , ply2 - 20 , black)
    Draw.Line ( plx - 5 , ply - 5 , plx2 - 25 , ply2 - 20 , black)
    % ---------
    %|Left Arm|
    % ---------
    Draw.FillBox ( plx - 10 , ply + 20 , plx2 - 2 , ply2 + 5 , grey)
    Draw.Box ( plx - 10 , ply + 20 , plx2 - 2 , ply2 + 5 , black)
    Draw.Line ( plx - 5 , ply + 20 , plx2 - 25 , ply2 + 5 , black)
    % ---------------
    %|Helm Right Horn|
    % ---------------
    Draw.Line ( plx, ply, plx2, ply2 - 20 , black)
    Draw.FillBox ( plx + 6 , ply - 10 , plx2 - 6 , ply2 - 25 , brown)
    Draw.Box ( plx + 6 , ply - 10 , plx2 - 6 , ply2 - 25 , black)
    Draw.FillBox ( plx + 8 , ply - 13 , plx2 - 8 , ply2 - 30 , brown)
    Draw.Box ( plx + 8 , ply - 13 , plx2 - 8 , ply2 - 30 , black)
    Draw.Box ( plx, ply, plx2, ply2, black)
    Draw.FillBox ( plx + 5 , ply - 5 , plx2 - 5 , ply2 - 15 , brown)
    Draw.Box ( plx + 5 , ply - 5 , plx2 - 5 , ply2 - 15 , black)
    Draw.Line ( plx, ply, plx2, ply2 - 20 , black)
    % ---------------
    %|Left Right Horn|
    % ---------------
    Draw.Line ( plx, ply + 20 , plx2, ply2, black)
    Draw.FillBox ( plx + 6 , ply + 25 , plx2 - 6 , ply2 + 10 , brown)
    Draw.Box ( plx + 6 , ply + 25 , plx2 - 6 , ply2 + 10 , black)
    Draw.FillBox ( plx + 8 , ply + 30 , plx2 - 8 , ply2 + 13 , brown)
    Draw.Box ( plx + 8 , ply + 30 , plx2 - 8 , ply2 + 13 , black)
    Draw.Box ( plx, ply, plx2, ply2, black)
    Draw.FillBox ( plx + 5 , ply + 15 , plx2 - 5 , ply2 + 5 , brown)
    Draw.Box ( plx + 5 , ply + 15 , plx2 - 5 , ply2 + 5 , black)
    Draw.Line ( plx, ply + 20 , plx2, ply2, black)
end  PlayerMoveLeft
%----------------------
%|Draw Player Attack Up|
% ---------------------
procedure  PlayerAttackUp
    if  keys ('a') then 
        plswu := true
        % -----
        %|Sword|
        % -----
        Draw.FillBox ( plx + 20 , ply + 40 , plx2 + 5 , ply2 + 55 , grey)
        Draw.Box ( plx + 20 , ply + 40 , plx2 + 5 , ply2 + 55 , black)
        Draw.Line ( plx + 22 , ply + 40 , plx2 + 2 , ply2 + 55 , black)
        Draw.Line ( plx + 23 , ply + 40 , plx2 + 3 , ply2 + 55 , black)
        % ------------
        %|Sword Handle|
        % ------------
        Draw.FillBox ( plx + 20 , ply + 30 , plx2 + 5 , ply2 + 15 , brown)
        Draw.Box ( plx + 20 , ply + 30 , plx2 + 5 , ply2 + 15 , black)
        Draw.FillBox ( plx + 15 , ply + 35 , plx2 + 10 , ply2 + 20 , brown)
        Draw.Box ( plx + 15 , ply + 35 , plx2 + 10 , ply2 + 20 , black)
        Draw.FillBox ( plx + 20 , ply + 35 , plx2 + 5 , ply2 + 20 , yellow)
        Draw.Box ( plx + 20 , ply + 35 , plx2 + 5 , ply2 + 20 , black)
    else 
        plswu := false
    end if
end  PlayerAttackUp
% -----------------------
%|Draw Player Attack Down|
% -----------------------
procedure  PlayerAttackDown
    if  keys ('a') then 
        plswd := true
        % -----
        %|Sword|
        % -----
        Draw.FillBox ( plx - 5 , ply - 55 , plx2 - 20 , ply2 - 40 , grey)
        Draw.Box ( plx - 5 , ply - 55 , plx2 - 20 , ply2 - 40 , black)
        Draw.Line ( plx - 3 , ply - 55 , plx2 - 23 , ply2 - 40 , black)
        Draw.Line ( plx - 2 , ply - 55 , plx2 - 22 , ply2 - 40 , black)
        % ------------
        %|Sword Handle|
        % ------------
        Draw.FillBox ( plx - 5 , ply - 15 , plx2 - 20 , ply2 - 30 , brown)
        Draw.Box ( plx - 5 , ply - 15 , plx2 - 20 , ply2 - 30 , black)
        Draw.FillBox ( plx - 10 , ply - 20 , plx2 - 15 , ply2 - 35 , brown)
        Draw.Box ( plx - 10 , ply - 20 , plx2 - 15 , ply2 - 35 , black)
        Draw.FillBox ( plx - 5 , ply - 20 , plx2 - 20 , ply2 - 35 , yellow)
        Draw.Box ( plx - 5 , ply - 20 , plx2 - 20 , ply2 - 35 , black)
    else 
        plswd := false
    end if
end  PlayerAttackDown
% ------------------------
%|Draw Player Attack Right|
% ------------------------
procedure  PlayerAttackRight
    if  keys ('a') then 
        plswr := true
        % -----
        %|Sword|
        % -----
        Draw.FillBox ( plx + 40 , ply - 5 , plx2 + 55 , ply2 - 20 , grey)
        Draw.Box ( plx + 40 , ply - 5 , plx2 + 55 , ply2 - 20 , black)
        Draw.Line ( plx + 40 , ply - 2 , plx2 + 55 , ply2 - 23 , black)
        Draw.Line ( plx + 40 , ply - 3 , plx2 + 55 , ply2 - 22 , black)
        % ------------
        %|Sword Handle|
        % ------------
        Draw.FillBox ( plx + 30 , ply - 5 , plx2 + 15 , ply2 - 20 , brown)
        Draw.Box ( plx + 30 , ply - 5 , plx2 + 15 , ply2 - 20 , black)
        Draw.FillBox ( plx + 35 , ply - 10 , plx2 + 20 , ply2 - 15 , brown)
        Draw.Box ( plx + 35 , ply - 10 , plx2 + 20 , ply2 - 15 , black)
        Draw.FillBox ( plx + 35 , ply - 5 , plx2 + 20 , ply2 - 20 , yellow)
        Draw.Box ( plx + 35 , ply - 5 , plx2 + 20 , ply2 - 20 , black)
    else 
        plswr := false
    end if
end  PlayerAttackRight
% -----------------------
%|Draw Player Attack Left|
% -----------------------
procedure  PlayerAttackLeft
    if  keys ('a') then 
        plswl := true
        % -----
        %|Sword|
        % -----
        Draw.FillBox ( plx - 55 , ply + 20 , plx2 - 40 , ply2 + 5 , grey)
        Draw.Box ( plx - 55 , ply + 20 , plx2 - 40 , ply2 + 5 , black)
        Draw.Line ( plx - 55 , ply + 23 , plx2 - 40 , ply2 + 2 , black)
        Draw.Line ( plx - 55 , ply + 22 , plx2 - 40 , ply2 + 3 , black)
        % ------------
        %|Sword Handle|
        % ------------
        Draw.FillBox ( plx - 15 , ply + 20 , plx2 - 30 , ply2 + 5 , brown)
        Draw.Box ( plx - 15 , ply + 20 , plx2 - 30 , ply2 + 5 , black)
        Draw.FillBox ( plx - 20 , ply + 15 , plx2 - 35 , ply2 + 10 , brown)
        Draw.Box ( plx - 20 , ply + 15 , plx2 - 35 , ply2 + 10 , black)
        Draw.FillBox ( plx - 20 , ply + 20 , plx2 - 35 , ply2 + 5 , yellow)
        Draw.Box ( plx - 20 , ply + 20 , plx2 - 35 , ply2 + 5 , black)
    else 
        plswl := false
    end if
end  PlayerAttackLeft
% --------------
%|Map Procedures|
% --------------
% ----------
%|Draw Map 1|
% ----------
procedure  DrawMap1
    % -----
    %}Floor|
    % -----
    colorback (25)
    % ----
    %|Exit|
    % ----
    Draw.FillBox (999 , 625 , 1024 , 700 , brown)
    Draw.Box (999 , 625 , 1023 , 700 , black)
end  DrawMap1
%fork Background
% ----------
%|Begin Game|
% ----------
loop
    % ----------
    %|Draw Map 1|
    % ---------- 
    DrawMap1
    % ------------------
    %|Draw Map 1 Enemies|
    % ------------------ 
    DrawMap1Goblin1
    % -------------------------
    %|Player VS. Map 1 Goblin 1|
    % -------------------------
    % ----------------
    %|Player Attack Up|
    % ----------------
    if  plx + 20  < gobx2 + 60 and  plx2 + 5  > gobx + 50 and  ply + 40  < goby2 + 210 and  ply2 + 55  > goby + 200 and  plswu = true then 
        gobhx2 :=  gobhx2 - 1
        if  gobhx2 = 0 then
            Draw.FillOval (55 , 200 , 20 , 20 , red) 
            gobx :=  -9999 
            goby :=  -9999 
            gobx2 :=  -9999 
            goby2 :=  -9999
        end if
    elsif  plx + 20  < gobx2 + 60 and  plx2 + 5  > gobx + 50 and  ply + 40  < goby2 + 210 and  ply2 + 55  > goby + 200 and  plswu = false then
    end if
    if  gobx =  -9999 then
        Draw.FillOval (60 , 210 , 20 , 20 , red)
    end if
    % ------------------
    %|Player Attack Down|
    % ------------------
    if  plx - 5  < gobx2 + 60 and  plx2 - 20  > gobx + 50 and  ply - 55  < goby2 + 210 and  ply2 - 40  > goby + 200 and  plswd = true then 
        gobhx2 :=  gobhx2 - 1
        if  gobhx2 = 0 then
            Draw.FillOval (55 , 200 , 20 , 20 , red) 
            gobx :=  -9999 
            goby :=  -9999 
            gobx2 :=  -9999 
            goby2 :=  -9999
        end if
    elsif  plx - 5  < gobx2 + 60 and  plx2 - 20  > gobx + 50 and  ply - 55  < goby2 + 210 and  ply2 - 40  > goby + 200 and  plswd = false then
    end if
    if  gobx =  -9999 then
        Draw.FillOval (60 , 210 , 20 , 20 , red)
    end if
    % -------------------
    %|Player Attack Right|
    % -------------------
    if  plx + 40  < gobx2 + 60 and  plx2 + 55  > gobx + 50 and  ply - 5  < goby2 + 210 and  ply2 - 20  > goby + 200 and  plswr = true then 
        gobhx2 :=  gobhx2 - 1
        if  gobhx2 = 0 then
            Draw.FillOval (55 , 200 , 20 , 20 , red) 
            gobx :=  -9999 
            goby :=  -9999 
            gobx2 :=  -9999 
            goby2 :=  -9999
        end if
    elsif  plx + 40  < gobx2 + 60 and  plx2 + 55  > gobx + 50 and  ply - 5  < goby2 + 210 and  ply2 - 20  > goby + 200 and  plswr = false then
    end if
    if  gobx =  -9999 then
        Draw.FillOval (60 , 210 , 20 , 20 , red)
    end if
    % ------------------
    %|Player Attack Left|
    % ------------------
    if  plx - 55  < gobx2 + 60 and  plx2 - 40  > gobx + 50 and  ply + 20  < goby2 + 210 and  ply2 + 5  > goby + 200 and  plswl = true then 
        gobhx2 :=  gobhx2 - 1
        if  gobhx2 = 0 then
            Draw.FillOval (55 , 200 , 20 , 20 , red) 
            gobx :=  -9999 
            goby :=  -9999 
            gobx2 :=  -9999 
            goby2 :=  -9999
        end if
    elsif  plx - 55  < gobx2 + 60 and  plx2 - 40  > gobx + 50 and  ply + 20  < goby2 + 210 and  ply2 + 5  > goby + 200 and  plswl = false then
    end if
    if  gobx =  -9999 then
        Draw.FillOval (60 , 210 , 20 , 20 , red)
    end if
    % ------------------------
    %|Player Movement & Attack|
    % ------------------------
    Input.KeyDown ( keys)
    if  keys (KEY_UP_ARROW) then 
        ply += 1 
        ply2 += 1 
        PlayerMoveUp
 
        PlayerAttackUp
 
        plmov := 0 
        platt := 0
    end if
    if  plmov = 0 then 
        PlayerMoveUp
    end if
    if  platt = 0 then 
        PlayerAttackUp
    end if
    if  keys (KEY_DOWN_ARROW) then 
        ply -= 1 
        ply2 -= 1 
        PlayerMoveDown
 
        PlayerAttackDown
 
        plmov := 1 
        platt := 1
    end if
    if  plmov = 1 then 
        PlayerMoveDown
    end if
    if  platt = 1 then 
        PlayerAttackDown
    end if
    if  keys (KEY_RIGHT_ARROW) then 
        plx += 1 
        plx2 += 1 
        PlayerMoveRight
 
        PlayerAttackRight
 
        plmov := 2 
        platt := 2
    end if
    if  plmov = 2 then 
        PlayerMoveRight
    end if
    if  platt = 2 then 
        PlayerAttackRight
    end if
    if  keys (KEY_LEFT_ARROW) then 
        plx -= 1 
        plx2 -= 1 
        PlayerMoveLeft
 
        PlayerAttackLeft
 
        plmov := 3 
        platt := 3
    end if
    if  plmov = 3 then 
        PlayerMoveLeft
    end if
    if  platt = 3 then 
        PlayerAttackLeft
    end if
    % ----------------
    %|Draw Status Bars|
    % ----------------
    Draw.FillBox (0 , 718 , 1024 , 768 , black)
    Draw.FillBox (0 , 0 , 1024 , 50 , black) 
    DrawMap1Goblin1Health
    Draw.Text ("Goblin 1", 100 , 740 , font, white)
    View.Update
    delay (10)
    cls
end loop | 
 |  
				|  |  |   
		|  |  |  
	  
		|  |   
		| Sponsor Sponsor
 
  
   |  |   
		|  |   
		| Insectoid 
 
  
 
 
 | 
			
				|  Posted: Wed Dec 10, 2008 4:30 pm    Post subject: RE:Game Attack Key |  |   
				| 
 |  
				| Once again; Boolean variables. You can use the same variable as you did for the atack animation. If the attack key is pressed, and the boolean variable is false, attack. |  
				|  |  |   
		|  |  |  
	  
		|  |   
		| Spence607 
 
  
 
 
 | 
			
				|  Posted: Wed Dec 10, 2008 5:27 pm    Post subject: Re: RE:Game Attack Key |  |   
				| 
 |  
				| insectoid @ Wed Dec 10, 2008 4:30 pm wrote: Once again; Boolean variables. You can use the same variable as you did for the atack animation. If the attack key is pressed, and the boolean variable is false, attack. 
 If I understood what you meant... this is what I did:
 
 
 	  | Turing: |  	  | 
%----------------------
%|Draw Player Attack Up|
% ---------------------
procedure PlayerAttackUp
    if  keys ('a') and  plswu = false then 
        plswu := true
        % -----
        %|Sword|
        % -----
        Draw.FillBox ( plx + 20 , ply + 40 , plx2 + 5 , ply2 + 55 , grey)
        Draw.Box ( plx + 20 , ply + 40 , plx2 + 5 , ply2 + 55 , black)
        Draw.Line ( plx + 22 , ply + 40 , plx2 + 2 , ply2 + 55 , black)
        Draw.Line ( plx + 23 , ply + 40 , plx2 + 3 , ply2 + 55 , black)
        % ------------
        %|Sword Handle|
        % ------------
        Draw.FillBox ( plx + 20 , ply + 30 , plx2 + 5 , ply2 + 15 , brown)
        Draw.Box ( plx + 20 , ply + 30 , plx2 + 5 , ply2 + 15 , black)
        Draw.FillBox ( plx + 15 , ply + 35 , plx2 + 10 , ply2 + 20 , brown)
        Draw.Box ( plx + 15 , ply + 35 , plx2 + 10 , ply2 + 20 , black)
        Draw.FillBox ( plx + 20 , ply + 35 , plx2 + 5 , ply2 + 20 , yellow)
        Draw.Box ( plx + 20 , ply + 35 , plx2 + 5 , ply2 + 20 , black)
    else 
        plswu := false
    end if
end  PlayerAttackUp
% -----------------------
%|Draw Player Attack Down|
% -----------------------
procedure  PlayerAttackDown
    if  keys ('a') and  plswd = false then 
        plswd := true
        % -----
        %|Sword|
        % -----
        Draw.FillBox ( plx - 5 , ply - 55 , plx2 - 20 , ply2 - 40 , grey)
        Draw.Box ( plx - 5 , ply - 55 , plx2 - 20 , ply2 - 40 , black)
        Draw.Line ( plx - 3 , ply - 55 , plx2 - 23 , ply2 - 40 , black)
        Draw.Line ( plx - 2 , ply - 55 , plx2 - 22 , ply2 - 40 , black)
        % ------------
        %|Sword Handle|
        % ------------
        Draw.FillBox ( plx - 5 , ply - 15 , plx2 - 20 , ply2 - 30 , brown)
        Draw.Box ( plx - 5 , ply - 15 , plx2 - 20 , ply2 - 30 , black)
        Draw.FillBox ( plx - 10 , ply - 20 , plx2 - 15 , ply2 - 35 , brown)
        Draw.Box ( plx - 10 , ply - 20 , plx2 - 15 , ply2 - 35 , black)
        Draw.FillBox ( plx - 5 , ply - 20 , plx2 - 20 , ply2 - 35 , yellow)
        Draw.Box ( plx - 5 , ply - 20 , plx2 - 20 , ply2 - 35 , black)
    else 
        plswd := false
    end if
end  PlayerAttackDown
% ------------------------
%|Draw Player Attack Right|
% ------------------------
procedure  PlayerAttackRight
    if  keys ('a') and  plswr = false then 
        plswr := true
        % -----
        %|Sword|
        % -----
        Draw.FillBox ( plx + 40 , ply - 5 , plx2 + 55 , ply2 - 20 , grey)
        Draw.Box ( plx + 40 , ply - 5 , plx2 + 55 , ply2 - 20 , black)
        Draw.Line ( plx + 40 , ply - 2 , plx2 + 55 , ply2 - 23 , black)
        Draw.Line ( plx + 40 , ply - 3 , plx2 + 55 , ply2 - 22 , black)
        % ------------
        %|Sword Handle|
        % ------------
        Draw.FillBox ( plx + 30 , ply - 5 , plx2 + 15 , ply2 - 20 , brown)
        Draw.Box ( plx + 30 , ply - 5 , plx2 + 15 , ply2 - 20 , black)
        Draw.FillBox ( plx + 35 , ply - 10 , plx2 + 20 , ply2 - 15 , brown)
        Draw.Box ( plx + 35 , ply - 10 , plx2 + 20 , ply2 - 15 , black)
        Draw.FillBox ( plx + 35 , ply - 5 , plx2 + 20 , ply2 - 20 , yellow)
        Draw.Box ( plx + 35 , ply - 5 , plx2 + 20 , ply2 - 20 , black)
    else 
        plswr := false
    end if
end  PlayerAttackRight
% -----------------------
%|Draw Player Attack Left|
% -----------------------
procedure  PlayerAttackLeft
    if  keys ('a') and  plswl = false then 
        plswl := true
        % -----
        %|Sword|
        % -----
        Draw.FillBox ( plx - 55 , ply + 20 , plx2 - 40 , ply2 + 5 , grey)
        Draw.Box ( plx - 55 , ply + 20 , plx2 - 40 , ply2 + 5 , black)
        Draw.Line ( plx - 55 , ply + 23 , plx2 - 40 , ply2 + 2 , black)
        Draw.Line ( plx - 55 , ply + 22 , plx2 - 40 , ply2 + 3 , black)
        % ------------
        %|Sword Handle|
        % ------------
        Draw.FillBox ( plx - 15 , ply + 20 , plx2 - 30 , ply2 + 5 , brown)
        Draw.Box ( plx - 15 , ply + 20 , plx2 - 30 , ply2 + 5 , black)
        Draw.FillBox ( plx - 20 , ply + 15 , plx2 - 35 , ply2 + 10 , brown)
        Draw.Box ( plx - 20 , ply + 15 , plx2 - 35 , ply2 + 10 , black)
        Draw.FillBox ( plx - 20 , ply + 20 , plx2 - 35 , ply2 + 5 , yellow)
        Draw.Box ( plx - 20 , ply + 20 , plx2 - 35 , ply2 + 5 , black)
    else 
        plswl := false
    end if
end  PlayerAttackLeft
 | 
 
 An attack is continuously made.. this is better, but not what I want exactly.. What I want exactly is if you press and hold the key only one attack occurs. Which in turn forces the player to repeatably hit the key to attack... The faster, the more damage done.
 |  
				|  |  |   
		|  |  |  
	  
		|  |   
		| S_Grimm 
 
  
 
 
 | 
			
				|  Posted: Wed Dec 10, 2008 5:37 pm    Post subject: RE:Game Attack Key |  |   
				| 
 |  
				| like insectoid said : Boolean Variables 
 	  | code: |  	  | if (a is pressed) then
attack = true
 end if
 if attack = true then
 attack
 attack = false
 end if
 
 | 
 
 Mod Edit: Remember to tag! Thanks
 |  
				|  |  |   
		|  |  |  
	  
		|  |   
		| Spence607 
 
  
 
 
 | 
			
				|  Posted: Wed Dec 10, 2008 5:46 pm    Post subject: Re: RE:Game Attack Key |  |   
				| 
 |  
				| AV @ Wed Dec 10, 2008 5:37 pm wrote: like insectoid said : Boolean Variables
 	  | code: |  	  | if (a is pressed) then
attack = true
 end if
 if attack = true then
 attack
 attack = false
 end if
 
 | 
 
 Mod Edit: Remember to tag! Thanks
 So.. like this?
 
 
 	  | Turing: |  	  | 
%----------------------
%|Draw Player Attack Up|
% ---------------------
procedure PlayerAttackUp
    if  keys ('a') then 
        plswu := true
    end if
    if  plswu = true then
    % -----
    %|Sword|
    % -----
    Draw.FillBox ( plx + 20 , ply + 40 , plx2 + 5 , ply2 + 55 , grey)
    Draw.Box ( plx + 20 , ply + 40 , plx2 + 5 , ply2 + 55 , black)
    Draw.Line ( plx + 22 , ply + 40 , plx2 + 2 , ply2 + 55 , black)
    Draw.Line ( plx + 23 , ply + 40 , plx2 + 3 , ply2 + 55 , black)
    % ------------
    %|Sword Handle|
    % ------------
    Draw.FillBox ( plx + 20 , ply + 30 , plx2 + 5 , ply2 + 15 , brown)
    Draw.Box ( plx + 20 , ply + 30 , plx2 + 5 , ply2 + 15 , black)
    Draw.FillBox ( plx + 15 , ply + 35 , plx2 + 10 , ply2 + 20 , brown)
    Draw.Box ( plx + 15 , ply + 35 , plx2 + 10 , ply2 + 20 , black)
    Draw.FillBox ( plx + 20 , ply + 35 , plx2 + 5 , ply2 + 20 , yellow)
    Draw.Box ( plx + 20 , ply + 35 , plx2 + 5 , ply2 + 20 , black)
    delay (1) 
    plswu := false
end if | 
 
 This does nothing.. no damage is applied.
 |  
				|  |  |   
		|  |  |  
	  
		|  |   
		| drij 
 
 
 
 
 | 
			
				|  Posted: Wed Dec 10, 2008 8:32 pm    Post subject: Re: Game Attack Key |  |   
				| 
 |  
				| Try this: 
 	  | code: |  	  | if (a is pressed) and canAttack then
attack
 canAttack := false
 elsif not (a is pressed) then
 canAttack := true
 end if
 | 
 where canAttack is a boolean variable.
 |  
				|  |  |   
		|  |  |  
	  
		|  |   
		| Spence607 
 
  
 
 
 | 
			
				|  Posted: Wed Dec 10, 2008 8:41 pm    Post subject: Re: Game Attack Key |  |   
				| 
 |  
				| drij @ Wed Dec 10, 2008 8:32 pm wrote: Try this:
 	  | code: |  	  | if (a is pressed) and canAttack then
attack
 canAttack := false
 elsif not (a is pressed) then
 canAttack := true
 end if
 | 
 where canAttack is a boolean variable.
 Nope.. right after one attack the enemies health decreases to zero quickly.
 |  
				|  |  |   
		|  |  |  
	  
		|  |   
		| drij 
 
 
 
 
 | 
			
				|  Posted: Wed Dec 10, 2008 8:58 pm    Post subject: Re: Game Attack Key |  |   
				| 
 |  
				| You might just have implemented it incorrectly, because this code works: 
 	  | Turing: |  	  | var canAttack : boolean := true
procedure  PlayerAttackUp
    if  keys ('a') then
        if  canAttack then 
            plswu := true 
            canAttack := false
        else 
            plswu := false
        end if
        % -----
        %|Sword|
        % -----
        Draw.FillBox ( plx + 20 , ply + 40 , plx2 + 5 , ply2 + 55 , grey)
        Draw.Box ( plx + 20 , ply + 40 , plx2 + 5 , ply2 + 55 , black)
        Draw.Line ( plx + 22 , ply + 40 , plx2 + 2 , ply2 + 55 , black)
        Draw.Line ( plx + 23 , ply + 40 , plx2 + 3 , ply2 + 55 , black)
        % ------------
        %|Sword Handle|
        % ------------
        Draw.FillBox ( plx + 20 , ply + 30 , plx2 + 5 , ply2 + 15 , brown)
        Draw.Box ( plx + 20 , ply + 30 , plx2 + 5 , ply2 + 15 , black)
        Draw.FillBox ( plx + 15 , ply + 35 , plx2 + 10 , ply2 + 20 , brown)
        Draw.Box ( plx + 15 , ply + 35 , plx2 + 10 , ply2 + 20 , black)
        Draw.FillBox ( plx + 20 , ply + 35 , plx2 + 5 , ply2 + 20 , yellow)
        Draw.Box ( plx + 20 , ply + 35 , plx2 + 5 , ply2 + 20 , black)
    elsif not  keys ('a') then 
        canAttack := true
    else 
        plswu := false
    end if
end  PlayerAttackUp | 
 
 Notice that it always displays the sword if you are pressing the a key, but only attacks once per keypress
 |  
				|  |  |   
		|  |  |  
	  
		|  |   
		| Sponsor Sponsor
 
  
   |  |   
		|  |   
		| Spence607 
 
  
 
 
 | 
			
				|  Posted: Wed Dec 10, 2008 9:05 pm    Post subject: Re: Game Attack Key |  |   
				| 
 |  
				| drij @ Wed Dec 10, 2008 8:58 pm wrote: You might just have implemented it incorrectly, because this code works:
 	  | Turing: |  	  | var canAttack : boolean := true
procedure  PlayerAttackUp
    if  keys ('a') then
        if  canAttack then 
            plswu := true 
            canAttack := false
        else 
            plswu := false
        end if
        % -----
        %|Sword|
        % -----
        Draw.FillBox ( plx + 20 , ply + 40 , plx2 + 5 , ply2 + 55 , grey)
        Draw.Box ( plx + 20 , ply + 40 , plx2 + 5 , ply2 + 55 , black)
        Draw.Line ( plx + 22 , ply + 40 , plx2 + 2 , ply2 + 55 , black)
        Draw.Line ( plx + 23 , ply + 40 , plx2 + 3 , ply2 + 55 , black)
        % ------------
        %|Sword Handle|
        % ------------
        Draw.FillBox ( plx + 20 , ply + 30 , plx2 + 5 , ply2 + 15 , brown)
        Draw.Box ( plx + 20 , ply + 30 , plx2 + 5 , ply2 + 15 , black)
        Draw.FillBox ( plx + 15 , ply + 35 , plx2 + 10 , ply2 + 20 , brown)
        Draw.Box ( plx + 15 , ply + 35 , plx2 + 10 , ply2 + 20 , black)
        Draw.FillBox ( plx + 20 , ply + 35 , plx2 + 5 , ply2 + 20 , yellow)
        Draw.Box ( plx + 20 , ply + 35 , plx2 + 5 , ply2 + 20 , black)
    elsif not  keys ('a') then 
        canAttack := true
    else 
        plswu := false
    end if
end  PlayerAttackUp | 
 
 Notice that it always displays the sword if you are pressing the a key, but only attacks once per keypress
 Yeah, I did. Awesome, this is exactly what I wanted, thanks a lot!
 |  
				|  |  |   
		|  |  |  
	  
		|  |   
		| drij 
 
 
 
 
 | 
			
				|  Posted: Thu Dec 11, 2008 2:23 pm    Post subject: Re: Game Attack Key |  |   
				| 
 |  
				| I noticed that there was an error in the way the if statements were layed in that code snippet. It should have been: 
 	  | Turing: |  	  | var canAttack : boolean := true 
procedure  PlayerAttackUp 
    if  keys ('a') then 
        if  canAttack then 
            plswu := true 
            canAttack := false 
        else 
            plswu := false 
        end if 
        % ----- 
        %|Sword| 
        % ----- 
        Draw.FillBox ( plx + 20 , ply + 40 , plx2 + 5 , ply2 + 55 , grey) 
        Draw.Box ( plx + 20 , ply + 40 , plx2 + 5 , ply2 + 55 , black) 
        Draw.Line ( plx + 22 , ply + 40 , plx2 + 2 , ply2 + 55 , black) 
        Draw.Line ( plx + 23 , ply + 40 , plx2 + 3 , ply2 + 55 , black) 
        % ------------ 
        %|Sword Handle| 
        % ------------ 
        Draw.FillBox ( plx + 20 , ply + 30 , plx2 + 5 , ply2 + 15 , brown) 
        Draw.Box ( plx + 20 , ply + 30 , plx2 + 5 , ply2 + 15 , black) 
        Draw.FillBox ( plx + 15 , ply + 35 , plx2 + 10 , ply2 + 20 , brown) 
        Draw.Box ( plx + 15 , ply + 35 , plx2 + 10 , ply2 + 20 , black) 
        Draw.FillBox ( plx + 20 , ply + 35 , plx2 + 5 , ply2 + 20 , yellow) 
        Draw.Box ( plx + 20 , ply + 35 , plx2 + 5 , ply2 + 20 , black) 
    else 
        plswu := false 
        canAttack := true 
    end if 
end  PlayerAttackUp | 
 
 Mod Edit: Fixed up typo in syntax tags
  |  
				|  |  |   
		|  |  |  
	  
		|  |   
		|  |  
 |