# Coding Questions

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

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

**Page:** 89

---

## [Passing an Array through recursive class objects](https://discourse.processing.org/t/passing-an-array-through-recursive-class-objects/21972)

<div class="topic-metadata">

**Author:** [@Hyperion65](https://discourse.processing.org/u/Hyperion65)\
**Replies:** 2\
**Last updated:** [June 18, 2020, 8:49am UTC](https://discourse.processing.org/t/passing-an-array-through-recursive-class-objects/21972 "2020-06-18T08:49:38Z")

</div>

Hello ! I am working on a data visualization for a tree, generated with processing. I have created a class that creates a branch of the tree and then recursively creates another object for each child branch. To connec…

---

## [Change Color Moving](https://discourse.processing.org/t/change-color-moving/21924)

<div class="topic-metadata">

**Author:** [@marika20](https://discourse.processing.org/u/marika20)\
**Replies:** 4\
**Last updated:** [June 18, 2020, 8:42am UTC](https://discourse.processing.org/t/change-color-moving/21924 "2020-06-18T08:42:26Z")

</div>

Hi everyone, I need a hand, on how I can make my static rectangles () inside my moving rectangles () change color: I have three squares: static green, purple and orange I have three moving rectangles (): yellow, red an…

---

## [PGraphics framebuffer can be rendered in \`noLoop\` mode but cannot be rendered in \`loop\` mode](https://discourse.processing.org/t/pgraphics-framebuffer-can-be-rendered-in-noloop-mode-but-cannot-be-rendered-in-loop-mode/21912)

<div class="topic-metadata">

**Author:** [@mgood7123](https://discourse.processing.org/u/mgood7123)\
**Replies:** 0\
**Last updated:** [June 16, 2020, 3:18am UTC](https://discourse.processing.org/t/pgraphics-framebuffer-can-be-rendered-in-noloop-mode-but-cannot-be-rendered-in-loop-mode/21912 "2020-06-16T03:18:51Z")

</div>

why can the PGraphics FrameBuffer be rendered when noLoop() is given but fails to image when noLoop() is not given? as the following works for noLoop(); however it fails for looping draw() as the screen is always black …

---

## [Pong game end screen buttons not working](https://discourse.processing.org/t/pong-game-end-screen-buttons-not-working/21896)

<div class="topic-metadata">

**Author:** [@mrporcessing](https://discourse.processing.org/u/mrporcessing)\
**Replies:** 2\
**Last updated:** [June 18, 2020, 12:12am UTC](https://discourse.processing.org/t/pong-game-end-screen-buttons-not-working/21896 "2020-06-18T00:12:32Z")

</div>

Hi, for some reason my end game screen at the very end, when I press the respected keys doesn’t go to that stage. When I do it on the menu screen however it works. I have no idea why. //all major variables int x,y,w,h,s…

---

## [Sleep() in processing](https://discourse.processing.org/t/sleep-in-processing/21966)

<div class="topic-metadata">

**Author:** [@jeyeffkay](https://discourse.processing.org/u/jeyeffkay)\
**Replies:** 2\
**Last updated:** [June 17, 2020, 8:54pm UTC](https://discourse.processing.org/t/sleep-in-processing/21966 "2020-06-17T20:54:32Z")

</div>

Hey guys, I am currently coding on a game for school and I asked myself and googled how can I use the sleep() command in processing. I want to create a flappy bird like game and I want one loop to wait e.g. two seconds …

---

## [How do I draw a line when the mouse is pressed, and then have that line change type when the mouse and a certain key are pressed at the same time?](https://discourse.processing.org/t/how-do-i-draw-a-line-when-the-mouse-is-pressed-and-then-have-that-line-change-type-when-the-mouse-and-a-certain-key-are-pressed-at-the-same-time/21956)

<div class="topic-metadata">

**Author:** [@keith](https://discourse.processing.org/u/keith)\
**Replies:** 1\
**Last updated:** [June 17, 2020, 4:54pm UTC](https://discourse.processing.org/t/how-do-i-draw-a-line-when-the-mouse-is-pressed-and-then-have-that-line-change-type-when-the-mouse-and-a-certain-key-are-pressed-at-the-same-time/21956 "2020-06-17T16:54:38Z")

</div>

For example, I would like to have a “normal” line drawn when only the mouse is pressed, but have that line change color and/or size when the mouse and a certain key are pressed at the same time.

---

## [Flappy bird beginner](https://discourse.processing.org/t/flappy-bird-beginner/6284)

<div class="topic-metadata">

**Author:** [@Yuma0444](https://discourse.processing.org/u/Yuma0444)\
**Replies:** 6\
**Last updated:** [December 4, 2018, 5:24pm UTC](https://discourse.processing.org/t/flappy-bird-beginner/6284 "2018-12-04T17:24:34Z")

</div>

I’m a beginner in processing and I’m making the flappy bird but, I’m stacked on the bar section. //Final\_project int x = 0; int y = 0; int value = 0; Bar\[\] bars; void setup() { size(500, 600); background(200); bars = n…

---

## [How do I make a loop that only runs once?](https://discourse.processing.org/t/how-do-i-make-a-loop-that-only-runs-once/21928)

<div class="topic-metadata">

**Author:** [@s.k9](https://discourse.processing.org/u/s.k9)\
**Replies:** 3\
**Last updated:** [June 17, 2020, 4:02pm UTC](https://discourse.processing.org/t/how-do-i-make-a-loop-that-only-runs-once/21928 "2020-06-17T16:02:26Z")

</div>

For a project, I want to change the background for the starting screen every time it is loaded up. So the user opens the program and the background is displayed, they play for a bit, press a key to reset and go back to t…

---

## [Problems with my mini game](https://discourse.processing.org/t/problems-with-my-mini-game/21949)

<div class="topic-metadata">

**Author:** [@iamthatoli](https://discourse.processing.org/u/iamthatoli)\
**Replies:** 2\
**Last updated:** [June 17, 2020, 3:55pm UTC](https://discourse.processing.org/t/problems-with-my-mini-game/21949 "2020-06-17T15:55:39Z")

</div>

Hey Guys! I have a problem with my mini game I want my circles to spawn after 1 second each of them. Can anyone pls help me? //Array deklarieren float\[\] x; float\[\] y; float xDir\[\]; float yDir\[\]; float xrect = random(1…

---

## [Natural "first person like" turning/moving in P3D](https://discourse.processing.org/t/natural-first-person-like-turning-moving-in-p3d/21854)

<div class="topic-metadata">

**Author:** [@jetjaguar](https://discourse.processing.org/u/jetjaguar)\
**Replies:** 2\
**Last updated:** [June 17, 2020, 10:39am UTC](https://discourse.processing.org/t/natural-first-person-like-turning-moving-in-p3d/21854 "2020-06-17T10:39:17Z")

</div>

Hey everyone, I think I’m making something more difficult than it needs to be. To begin with I am simply trying to be able to turn the camera in the P3D environment so that when I then move forward, the camera moves in …

---

## [Making a simple counter/timer](https://discourse.processing.org/t/making-a-simple-counter-timer/21923)

<div class="topic-metadata">

**Author:** [@AverageBiped](https://discourse.processing.org/u/AverageBiped)\
**Replies:** 7\
**Last updated:** [June 17, 2020, 8:06am UTC](https://discourse.processing.org/t/making-a-simple-counter-timer/21923 "2020-06-17T08:06:24Z")

</div>

I am trying to do something very simple and can’t figure out how. I want to implement a counter that counts from 0 to 12, printing out 1 number per second (so on run it will immediately print “0”, followed by “1” 1 seco…

---

## [How to use web crawling after you enter something to a online site?](https://discourse.processing.org/t/how-to-use-web-crawling-after-you-enter-something-to-a-online-site/21865)

<div class="topic-metadata">

**Author:** [@SilverPrevail](https://discourse.processing.org/u/SilverPrevail)\
**Replies:** 5\
**Last updated:** [June 17, 2020, 12:58am UTC](https://discourse.processing.org/t/how-to-use-web-crawling-after-you-enter-something-to-a-online-site/21865 "2020-06-17T00:58:03Z")

</div>

For instance, if I try to use a matrix calculator site (https://matrixcalc.org/) from my code, I have to enter my matrices into a site, and then use web crawling to get the answer. Like this example, I need to get the r…

---

## [Looking in Folders and Building Arrays of contents on program startup](https://discourse.processing.org/t/looking-in-folders-and-building-arrays-of-contents-on-program-startup/21902)

<div class="topic-metadata">

**Author:** [@Eyetoof](https://discourse.processing.org/u/Eyetoof)\
**Replies:** 1\
**Last updated:** [June 17, 2020, 1:02am UTC](https://discourse.processing.org/t/looking-in-folders-and-building-arrays-of-contents-on-program-startup/21902 "2020-06-17T01:02:43Z")

</div>

Hello, I Have been reviewing this page on listing the contents of directories and sub directories Processing Directory List My question now is how to work with this data effectively once gathered. I say “effectively”…

---

## [How to draw bitmap array in Processing?](https://discourse.processing.org/t/how-to-draw-bitmap-array-in-processing/21875)

<div class="topic-metadata">

**Author:** [@R1S8K](https://discourse.processing.org/u/R1S8K)\
**Replies:** 5\
**Last updated:** [June 16, 2020, 8:07pm UTC](https://discourse.processing.org/t/how-to-draw-bitmap-array-in-processing/21875 "2020-06-16T20:07:27Z")

</div>

Hi, I have three points in my question: How to draw this bitmap array in Processing ? I also want to scale up the final output drawing. Would Processing accept my C coding ? This is my code: bitmap draw file: void…

---

## [How would I create function to select newest object in array list](https://discourse.processing.org/t/how-would-i-create-function-to-select-newest-object-in-array-list/21925)

<div class="topic-metadata">

**Author:** [@s.k9](https://discourse.processing.org/u/s.k9)\
**Replies:** 2\
**Last updated:** [June 16, 2020, 5:39pm UTC](https://discourse.processing.org/t/how-would-i-create-function-to-select-newest-object-in-array-list/21925 "2020-06-16T17:39:30Z")

</div>

For a project, I am making a game where users can press a key to add legos. However, I also want there to be a key for them to delete the last lego placed. Right now I can delete the first lego placed using Legos.remove(…

---

## [Fullscreen, what do I miss here?](https://discourse.processing.org/t/fullscreen-what-do-i-miss-here/21917)

<div class="topic-metadata">

**Author:** [@klap](https://discourse.processing.org/u/klap)\
**Replies:** 4\
**Last updated:** [June 16, 2020, 1:19pm UTC](https://discourse.processing.org/t/fullscreen-what-do-i-miss-here/21917 "2020-06-16T13:19:21Z")

</div>

Objects doesn’t adapt to fullscreen size. A tiny ball in on a large screen. What do I miss here? float ellipseX = (width / 2); float ellipseY = (height / 10); int rectX = ((width / 2) - 10); int rectY = (height - 10); f…

---

## [Why the pixel isn't squared?](https://discourse.processing.org/t/why-the-pixel-isnt-squared/21877)

<div class="topic-metadata">

**Author:** [@R1S8K](https://discourse.processing.org/u/R1S8K)\
**Replies:** 6\
**Last updated:** [June 16, 2020, 12:06am UTC](https://discourse.processing.org/t/why-the-pixel-isnt-squared/21877 "2020-06-16T00:06:35Z")

</div>

Hi, I’m trying to draw a bitmap with C arrays, but the pixel turned out that it’s not squared and rather rectangular in horizontal shape. This is the code: void setup(){ size(1280, 640); } void draw() { backgro…

---

## [Help combining the start of one easing function with the end of a different one](https://discourse.processing.org/t/help-combining-the-start-of-one-easing-function-with-the-end-of-a-different-one/21901)

<div class="topic-metadata">

**Author:** [@ottenm](https://discourse.processing.org/u/ottenm)\
**Replies:** 0\
**Last updated:** [June 15, 2020, 10:44pm UTC](https://discourse.processing.org/t/help-combining-the-start-of-one-easing-function-with-the-end-of-a-different-one/21901 "2020-06-15T22:44:09Z")

</div>

This sketch draws an oval as the user drags horizontally across the screen from right-to-left . But the oval starts and completes too quickly to match the feel of the mouse drag. I’d like to use easing to a) start out …

---

## [PShape vs PGraphics](https://discourse.processing.org/t/pshape-vs-pgraphics/21834)

<div class="topic-metadata">

**Author:** [@mgood7123](https://discourse.processing.org/u/mgood7123)\
**Replies:** 2\
**Last updated:** [June 15, 2020, 6:38pm UTC](https://discourse.processing.org/t/pshape-vs-pgraphics/21834 "2020-06-15T18:38:18Z")

</div>

can PShape do everything that a PGraphics object can? if so, would it be faster in a multi-object context? for example for PGraphics, i get 29 FPS without beginDraw and endDraw for each draw() mostly due to PGraphics …

---

## [Tint() issue when used in Class Object - Does tint() interact across objects?](https://discourse.processing.org/t/tint-issue-when-used-in-class-object-does-tint-interact-across-objects/21812)

<div class="topic-metadata">

**Author:** [@poltergeister](https://discourse.processing.org/u/poltergeister)\
**Replies:** 2\
**Last updated:** [June 15, 2020, 6:51pm UTC](https://discourse.processing.org/t/tint-issue-when-used-in-class-object-does-tint-interact-across-objects/21812 "2020-06-15T18:51:15Z")

</div>

I’m trying to build a program that displays different slide-shows in multiple locations on the screen. I’ve created class to build individual slide-shows. I’m using tint() to fade one image to the next. This works when…

---

## [Can someone help me delete the boundary inside？](https://discourse.processing.org/t/can-someone-help-me-delete-the-boundary-inside/21816)

<div class="topic-metadata">

**Author:** [@IAN](https://discourse.processing.org/u/IAN)\
**Replies:** 2\
**Last updated:** [June 15, 2020, 6:51pm UTC](https://discourse.processing.org/t/can-someone-help-me-delete-the-boundary-inside/21816 "2020-06-15T18:51:12Z")

</div>

/\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* \*Copyright (c) 2014, Stephen Macke \*All rights reserved. \* \*Redistribution and use in source and binary forms, with or without \*modification,…

---

## [How to control a Softbody ball](https://discourse.processing.org/t/how-to-control-a-softbody-ball/21796)

<div class="topic-metadata">

**Author:** [@IAN](https://discourse.processing.org/u/IAN)\
**Replies:** 2\
**Last updated:** [June 12, 2020, 12:44pm UTC](https://discourse.processing.org/t/how-to-control-a-softbody-ball/21796 "2020-06-12T12:44:04Z")

</div>

float r = 10; float grav = 1100;//gravity float resolution = 30; float dt = 0.01; float mouseR = 200; Softbody softbody; void setup(){ fullScreen(); //size(500, 500); softbody = new Softbody(r, resolution); } voi…

---

## [PGraphicsOpenGL - beginDraw, image, endDraw optimising](https://discourse.processing.org/t/pgraphicsopengl-begindraw-image-enddraw-optimising/21890)

<div class="topic-metadata">

**Author:** [@mgood7123](https://discourse.processing.org/u/mgood7123)\
**Replies:** 0\
**Last updated:** [June 15, 2020, 10:52am UTC](https://discourse.processing.org/t/pgraphicsopengl-begindraw-image-enddraw-optimising/21890 "2020-06-15T10:52:21Z")

</div>

how would i optimize PGraphicsOpenGL.beginDraw(); and PGraphicsOpenGL.endDraw() in the context of being called 3,840 times per second or more as i do have this which works for noLoop() but not for loop, im not sure why …

---

## [Clip not behaving as expected in relation to graphic transformations (eg rotateX)](https://discourse.processing.org/t/clip-not-behaving-as-expected-in-relation-to-graphic-transformations-eg-rotatex/21828)

<div class="topic-metadata">

**Author:** [@mgood7123](https://discourse.processing.org/u/mgood7123)\
**Replies:** 15\
**Last updated:** [June 15, 2020, 5:17pm UTC](https://discourse.processing.org/t/clip-not-behaving-as-expected-in-relation-to-graphic-transformations-eg-rotatex/21828 "2020-06-15T17:17:06Z")

</div>

why does clip not behave as expected? as my clip seems to be rotating the entire boarder instead of the contents inside of the border clipping to GRAPHICS 400 400 200 200 clipping to WINDOW 3 20 194 177 clipping to W…

---

## [PGraphics.beginDraw(), PGraphics.endDraw() alternatives](https://discourse.processing.org/t/pgraphics-begindraw-pgraphics-enddraw-alternatives/21769)

<div class="topic-metadata">

**Author:** [@mgood7123](https://discourse.processing.org/u/mgood7123)\
**Replies:** 12\
**Last updated:** [June 15, 2020, 9:03am UTC](https://discourse.processing.org/t/pgraphics-begindraw-pgraphics-enddraw-alternatives/21769 "2020-06-15T09:03:14Z")

</div>

are there any alternatives to beginDraw() and endDraw()? as using beginDraw and endDraw are expensive if i do graphics.endDraw(); if (displayFPS) { window.graphics.beginDraw(); int oldColor = windo…

---

## [textAlign(CENTER, CENTER)](https://discourse.processing.org/t/textalign-center-center/21866)

<div class="topic-metadata">

**Author:** [@slashwreck](https://discourse.processing.org/u/slashwreck)\
**Replies:** 1\
**Last updated:** [June 14, 2020, 2:37pm UTC](https://discourse.processing.org/t/textalign-center-center/21866 "2020-06-14T14:37:08Z")

</div>

In processing I make a two dimensional grid of petri dishes, and then center a name under each petridish. I get aligned text by using textAlign(CENTER, CENTER). beginRecord(SVG, svgs\[2\]) textAlign(CENTER, CENT…

---

## [Fast Pixel by Pixel Image Editing](https://discourse.processing.org/t/fast-pixel-by-pixel-image-editing/21876)

<div class="topic-metadata">

**Author:** [@F53](https://discourse.processing.org/u/F53)\
**Replies:** 3\
**Last updated:** [June 14, 2020, 11:47pm UTC](https://discourse.processing.org/t/fast-pixel-by-pixel-image-editing/21876 "2020-06-14T23:47:37Z")

</div>

I have an array of PImages upscaledImages\[\] pulled from a folder How would I: Edit Individual pixel’s based on their contents Save the array of edited images, overwriting the unedited ones All of this needs to be don…

---

## [Need help to make very simple game](https://discourse.processing.org/t/need-help-to-make-very-simple-game/21857)

<div class="topic-metadata">

**Author:** [@malik2712](https://discourse.processing.org/u/malik2712)\
**Replies:** 5\
**Last updated:** [June 14, 2020, 3:18pm UTC](https://discourse.processing.org/t/need-help-to-make-very-simple-game/21857 "2020-06-14T15:18:18Z")

</div>

please format code with \</\> button \* homework policy \* asking questions I just need code made to run that game in processing It’s for an assessment due tomorrow I need to make a little game in the coding app processi…

---

## [FrameBuffer - draw directly to PImage or Texture](https://discourse.processing.org/t/framebuffer-draw-directly-to-pimage-or-texture/21864)

<div class="topic-metadata">

**Author:** [@mgood7123](https://discourse.processing.org/u/mgood7123)\
**Replies:** 0\
**Last updated:** [June 14, 2020, 1:13pm UTC](https://discourse.processing.org/t/framebuffer-draw-directly-to-pimage-or-texture/21864 "2020-06-14T13:13:25Z")

</div>

how would i set up a FrameBuffer such that, i can draw directly to some Texture or PImage and then immediatly image that to my screen for example PGraphics g2; void settings() { size(400, 400, P3D); } void setup() …

---

## [PGraphicsOpenGL - how to read from the framebuffer](https://discourse.processing.org/t/pgraphicsopengl-how-to-read-from-the-framebuffer/21842)

<div class="topic-metadata">

**Author:** [@mgood7123](https://discourse.processing.org/u/mgood7123)\
**Replies:** 0\
**Last updated:** [June 13, 2020, 2:45pm UTC](https://discourse.processing.org/t/pgraphicsopengl-how-to-read-from-the-framebuffer/21842 "2020-06-13T14:45:53Z")

</div>

how would i go about reading the FrameBuffer that PGraphics uses for rendering to AFTER beginDraw(); and BEFORE \`endDraw()’ as my goal is to only call beginDraw() ONCE during setup, then read LIVE pixel data in onDraw()…

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

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