# Coding Questions

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

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

**Page:** 81

---

## [On/off with keypressed and released](https://discourse.processing.org/t/on-off-with-keypressed-and-released/17211)

<div class="topic-metadata">

**Author:** [@floflopm](https://discourse.processing.org/u/floflopm)\
**Replies:** 2\
**Last updated:** [September 18, 2020, 9:49pm UTC](https://discourse.processing.org/t/on-off-with-keypressed-and-released/17211 "2020-09-18T21:49:02Z")

</div>

Hi, the following bit of my script I would like to activate only when a key is pressed and hold. I would like to deactivate it as soon as the key is released. How can I do this? Thanks, // (it is located at the end of…

---

## [CA air imitation issues](https://discourse.processing.org/t/ca-air-imitation-issues/23869)

<div class="topic-metadata">

**Author:** [@PinkyRng](https://discourse.processing.org/u/PinkyRng)\
**Replies:** 2\
**Last updated:** [September 18, 2020, 11:23am UTC](https://discourse.processing.org/t/ca-air-imitation-issues/23869 "2020-09-18T11:23:24Z")

</div>

Hey! So I’m trying to create and prototype a small simulation for fun. I’m using CA(Cellular Automata) in 2D environment to imitate air. Now I done some progress and ironed out some issues I think… My math is sub par and…

---

## [Platform game mechanics](https://discourse.processing.org/t/platform-game-mechanics/23889)

<div class="topic-metadata">

**Author:** [@koenterheegde57](https://discourse.processing.org/u/koenterheegde57)\
**Replies:** 3\
**Last updated:** [September 18, 2020, 10:22am UTC](https://discourse.processing.org/t/platform-game-mechanics/23889 "2020-09-18T10:22:39Z")

</div>

Hi guys, I’m trying to make a simple platform game but I can’t solve the problem of my Ball having a different y level after a jump. When my yvelocity is high, my Ball just goes through the platform, because it’s not de…

---

## [Refering to a class rather than an object for collision](https://discourse.processing.org/t/refering-to-a-class-rather-than-an-object-for-collision/23933)

<div class="topic-metadata">

**Author:** [@Dan999](https://discourse.processing.org/u/Dan999)\
**Replies:** 1\
**Last updated:** [September 18, 2020, 10:06am UTC](https://discourse.processing.org/t/refering-to-a-class-rather-than-an-object-for-collision/23933 "2020-09-18T10:06:54Z")

</div>

I want to refer to a class rather than an object, so I don’t need a seperate if statement for each object, does anybody know how to do this?

---

## [Snapping the mouse to the center of the window?](https://discourse.processing.org/t/snapping-the-mouse-to-the-center-of-the-window/23896)

<div class="topic-metadata">

**Author:** [@sashakoshka](https://discourse.processing.org/u/sashakoshka)\
**Replies:** 2\
**Last updated:** [September 18, 2020, 8:36am UTC](https://discourse.processing.org/t/snapping-the-mouse-to-the-center-of-the-window/23896 "2020-09-18T08:36:23Z")

</div>

I am trying to snap the mouse cursor to the center of the window every frame. I tried using the robot class to do this, but the problem with that solution is it positions the cursor relative to the screen, not the window…

---

## [Translating twice, Once to rotate around center, Again for placement on page](https://discourse.processing.org/t/translating-twice-once-to-rotate-around-center-again-for-placement-on-page/23881)

<div class="topic-metadata">

**Author:** [@tobie](https://discourse.processing.org/u/tobie)\
**Replies:** 2\
**Last updated:** [September 17, 2020, 6:49pm UTC](https://discourse.processing.org/t/translating-twice-once-to-rotate-around-center-again-for-placement-on-page/23881 "2020-09-17T18:49:23Z")

</div>

void setup() { background(240, 237, 235); size(500, 500); } void draw(){ background(240, 237, 235); noStroke(); int gap = 20; float mult = 2; for(int i = -width; i \<= width; i+=(gap\*mult)){ pushMatrix(…

---

## [Holding the same angle](https://discourse.processing.org/t/holding-the-same-angle/23919)

<div class="topic-metadata">

**Author:** [@koenterheegde57](https://discourse.processing.org/u/koenterheegde57)\
**Replies:** 1\
**Last updated:** [September 17, 2020, 4:00pm UTC](https://discourse.processing.org/t/holding-the-same-angle/23919 "2020-09-17T16:00:31Z")

</div>

Hi guys, A few days ago i posted a question about a bubbleshooter game i wanted to make. I’ve now managed to make the bullet move towards my mouse position, but the angle keeps changing if i move the mouse. I want the a…

---

## [How to wrap with circular motion](https://discourse.processing.org/t/how-to-wrap-with-circular-motion/23906)

<div class="topic-metadata">

**Author:** [@lkalotihos](https://discourse.processing.org/u/lkalotihos)\
**Replies:** 3\
**Last updated:** [September 17, 2020, 1:34pm UTC](https://discourse.processing.org/t/how-to-wrap-with-circular-motion/23906 "2020-09-17T13:34:31Z")

</div>

Hi there, I’m trying to get this circular motion to bound off the border of my container (wrap I think) how would I go about that? Thanks, Lena float x; float y; float x1; float y1; float x2; float y2; //float = deci…

---

## [How do I use the encryption (secure) random method?](https://discourse.processing.org/t/how-do-i-use-the-encryption-secure-random-method/23728)

<div class="topic-metadata">

**Author:** [@AntiViral\_Builder](https://discourse.processing.org/u/AntiViral_Builder)\
**Replies:** 1\
**Last updated:** [September 15, 2020, 6:17pm UTC](https://discourse.processing.org/t/how-do-i-use-the-encryption-secure-random-method/23728 "2020-09-15T18:17:01Z")

</div>

So I would just like to know how to generate arrays with a size and number range.

---

## [Separate objects in an ArrayList](https://discourse.processing.org/t/separate-objects-in-an-arraylist/23823)

<div class="topic-metadata">

**Author:** [@yanze03](https://discourse.processing.org/u/yanze03)\
**Replies:** 16\
**Last updated:** [September 15, 2020, 4:41pm UTC](https://discourse.processing.org/t/separate-objects-in-an-arraylist/23823 "2020-09-15T16:41:47Z")

</div>

please format code with \</\> button \* homework policy \* asking questions Hello fellow processing members, I am working on a project where Iam trying to make a program using an ArrayList. The goal is to have a square…

---

## [Problem with mouseClicked Function](https://discourse.processing.org/t/problem-with-mouseclicked-function/23852)

<div class="topic-metadata">

**Author:** [@lkalotihos](https://discourse.processing.org/u/lkalotihos)\
**Replies:** 2\
**Last updated:** [September 15, 2020, 4:31pm UTC](https://discourse.processing.org/t/problem-with-mouseclicked-function/23852 "2020-09-15T16:31:14Z")

</div>

Hi there, I’m trying to get the ellipses that make up the “interactive eyes” change to a random color when mouse is pressed. I tried fill(random(255), random(255), random(255)); but it doesn’t seem to be working. Wh…

---

## [3D camera rotation](https://discourse.processing.org/t/3d-camera-rotation/23742)

<div class="topic-metadata">

**Author:** [@Kport1](https://discourse.processing.org/u/Kport1)\
**Replies:** 14\
**Last updated:** [September 15, 2020, 6:12am UTC](https://discourse.processing.org/t/3d-camera-rotation/23742 "2020-09-15T06:12:11Z")

</div>

Hello! im trying to create a 3D camera that rotates when mouse is dragged. I created something that works, but the movement feels very strange. Here’s my code: Planet p = new Planet(new PVector(width / 2, height / 2, …

---

## [Java.lang.RuntimeException Error in Processing](https://discourse.processing.org/t/java-lang-runtimeexception-error-in-processing/23860)

<div class="topic-metadata">

**Author:** [@cottonchipper](https://discourse.processing.org/u/cottonchipper)\
**Replies:** 1\
**Last updated:** [September 14, 2020, 8:42pm UTC](https://discourse.processing.org/t/java-lang-runtimeexception-error-in-processing/23860 "2020-09-14T20:42:34Z")

</div>

I’m very new to learning Processing on my own and would like to work with a sketch I found that mimics the old Solari train station timetable displays. I found the sketch here: https://github.com/lukecyca/Solari The ske…

---

## [Why is an ellipse in the wrong spot?](https://discourse.processing.org/t/why-is-an-ellipse-in-the-wrong-spot/23843)

<div class="topic-metadata">

**Author:** [@alejo\_rgb](https://discourse.processing.org/u/alejo_rgb)\
**Replies:** 5\
**Last updated:** [September 14, 2020, 1:24pm UTC](https://discourse.processing.org/t/why-is-an-ellipse-in-the-wrong-spot/23843 "2020-09-14T13:24:56Z")

</div>

Hi Why my code is drawing an ellipse in the top left corner? Circulo\[\] circ = new Circulo\[49\]; void setup() { size(800, 800); for (int i = 0; i \< 48; i++) { circ\[i\] = new Circulo(); } } void draw() { bac…

---

## [\[SOLVED\] Running a sketch at a low resolution in fullscreen](https://discourse.processing.org/t/solved-running-a-sketch-at-a-low-resolution-in-fullscreen/2461)

<div class="topic-metadata">

**Author:** [@Upow](https://discourse.processing.org/u/Upow)\
**Replies:** 18\
**Last updated:** [September 14, 2020, 9:59am UTC](https://discourse.processing.org/t/solved-running-a-sketch-at-a-low-resolution-in-fullscreen/2461 "2020-09-14T09:59:25Z")

</div>

Hello everyone, Is there a good way to run a sketch at a low resolution, say with size(640, 480), but then run that low resolution size at a full screen size? In addition it would be important to be able to run on a sec…

---

## [Checking if all elements in an array are the same](https://discourse.processing.org/t/checking-if-all-elements-in-an-array-are-the-same/23708)

<div class="topic-metadata">

**Author:** [@TheEternalDragon](https://discourse.processing.org/u/TheEternalDragon)\
**Replies:** 5\
**Last updated:** [September 14, 2020, 5:59am UTC](https://discourse.processing.org/t/checking-if-all-elements-in-an-array-are-the-same/23708 "2020-09-14T05:59:42Z")

</div>

So I have been trying to get a program to work, the point of the program is to display every image in an arraylist in a random order (taking the mouse as input to go to the next image) and then reset and repeat to do thi…

---

## [Player keeps moving with the bullet](https://discourse.processing.org/t/player-keeps-moving-with-the-bullet/23320)

<div class="topic-metadata">

**Author:** [@Cybernet](https://discourse.processing.org/u/Cybernet)\
**Replies:** 3\
**Last updated:** [September 13, 2020, 10:00pm UTC](https://discourse.processing.org/t/player-keeps-moving-with-the-bullet/23320 "2020-09-13T22:00:19Z")

</div>

I have this code, and there’s a player class and a bullet class. But when I shoot a bullet, it moves the player along with it… class Bullet { PVector pos; PVector vel; float rotation; Bullet(PVector pos, PVec…

---

## [Changing color fill with keyPressed in the function](https://discourse.processing.org/t/changing-color-fill-with-keypressed-in-the-function/23828)

<div class="topic-metadata">

**Author:** [@breadstixnsalad](https://discourse.processing.org/u/breadstixnsalad)\
**Replies:** 11\
**Last updated:** [September 13, 2020, 8:31pm UTC](https://discourse.processing.org/t/changing-color-fill-with-keypressed-in-the-function/23828 "2020-09-13T20:31:28Z")

</div>

I am a noob at Processing and looking to make it so that if you press an arrow, t hebackground goes from ‘day’ color to either ‘sunset’ or ‘night’, while hiding the trails left by the moving cloud when it follows your m…

---

## [Drag and Drop Boolean Array](https://discourse.processing.org/t/drag-and-drop-boolean-array/23803)

<div class="topic-metadata">

**Author:** [@jaspervb](https://discourse.processing.org/u/jaspervb)\
**Replies:** 6\
**Last updated:** [September 13, 2020, 3:14am UTC](https://discourse.processing.org/t/drag-and-drop-boolean-array/23803 "2020-09-13T03:14:11Z")

</div>

Hello there, I need help with processing. I want to make a drag&drop example in a array of elements. Unfortunaly, it still does not work after struggling in processing. int num = 3; Drag\[\] element = new Drag\[int(num…

---

## [Limiting rotation](https://discourse.processing.org/t/limiting-rotation/23825)

<div class="topic-metadata">

**Author:** [@BACI821](https://discourse.processing.org/u/BACI821)\
**Replies:** 2\
**Last updated:** [September 12, 2020, 5:58pm UTC](https://discourse.processing.org/t/limiting-rotation/23825 "2020-09-12T17:58:36Z")

</div>

Hello Alll, Newbie programmer here (just learning the ropes). I’m trying to create a dash for a boat which runs off arduino. I’m trying to make the UI right now.I need to limit the rotation of my indicator. The indicato…

---

## [Thoroughly seeding random()](https://discourse.processing.org/t/thoroughly-seeding-random/23819)

<div class="topic-metadata">

**Author:** [@somegrue](https://discourse.processing.org/u/somegrue)\
**Replies:** 4\
**Last updated:** [September 12, 2020, 3:00pm UTC](https://discourse.processing.org/t/thoroughly-seeding-random/23819 "2020-09-12T15:00:57Z")

</div>

Hello board, so, I want to generate numbers that are random but, optionally, repeatable. What I gleaned from other threads is that the most straightforward way to do that is along these lines: By default, use random()…

---

## [Bubble shooter game mechanics](https://discourse.processing.org/t/bubble-shooter-game-mechanics/23774)

<div class="topic-metadata">

**Author:** [@koenterheegde57](https://discourse.processing.org/u/koenterheegde57)\
**Replies:** 1\
**Last updated:** [September 12, 2020, 8:07am UTC](https://discourse.processing.org/t/bubble-shooter-game-mechanics/23774 "2020-09-12T08:07:52Z")

</div>

Hi everybody, I want to recreate the bubbleshooter game but I can’t figure out how to get a ‘bullet’ moving towards my mouse, which will be the direction of the bullet. I tried using the formula y=ax+b and also tried to…

---

## [Controlling an array of Blinking Eyes Independently of Each Other](https://discourse.processing.org/t/controlling-an-array-of-blinking-eyes-independently-of-each-other/23761)

<div class="topic-metadata">

**Author:** [@jcser](https://discourse.processing.org/u/jcser)\
**Replies:** 3\
**Last updated:** [September 10, 2020, 8:10am UTC](https://discourse.processing.org/t/controlling-an-array-of-blinking-eyes-independently-of-each-other/23761 "2020-09-10T08:10:23Z")

</div>

Hi, I am very new to processing and I am making a program based on a Coding Train Video. I have created an Eye Class that display’s an eye and then makes it blink. At the moment I can populate the scene with an array of …

---

## [Class may need some refinement](https://discourse.processing.org/t/class-may-need-some-refinement/23768)

<div class="topic-metadata">

**Author:** [@pandl](https://discourse.processing.org/u/pandl)\
**Replies:** 0\
**Last updated:** [September 10, 2020, 12:55am UTC](https://discourse.processing.org/t/class-may-need-some-refinement/23768 "2020-09-10T00:55:48Z")

</div>

Thank you for reading this. I have created a simple LED class that, no doubt, needs some refinement. I thought about adding a capability to have square LEDS as well as a size option. I also wanted to have the colours as…

---

## [Creating field for integer input](https://discourse.processing.org/t/creating-field-for-integer-input/23749)

<div class="topic-metadata">

**Author:** [@Jaguar](https://discourse.processing.org/u/Jaguar)\
**Replies:** 3\
**Last updated:** [September 9, 2020, 9:01pm UTC](https://discourse.processing.org/t/creating-field-for-integer-input/23749 "2020-09-09T21:01:46Z")

</div>

Could you please guide me where to look for creating a field to enter integer/digits in processing? Would appreciate your help!

---

## [How to put text in motion?](https://discourse.processing.org/t/how-to-put-text-in-motion/23762)

<div class="topic-metadata">

**Author:** [@carole\_line](https://discourse.processing.org/u/carole_line)\
**Replies:** 1\
**Last updated:** [September 9, 2020, 8:56pm UTC](https://discourse.processing.org/t/how-to-put-text-in-motion/23762 "2020-09-09T20:56:11Z")

</div>

Good evening, so there you go. I’m doing my college semester on Processing programming, but I don’t know how to get the text moving. A series of numbers appears, but my texts remain motionless.

---

## [PGraphics color and saving](https://discourse.processing.org/t/pgraphics-color-and-saving/23748)

<div class="topic-metadata">

**Author:** [@mr\_riptano](https://discourse.processing.org/u/mr_riptano)\
**Replies:** 10\
**Last updated:** [September 9, 2020, 6:22pm UTC](https://discourse.processing.org/t/pgraphics-color-and-saving/23748 "2020-09-09T18:22:52Z")

</div>

Trying to get offscreen graphics working. Two issues I’m running into: (1) The coloring is off. HSB(0, 100, 100) should be a nice bright red. And when I draw directly on the main canvas, it is. Drawing to pg first a…

---

## [Bounce ray casting recursion problem](https://discourse.processing.org/t/bounce-ray-casting-recursion-problem/23667)

<div class="topic-metadata">

**Author:** [@arcadeperfect](https://discourse.processing.org/u/arcadeperfect)\
**Replies:** 1\
**Last updated:** [September 9, 2020, 2:47pm UTC](https://discourse.processing.org/t/bounce-ray-casting-recursion-problem/23667 "2020-09-09T14:47:30Z")

</div>

Hello! TLDR; trying to add recursive bounces to a raycasting algorithm first set of rays works, subsequent ones sort of work but are very buggy indeed. I’m working on a 2D ray casting idea based on my hero Dan Schiff…

---

## [Successive draws of a transparent object don't end up fully opaque?](https://discourse.processing.org/t/successive-draws-of-a-transparent-object-dont-end-up-fully-opaque/23715)

<div class="topic-metadata">

**Author:** [@pablohotsauce](https://discourse.processing.org/u/pablohotsauce)\
**Replies:** 3\
**Last updated:** [September 8, 2020, 6:55pm UTC](https://discourse.processing.org/t/successive-draws-of-a-transparent-object-dont-end-up-fully-opaque/23715 "2020-09-08T18:55:56Z")

</div>

In this example, I draw a semi-transparent black rectangle to cover the canvas on every run-through of draw(), to gradually cover up and darken the results of the stuff I’d drawn in all previous draw() runs. Shouldn’t th…

---

## [How can I mask graphics to a resizable rectangle?](https://discourse.processing.org/t/how-can-i-mask-graphics-to-a-resizable-rectangle/23632)

<div class="topic-metadata">

**Author:** [@Brastin](https://discourse.processing.org/u/Brastin)\
**Replies:** 13\
**Last updated:** [September 8, 2020, 1:54pm UTC](https://discourse.processing.org/t/how-can-i-mask-graphics-to-a-resizable-rectangle/23632 "2020-09-08T13:54:17Z")

</div>

Hey, I’m in the process of writing a windowed environment in processing. An issue that I’ve struggled with for a while now is being able to mask the contents of a window to the window. Say if I wanted to scroll some text…

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

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