Log In  

I have got a rectangle drawn on the screen but need help. When I move it left to right it gets bigger. I want it to stay the same size and just move. Can someone please help me with my code

x=1
x1=5
y=2
y1=2
speed=2

function _init()
cls()
end

function _update60()
if btn(0) then x=x-speed end
if btn(1) then x=x+speed end
end

function _draw()
cls()
rect(x,y,x1,y1,8)
end

P#67603 2019-09-12 22:20

X1 and Y1 are coordinates on the screen for the bottom-right corner, not the width or height of the rectangle.
You might not want to have two different variables for a fixed size rectangle.
Try something like this maybe.

rect( x, y, x+width, y+height, color)

Width and height could be a number instead of a variable if the rectangle never changes size.

I hope this helps.

P#67604 2019-09-12 22:35 ( Edited 2019-09-12 22:36)

[Please log in to post a comment]

About | Contact | Updates | Terms of Use
Follow Lexaloffle:        
Generated 2019-11-19 05:18 | 0.009s | 2097k | Q:15