# Coding Questions

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

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

**Page:** 164

---

## [How can you reuse a variable?](https://discourse.processing.org/t/how-can-you-reuse-a-variable/5842)

<div class="topic-metadata">

**Author:** [@dennisreyes](https://discourse.processing.org/u/dennisreyes)\
**Replies:** 4\
**Last updated:** [November 23, 2018, 3:19am UTC](https://discourse.processing.org/t/how-can-you-reuse-a-variable/5842 "2018-11-23T03:19:39Z")

</div>

I’m trying to make some sort of non-graphic version of a game. It involves two dices and when you roll any number besides the ones listed, you roll again until you get the one on the first roll. What have I done wrong or…

---

## [Random StrokeWeight not working?](https://discourse.processing.org/t/random-strokeweight-not-working/5840)

<div class="topic-metadata">

**Author:** [@ReDeagle](https://discourse.processing.org/u/ReDeagle)\
**Replies:** 2\
**Last updated:** [November 23, 2018, 2:45am UTC](https://discourse.processing.org/t/random-strokeweight-not-working/5840 "2018-11-23T02:45:36Z")

</div>

Hey everyone, I’m making a program that will output balloons of different sizes using for loops. The fill should also be using stroke (another for loop). The program outputs balloons of the same size (code is below)… Hel…

---

## [Change tint/color of image on click](https://discourse.processing.org/t/change-tint-color-of-image-on-click/4517)

<div class="topic-metadata">

**Author:** [@dennisreyes](https://discourse.processing.org/u/dennisreyes)\
**Replies:** 5\
**Last updated:** [October 16, 2018, 10:31pm UTC](https://discourse.processing.org/t/change-tint-color-of-image-on-click/4517 "2018-10-16T22:31:27Z")

</div>

Hi! I am new to processing and I was wondering if it is possible to change the tint of an image on click?

---

## [Why is my ball going downwards?](https://discourse.processing.org/t/why-is-my-ball-going-downwards/5822)

<div class="topic-metadata">

**Author:** [@OliverMcDk](https://discourse.processing.org/u/OliverMcDk)\
**Replies:** 7\
**Last updated:** [November 22, 2018, 4:39pm UTC](https://discourse.processing.org/t/why-is-my-ball-going-downwards/5822 "2018-11-22T16:39:20Z")

</div>

Hey, can anyone help me to get my ball to “shoot” upwards. Kinda like a canon, so my ball shoots, and i can change the degrees its shoots after. My code is very simple, cause im new to this program. We are trying to ma…

---

## [Translate Java code into Processing](https://discourse.processing.org/t/translate-java-code-into-processing/5807)

<div class="topic-metadata">

**Author:** [@DarkSt0ne](https://discourse.processing.org/u/DarkSt0ne)\
**Replies:** 1\
**Last updated:** [November 21, 2018, 10:31pm UTC](https://discourse.processing.org/t/translate-java-code-into-processing/5807 "2018-11-21T22:31:51Z")

</div>

Hello there, I was wondering if any of you could translate the following java code into processing: import java.util.Scanner; public class AtmMachine{ private static Scanner in; private static float balance = 0 ; /…

---

## [Need help with frogger](https://discourse.processing.org/t/need-help-with-frogger/5639)

<div class="topic-metadata">

**Author:** [@Hunter\_noob](https://discourse.processing.org/u/Hunter_noob)\
**Replies:** 3\
**Last updated:** [November 21, 2018, 9:30pm UTC](https://discourse.processing.org/t/need-help-with-frogger/5639 "2018-11-21T21:30:16Z")

</div>

Hi guys, I’m working on a processing game called Frogger. I created the world and the frog, but I could not move the frog. I am pretty sure there are some problems in my codes, but I just could not find the problems, co…

---

## [Inheritance override draw()](https://discourse.processing.org/t/inheritance-override-draw/5724)

<div class="topic-metadata">

**Author:** [@donone](https://discourse.processing.org/u/donone)\
**Replies:** 6\
**Last updated:** [November 21, 2018, 6:59pm UTC](https://discourse.processing.org/t/inheritance-override-draw/5724 "2018-11-21T18:59:33Z")

</div>

I have a class using registerMethod(“draw”,this); Works fine. In a subclass I am attempting to override the draw() method in the parent in order to ‘add’ to the original. I cannot override, and I have tried super.draw(…

---

## [Maze generation](https://discourse.processing.org/t/maze-generation/5801)

<div class="topic-metadata">

**Author:** [@eduzal](https://discourse.processing.org/u/eduzal)\
**Replies:** 0\
**Last updated:** [November 21, 2018, 6:32pm UTC](https://discourse.processing.org/t/maze-generation/5801 "2018-11-21T18:32:12Z")

</div>

Hi guys. I’ve hit a wall here. I’m trying to build a generative keith herring’s maze, or something like those grafitti fillings maze, like the image below. I’ve done a few thing, but now I hit a wall and I’m stuck. I…

---

## [getLocation() of the sketch](https://discourse.processing.org/t/getlocation-of-the-sketch/5763)

<div class="topic-metadata">

**Author:** [@Stanlepunk](https://discourse.processing.org/u/Stanlepunk)\
**Replies:** 5\
**Last updated:** [November 21, 2018, 5:30pm UTC](https://discourse.processing.org/t/getlocation-of-the-sketch/5763 "2018-11-21T17:30:00Z")

</div>

I try to catch the location of my sketch, but I don’t find any option to do that like surface.setLocation(). Any idea which method can be used to catch the sketch position, like before getLocationOnScreen()

---

## [Strange Font & Math Problems, Basic Math would Probably Help](https://discourse.processing.org/t/strange-font-math-problems-basic-math-would-probably-help/5755)

<div class="topic-metadata">

**Author:** [@c0nfused\_t3chie](https://discourse.processing.org/u/c0nfused_t3chie)\
**Replies:** 3\
**Last updated:** [November 21, 2018, 5:57am UTC](https://discourse.processing.org/t/strange-font-math-problems-basic-math-would-probably-help/5755 "2018-11-21T05:57:44Z")

</div>

Hello, first time posting sorry if this is vauge, just needing some help with what I thought should be basic math. For random reasons I felt making a sandbox version of a terminal window to help teach someone more power…

---

## [Erasing draw after "x" frames](https://discourse.processing.org/t/erasing-draw-after-x-frames/5707)

<div class="topic-metadata">

**Author:** [@vayjean](https://discourse.processing.org/u/vayjean)\
**Replies:** 4\
**Last updated:** [November 21, 2018, 1:57am UTC](https://discourse.processing.org/t/erasing-draw-after-x-frames/5707 "2018-11-21T01:57:06Z")

</div>

Hi everyone, I’m a new user of processing and i’m trying to make abstractions drawing with the below code. However I don’t arrive to erase the drawing after a certain amount of frames. Does someone knows how to do this …

---

## [Hi i am getting an error on the boolean method saying missing left curly brace at the end of the crash method](https://discourse.processing.org/t/hi-i-am-getting-an-error-on-the-boolean-method-saying-missing-left-curly-brace-at-the-end-of-the-crash-method/5759)

<div class="topic-metadata">

**Author:** [@redFoa](https://discourse.processing.org/u/redFoa)\
**Replies:** 2\
**Last updated:** [November 20, 2018, 10:04pm UTC](https://discourse.processing.org/t/hi-i-am-getting-an-error-on-the-boolean-method-saying-missing-left-curly-brace-at-the-end-of-the-crash-method/5759 "2018-11-20T22:04:35Z")

</div>

bnbmb,n,m,jkhkhkj;h;hjj

---

## [Question about deleting an object](https://discourse.processing.org/t/question-about-deleting-an-object/5760)

<div class="topic-metadata">

**Author:** [@Jeany](https://discourse.processing.org/u/Jeany)\
**Replies:** 2\
**Last updated:** [November 20, 2018, 2:29pm UTC](https://discourse.processing.org/t/question-about-deleting-an-object/5760 "2018-11-20T14:29:33Z")

</div>

Hello, I’m working with a team on a school project and we’re making a little race game. Sadly we are stuck on a bug/problem we are having. I hoped someone would help us here. We would really appreciate it! So the probl…

---

## [Not reading text file for example on website](https://discourse.processing.org/t/not-reading-text-file-for-example-on-website/5750)

<div class="topic-metadata">

**Author:** [@Oz\_joker](https://discourse.processing.org/u/Oz_joker)\
**Replies:** 3\
**Last updated:** [November 20, 2018, 4:32am UTC](https://discourse.processing.org/t/not-reading-text-file-for-example-on-website/5750 "2018-11-20T04:32:31Z")

</div>

Hi, I’m trying to get this simple example to work from your website: https://processing.org/examples/loadfile1.html I’ve made a text file called positions.txt, and followed the instructions on the website, "Loads a te…

---

## [Anti-rotation command](https://discourse.processing.org/t/anti-rotation-command/5752)

<div class="topic-metadata">

**Author:** [@alk5603](https://discourse.processing.org/u/alk5603)\
**Replies:** 2\
**Last updated:** [November 20, 2018, 4:27am UTC](https://discourse.processing.org/t/anti-rotation-command/5752 "2018-11-20T04:27:12Z")

</div>

float angle = 0, radius = 300; int num = 6; void setup() { size(800, 800); fill(255); } void draw() { fill(0, 20); rect(-50, -50, width+100, height+100); translate(width/2, height/2); rotate(angle); if (mouseP…

---

## [I need help morphing two jpg images](https://discourse.processing.org/t/i-need-help-morphing-two-jpg-images/5722)

<div class="topic-metadata">

**Author:** [@morphinghero](https://discourse.processing.org/u/morphinghero)\
**Replies:** 1\
**Last updated:** [November 19, 2018, 11:08pm UTC](https://discourse.processing.org/t/i-need-help-morphing-two-jpg-images/5722 "2018-11-19T23:08:31Z")

</div>

Does anyone know how to morph two jpg images using Processing? If so can I please have the code for it I am stuck and I cannot find the information everywhere.

---

## [A caught error exception occurred on Raspberry Pi](https://discourse.processing.org/t/a-caught-error-exception-occurred-on-raspberry-pi/1129)

<div class="topic-metadata">

**Author:** [@Samsanit](https://discourse.processing.org/u/Samsanit)\
**Replies:** 5\
**Last updated:** [June 22, 2018, 9:55pm UTC](https://discourse.processing.org/t/a-caught-error-exception-occurred-on-raspberry-pi/1129 "2018-06-22T21:55:01Z")

</div>

Hi, while working with processing on raspberry pi I was attempting to have a second screen pop up with data I had gathered in a separate method. On short runs (about 1 minute or less), the code is able to make this witho…

---

## [Culling text outside of a certain bounds?](https://discourse.processing.org/t/culling-text-outside-of-a-certain-bounds/5701)

<div class="topic-metadata">

**Author:** [@Bluu](https://discourse.processing.org/u/Bluu)\
**Replies:** 2\
**Last updated:** [November 19, 2018, 2:14pm UTC](https://discourse.processing.org/t/culling-text-outside-of-a-certain-bounds/5701 "2018-11-19T14:14:32Z")

</div>

I’m making a scrolling textbox(much like an HTML textarea) in a processing project, but when the box is full and has nowhere to overflow, it bleeds into other elements. is there any way to make the text only appear withi…

---

## [Flickering background when updating img.pixels\[\] in another thread](https://discourse.processing.org/t/flickering-background-when-updating-img-pixels-in-another-thread/5710)

<div class="topic-metadata">

**Author:** [@companje](https://discourse.processing.org/u/companje)\
**Replies:** 2\
**Last updated:** [November 19, 2018, 2:10pm UTC](https://discourse.processing.org/t/flickering-background-when-updating-img-pixels-in-another-thread/5710 "2018-11-19T14:10:11Z")

</div>

Hello, When I’m updating the pixels of an PImage in a different thread this somehow effects the background of my main (P3D) sketch (on both Mac and Window). Even when the image is not bound as a texture. Any idea? PIma…

---

## [Text() and Delay()](https://discourse.processing.org/t/text-and-delay/5698)

<div class="topic-metadata">

**Author:** [@CodeMonkey](https://discourse.processing.org/u/CodeMonkey)\
**Replies:** 8\
**Last updated:** [November 19, 2018, 11:17am UTC](https://discourse.processing.org/t/text-and-delay/5698 "2018-11-19T11:17:28Z")

</div>

I want text to appear on the screen, but letter by letter and slowly. When I execute this code nothing is displayed to the user and I’m unsure as to why. String textLine = “This is a test to see if I can do this”; St…

---

## [Replicate inbuilt functions](https://discourse.processing.org/t/replicate-inbuilt-functions/5473)

<div class="topic-metadata">

**Author:** [@Dee-3\_123](https://discourse.processing.org/u/Dee-3_123)\
**Replies:** 9\
**Last updated:** [November 19, 2018, 5:40am UTC](https://discourse.processing.org/t/replicate-inbuilt-functions/5473 "2018-11-19T05:40:51Z")

</div>

I want to understand the logic of below functions… 10. float pow(float n, int pow) 13. int String.indexOf(String str) 14. boolean String.contains(String str) 16. boolean String.equalsIgnoreCase(String str)

---

## [selectOutput feature](https://discourse.processing.org/t/selectoutput-feature/5606)

<div class="topic-metadata">

**Author:** [@FerrariLuigi](https://discourse.processing.org/u/FerrariLuigi)\
**Replies:** 6\
**Last updated:** [November 18, 2018, 6:16pm UTC](https://discourse.processing.org/t/selectoutput-feature/5606 "2018-11-18T18:16:04Z")

</div>

Dear all, I developed a very simple sketch in which I use the selectOutput function. It works but, as soon as the select output file window is open, the sketch graphic disappear and the desktop is shown. Did you have …

---

## [Ohm's law exercice](https://discourse.processing.org/t/ohms-law-exercice/5660)

<div class="topic-metadata">

**Author:** [@saotome](https://discourse.processing.org/u/saotome)\
**Replies:** 2\
**Last updated:** [November 18, 2018, 4:47pm UTC](https://discourse.processing.org/t/ohms-law-exercice/5660 "2018-11-18T16:47:10Z")

</div>

Good morning. Thanks to jb4x I been able to draw a simple electric circuit boolean isOpen; float Vpila=10.0; float R1=100.00; float Rv=500.00; float DR=5.00; float color\_alpha=0; float I=0.00; void setup() { size(600…

---

## [Basic computer course project University](https://discourse.processing.org/t/basic-computer-course-project-university/5526)

<div class="topic-metadata">

**Author:** [@SeanTYH](https://discourse.processing.org/u/SeanTYH)\
**Replies:** 30\
**Last updated:** [November 18, 2018, 1:34pm UTC](https://discourse.processing.org/t/basic-computer-course-project-university/5526 "2018-11-18T13:34:14Z")

</div>

i was doing an assignment for my basic level computer course. what i wanted was to draw pac man ghosts in different colors (3 color choices) and 3 pac man ghosts at time = 3 which will slowly increase as the ghosts are k…

---

## [How to store last 20 mouse positions in an array?](https://discourse.processing.org/t/how-to-store-last-20-mouse-positions-in-an-array/5626)

<div class="topic-metadata">

**Author:** [@fmS3lect](https://discourse.processing.org/u/fmS3lect)\
**Replies:** 5\
**Last updated:** [November 17, 2018, 10:48pm UTC](https://discourse.processing.org/t/how-to-store-last-20-mouse-positions-in-an-array/5626 "2018-11-17T22:48:02Z")

</div>

Hey all together, i am Sebastian, i am very new to programming and i think i need some help :smiley: i wrote this code snippet to store the last 20 mouse positions but it only stores the same 20times… i cannot figure …

---

## [Rotate image implementation](https://discourse.processing.org/t/rotate-image-implementation/5615)

<div class="topic-metadata">

**Author:** [@molo32](https://discourse.processing.org/u/molo32)\
**Replies:** 2\
**Last updated:** [November 17, 2018, 11:17am UTC](https://discourse.processing.org/t/rotate-image-implementation/5615 "2018-11-17T11:17:32Z")

</div>

I’m implementing the matrix rotation from here My code works but the rotated image has holes, I guess it’s because of the rounding of the values of sin () and cos () How to fill the holes in the rotated image? …

---

## [How to make a switch in a circuit?](https://discourse.processing.org/t/how-to-make-a-switch-in-a-circuit/5603)

<div class="topic-metadata">

**Author:** [@saotome](https://discourse.processing.org/u/saotome)\
**Replies:** 5\
**Last updated:** [November 17, 2018, 11:07am UTC](https://discourse.processing.org/t/how-to-make-a-switch-in-a-circuit/5603 "2018-11-17T11:07:32Z")

</div>

Hello. I have this "circuit! void setup() { size(600, 600); } void draw() { ellipse (300, 150, 40, 40); line (280, 150, 120, 150); line (120, 150, 120, 220); line (120, 220, 120, 290); //closed circuit line (1…

---

## [Problem with saving PImage with transparency](https://discourse.processing.org/t/problem-with-saving-pimage-with-transparency/5566)

<div class="topic-metadata">

**Author:** [@Spu7Nix](https://discourse.processing.org/u/Spu7Nix)\
**Replies:** 4\
**Last updated:** [November 16, 2018, 6:09pm UTC](https://discourse.processing.org/t/problem-with-saving-pimage-with-transparency/5566 "2018-11-16T18:09:07Z")

</div>

Hi, i have written this little program to cut a spritesheet for me, but it doesn’t work with transparency. Anybody know a fix? PImage sheet = loadImage("dirtTiles.png"); PImage\[\] tiles = new PImage\[25\]; int s = 16; bac…

---

## [Aim Game coding help](https://discourse.processing.org/t/aim-game-coding-help/5562)

<div class="topic-metadata">

**Author:** [@SpeedKillerX](https://discourse.processing.org/u/SpeedKillerX)\
**Replies:** 1\
**Last updated:** [November 15, 2018, 7:15pm UTC](https://discourse.processing.org/t/aim-game-coding-help/5562 "2018-11-15T19:15:47Z")

</div>

I need help with my code in processing, which is an easy code but since I am new to coding I will be needing some help with My code is sort of like an aim game where different boxes pop up and you will have to click (Sh…

---

## [Can Mouse Coordinates Change with Translate and Rotate?](https://discourse.processing.org/t/can-mouse-coordinates-change-with-translate-and-rotate/5580)

<div class="topic-metadata">

**Author:** [@Erit1566](https://discourse.processing.org/u/Erit1566)\
**Replies:** 1\
**Last updated:** [November 16, 2018, 6:14am UTC](https://discourse.processing.org/t/can-mouse-coordinates-change-with-translate-and-rotate/5580 "2018-11-16T06:14:56Z")

</div>

Hi, I am trying to be able to change where the mouse cursor is so it would be easier to see if I am hovering over one of my objects without looking at every pixel by pixel. Thanks in advance, Eric

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

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