Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 why wont my paddle move
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Genisis




PostPosted: Tue Nov 01, 2005 9:36 am   Post subject: why wont my paddle move

my paddle wont move can someone help me heres the code :

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
Sponsor
Sponsor
Sponsor
sponsor
codemage




PostPosted: Tue Nov 01, 2005 9:49 am   Post subject: (No subject)

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




PostPosted: Tue Nov 01, 2005 4:38 pm   Post subject: (No subject)

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




PostPosted: Tue Nov 01, 2005 7:37 pm   Post subject: Alex's Opinion

Time for your monthly check-up with Dr. BAN, haseeb. Blowing up
codemage




PostPosted: Wed Nov 02, 2005 8:47 am   Post subject: (No subject)

I thought haseeb was already banned. If not, it's definitely that time.
Tony




PostPosted: Wed Nov 02, 2005 11:47 am   Post subject: (No subject)

codemage wrote:
I thought haseeb was already banned.

well users would usually have Posted Image, might have been reduced in size. Click Image to view fullscreen. next to their name..

you guys got to point those newbcakes out to me sooner. Feel free to PM
Jekate




PostPosted: Thu Nov 03, 2005 2:28 pm   Post subject: (No subject)

Here is a little help:

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, 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




PostPosted: Sat Nov 05, 2005 1:34 pm   Post subject: (No subject)

Just an edit - it will refresh the paddle so that it doesnt end up with a huge green line on the side.
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, 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
Sponsor
Sponsor
Sponsor
sponsor
Jekate




PostPosted: Sat Nov 05, 2005 2:58 pm   Post subject: (No subject)

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




PostPosted: Sat Nov 05, 2005 3:28 pm   Post subject: 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




PostPosted: Sat Nov 05, 2005 3:31 pm   Post subject: (No subject)

why is haseeb banned?

i'm just curious so i dont also do it and get myself banned
Cervantes




PostPosted: Sat Nov 05, 2005 6:23 pm   Post subject: (No subject)

Geminias wrote:
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.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 12 Posts ]
Jump to:   


Style:  
Search: