# Coding Questions

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

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

**Page:** 112

---

## [Time class, carry, don't understand how it works exactly](https://discourse.processing.org/t/time-class-carry-dont-understand-how-it-works-exactly/17098)

<div class="topic-metadata">

**Author:** [@ddownn](https://discourse.processing.org/u/ddownn)\
**Replies:** 2\
**Last updated:** [January 17, 2020, 12:52pm UTC](https://discourse.processing.org/t/time-class-carry-dont-understand-how-it-works-exactly/17098 "2020-01-17T12:52:26Z")

</div>

I need help understanding how the pre() function in this Time class works. Edit: I think maybe I have it, does this seem sound? So far it seems to be working. The thing I don’t like about this is that I made it work by…

---

## [Mouse click doesn't change back on time table](https://discourse.processing.org/t/mouse-click-doesnt-change-back-on-time-table/16987)

<div class="topic-metadata">

**Author:** [@Rango](https://discourse.processing.org/u/Rango)\
**Replies:** 11\
**Last updated:** [January 16, 2020, 5:39pm UTC](https://discourse.processing.org/t/mouse-click-doesnt-change-back-on-time-table/16987 "2020-01-16T17:39:30Z")

</div>

I have created a time table everything works, the only problem is when I click my mouse it changes to what I wanted but doesn’t go back. Can any one help. Thanks PImage chemistry; // Declare a PImage named chemistry PI…

---

## [A key that when clicked will increase the speed of the square](https://discourse.processing.org/t/a-key-that-when-clicked-will-increase-the-speed-of-the-square/16939)

<div class="topic-metadata">

**Author:** [@Rango](https://discourse.processing.org/u/Rango)\
**Replies:** 18\
**Last updated:** [January 16, 2020, 5:33pm UTC](https://discourse.processing.org/t/a-key-that-when-clicked-will-increase-the-speed-of-the-square/16939 "2020-01-16T17:33:15Z")

</div>

int x=20; int y=650; int w=20; int h=20; int c=1; int d=20; String a= ""; String b= "Warning: Wormhole detected ahead. Approach with caution."; float rectX; float rectY; float rectA; float rectB; float rectC; float…

---

## [Decreasing opacity in a text String](https://discourse.processing.org/t/decreasing-opacity-in-a-text-string/17006)

<div class="topic-metadata">

**Author:** [@VictoireCl](https://discourse.processing.org/u/VictoireCl)\
**Replies:** 4\
**Last updated:** [January 15, 2020, 10:52am UTC](https://discourse.processing.org/t/decreasing-opacity-in-a-text-string/17006 "2020-01-15T10:52:32Z")

</div>

Hello everyone, I am new to Processing and trying to code a clock for a school project. I would like the opacity to gradually decrease across several pieces of text but none of the things I’ve tried worked out. Here is…

---

## [Problem coding an easy game / how to make it restart](https://discourse.processing.org/t/problem-coding-an-easy-game-how-to-make-it-restart/17030)

<div class="topic-metadata">

**Author:** [@mezza](https://discourse.processing.org/u/mezza)\
**Replies:** 5\
**Last updated:** [January 15, 2020, 2:11am UTC](https://discourse.processing.org/t/problem-coding-an-easy-game-how-to-make-it-restart/17030 "2020-01-15T02:11:57Z")

</div>

Hi everyone! I’m doing a game using processing. The game’s pretty simple: there’s a black bar that slowly rises when you get a point and your goal is to bring the bar up to the top. To get a point it works pretty much l…

---

## [How to make a game with many different objects (ArrayList)](https://discourse.processing.org/t/how-to-make-a-game-with-many-different-objects-arraylist/16839)

<div class="topic-metadata">

**Author:** [@BennyHacker](https://discourse.processing.org/u/BennyHacker)\
**Replies:** 5\
**Last updated:** [January 14, 2020, 10:46pm UTC](https://discourse.processing.org/t/how-to-make-a-game-with-many-different-objects-arraylist/16839 "2020-01-14T22:46:17Z")

</div>

Hello forum, I’m not sure how to make many unique objects that can all be defined in a single class. The problem stems from the fact that I’m trying to put many different entities into a single ArrayList for efficiency…

---

## [Check if line intersects a polygon](https://discourse.processing.org/t/check-if-line-intersects-a-polygon/16978)

<div class="topic-metadata">

**Author:** [@AndreasRef](https://discourse.processing.org/u/AndreasRef)\
**Replies:** 7\
**Last updated:** [January 14, 2020, 2:07pm UTC](https://discourse.processing.org/t/check-if-line-intersects-a-polygon/16978 "2020-01-14T14:07:02Z")

</div>

Hi How do I find out if a line between two points are intersecting a polygon? To give a bit of context I am trying to build a small tool that draws perspective lines between a flat polygon and a vanishing point. It is …

---

## [Recursive Tree without using rotate()](https://discourse.processing.org/t/recursive-tree-without-using-rotate/17080)

<div class="topic-metadata">

**Author:** [@AndreasRef](https://discourse.processing.org/u/AndreasRef)\
**Replies:** 6\
**Last updated:** [January 14, 2020, 1:15pm UTC](https://discourse.processing.org/t/recursive-tree-without-using-rotate/17080 "2020-01-14T13:15:32Z")

</div>

This might be a weird question :thinking:, but here goes: Would it be possible to draw a Recursive Tree WITHOUT using rotate()? I ask because I am preparing a couple of interactive projects where I use Processing to co…

---

## [P2Matrix to turn around axis](https://discourse.processing.org/t/p2matrix-to-turn-around-axis/17031)

<div class="topic-metadata">

**Author:** [@matheplica](https://discourse.processing.org/u/matheplica)\
**Replies:** 6\
**Last updated:** [January 14, 2020, 12:58pm UTC](https://discourse.processing.org/t/p2matrix-to-turn-around-axis/17031 "2020-01-14T12:58:47Z")

</div>

Hi, I’m trying to turn a PVector to 60 degree with a PMatrix2D. I found this formula : https://en.wikipedia.org/wiki/Rotation\_matrix But I don’t find the right way to code it. Results are always on the down of the scre…

---

## [Need help for a simple Grid](https://discourse.processing.org/t/need-help-for-a-simple-grid/17033)

<div class="topic-metadata">

**Author:** [@DeadApe](https://discourse.processing.org/u/DeadApe)\
**Replies:** 4\
**Last updated:** [January 12, 2020, 1:51am UTC](https://discourse.processing.org/t/need-help-for-a-simple-grid/17033 "2020-01-12T01:51:18Z")

</div>

Hello ppl, i don’t get the failure in my code. I just want to draw a simple grid out of rectangles. My Code: void settings(){ size(800, 800); } void setup(){ int blockSize = 30; int hBlocks = 10; int wBlocks …

---

## [Game 2D light and shadow ray casting with colors](https://discourse.processing.org/t/game-2d-light-and-shadow-ray-casting-with-colors/14025)

<div class="topic-metadata">

**Author:** [@GeorgeJava](https://discourse.processing.org/u/GeorgeJava)\
**Replies:** 6\
**Last updated:** [January 11, 2020, 9:23am UTC](https://discourse.processing.org/t/game-2d-light-and-shadow-ray-casting-with-colors/14025 "2020-01-11T09:23:17Z")

</div>

Hello, I create sketch that uses ray casting with shadows and lights, but i want to tint every single light with own color, how i can do it ? boolean lihghtsEnable = true; PImage background, screen; PGraphics lightMas…

---

## [The algorithm is too slow](https://discourse.processing.org/t/the-algorithm-is-too-slow/16553)

<div class="topic-metadata">

**Author:** [@costachemadalin](https://discourse.processing.org/u/costachemadalin)\
**Replies:** 2\
**Last updated:** [January 10, 2020, 11:18pm UTC](https://discourse.processing.org/t/the-algorithm-is-too-slow/16553 "2020-01-10T23:18:21Z")

</div>

Hello, i am trying to calculate disparity from 2 rectified images and for that i need to take every pixel from left image and seach in one line from right image and find the similar pixel ,the dimension of the images is …

---

## [Small problem while making snake game](https://discourse.processing.org/t/small-problem-while-making-snake-game/16990)

<div class="topic-metadata">

**Author:** [@RoebenV](https://discourse.processing.org/u/RoebenV)\
**Replies:** 11\
**Last updated:** [January 10, 2020, 9:35pm UTC](https://discourse.processing.org/t/small-problem-while-making-snake-game/16990 "2020-01-10T21:35:21Z")

</div>

I’m making a snake game where you can control the snake using the mouse, so if you’re above the snake’s head it should go up etc. I don’t know how I can make this, I’ve tried switching around if statements but to no avai…

---

## [Help with catcher game](https://discourse.processing.org/t/help-with-catcher-game/16715)

<div class="topic-metadata">

**Author:** [@Clay1](https://discourse.processing.org/u/Clay1)\
**Replies:** 6\
**Last updated:** [January 8, 2020, 11:36am UTC](https://discourse.processing.org/t/help-with-catcher-game/16715 "2020-01-08T11:36:19Z")

</div>

I am trying to make a catcher game (im a beginner) and some how the balls that fall are making a line and are not delating so, you don’t se a ball faling but a thick line. Can somebody help me out and look at my code? …

---

## [I want to clear these buttons from the canvas any tips? (processing 3+)](https://discourse.processing.org/t/i-want-to-clear-these-buttons-from-the-canvas-any-tips-processing-3/16962)

<div class="topic-metadata">

**Author:** [@NinjaKittens](https://discourse.processing.org/u/NinjaKittens)\
**Replies:** 10\
**Last updated:** [January 10, 2020, 8:25am UTC](https://discourse.processing.org/t/i-want-to-clear-these-buttons-from-the-canvas-any-tips-processing-3/16962 "2020-01-10T08:25:15Z")

</div>

This is the code that I have so far: PImage a; PImage b; void setup() { size(1000,1000); background(100,255,110); a = loadImage("https://www.openprocessing.org/sketch/813047/files/Screenshot\_2019-12-19\_at\_84649\_AM.png"…

---

## [Moving object Speed increases when key pressed](https://discourse.processing.org/t/moving-object-speed-increases-when-key-pressed/16993)

<div class="topic-metadata">

**Author:** [@jegg](https://discourse.processing.org/u/jegg)\
**Replies:** 1\
**Last updated:** [January 10, 2020, 1:12am UTC](https://discourse.processing.org/t/moving-object-speed-increases-when-key-pressed/16993 "2020-01-10T01:12:10Z")

</div>

I need help with a code i want to increase the speed of a moving object when the key “P” is pressed i cant find the code. I need this for a project Here is my code float x = 100; float y = 100; float xSpeed = 0; flo…

---

## [Reset Arraylist of "Enemies" in order to Replay the Game](https://discourse.processing.org/t/reset-arraylist-of-enemies-in-order-to-replay-the-game/16975)

<div class="topic-metadata">

**Author:** [@cp796](https://discourse.processing.org/u/cp796)\
**Replies:** 8\
**Last updated:** [January 9, 2020, 5:46pm UTC](https://discourse.processing.org/t/reset-arraylist-of-enemies-in-order-to-replay-the-game/16975 "2020-01-09T17:46:12Z")

</div>

Hi, So I’m trying to create a game and I have an Arraylist of enemies. I want upon collision to reset it, in order if chosen by the player to play again from the “lose” screen to take him back and totally restart the ga…

---

## [Use input methods like Microsoft Chinese and Japanese Input](https://discourse.processing.org/t/use-input-methods-like-microsoft-chinese-and-japanese-input/16982)

<div class="topic-metadata">

**Author:** [@LoliProcessor](https://discourse.processing.org/u/LoliProcessor)\
**Replies:** 0\
**Last updated:** [January 9, 2020, 3:47pm UTC](https://discourse.processing.org/t/use-input-methods-like-microsoft-chinese-and-japanese-input/16982 "2020-01-09T15:47:02Z")

</div>

Is there a way to create an interface that let’s you use the input from the Microsoft Chinese and Japanese Input for example? JTextInput seems to be able to detect it, but I already started writing my project in Process…

---

## [Count identical strings in array for each unique entry](https://discourse.processing.org/t/count-identical-strings-in-array-for-each-unique-entry/16678)

<div class="topic-metadata">

**Author:** [@AndreasRef](https://discourse.processing.org/u/AndreasRef)\
**Replies:** 6\
**Last updated:** [January 9, 2020, 12:24pm UTC](https://discourse.processing.org/t/count-identical-strings-in-array-for-each-unique-entry/16678 "2020-01-09T12:24:41Z")

</div>

If I have an array of strings, how do I count the number of times each unique string occurs in the array? I do not know the content of the array beforehand.

---

## [Println order help?](https://discourse.processing.org/t/println-order-help/16928)

<div class="topic-metadata">

**Author:** [@crazybob5](https://discourse.processing.org/u/crazybob5)\
**Replies:** 3\
**Last updated:** [January 9, 2020, 9:19am UTC](https://discourse.processing.org/t/println-order-help/16928 "2020-01-09T09:19:42Z")

</div>

Can someone explain me the order of printlines here? int a = 4; int b = 7; void setup() { println("Setup: " + knutsel(a, b)); } int knutsel(int b, int a) { println("Knutsel: " + a); println("Knutsel: " + b); return …

---

## [Is there a way to pivot an image around a certain point?](https://discourse.processing.org/t/is-there-a-way-to-pivot-an-image-around-a-certain-point/16947)

<div class="topic-metadata">

**Author:** [@laptophead](https://discourse.processing.org/u/laptophead)\
**Replies:** 3\
**Last updated:** [January 9, 2020, 1:22am UTC](https://discourse.processing.org/t/is-there-a-way-to-pivot-an-image-around-a-certain-point/16947 "2020-01-09T01:22:07Z")

</div>

I need to turn this image around the hole in bottom. The hole is located 323 pixels from the top and 182 from the left edge. I tried something like: PImage BD1; float R; void setup() { size(1790, 1100, JAVA2D); …

---

## [For loops in for loops](https://discourse.processing.org/t/for-loops-in-for-loops/16957)

<div class="topic-metadata">

**Author:** [@Clay1](https://discourse.processing.org/u/Clay1)\
**Replies:** 6\
**Last updated:** [January 8, 2020, 7:40pm UTC](https://discourse.processing.org/t/for-loops-in-for-loops/16957 "2020-01-08T19:40:09Z")

</div>

Hi, I have created this code to make a poster. But I really want to make the code shorter, since it is the same for loop again and again only different placing and the amount of circles it creates. But I don’t know ho…

---

## [I need help to make it so that when the square touches a green rectangle it resets to position (20,650)](https://discourse.processing.org/t/i-need-help-to-make-it-so-that-when-the-square-touches-a-green-rectangle-it-resets-to-position-20-650/16940)

<div class="topic-metadata">

**Author:** [@Rango](https://discourse.processing.org/u/Rango)\
**Replies:** 2\
**Last updated:** [January 8, 2020, 4:17pm UTC](https://discourse.processing.org/t/i-need-help-to-make-it-so-that-when-the-square-touches-a-green-rectangle-it-resets-to-position-20-650/16940 "2020-01-08T16:17:08Z")

</div>

int x=20; int y=650; int w=20; int h=20; int c=1; int d=20; String a= ""; String b= "Warning: Wormhole detected ahead. Approach with caution."; float rectX; float rectY; float rectA; float rectB; float rectC; float …

---

## [Get a higher resolution](https://discourse.processing.org/t/get-a-higher-resolution/16951)

<div class="topic-metadata">

**Author:** [@fabnai](https://discourse.processing.org/u/fabnai)\
**Replies:** 2\
**Last updated:** [January 8, 2020, 12:45pm UTC](https://discourse.processing.org/t/get-a-higher-resolution/16951 "2020-01-08T12:45:15Z")

</div>

Hello Everybody I have a question: I found this code from Dan Shifman about fluid simulation. If I run the code the resolution is very poor can someone tell me how I can get a better resolution? Thank you verry much f…

---

## [Writing console output to a text file](https://discourse.processing.org/t/writing-console-output-to-a-text-file/16949)

<div class="topic-metadata">

**Author:** [@idisc007](https://discourse.processing.org/u/idisc007)\
**Replies:** 2\
**Last updated:** [January 8, 2020, 8:05am UTC](https://discourse.processing.org/t/writing-console-output-to-a-text-file/16949 "2020-01-08T08:05:31Z")

</div>

The output in my sketch produces a maximum of 500 lines, which forces the first lines to disappear. My output is thousands of lines. I need code that will write all output lines from the console window to a text file. Th…

---

## [Making my stick figure blink](https://discourse.processing.org/t/making-my-stick-figure-blink/16934)

<div class="topic-metadata">

**Author:** [@Kvigna](https://discourse.processing.org/u/Kvigna)\
**Replies:** 3\
**Last updated:** [January 8, 2020, 4:12am UTC](https://discourse.processing.org/t/making-my-stick-figure-blink/16934 "2020-01-08T04:12:22Z")

</div>

Hi! I’m trying to figure out how I would make the eyes of my stick figure blink. Please help me figure it out. My code is: //Drawing a character void setup(){ size(400,400); background(200,255,100); } void draw(){ …

---

## [Catcher game (game over)](https://discourse.processing.org/t/catcher-game-game-over/16944)

<div class="topic-metadata">

**Author:** [@Clay1](https://discourse.processing.org/u/Clay1)\
**Replies:** 1\
**Last updated:** [January 8, 2020, 1:47am UTC](https://discourse.processing.org/t/catcher-game-game-over/16944 "2020-01-08T01:47:04Z")

</div>

How do i make my code so that if you dont catch something and it hits the ground it will reset? So it will start a new game and say like game over? Can some help me? Thanks Catcher myCatcher; Ball\[\] fallingBall; void…

---

## ["Variable in variable"/putting a variable in the name behind void / calling methods by name](https://discourse.processing.org/t/variable-in-variable-putting-a-variable-in-the-name-behind-void-calling-methods-by-name/16935)

<div class="topic-metadata">

**Author:** [@Optyfen\_met\_Eenden](https://discourse.processing.org/u/Optyfen_met_Eenden)\
**Replies:** 10\
**Last updated:** [January 7, 2020, 6:36pm UTC](https://discourse.processing.org/t/variable-in-variable-putting-a-variable-in-the-name-behind-void-calling-methods-by-name/16935 "2020-01-07T18:36:52Z")

</div>

Hey everyone, Does anyone know how to put a variable in the name behind void, also does the method work with regular variables, not implementing an array? an example to explain this question: int Mode=0; void draw(){ …

---

## [Map processing sketch coordinates to shader .frag coordinates](https://discourse.processing.org/t/map-processing-sketch-coordinates-to-shader-frag-coordinates/16844)

<div class="topic-metadata">

**Author:** [@rojele](https://discourse.processing.org/u/rojele)\
**Replies:** 5\
**Last updated:** [January 7, 2020, 5:34pm UTC](https://discourse.processing.org/t/map-processing-sketch-coordinates-to-shader-frag-coordinates/16844 "2020-01-07T17:34:16Z")

</div>

Hi, everyone, Since I am a beginer with shaders, I’m stuck in this very basic matter. I would like to generate a shader image output in the exact point where the mouse is, as a first step in the project I am currently i…

---

## [Setting different time variables](https://discourse.processing.org/t/setting-different-time-variables/16861)

<div class="topic-metadata">

**Author:** [@Salttt](https://discourse.processing.org/u/Salttt)\
**Replies:** 9\
**Last updated:** [January 7, 2020, 2:04am UTC](https://discourse.processing.org/t/setting-different-time-variables/16861 "2020-01-07T02:04:54Z")

</div>

I am trying to make two things happen in time but independently to each other. I want the time after each of them to reset, but not reset the time for the other thing. Here’s example code to show what I mean; int time =…

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

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