Discord
Login
Community
DARK THEME

mouse.x and mouse.y don't change their sign

I don't know why, but when my cursor moves up and down, left and right near the zero coordinates, the values repeat, but the minus does not appear, and now because of this, I cannot make an action in a certain range work for me at minus coordinates. My code:

Blocks = [Blocl1, Blocl1,Blocl1,Blocl1,Blocl1, ]

Block1 = [0.5,0, [0,0,0,0,],[1,1,0,0,],[0,0,0,0,],[0,0,0,0,]]

sizeB1 = 18 // размер блоков на поле sizeB2 = 20 // размер блоков в руке sizeB3 = 12 // размер блоков в слотах sizeFV = 9 // размер поля по вертикали sizeFG = 9 // размер поля по горизонтали sizeFV12 = 4 // 1/2 и должно быть на 1 меньше (9) - 8/2 = 4 я гений sizeFG12 = 4 field = [[]] // Массив с данными о блоках на поле for i=0 to sizeFV-1 by 1 for y=0 to sizeFG-1 by 1 field [i [y]] = 0 end end

end

update = function()

if (mouse.press and ((mouse.x < slot2[1] and mouse.x > slot2[2]) and (mouse.y < slot2[3] and mouse.y > slot2[4])) ) then keep2 = 1 end b_x = mouse.x b_y = mouse.y

end

draw = function() screen.clear() screen.fillRect(0,0,screen.width,screen.height,"rgb(0,0,0)")

for i=-sizeFV12 to sizeFV12 by 1 for y=-sizeFG12 to sizeFG12 by 1 screen.drawSprite("field",isizeB1,ysizeB1,sizeB1) end end screen.drawLine(lineGH[0],lineGH[1],lineGH[2],lineGH[3],"rgb(79,79,79)") screen.drawLine(lineGD[0],lineGD[1],lineGD[2],lineGD[3],"rgb(79,79,79)") screen.drawLine(lineVL[0],lineVL[1],lineVL[2],lineVL[3],"rgb(79,79,79)") screen.drawLine(lineVR[0],lineVR[1],lineVR[2],lineVR[3],"rgb(79,79,79)")

if (mouse.pressed and keep2 = 1) then for i=2 to 5 by 1 for y=0 to 3 by 1 local z = y //Blocks[slot2[0] [i [y]]] if Blocks[slot2[0] [i [y]]] == 1 then screen.drawSprite("block1", mouse.x + ((3-i)*Blocks[[0]]2sizeB2), mouse.y+((1-y)*Blocks[[1]]2sizeB2), sizeB2 ) else keep2 = 0

  end
end

I know that my code isn't good but I think it should work. The main idea is that I need to essentially make a button, for this I need the mouse coordinates to check, but due to the fact that the coordinates do not change the sign, I cannot do this.

show your code

are you talking about negatives?

Post a reply

Progress

Status

Preview
Cancel
Post
Validate your e-mail address to participate in the community