# Coding Questions

**URL:** https://discourse.processing.org/c/processing/processing-questions/15.md?page=43

[Latest](https://discourse.processing.org/latest.md) · [Categories](https://discourse.processing.org/categories.md) · [Tags](https://discourse.processing.org/tags.md)

**Page:** 44

---

## [Rect following mouseX slowing speed problem](https://discourse.processing.org/t/rect-following-mousex-slowing-speed-problem/32491)

<div class="topic-metadata">

**Author:** [@Kenga123456](https://discourse.processing.org/u/Kenga123456)\
**Replies:** 2\
**Last updated:** [September 28, 2021, 9:05pm UTC](https://discourse.processing.org/t/rect-following-mousex-slowing-speed-problem/32491 "2021-09-28T21:05:30Z")

</div>

I have tried changing this line -xVel = xVel\*0,999- here but I can’t find a way to make the ellipse more gradually lose speed. Here is my code float ellipseXPos = 300; float ellipseYPos = 300; float xVel = 1; float yVe…

---

## [I want to draw pixels in bigger sizes with more simple methods](https://discourse.processing.org/t/i-want-to-draw-pixels-in-bigger-sizes-with-more-simple-methods/32485)

<div class="topic-metadata">

**Author:** [@R1S8K](https://discourse.processing.org/u/R1S8K)\
**Replies:** 1\
**Last updated:** [September 28, 2021, 8:39pm UTC](https://discourse.processing.org/t/i-want-to-draw-pixels-in-bigger-sizes-with-more-simple-methods/32485 "2021-09-28T20:39:14Z")

</div>

Hi, I want a simple way to draw pixels in bigger shapes. I want to test basic pixel draw functions; like, lines, circles, rectangles … etc. With small resolutions like 128 x 64. Even if you know a simple library that c…

---

## [Why does the square stay in the previous position](https://discourse.processing.org/t/why-does-the-square-stay-in-the-previous-position/32487)

<div class="topic-metadata">

**Author:** [@MoonAlien822](https://discourse.processing.org/u/MoonAlien822)\
**Replies:** 4\
**Last updated:** [September 28, 2021, 8:29pm UTC](https://discourse.processing.org/t/why-does-the-square-stay-in-the-previous-position/32487 "2021-09-28T20:29:07Z")

</div>

when the square moves it also stays in the previous position. noStroke(); dit not solve it PVector pos1; PVector pos2; PVector pos3; PVector pos4; PVector pos5; PVector pos6; PVector pos7; PVector pos8; PVector pos9; i…

---

## [Block does not move when button is pressed](https://discourse.processing.org/t/block-does-not-move-when-button-is-pressed/32456)

<div class="topic-metadata">

**Author:** [@MoonAlien822](https://discourse.processing.org/u/MoonAlien822)\
**Replies:** 6\
**Last updated:** [September 28, 2021, 3:12pm UTC](https://discourse.processing.org/t/block-does-not-move-when-button-is-pressed/32456 "2021-09-28T15:12:25Z")

</div>

float\[\] blockx= new float\[9\]; float\[\] blocky= new float\[9\]; int i=1; void setup(){ size(400,300); blockx\[1\]= 0; blocky\[1\]=0; } void draw(){ if(keyPressed){ if(key=='d'){ blockx\[i\]=blockx\[i\]+100;}} …

---

## [Making Box appear in random locations](https://discourse.processing.org/t/making-box-appear-in-random-locations/32458)

<div class="topic-metadata">

**Author:** [@zack10](https://discourse.processing.org/u/zack10)\
**Replies:** 2\
**Last updated:** [September 28, 2021, 10:18am UTC](https://discourse.processing.org/t/making-box-appear-in-random-locations/32458 "2021-09-28T10:18:17Z")

</div>

class Box{ float z = 50; float dz = 2; void moveBox() { z += dz; } void show() { lights(); pushMatrix(); translate(130, 220, z); noStroke(); fill(10, 98, 240); rotateX(fra…

---

## [How can I light up separate circles instead of them all](https://discourse.processing.org/t/how-can-i-light-up-separate-circles-instead-of-them-all/32468)

<div class="topic-metadata">

**Author:** [@Caprisunny](https://discourse.processing.org/u/Caprisunny)\
**Replies:** 2\
**Last updated:** [September 28, 2021, 10:08am UTC](https://discourse.processing.org/t/how-can-i-light-up-separate-circles-instead-of-them-all/32468 "2021-09-28T10:08:14Z")

</div>

int\[\]\[\] cirkels = { {10, 15}, {100, 130}, {77, 43}, {30, 145}, {185, 17}, {99, 76} }; final int DIAMETER = 20; final int STRAAL = 10; final int GEEL = #FFFF00; final int ROOD = #FF0000; int kleur; void setup() { size(…

---

## [Adjust text size based on length of text](https://discourse.processing.org/t/adjust-text-size-based-on-length-of-text/32411)

<div class="topic-metadata">

**Author:** [@Naison](https://discourse.processing.org/u/Naison)\
**Replies:** 8\
**Last updated:** [September 28, 2021, 2:41am UTC](https://discourse.processing.org/t/adjust-text-size-based-on-length-of-text/32411 "2021-09-28T02:41:44Z")

</div>

Hello, I am coding a game and for this, I tryna write code that sizes the text based on the length of the text. My goal is to scale the text (the bigger the text width / the longer the text, the smaller the text size) t…

---

## [SVG exception thrown on loadShape()](https://discourse.processing.org/t/svg-exception-thrown-on-loadshape/32422)

<div class="topic-metadata">

**Author:** [@strfry](https://discourse.processing.org/u/strfry)\
**Replies:** 6\
**Last updated:** [September 27, 2021, 5:52pm UTC](https://discourse.processing.org/t/svg-exception-thrown-on-loadshape/32422 "2021-09-27T17:52:33Z")

</div>

Hi, I’m new to processing, and I’m having an issue with loading a .svg saved in Adobe Illustrator using image trace. I get an error that looks like: RuntimeException: shape command not handled: .49 I believe the iss…

---

## [Problem with a loop](https://discourse.processing.org/t/problem-with-a-loop/3415)

<div class="topic-metadata">

**Author:** [@vincentstrebelle](https://discourse.processing.org/u/vincentstrebelle)\
**Replies:** 31\
**Last updated:** [September 11, 2018, 1:01pm UTC](https://discourse.processing.org/t/problem-with-a-loop/3415 "2018-09-11T13:01:32Z")

</div>

Hi i tried to use the code i recieve from my post “a pathfinding solution” to make my creatur find food. here is the case : my creatures walk randomly and when they are hungry they go to the closest food, but my foods …

---

## [How to add a target to a pong simulator game?](https://discourse.processing.org/t/how-to-add-a-target-to-a-pong-simulator-game/32427)

<div class="topic-metadata">

**Author:** [@Lulua](https://discourse.processing.org/u/Lulua)\
**Replies:** 1\
**Last updated:** [September 26, 2021, 8:38pm UTC](https://discourse.processing.org/t/how-to-add-a-target-to-a-pong-simulator-game/32427 "2021-09-26T20:38:05Z")

</div>

I have made a pong simulator game. I added a circle as a target but need to make it so that when the ball hits the target, the player wins and the game restarts. Help!!! PImage dragon; PFont font; int base=40; int x,…

---

## [setJSONArray should start a new line when inserting an array into a JSON object](https://discourse.processing.org/t/setjsonarray-should-start-a-new-line-when-inserting-an-array-into-a-json-object/32417)

<div class="topic-metadata">

**Author:** [@seanbetts](https://discourse.processing.org/u/seanbetts)\
**Replies:** 2\
**Last updated:** [September 25, 2021, 9:17pm UTC](https://discourse.processing.org/t/setjsonarray-should-start-a-new-line-when-inserting-an-array-into-a-json-object/32417 "2021-09-25T21:17:09Z")

</div>

I am trying to output a JSON file from my code which include some JSON objects and also a JSON array but the JSON array is not starting on a new line in the output JSON file, which causes problems when using the file. C…

---

## [Oval with straight edges](https://discourse.processing.org/t/oval-with-straight-edges/32390)

<div class="topic-metadata">

**Author:** [@MoonAlien822](https://discourse.processing.org/u/MoonAlien822)\
**Replies:** 3\
**Last updated:** [September 25, 2021, 5:58pm UTC](https://discourse.processing.org/t/oval-with-straight-edges/32390 "2021-09-25T17:58:05Z")

</div>

is there a way to create this shape as a single thing instead of having an ellipse and a rect?

---

## [Disable ESC from exiting program in fullscreen?](https://discourse.processing.org/t/disable-esc-from-exiting-program-in-fullscreen/32383)

<div class="topic-metadata">

**Author:** [@jonnyetiz](https://discourse.processing.org/u/jonnyetiz)\
**Replies:** 3\
**Last updated:** [September 24, 2021, 4:27pm UTC](https://discourse.processing.org/t/disable-esc-from-exiting-program-in-fullscreen/32383 "2021-09-24T16:27:36Z")

</div>

I’m trying to use fullscreen and also bind escape to a button. Relevant code below (not complete obviously) void setup() { fullScreen(P2D); ... }

---

## [PShape Error Fatal Error :1:1:](https://discourse.processing.org/t/pshape-error-fatal-error-1/32285)

<div class="topic-metadata">

**Author:** [@TomLeVeritable](https://discourse.processing.org/u/TomLeVeritable)\
**Replies:** 2\
**Last updated:** [September 23, 2021, 8:18am UTC](https://discourse.processing.org/t/pshape-error-fatal-error-1/32285 "2021-09-23T08:18:45Z")

</div>

Hi I’m trying to use Pshape with this code PShape planet; void setup(){ size(600,600); planet = loadShape("sphere.svg"); } void draw(){ background(0); shape(planet, 250,250,150,100); } and I’ve got this error …

---

## [How do i make gradient lines?](https://discourse.processing.org/t/how-do-i-make-gradient-lines/32377)

<div class="topic-metadata">

**Author:** [@BAE](https://discourse.processing.org/u/BAE)\
**Replies:** 5\
**Last updated:** [September 23, 2021, 8:09am UTC](https://discourse.processing.org/t/how-do-i-make-gradient-lines/32377 "2021-09-23T08:09:30Z")

</div>

Sorry guys. I can’t English well So, I want to know How to make gradient line like this picture? I made shape size(600,600); background(255); fill(255); for(int a=1; a\<6; ++a) for(int b=1; b\<6; ++b) for(int c=1; c\<…

---

## [Get position of PShape](https://discourse.processing.org/t/get-position-of-pshape/32362)

<div class="topic-metadata">

**Author:** [@shishironeal](https://discourse.processing.org/u/shishironeal)\
**Replies:** 3\
**Last updated:** [September 23, 2021, 1:13am UTC](https://discourse.processing.org/t/get-position-of-pshape/32362 "2021-09-23T01:13:00Z")

</div>

I’m loading an SVG using loadShape and I want to get the position of a child PShape so I can draw a bounding box around it. I tried looking through the PShape class and also tried getVertexX (which results in a NPE since…

---

## [Twisted quads vs. Expressive quads](https://discourse.processing.org/t/twisted-quads-vs-expressive-quads/32292)

<div class="topic-metadata">

**Author:** [@humano](https://discourse.processing.org/u/humano)\
**Replies:** 6\
**Last updated:** [September 20, 2021, 9:28pm UTC](https://discourse.processing.org/t/twisted-quads-vs-expressive-quads/32292 "2021-09-20T21:28:10Z")

</div>

Hi there! These days i have been working with quads and some Users have gave me different solutions for my problems. One of my biggest problems is that some of my random quads are twisted. With new ways of drawing quad…

---

## [Simulate mouse action](https://discourse.processing.org/t/simulate-mouse-action/32312)

<div class="topic-metadata">

**Author:** [@potter3366](https://discourse.processing.org/u/potter3366)\
**Replies:** 4\
**Last updated:** [September 20, 2021, 6:01pm UTC](https://discourse.processing.org/t/simulate-mouse-action/32312 "2021-09-20T18:01:56Z")

</div>

I have to simulate this mouse action. Instead of a mouse I can use the space button or with the jumps in front of the kinect. How can I control these actions over time or the frequency of repeating something at a certain…

---

## [Problem loading screen](https://discourse.processing.org/t/problem-loading-screen/32272)

<div class="topic-metadata">

**Author:** [@tati1202](https://discourse.processing.org/u/tati1202)\
**Replies:** 7\
**Last updated:** [September 20, 2021, 2:49pm UTC](https://discourse.processing.org/t/problem-loading-screen/32272 "2021-09-20T14:49:29Z")

</div>

hey, I have a problem executing my screen, it takes a second for the screen to run (it appears grey for a second), why could that be? I´m using array of images, text and some functions with buttons. The structure of the…

---

## [Register a key press while working outside the sketch window?](https://discourse.processing.org/t/register-a-key-press-while-working-outside-the-sketch-window/32036)

<div class="topic-metadata">

**Author:** [@NumericPrime](https://discourse.processing.org/u/NumericPrime)\
**Replies:** 1\
**Last updated:** [September 20, 2021, 6:04am UTC](https://discourse.processing.org/t/register-a-key-press-while-working-outside-the-sketch-window/32036 "2021-09-20T06:04:59Z")

</div>

I’m currently working on a program to assist me in a game but I’d like to add a few other controlls including when to shut the program down. However the keyPressed method only is called when the window is currently acti…

---

## [Need help making my code display random set of images](https://discourse.processing.org/t/need-help-making-my-code-display-random-set-of-images/32316)

<div class="topic-metadata">

**Author:** [@colehodl](https://discourse.processing.org/u/colehodl)\
**Replies:** 7\
**Last updated:** [September 20, 2021, 3:37am UTC](https://discourse.processing.org/t/need-help-making-my-code-display-random-set-of-images/32316 "2021-09-20T03:37:41Z")

</div>

I am trying to make a code that will display random images, I wanted to create a RandomCatGenerator that would have a random value between 1 and 3, and a random picture of a cat would show up depending on which number R…

---

## [How to make object shoot in Processing](https://discourse.processing.org/t/how-to-make-object-shoot-in-processing/32087)

<div class="topic-metadata">

**Author:** [@NewCoder1](https://discourse.processing.org/u/NewCoder1)\
**Replies:** 11\
**Last updated:** [September 20, 2021, 3:18am UTC](https://discourse.processing.org/t/how-to-make-object-shoot-in-processing/32087 "2021-09-20T03:18:01Z")

</div>

Hi everyone, I’m doing my Processing homework and I’ve got my object but I can’t get it to shoot. Can someone tell me the correct code please? I have the following so far: int x = 30; int y = 30; void setup(){ size(50…

---

## [How to make bullet shoot only when the previous bullet is off the screen](https://discourse.processing.org/t/how-to-make-bullet-shoot-only-when-the-previous-bullet-is-off-the-screen/32314)

<div class="topic-metadata">

**Author:** [@MarkShaker](https://discourse.processing.org/u/MarkShaker)\
**Replies:** 2\
**Last updated:** [September 20, 2021, 2:20am UTC](https://discourse.processing.org/t/how-to-make-bullet-shoot-only-when-the-previous-bullet-is-off-the-screen/32314 "2021-09-20T02:20:17Z")

</div>

Hi everyone, I’m having trouble with shooting another bullet only when the previous bullet fired is off the screen. This is my current code. int x = 30; int y = 60; float gunX = x+20; float gunY = y+20; float circl…

---

## [Render without displaying for performance](https://discourse.processing.org/t/render-without-displaying-for-performance/32307)

<div class="topic-metadata">

**Author:** [@shishironeal](https://discourse.processing.org/u/shishironeal)\
**Replies:** 1\
**Last updated:** [September 19, 2021, 10:26am UTC](https://discourse.processing.org/t/render-without-displaying-for-performance/32307 "2021-09-19T10:26:01Z")

</div>

Is it possible to render frames without having to display them? Would this be faster than normal rendering (with JAVA2D or P2D)? (i.e. with saveFrame)

---

## [Loops inside loops](https://discourse.processing.org/t/loops-inside-loops/32289)

<div class="topic-metadata">

**Author:** [@humano](https://discourse.processing.org/u/humano)\
**Replies:** 2\
**Last updated:** [September 17, 2021, 7:39pm UTC](https://discourse.processing.org/t/loops-inside-loops/32289 "2021-09-17T19:39:35Z")

</div>

Hi there! I have created a function with a diagonal queue of points in random positions and now I want to convert It into blocks of diagonal queues in random positions, as you can see in the picture. I am trying to make…

---

## [Multiple polygons with a loop](https://discourse.processing.org/t/multiple-polygons-with-a-loop/32260)

<div class="topic-metadata">

**Author:** [@humano](https://discourse.processing.org/u/humano)\
**Replies:** 8\
**Last updated:** [September 17, 2021, 7:05pm UTC](https://discourse.processing.org/t/multiple-polygons-with-a-loop/32260 "2021-09-17T19:05:57Z")

</div>

Hi there! I have made a function to create a random polygon, could you please help me to create, for example, 30 polygons like this? Thank you so much void setup(){ size(1000,1000); float x1 = random(width); …

---

## [Resetting a PShape](https://discourse.processing.org/t/resetting-a-pshape/31866)

<div class="topic-metadata">

**Author:** [@SNICKRS](https://discourse.processing.org/u/SNICKRS)\
**Replies:** 3\
**Last updated:** [September 16, 2021, 6:12pm UTC](https://discourse.processing.org/t/resetting-a-pshape/31866 "2021-09-16T18:12:58Z")

</div>

Hello everyone, I am making a voxel game and have been using PShapes to generate chunk meshes. I am currently working on Raycasting so that the player can break and place a block. However, when the player breaks a block,…

---

## [Polygons Distribution with loops](https://discourse.processing.org/t/polygons-distribution-with-loops/32270)

<div class="topic-metadata">

**Author:** [@humano](https://discourse.processing.org/u/humano)\
**Replies:** 5\
**Last updated:** [September 16, 2021, 4:18pm UTC](https://discourse.processing.org/t/polygons-distribution-with-loops/32270 "2021-09-16T16:18:36Z")

</div>

Hi there! I am learning about loops these weeks and I have been able to do a screen full of rectangles like the one you can see in the picture. Now I would like to do a screen full of quadrilaterals, but If I do a loop a…

---

## [Stroke Gradient for Lines](https://discourse.processing.org/t/stroke-gradient-for-lines/32112)

<div class="topic-metadata">

**Author:** [@humano](https://discourse.processing.org/u/humano)\
**Replies:** 15\
**Last updated:** [September 16, 2021, 1:54am UTC](https://discourse.processing.org/t/stroke-gradient-for-lines/32112 "2021-09-16T01:54:23Z")

</div>

Hi there, I am trying to make lines with gradient strokes. I have done something, but It does not work, who can help me with this? Thanks! size (900, 900); background (255); colorMode(HSB, 360, 100, 100); int hueStart…

---

## [Check if character sees other character](https://discourse.processing.org/t/check-if-character-sees-other-character/32274)

<div class="topic-metadata">

**Author:** [@MoonAlien822](https://discourse.processing.org/u/MoonAlien822)\
**Replies:** 1\
**Last updated:** [September 15, 2021, 8:23pm UTC](https://discourse.processing.org/t/check-if-character-sees-other-character/32274 "2021-09-15T20:23:57Z")

</div>

how to check if enimy sees midas? if i3 is 1, enimy looks to the left and if its 2 he looks to the right. //characters int midashp= 30; int enimyhp= 30; PImage\[\] midas= new PImage\[8\]; PImage\[\] reversemidas= new PIma…

[Previous page](https://discourse.processing.org/c/processing/processing-questions/15.md?page=42)

[Next page](https://discourse.processing.org/c/processing/processing-questions/15.md?page=44)
