
-----------------------------------
STLearning
Sat Jun 12, 2010 2:03 pm

Why are the players speeding up when shooting?
-----------------------------------
What is it you are trying to achieve?
I am trying to ensure speeds stay the same even if they are shooting.

What is the problem you are having?
When the opposing player shoots, the other player slows down. However when the player shoots and moves at the same time, they go incredibly fast. When both players are shooting at the same time, and moving as well, it seems to go back to normal speeds.


Describe what you have tried to solve this problem
I've tried tinkering with delays and just about everything I could think of to make it normal, but I just can't get it right. (I also have no idea why its occurring.)
I've also tried to get rid of the processes in general, since I have a feeling that is what causing the randomness,  but I completely failed at figuring out a method of doing that without bugging the entire code.

Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)



%Developer : 
%Program Title: Dodgeball
%Version Number : 1.00
%Creation Date : May 27, 2010



%----------------------------------------------------------------------
%STARTING MENU + START BUTTON
%----------------------------------------------------------------------


import GUI                            %Required to set up GUI
setscreen ("graphics:500;400")        %Resolution
View.Set ("offscreenonly")            %Required to remove flickering

procedure hello (ch : char)
    if ch = "x" or ch = "X" then      %What happens when button is pressed -> Goes to Credits
        GUI.Quit
    end if
end hello

var quitButton : int := GUI.CreateButton (175, 50, 0, "press here when  ready", GUI.Quit)  %Creates Button
GUI.SetKeyEventHandler (hello)

View.Update

loop
    exit when GUI.ProcessEvent                %Keeps screen at button until it is clicked
end loop

%--------------------------------------------
%Credit Screen
%--------------------------------------------
cls

var font : int
font := Font.New ("Castellar:28")           %Sets font size and type for Load Bar
var loadbar : int := 50

put "Developer : 
put "Program Title: Dodgeball"
put "Version Number : 1.00"
put "Creation Date : May 27, 2010"
put "With thanks to, Compsci.ca and its members
put " "
put "Please wait while the game loads"
View.Update

for count : 1 .. 5                              %Load Bar
    Font.Draw ("LOADING", 150, 155, font, black)
    drawbox (150, 100, 350, 150, black)
    drawfillbox (150, 100, 100 + loadbar, 150, green)
    View.Update
    loadbar += 50
    delay (1000)
end for

delay (1000)

%------------------------------------------------------
%GLOBAL VARIABLES
var speed : int := 0
%------------------------------------------------------

%------------------------------------------------------
%Asking for Game Speed
%------------------------------------------------------
cls

put "Please choose your game speed"
put "For a good computer please, enter a speed from 3 to 6, depending on the speed you wish the game to run at"
put "For weaker computers, please put a delay of 1 to 2"
put "After typping in your number, please press enter "

View.Update

get speed

%---------------------------------------------------
%VARIABLES FOR MOVEMENT
var x, y : int          %stores coordinates for right player
x := 400
y := 200

var a, b : int          %stores coordinates for left player
a := 100
b := 200

var bulletx1, bulleta2, bullety1, bulletb2 : int  %Stores Bullet coordinates
var shot1, shot2 : int := 0
forward proc player1movement
forward proc player2movement
%---------------------------------------------------


%---------------------------------------------------
%Process
%---------------------------------------------------
process movement1
    player1movement
end movement1
process movement2
    player2movement
end movement2

%----------------------------------------------------
%PROCEDURES
%----------------------------------------------------
proc draw
    drawfillbox (0, 0, 50, 50, gray)
    drawbox (0, 0, maxx, maxy, black)        %Boundaries
    drawline (250, 0, 250, maxy, black)
end draw


proc shoot1
    loop
        shot1 := 1                                  %Fuifills condition to draw bullet
        bulletx1 -= 1                               %Moves location of bullet
        exit when bulletx1 + 20 < 0                %exits loop after bullet leaves screen
        player1movement
    end loop
    shot1 := 0                                     %resets bullet loop
end shoot1


proc shoot2
    loop
        shot2 := 1                          %Fuifills condition to draw bullet
        bulleta2 += 1                       %Moves location of bullet
        exit when bulleta2 + 20 > maxx      %exits loop after bullet leaves screen
        player2movement

    end loop
    shot2 := 0
end shoot2


body proc player1movement

    var chars : array char of boolean         %Movement right Player
    Input.KeyDown (chars)

    if chars (KEY_UP_ARROW) and y = 0 then  %Down Button
        y := y - 1
    end if
    if x = 250 then                             %Middle Boundary
        x := x + 0
    elsif chars (KEY_LEFT_ARROW) and x >= 0 then  %Left Button
        x := x - 1
    end if

    if chars (KEY_RIGHT_ARROW) and x = 0 then       %Left Button
        a := a - 1
    end if
    if a = 250 then                        %Middle Boundary
        a := a + 0
    elsif char1 ('d') and a 