processing

Move a point toward the mouse

ぃ、小莉子 提交于 2021-01-28 06:11:16
问题 (I'm using processing for this but it is not necessarily relevant.) I'm looking for an algorithm that would take the point A and the point B (B being the mouse cursor position) and use them so that every frame the point A moves a little bit towards B (from -1px to 1px left/right up/down) I tried x1 += cos(atan((mouseY-y1)/(mouseX-x1))) and the same with sin for y1, but I doesn't seem to work. If someone has an idea I would appreciate it. I'm not looking for a built-in function that would do

find intersection point of two vectors independent from direction

有些话、适合烂在心里 提交于 2021-01-21 11:46:12
问题 I have two vectors and i want to know where these vectors will intersect independent from direction or length. So lets just say i would draw an infinite line in either direction and i want to know where those two lines will intersect and get the coordinates. See image below for clarification: So i want to know the coordinates of the pink X. But i can only find formulas for calculating the intersection point of two lines with an stard and end point which i dont have :( So i am looking for some

How to write on other values placed after the operators case?

大憨熊 提交于 2021-01-20 08:40:57
问题 Good afternoon, I am using the switch construction, but I don’t know how to write correctly for other values after the case operators. In the DisplayData code, in the switch construction, I assign a command number to the fields, for example: Vin = cp5.addTextlabel, so that later, when connecting via a com port, display or change the data by sending this command "60",123 in the Vin = cp5.addTextlabel field. Only works in (minutess = cp5.addButton) - 10, (Vin = cp5.addTextlabel) - 60,

How to write on other values placed after the operators case?

不羁的心 提交于 2021-01-20 08:40:06
问题 Good afternoon, I am using the switch construction, but I don’t know how to write correctly for other values after the case operators. In the DisplayData code, in the switch construction, I assign a command number to the fields, for example: Vin = cp5.addTextlabel, so that later, when connecting via a com port, display or change the data by sending this command "60",123 in the Vin = cp5.addTextlabel field. Only works in (minutess = cp5.addButton) - 10, (Vin = cp5.addTextlabel) - 60,

Collision detection only works when object hits right in the centre

谁都会走 提交于 2021-01-16 03:54:10
问题 Hi so i have here a 'falling' style game where i have homer simpsons head falling through the sky avoiding the salads and collecting burgers to increase score. I have implemented collision detection so when homer hits a salad he should re-spawn and have a life deducted which works fine. However if homers head hits the side of the salad and not directly in the centre of it the game will freeze for a moment and then carry on like nothing happened. I am not sure why this happens and wondering if

Collision detection only works when object hits right in the centre

戏子无情 提交于 2021-01-16 03:53:42
问题 Hi so i have here a 'falling' style game where i have homer simpsons head falling through the sky avoiding the salads and collecting burgers to increase score. I have implemented collision detection so when homer hits a salad he should re-spawn and have a life deducted which works fine. However if homers head hits the side of the salad and not directly in the centre of it the game will freeze for a moment and then carry on like nothing happened. I am not sure why this happens and wondering if

Collision detection only works when object hits right in the centre

丶灬走出姿态 提交于 2021-01-16 03:53:39
问题 Hi so i have here a 'falling' style game where i have homer simpsons head falling through the sky avoiding the salads and collecting burgers to increase score. I have implemented collision detection so when homer hits a salad he should re-spawn and have a life deducted which works fine. However if homers head hits the side of the salad and not directly in the centre of it the game will freeze for a moment and then carry on like nothing happened. I am not sure why this happens and wondering if

How do I make the conditions of the data in the textbox two fields meet?

二次信任 提交于 2021-01-05 18:52:46
问题 Good afternoon, I was already prompted how this can be done with cp5.addNumberbox, but I tried different options and still could not beat cp5.addTextfield. Nothing works! The tasks were as follows: 1). The minValue field must not exceed the MaxValue field when entering numbers. 2). The MaxValue field must not be less than the minValue field when entering numbers. 3). The minValue field must not exceed the range from the maxValue field by 500 units. I post the simplest version of the code

How do I make the conditions of the data in the textbox two fields meet?

落花浮王杯 提交于 2021-01-05 18:49:29
问题 Good afternoon, I was already prompted how this can be done with cp5.addNumberbox, but I tried different options and still could not beat cp5.addTextfield. Nothing works! The tasks were as follows: 1). The minValue field must not exceed the MaxValue field when entering numbers. 2). The MaxValue field must not be less than the minValue field when entering numbers. 3). The minValue field must not exceed the range from the maxValue field by 500 units. I post the simplest version of the code

p5js: How do I make my randomly generated circle packing sketch/canvas responsive when the window is resized?

限于喜欢 提交于 2020-12-13 04:58:05
问题 When I load the window from a narrow size and make it wider, the added canvas space is white. Canvas resize from narrow to wide: When I load from a larger window to a smaller size, the canvas stays in the larger size, while HTML and CSS elements respond. In the second picture, the circles are supposed to cut off at the same point at the black rectangle. I think this is happening because the circles are randomly generated and the layout of them is different whenever the page loads/reloads.