I have an assignment where I have to make a ball move and make a paddle move. I cannot move onto the next step because I can't seem to get the paddle to move when i press the buttons. Any help would be appreciated. Here is what I have for a code so far.
ball_x = 3
x_speed = 1
ball_y = 15
y_speed = 1
ball_round = 3
col = 0
pad_x = 52
pad_y = 120
pad_dx = 0
pad_w = 24
pad_h = 3
pad_c = 7
function _init()
cls()
end
function _update()
ball_y = ball_y+y_speed
ball_x = ball_x+x_speed
col=col+1
pad_y = pad_y+pad_dx
pad_x = pad_x+pad_dx
pad_c=pad_c+1
buttpress = false
if btn(0)
then pad_dx =-5
end
if btn(1)
then pad_dx+=5
end
if not (buttpress) then
pad_dx = pad_dx/1.7
end
pad_x+=pad_dx
if ball_x > 127
then x_speed = -2
end
if ball_x < 0
then x_speed = 2
end
if ball_y > 127
then y_speed = -2
end
if ball_y < 0
then y_speed = 2
end
end
function _draw()
cls()
circfill(ball_x,ball_y,ball_round,col)
rectfill(30,10,3,8)
end
[Please log in to post a comment]