
-----------------------------------
Genisis
Tue Nov 01, 2005 9:36 am

why wont my paddle move
-----------------------------------
my paddle wont move can someone help me heres the code :

var winID : int
winID := Window.Open ("position:0;500,graphics:1010;708")
var moveball : int
var font1 : int
font1 := Font.New ("mono:20")
var x, y, y1, yy1, y2, yy2 : int
x := 505
y := 324
y1 := 294
yy1 := 364
y2 := 294
yy2 := 364


colorback (black)
cls

%pong paddles
drawfillbox (10, y1, 20, yy1, green)
drawfillbox (990, y2, 1000, yy2, green)
drawline (20, 0, 20, maxy, green)
drawline (990, 0, 990, maxy, green)

%court
drawbox (3, 3, maxx - 3, maxy - 3, green)
drawfill (0, 0, green, green)
drawfill (maxx, 0, green, green)
drawline (504, 0, 504, maxy, green)
drawline (506, 0, 506, maxy, green)
drawfill (505, 5, green, green)

%point system
drawline (0, maxy - 50, maxx, maxy - 50, green)
Draw.Text ("Team 1:", 22, maxy - 40, font1, green)
Draw.Text ("Team 2:", 508, maxy - 40, font1, green)

%ball

drawfilloval (x, y, 8, 8, white)

%move paddle 1
var key : array char of boolean
Input.KeyDown (key)
loop
    if key (KEY_UP_ARROW) then
        y1 := y1 + 10
    end if
    if key (KEY_UP_ARROW) then
        yy1 := yy1 + 10
    end if
    if key (KEY_DOWN_ARROW) then
        yy1 := yy1 - 10
    end if
    if key (KEY_DOWN_ARROW) then
        y1 := y1 - 10
    end if
end loop

-----------------------------------
codemage
Tue Nov 01, 2005 9:49 am


-----------------------------------
Your 'outer loop' needs to start where you're drawing the stuff to screen - not just where you're checking for use input.

In your code, the paddle is moving virtually - but that's not reflected on screen.

-----------------------------------
haseeb
Tue Nov 01, 2005 4:38 pm


-----------------------------------
Here use this code.
% The "StepperMotor" program.
% Repeats the sequence one hundred times.
for count : 1 .. 100
    % Counts 0, 1, 2, and 3 which activates D0, D1, D2,
    % and D3 successively.
    for counter : 0 .. 3
        % Outputs to the parallel port.
        parallelput (2 ** counter)
        % Delays for one-tenth of a second.
        delay (100)
    end for
end for

% Delays for two seconds.
delay (2000)

% Again, repeats pattern one hundred times.
for count : 1 .. 100
    % Counts 3, 2, 1, and 0 which activates D3, D2, D1,
    % and D0 successively.
    for decreasing counter : 3 .. 0
        % Outputs to the parallel port.
        parallelput (2 ** counter)
        % Delays for one-tenth of a second.
        delay (100)
    end for
end for

-----------------------------------
Mr. T
Tue Nov 01, 2005 7:37 pm

Alex's Opinion
-----------------------------------
Time for your monthly check-up with Dr. BAN, haseeb. :boom:

-----------------------------------
codemage
Wed Nov 02, 2005 8:47 am


-----------------------------------
I thought haseeb was already banned.  If not, it's definitely that time.

-----------------------------------
Tony
Wed Nov 02, 2005 11:47 am


-----------------------------------
I thought haseeb was already banned.
well users would usually have http://www.compsci.ca/v2/rankban.gif next to their name..

you guys got to point those newbcakes out to me sooner. Feel free to PM

-----------------------------------
Jekate
Thu Nov 03, 2005 2:28 pm


-----------------------------------
Here is a little help:


var winID : int
winID := Window.Open ("position:0;500,graphics:1010;708")
var moveball : int
var font1 : int
font1 := Font.New ("mono:20")
var x, y, y1, y2 : int
x := 505
y := 324
y1 := 294
y2 := 294


colorback (black)
cls

%pong paddles
drawfillbox (10, y1, 20, y1 + 60, green)
drawfillbox (990, y2, 1000, y2 + 60, green)
drawline (20, 0, 20, maxy, green)
drawline (990, 0, 990, maxy, green)

%court
drawbox (3, 3, maxx - 3, maxy - 3, green)
drawfill (0, 0, green, green)
drawfill (maxx, 0, green, green)
drawline (504, 0, 504, maxy, green)
drawline (506, 0, 506, maxy, green)
drawfill (505, 5, green, green)

%point system
drawline (0, maxy - 50, maxx, maxy - 50, green)
Draw.Text ("Team 1:", 22, maxy - 40, font1, green)
Draw.Text ("Team 2:", 508, maxy - 40, font1, green)

%ball

drawfilloval (x, y, 8, 8, white)

%move paddle 1
var key : array char of boolean
loop
    Input.KeyDown (key)
    if key (KEY_UP_ARROW) then
        y1 := y1 + 10
        delay(15)
    elsif key (KEY_DOWN_ARROW) then
        y1 := y1 - 10
        delay(15)
    end if
    %pong paddles
    drawfillbox (10, y1, 20, y1 + 60, green)
    drawfillbox (990, y2, 1000, y2 + 60, green)
    drawline (20, 0, 20, maxy, green)
    drawline (990, 0, 990, maxy, green)
end loop


I took out yy1 and yy2 because all you needed to do was to put "y1 + 60" or however big you wanted the paddle. You also have to put the Input.KeyDown (key) in the loop so it can get input everytime, not just once.

-----------------------------------
RedRogueXIII
Sat Nov 05, 2005 1:34 pm


-----------------------------------
Just an edit - it will refresh the paddle so that it doesnt end up with a huge green line on the side.

var winID : int
winID := Window.Open ("position:0;500,graphics:1010;708")
var moveball : int
var font1 : int
font1 := Font.New ("mono:20")
var x, y, y1, y2 : int
x := 505
y := 324
y1 := 294
y2 := 294


colorback (black)
cls

%pong paddles
drawfillbox (10, y1, 20, y1 + 60, green)
drawfillbox (990, y2, 1000, y2 + 60, green)
drawline (20, 0, 20, maxy, green)
drawline (990, 0, 990, maxy, green)

%court
drawbox (3, 3, maxx - 3, maxy - 3, green)
drawfill (0, 0, green, green)
drawfill (maxx, 0, green, green)
drawline (504, 0, 504, maxy, green)
drawline (506, 0, 506, maxy, green)
drawfill (505, 5, green, green)

%point system
drawline (0, maxy - 50, maxx, maxy - 50, green)
Draw.Text ("Team 1:", 22, maxy - 40, font1, green)
Draw.Text ("Team 2:", 508, maxy - 40, font1, green)

%ball

drawfilloval (x, y, 8, 8, white)

%move paddle 1
var key : array char of boolean
loop
    Input.KeyDown (key)
    if key (KEY_UP_ARROW) then
        y1 := y1 + 10
        delay(15)
    elsif key (KEY_DOWN_ARROW) then
        y1 := y1 - 10
        delay(15)
    end if
    %pong paddles
    drawfillbox (10, y1, 20, y1 + 60, green)
    %refresh pong paddle 1
    drawfillbox (10, y1+80 ,19, y1+90,black)
    drawfillbox (10, y1-20 ,19, y1,black)
    drawfillbox (990, y2, 1000, y2 + 60, green)
    %refresh pong paddle 2
    drawfillbox (991, y2+80 ,1000, y2+90,black)
    drawfillbox (991, y2-20 ,1000, y2,black)
    drawline (20, 0, 20, maxy, green)
    drawline (990, 0, 990, maxy, green)
end loop 


-----------------------------------
Jekate
Sat Nov 05, 2005 2:58 pm


-----------------------------------
Another suggestion is to take a picture of your background so that when the paddles or ball passes over any of the lines, the lines are still there.

-----------------------------------
Mr. T
Sat Nov 05, 2005 3:28 pm

Alex's Opinion
-----------------------------------
You don't necessarilly need a picture background in order ensure lines won't get deleted.  You just have to make sure you're redrawing everything every time the program loops.

-----------------------------------
Geminias
Sat Nov 05, 2005 3:31 pm


-----------------------------------
why is haseeb banned?  

i'm just curious so i dont also do it and get myself banned

-----------------------------------
Cervantes
Sat Nov 05, 2005 6:23 pm


-----------------------------------
why is haseeb banned?  

i'm just curious so i dont also do it and get myself banned
Spamming, inappropriately giving out answers, making totally unrelated/off topic posts.  Be sure to check out the rules announcement in General Discussion.
