# Coding Questions

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

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

**Page:** 149

---

## [Detecting if object is within image](https://discourse.processing.org/t/detecting-if-object-is-within-image/9054)

<div class="topic-metadata">

**Author:** [@cdallan](https://discourse.processing.org/u/cdallan)\
**Replies:** 1\
**Last updated:** [March 7, 2019, 3:01pm UTC](https://discourse.processing.org/t/detecting-if-object-is-within-image/9054 "2019-03-07T15:01:41Z")

</div>

Greetings all, I’m a newcomer to processing and have had fun creating various designs in the program. In an attempt to tackle something more complex, I’m currently creating a game where a mouse-controlled “parasite” obj…

---

## [Sprites using arrays](https://discourse.processing.org/t/sprites-using-arrays/8825)

<div class="topic-metadata">

**Author:** [@taryncollymore](https://discourse.processing.org/u/taryncollymore)\
**Replies:** 3\
**Last updated:** [March 6, 2019, 9:26pm UTC](https://discourse.processing.org/t/sprites-using-arrays/8825 "2019-03-06T21:26:24Z")

</div>

I need help with using multiple images to create an animated sprite that moves as the mouse moves. My professor wants us to use arrays to accomplish this, but I’m not sure how to integrate multiple images into the code t…

---

## [Solving an exercise in Dan Shiffman "Learning Processing"](https://discourse.processing.org/t/solving-an-exercise-in-dan-shiffman-learning-processing/8817)

<div class="topic-metadata">

**Author:** [@debxyz](https://discourse.processing.org/u/debxyz)\
**Replies:** 4\
**Last updated:** [March 6, 2019, 8:51pm UTC](https://discourse.processing.org/t/solving-an-exercise-in-dan-shiffman-learning-processing/8817 "2019-03-06T20:51:55Z")

</div>

Trying to solve Exercise 5-8 (p.83) in D. Shiffman book “Learning Processing” Keep getting an error message: "unexpected token: void" Goal: circle starts moving in sketch once the mouse has been pressed. Here is my co…

---

## [Parallel line that follows the mouse with circle](https://discourse.processing.org/t/parallel-line-that-follows-the-mouse-with-circle/8909)

<div class="topic-metadata">

**Author:** [@JasJones](https://discourse.processing.org/u/JasJones)\
**Replies:** 3\
**Last updated:** [March 6, 2019, 7:32pm UTC](https://discourse.processing.org/t/parallel-line-that-follows-the-mouse-with-circle/8909 "2019-03-06T19:32:42Z")

</div>

How can I fix the ellipse in the middle / left outside of the background-window? Here is my code until now: void setup(){ size(100,100); } void draw(){ background(200); line(mouseX,0,mouseX,100); ellipseMode(CO…

---

## [How can I implement objects with colliders?](https://discourse.processing.org/t/how-can-i-implement-objects-with-colliders/9033)

<div class="topic-metadata">

**Author:** [@mone](https://discourse.processing.org/u/mone)\
**Replies:** 1\
**Last updated:** [March 6, 2019, 7:32pm UTC](https://discourse.processing.org/t/how-can-i-implement-objects-with-colliders/9033 "2019-03-06T19:32:23Z")

</div>

I have to do a program where the player moves an object with the keyboard and there are obstacles that collide with the player. I have the movement part and it works really well but I really dont know how to print object…

---

## [Zombie game kill counter increments nonstop](https://discourse.processing.org/t/zombie-game-kill-counter-increments-nonstop/9032)

<div class="topic-metadata">

**Author:** [@ZAZ](https://discourse.processing.org/u/ZAZ)\
**Replies:** 1\
**Last updated:** [March 6, 2019, 7:22pm UTC](https://discourse.processing.org/t/zombie-game-kill-counter-increments-nonstop/9032 "2019-03-06T19:22:55Z")

</div>

Okay so I have been working on this project for quite a while. Basically I made a shooting game. Zombies are rendered on the screen frame by frame. and when they are shot, an explosion is rendered (Technically the zombie…

---

## [Problems with loading pictures and keeping framerate at 60](https://discourse.processing.org/t/problems-with-loading-pictures-and-keeping-framerate-at-60/9008)

<div class="topic-metadata">

**Author:** [@jensemand](https://discourse.processing.org/u/jensemand)\
**Replies:** 1\
**Last updated:** [March 6, 2019, 2:05pm UTC](https://discourse.processing.org/t/problems-with-loading-pictures-and-keeping-framerate-at-60/9008 "2019-03-06T14:05:25Z")

</div>

Hi, i am trying to make a game, where it is necessary to load pictures, however my framerate drops every time I load a picture (For now i only load one picture at a time). It may be because the quality of the pictures is…

---

## [Trying to create a BCD clock](https://discourse.processing.org/t/trying-to-create-a-bcd-clock/8560)

<div class="topic-metadata">

**Author:** [@Banansplitt](https://discourse.processing.org/u/Banansplitt)\
**Replies:** 2\
**Last updated:** [March 6, 2019, 10:32am UTC](https://discourse.processing.org/t/trying-to-create-a-bcd-clock/8560 "2019-03-06T10:32:30Z")

</div>

I’m trying o create a BCD clock, but something seems very off. The value of s = second(); returns a negative value, and the clock isn’t displaying correctly. What am I doing wrong? int h; int m; int s; void setup(){ …

---

## [Ellipse moving in rectangular shape](https://discourse.processing.org/t/ellipse-moving-in-rectangular-shape/8988)

<div class="topic-metadata">

**Author:** [@cathfrier](https://discourse.processing.org/u/cathfrier)\
**Replies:** 2\
**Last updated:** [March 6, 2019, 7:31am UTC](https://discourse.processing.org/t/ellipse-moving-in-rectangular-shape/8988 "2019-03-06T07:31:15Z")

</div>

Hi there! The solution is probably right in front of me, but I’m struggling with my code. I have an ellipse that are meant to move in a rectangular shape, from top right (x0, y0) \> bottom right (x1, y1) \> diagonal bott…

---

## [Files must be loaded inside setup() or after it has been called](https://discourse.processing.org/t/files-must-be-loaded-inside-setup-or-after-it-has-been-called/8751)

<div class="topic-metadata">

**Author:** [@Kyle](https://discourse.processing.org/u/Kyle)\
**Replies:** 7\
**Last updated:** [March 6, 2019, 12:31am UTC](https://discourse.processing.org/t/files-must-be-loaded-inside-setup-or-after-it-has-been-called/8751 "2019-03-06T00:31:58Z")

</div>

My code has many different object classes which all extend the main class. Each one has its own set of PImages (I have found that the only way to make them work is to loadImage them inside the class constructor, you can …

---

## [Printing characters one by one?](https://discourse.processing.org/t/printing-characters-one-by-one/8952)

<div class="topic-metadata">

**Author:** [@JsRambles](https://discourse.processing.org/u/JsRambles)\
**Replies:** 2\
**Last updated:** [March 5, 2019, 2:59am UTC](https://discourse.processing.org/t/printing-characters-one-by-one/8952 "2019-03-05T02:59:19Z")

</div>

Hello, How can I print out string characters one by one? Kind of like how in some RPG games when an NPC is talking the text will print out slowing at a certain speed each letter one by one. However I’m not going left …

---

## [How do I optimize/make my script run better/let processing take more resources](https://discourse.processing.org/t/how-do-i-optimize-make-my-script-run-better-let-processing-take-more-resources/8948)

<div class="topic-metadata">

**Author:** [@F53](https://discourse.processing.org/u/F53)\
**Replies:** 2\
**Last updated:** [March 5, 2019, 12:56am UTC](https://discourse.processing.org/t/how-do-i-optimize-make-my-script-run-better-let-processing-take-more-resources/8948 "2019-03-05T00:56:56Z")

</div>

I recently coded a simple point cloud script but it starts to lag really bad when I go above 250 or so points. Is there any way to optimize my script / let processing take more resources? keep in mind I am new to Proce…

---

## [Rectangle moving along the z-axis](https://discourse.processing.org/t/rectangle-moving-along-the-z-axis/8736)

<div class="topic-metadata">

**Author:** [@Raoul](https://discourse.processing.org/u/Raoul)\
**Replies:** 6\
**Last updated:** [March 4, 2019, 3:55pm UTC](https://discourse.processing.org/t/rectangle-moving-along-the-z-axis/8736 "2019-03-04T15:55:28Z")

</div>

Hello, I am learning Processing reading the Daniel Shiffman book and I just started the Chapter “Trasformation and 3D”. The following code is the first example about using the z axis. I can not understand why once Z re…

---

## [Why background() is not updated in a draw() loop](https://discourse.processing.org/t/why-background-is-not-updated-in-a-draw-loop/8904)

<div class="topic-metadata">

**Author:** [@elode](https://discourse.processing.org/u/elode)\
**Replies:** 3\
**Last updated:** [March 3, 2019, 11:13pm UTC](https://discourse.processing.org/t/why-background-is-not-updated-in-a-draw-loop/8904 "2019-03-03T23:13:39Z")

</div>

I start with Processing. I’m studying Daniel Shiffman’s book “Learning Processing”. In Exercise 6.5 of the book, I can not understand why background(0) which is in draw() is not updated each time a new line is drawn, e…

---

## [Beginners, processing, moving more than one object](https://discourse.processing.org/t/beginners-processing-moving-more-than-one-object/8903)

<div class="topic-metadata">

**Author:** [@Valete](https://discourse.processing.org/u/Valete)\
**Replies:** 4\
**Last updated:** [March 3, 2019, 9:18pm UTC](https://discourse.processing.org/t/beginners-processing-moving-more-than-one-object/8903 "2019-03-03T21:18:07Z")

</div>

hello, i am a super beginner at processing and java, but i have a reasonable background at C language, so i know some of the concepts of programing, but i decided learn something new, and i am trying to learn processing. …

---

## [Skybox, Skysphere](https://discourse.processing.org/t/skybox-skysphere/8735)

<div class="topic-metadata">

**Author:** [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Replies:** 3\
**Last updated:** [March 3, 2019, 8:10am UTC](https://discourse.processing.org/t/skybox-skysphere/8735 "2019-03-03T08:10:37Z")

</div>

Hello all, can anyone provide the code for a skybox, maybe with a kind of floor? It’s for a graphic program (Menger Sponge) I work on. A full code would be great… Thanks! Regards, Chrisir

---

## [Need help with Twister game with changing rules i.e if statements](https://discourse.processing.org/t/need-help-with-twister-game-with-changing-rules-i-e-if-statements/8806)

<div class="topic-metadata">

**Author:** [@jacobm](https://discourse.processing.org/u/jacobm)\
**Replies:** 6\
**Last updated:** [March 3, 2019, 12:38am UTC](https://discourse.processing.org/t/need-help-with-twister-game-with-changing-rules-i-e-if-statements/8806 "2019-03-03T00:38:18Z")

</div>

Hi, I am new to processing and I have written this code for a easy twister game. Now I want to change the rules so that the instruction like for example left hand floor does not repeat. So basically altering the random …

---

## [Help with code pastebin link is https://pastebin.com/fr4Gs5YH](https://discourse.processing.org/t/help-with-code-pastebin-link-is-https-pastebin-com-fr4gs5yh/8798)

<div class="topic-metadata">

**Author:** [@DumboWumbo](https://discourse.processing.org/u/DumboWumbo)\
**Replies:** 1\
**Last updated:** [March 3, 2019, 12:23am UTC](https://discourse.processing.org/t/help-with-code-pastebin-link-is-https-pastebin-com-fr4gs5yh/8798 "2019-03-03T00:23:44Z")

</div>

Hello i recently madea some code in order to “distort” the image but the original image continues to be put on top of tge scrambled image and i do not know what is wrong.(paste bin link https://pastebin.com/fr4Gs5YH

---

## [2D Array Help needed](https://discourse.processing.org/t/2d-array-help-needed/8567)

<div class="topic-metadata">

**Author:** [@Awal](https://discourse.processing.org/u/Awal)\
**Replies:** 2\
**Last updated:** [February 21, 2019, 10:26am UTC](https://discourse.processing.org/t/2d-array-help-needed/8567 "2019-02-21T10:26:35Z")

</div>

Hi, I am hoping someone can help me again with my Processing assignment. This is a red and black checker board. The question is “add one line of code that will create a circle using the ellipse function and place it on …

---

## [How to fill the canvas with a string?](https://discourse.processing.org/t/how-to-fill-the-canvas-with-a-string/8742)

<div class="topic-metadata">

**Author:** [@jacobo](https://discourse.processing.org/u/jacobo)\
**Replies:** 3\
**Last updated:** [March 2, 2019, 4:19am UTC](https://discourse.processing.org/t/how-to-fill-the-canvas-with-a-string/8742 "2019-03-02T04:19:05Z")

</div>

Hi! Basically I want to fill the 700x1000 canvas with 3 sets of text lines till it hits 600 pixels y. I’ve tried to make a String with the lines of text and put it into a for loop but I’m not sure if it’s the correct w…

---

## [How to make something inside a loop happen once?](https://discourse.processing.org/t/how-to-make-something-inside-a-loop-happen-once/8807)

<div class="topic-metadata">

**Author:** [@jacobo](https://discourse.processing.org/u/jacobo)\
**Replies:** 8\
**Last updated:** [March 1, 2019, 8:33pm UTC](https://discourse.processing.org/t/how-to-make-something-inside-a-loop-happen-once/8807 "2019-03-01T20:33:23Z")

</div>

Hey guys. In this code I’d like the words to be randomly generated just once and not over and over again, while still keeping it bouncing from left to right. I’m new at processing so help is much appreciated! float te…

---

## [Create collision between the characters](https://discourse.processing.org/t/create-collision-between-the-characters/8791)

<div class="topic-metadata">

**Author:** [@Rey](https://discourse.processing.org/u/Rey)\
**Replies:** 1\
**Last updated:** [March 1, 2019, 6:41pm UTC](https://discourse.processing.org/t/create-collision-between-the-characters/8791 "2019-03-01T18:41:39Z")

</div>

ex: Game and watch Hi I should create a collision between the characters, example, \* character \* touches the \* enemy \* and the enemy disappears. can you help me? Code here (http://fromsmash.com/9b1ee406-3b42-11e9-a045…

---

## [Storing previous points when using a for-loop?](https://discourse.processing.org/t/storing-previous-points-when-using-a-for-loop/8829)

<div class="topic-metadata">

**Author:** [@JsRambles](https://discourse.processing.org/u/JsRambles)\
**Replies:** 2\
**Last updated:** [March 1, 2019, 2:11pm UTC](https://discourse.processing.org/t/storing-previous-points-when-using-a-for-loop/8829 "2019-03-01T14:11:41Z")

</div>

Hello, I am trying to make a 9 sided polygon using points and than connecting the points with lines. Reading other forums I know there is a way to do this using the vertex() commands and using arrays however this is fo…

---

## [Help making a diagonal ellipse](https://discourse.processing.org/t/help-making-a-diagonal-ellipse/8827)

<div class="topic-metadata">

**Author:** [@Velouria](https://discourse.processing.org/u/Velouria)\
**Replies:** 1\
**Last updated:** [March 1, 2019, 4:53am UTC](https://discourse.processing.org/t/help-making-a-diagonal-ellipse/8827 "2019-03-01T04:53:36Z")

</div>

Hi everyone! So i´ve been trying to make an ellipse that crosses the screen diagonally but even with the different types of ellipseMode i can only do them cross the screen either horizontally or vertically. Any suggesti…

---

## [Adding wind to bouncing ball example](https://discourse.processing.org/t/adding-wind-to-bouncing-ball-example/8748)

<div class="topic-metadata">

**Author:** [@pieceofcrazy](https://discourse.processing.org/u/pieceofcrazy)\
**Replies:** 1\
**Last updated:** [February 28, 2019, 7:07pm UTC](https://discourse.processing.org/t/adding-wind-to-bouncing-ball-example/8748 "2019-02-28T19:07:00Z")

</div>

I’m pretty new to coding and while playing around with the BouncingBall example I tried to add some air pushing the ball up if the mouse button in pressed, but it looks really goofy because the ball just goes up in a str…

---

## [Minification question](https://discourse.processing.org/t/minification-question/8724)

<div class="topic-metadata">

**Author:** [@Tsskyx](https://discourse.processing.org/u/Tsskyx)\
**Replies:** 6\
**Last updated:** [February 27, 2019, 8:02pm UTC](https://discourse.processing.org/t/minification-question/8724 "2019-02-27T20:02:05Z")

</div>

The following code cycles the value of the variable NET within a range of 0 to 4. int NET; void setup() { println(NET); } void draw() { } void keyPressed() { if (keyCode == UP || keyCode == DOWN) NET = ((NET += keyC…

---

## [How to scale text and distance proportionally to avoid overlap?](https://discourse.processing.org/t/how-to-scale-text-and-distance-proportionally-to-avoid-overlap/8763)

<div class="topic-metadata">

**Author:** [@jacobo](https://discourse.processing.org/u/jacobo)\
**Replies:** 1\
**Last updated:** [February 27, 2019, 6:52pm UTC](https://discourse.processing.org/t/how-to-scale-text-and-distance-proportionally-to-avoid-overlap/8763 "2019-02-27T18:52:17Z")

</div>

Hi! I want to be able to scale text size and spacing/leading proportionally to avoid overlaps of text. I’d like to be able to scale the text from it’s current size in 5 columns to a bigger text size in for example 3 colu…

---

## [Problem with adding objects to ArrayList](https://discourse.processing.org/t/problem-with-adding-objects-to-arraylist/8764)

<div class="topic-metadata">

**Author:** [@Tymek](https://discourse.processing.org/u/Tymek)\
**Replies:** 3\
**Last updated:** [February 27, 2019, 5:27pm UTC](https://discourse.processing.org/t/problem-with-adding-objects-to-arraylist/8764 "2019-02-27T17:27:48Z")

</div>

Hello, I wonder how to add object to ArrayList, when some conditions have been fullfiled. For example, i want to add new cell only if my mouse coursor is over one of each cells. Code is here. Thanks in advance :slight\_s…

---

## [Calling a function that returns array stops printArray](https://discourse.processing.org/t/calling-a-function-that-returns-array-stops-printarray/6108)

<div class="topic-metadata">

**Author:** [@thenewkgb](https://discourse.processing.org/u/thenewkgb)\
**Replies:** 15\
**Last updated:** [February 27, 2019, 3:59pm UTC](https://discourse.processing.org/t/calling-a-function-that-returns-array-stops-printarray/6108 "2019-02-27T15:59:13Z")

</div>

Try uncommenting grabline’s (r\[\]=details;) line. I haven’t been instructed where to place things really. Any help? int ws=6; int ls=6; int sx=0; int ex=findex(); int myline\[\]; void setup() { background(255); size(…

---

## [PImages change to null in separate class](https://discourse.processing.org/t/pimages-change-to-null-in-separate-class/8403)

<div class="topic-metadata">

**Author:** [@Kyle](https://discourse.processing.org/u/Kyle)\
**Replies:** 9\
**Last updated:** [February 27, 2019, 4:05am UTC](https://discourse.processing.org/t/pimages-change-to-null-in-separate-class/8403 "2019-02-27T04:05:49Z")

</div>

I am using Processing core in Eclipse IDE, and I’m currently working on some code where I have many object classes inside of the main class. Recently I decided to move one of those classes (a class called bat) into a sep…

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

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