# Coding Questions

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

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

**Page:** 78

---

## [NullPointerException when calling fill() from another class](https://discourse.processing.org/t/nullpointerexception-when-calling-fill-from-another-class/24594)

<div class="topic-metadata">

**Author:** [@S\_V](https://discourse.processing.org/u/S_V)\
**Replies:** 2\
**Last updated:** [October 14, 2020, 4:06pm UTC](https://discourse.processing.org/t/nullpointerexception-when-calling-fill-from-another-class/24594 "2020-10-14T16:06:57Z")

</div>

Hi, I’m new to processing and trying to learn the basics of it. However I’m having this weird error which is hindering me from properly organizing my code. Basically: I have a base class which has functions for drawing…

---

## [Embed .txt file in a sketch](https://discourse.processing.org/t/embed-txt-file-in-a-sketch/24542)

<div class="topic-metadata">

**Author:** [@kurtis452](https://discourse.processing.org/u/kurtis452)\
**Replies:** 4\
**Last updated:** [October 14, 2020, 12:48pm UTC](https://discourse.processing.org/t/embed-txt-file-in-a-sketch/24542 "2020-10-14T12:48:10Z")

</div>

I’m making a simple desktop app which links to a few websites, but I also want it to be able to display a .txt file embedded in the sketch if possible. I’d prefer not to rebuild the document by doing loadlines(), but ins…

---

## [Making shape change color with keys](https://discourse.processing.org/t/making-shape-change-color-with-keys/24584)

<div class="topic-metadata">

**Author:** [@karbon](https://discourse.processing.org/u/karbon)\
**Replies:** 1\
**Last updated:** [October 14, 2020, 7:12am UTC](https://discourse.processing.org/t/making-shape-change-color-with-keys/24584 "2020-10-14T07:12:27Z")

</div>

I am coding for an assignment and I am having a hard time. I want to make a shape, then particles, change between red. yellow and blue by hitting keys. I can’t tell what I’m doing wrong. Please help! float offset =180; …

---

## [Help, how to change the size](https://discourse.processing.org/t/help-how-to-change-the-size/24517)

<div class="topic-metadata">

**Author:** [@Ellie98](https://discourse.processing.org/u/Ellie98)\
**Replies:** 7\
**Last updated:** [October 13, 2020, 3:49pm UTC](https://discourse.processing.org/t/help-how-to-change-the-size/24517 "2020-10-13T15:49:25Z")

</div>

Hello, how do I make that the size of the green square gets bigger if I go up with the mouse and the red one gets smaller at the same time and if I go down with the mouse that the green one gets smaller and the red one …

---

## [Memory leak in PGraphics](https://discourse.processing.org/t/memory-leak-in-pgraphics/24500)

<div class="topic-metadata">

**Author:** [@NullPointer](https://discourse.processing.org/u/NullPointer)\
**Replies:** 10\
**Last updated:** [October 13, 2020, 6:48pm UTC](https://discourse.processing.org/t/memory-leak-in-pgraphics/24500 "2020-10-13T18:48:02Z")

</div>

Hi, I am working on a scientific visualization project for my degree and it requires us to draw many circles to the screen representing trees. This we did via the following code which runs as a thread and updates its PGr…

---

## [Screen flickering when running Particle system](https://discourse.processing.org/t/screen-flickering-when-running-particle-system/24540)

<div class="topic-metadata">

**Author:** [@Kachow095](https://discourse.processing.org/u/Kachow095)\
**Replies:** 1\
**Last updated:** [October 13, 2020, 6:33pm UTC](https://discourse.processing.org/t/screen-flickering-when-running-particle-system/24540 "2020-10-13T18:33:10Z")

</div>

please format code with \</\> button \* homework policy \* asking questions I was coding a particle system that spews out fountains. I have been working to make the program more efficient, but now it starts flickering wh…

---

## [Box fixed in front of camera Processing](https://discourse.processing.org/t/box-fixed-in-front-of-camera-processing/24562)

<div class="topic-metadata">

**Author:** [@Faceless](https://discourse.processing.org/u/Faceless)\
**Replies:** 1\
**Last updated:** [October 13, 2020, 2:23pm UTC](https://discourse.processing.org/t/box-fixed-in-front-of-camera-processing/24562 "2020-10-13T14:23:45Z")

</div>

Hey, is there any way to fix a box in front of the camera? Im using this to move the camera with the mouse: rotationAngle = map(mouseX, 0, width, 0, TWO\_PI); elevationAngle = map(mouseY, 0, height, 0, PI); …

---

## [Randomly coloring x amount of tiles within a grid](https://discourse.processing.org/t/randomly-coloring-x-amount-of-tiles-within-a-grid/24549)

<div class="topic-metadata">

**Author:** [@arizona440](https://discourse.processing.org/u/arizona440)\
**Replies:** 7\
**Last updated:** [October 13, 2020, 12:02pm UTC](https://discourse.processing.org/t/randomly-coloring-x-amount-of-tiles-within-a-grid/24549 "2020-10-13T12:02:24Z")

</div>

Hey guys, Im working on a project for school where I have to randomly generate x amount of colored tiles within a grid. In my current code every tile in the grid randomly receives a red or blue color. What do I need to…

---

## [Help me make bullets for a game I'm trying to make](https://discourse.processing.org/t/help-me-make-bullets-for-a-game-im-trying-to-make/24555)

<div class="topic-metadata">

**Author:** [@Cal\_codes](https://discourse.processing.org/u/Cal_codes)\
**Replies:** 7\
**Last updated:** [October 13, 2020, 11:46am UTC](https://discourse.processing.org/t/help-me-make-bullets-for-a-game-im-trying-to-make/24555 "2020-10-13T11:46:19Z")

</div>

Hi! I’m trying to build a retro top down arena shooter game and I’m struggling to get shooting to work. What I want is to have an ArrayList of bullets that can be shot using a keypressed fucntion and that are shot in th…

---

## [How to make an ArrayList object "blink" without drawing the background](https://discourse.processing.org/t/how-to-make-an-arraylist-object-blink-without-drawing-the-background/24534)

<div class="topic-metadata">

**Author:** [@marianalimoes](https://discourse.processing.org/u/marianalimoes)\
**Replies:** 8\
**Last updated:** [October 13, 2020, 8:03am UTC](https://discourse.processing.org/t/how-to-make-an-arraylist-object-blink-without-drawing-the-background/24534 "2020-10-13T08:03:36Z")

</div>

Hello. I have this code I can’t solve. I’m using two arraylists that draw balls in a random location. The first one, “Bola” (= “Ball” in Portuguese), is random colored and placed on canvas with a timer. The second one, …

---

## [Can someone help me create an energy bar for a game that gets higher when clicked](https://discourse.processing.org/t/can-someone-help-me-create-an-energy-bar-for-a-game-that-gets-higher-when-clicked/24543)

<div class="topic-metadata">

**Author:** [@Cal\_codes](https://discourse.processing.org/u/Cal_codes)\
**Replies:** 3\
**Last updated:** [October 12, 2020, 4:07pm UTC](https://discourse.processing.org/t/can-someone-help-me-create-an-energy-bar-for-a-game-that-gets-higher-when-clicked/24543 "2020-10-12T16:07:10Z")

</div>

Hi guys! I’ve been trying to teach myself coding and I wanted to try to make an energy bar that goes up when its clicked instead of just immediately displaying the entire energy bar. This is the code I have so far. Th…

---

## [Do these seem right? can't seem to make it work](https://discourse.processing.org/t/do-these-seem-right-cant-seem-to-make-it-work/24544)

<div class="topic-metadata">

**Author:** [@thughes](https://discourse.processing.org/u/thughes)\
**Replies:** 4\
**Last updated:** [October 12, 2020, 3:24pm UTC](https://discourse.processing.org/t/do-these-seem-right-cant-seem-to-make-it-work/24544 "2020-10-12T15:24:35Z")

</div>

Another if statement will check to see if the Blue and Red ball are within a certain distance of each other. This function will check to see if the x and y position of the BLUE ball is less than 20 from the x and y pos…

---

## [What is the xRed position?](https://discourse.processing.org/t/what-is-the-xred-position/24527)

<div class="topic-metadata">

**Author:** [@thughes](https://discourse.processing.org/u/thughes)\
**Replies:** 3\
**Last updated:** [October 12, 2020, 12:34pm UTC](https://discourse.processing.org/t/what-is-the-xred-position/24527 "2020-10-12T12:34:22Z")

</div>

I’m a little confused on the xRed position?!?! xRed and yRed position for the RED ball . Remember this should be set to x anywhere and y will be a random between 200 and 400. The ball will be width and height of 3…

---

## [Different background, Different item by mousePressed](https://discourse.processing.org/t/different-background-different-item-by-mousepressed/24530)

<div class="topic-metadata">

**Author:** [@fisher](https://discourse.processing.org/u/fisher)\
**Replies:** 1\
**Last updated:** [October 12, 2020, 7:15am UTC](https://discourse.processing.org/t/different-background-different-item-by-mousepressed/24530 "2020-10-12T07:15:05Z")

</div>

please format code with \</\> button \* homework policy \* asking questions I’m making day/night animation where I use “mousePressed” on locating the sun on the blue sky according to the mouseX,mouseY. When the key ‘n’ i…

---

## [Using keyboard events](https://discourse.processing.org/t/using-keyboard-events/24503)

<div class="topic-metadata">

**Author:** [@thughes](https://discourse.processing.org/u/thughes)\
**Replies:** 5\
**Last updated:** [October 11, 2020, 7:02am UTC](https://discourse.processing.org/t/using-keyboard-events/24503 "2020-10-11T07:02:11Z")

</div>

Advice please: public void change This function will increment the y2 of the 2nd ellipse by 2. Use the short cut operator for the assignment. If the y2 is greater than height, reset the y2 to 30. this is what i have so…

---

## [How to open maximized window?](https://discourse.processing.org/t/how-to-open-maximized-window/22941)

<div class="topic-metadata">

**Author:** [@Rafsing](https://discourse.processing.org/u/Rafsing)\
**Replies:** 8\
**Last updated:** [July 31, 2020, 3:05pm UTC](https://discourse.processing.org/t/how-to-open-maximized-window/22941 "2020-07-31T15:05:10Z")

</div>

How to open maximized window with windows taskbar. I’m using the newest version of processing, and any version of size(displayWidth, displayHeight); surface.setResizable(true); surface.setLocation(0, 0); doesn’t work.

---

## [Mouse draw sketch](https://discourse.processing.org/t/mouse-draw-sketch/24449)

<div class="topic-metadata">

**Author:** [@joe\_processing](https://discourse.processing.org/u/joe_processing)\
**Replies:** 4\
**Last updated:** [October 11, 2020, 7:01am UTC](https://discourse.processing.org/t/mouse-draw-sketch/24449 "2020-10-11T07:01:28Z")

</div>

hi, |'m trying to write a code that demonstrates a spread of infected pixels that appear from and after the user draws a line in processing (I added a picture that demonstrates the stages that code makes). But my code …

---

## [Lighting for 3d gravity sim](https://discourse.processing.org/t/lighting-for-3d-gravity-sim/24388)

<div class="topic-metadata">

**Author:** [@Kport1](https://discourse.processing.org/u/Kport1)\
**Replies:** 5\
**Last updated:** [October 10, 2020, 1:58pm UTC](https://discourse.processing.org/t/lighting-for-3d-gravity-sim/24388 "2020-10-10T13:58:11Z")

</div>

Hello! Im having trouble with the lighting in my 3d gravity sim. I am trying to programm stars but the lighting function in processing doesnt give of direct light to the camera, so the stars appear like planets, but they…

---

## [Using multiple mouse functions](https://discourse.processing.org/t/using-multiple-mouse-functions/24485)

<div class="topic-metadata">

**Author:** [@thughes](https://discourse.processing.org/u/thughes)\
**Replies:** 6\
**Last updated:** [October 10, 2020, 1:03pm UTC](https://discourse.processing.org/t/using-multiple-mouse-functions/24485 "2020-10-10T13:03:39Z")

</div>

this is what i’m trying to do: Create a program that will change the background color based on the mouse. You will create a setup(), draw() function. The size of the frame will by 400 by 400. Create a mousePressed() …

---

## [Connect dots with lines](https://discourse.processing.org/t/connect-dots-with-lines/24493)

<div class="topic-metadata">

**Author:** [@fernanda\_123](https://discourse.processing.org/u/fernanda_123)\
**Replies:** 1\
**Last updated:** [October 10, 2020, 10:52am UTC](https://discourse.processing.org/t/connect-dots-with-lines/24493 "2020-10-10T10:52:54Z")

</div>

please format code with \</\> button \* homework policy \* asking questions Hi, I’m new in processing and I hope someone can help me with a proyect :smiley: So, I have to make a program where I make points and each poin…

---

## [Calculating angle of triangle](https://discourse.processing.org/t/calculating-angle-of-triangle/24483)

<div class="topic-metadata">

**Author:** [@arcadeperfect](https://discourse.processing.org/u/arcadeperfect)\
**Replies:** 15\
**Last updated:** [October 9, 2020, 10:33pm UTC](https://discourse.processing.org/t/calculating-angle-of-triangle/24483 "2020-10-09T22:33:36Z")

</div>

Sorry, this is a math question more than a Processing one. I’m trying to calculate an angle “a” that will always give a specified constant length “d” for any given position of p. P can move, and the other two points ar…

---

## [I need help asap BEFORE 19:00 PM](https://discourse.processing.org/t/i-need-help-asap-before-19-00-pm/24469)

<div class="topic-metadata">

**Author:** [@INEEDHELP](https://discourse.processing.org/u/INEEDHELP)\
**Replies:** 12\
**Last updated:** [October 9, 2020, 5:33pm UTC](https://discourse.processing.org/t/i-need-help-asap-before-19-00-pm/24469 "2020-10-09T17:33:18Z")

</div>

please format code with \</\> button \* homework policy \* asking questions I'm making a bubble shoot game and I want to know when my bullet hit the bubble then it will vanish and i get a point. PLEASE explain

---

## [How to save an image from sketch windows](https://discourse.processing.org/t/how-to-save-an-image-from-sketch-windows/24436)

<div class="topic-metadata">

**Author:** [@rafaelb](https://discourse.processing.org/u/rafaelb)\
**Replies:** 4\
**Last updated:** [October 9, 2020, 12:43pm UTC](https://discourse.processing.org/t/how-to-save-an-image-from-sketch-windows/24436 "2020-10-09T12:43:36Z")

</div>

please format code with \</\> button \* homework policy \* asking questions PArdon my beginnereness!!! When I have a Sketch window and want to save it as a single figure (image) in .png or .jpg, what do I have to do??. …

---

## [Image Manipulation](https://discourse.processing.org/t/image-manipulation/24459)

<div class="topic-metadata">

**Author:** [@stellakramer](https://discourse.processing.org/u/stellakramer)\
**Replies:** 1\
**Last updated:** [October 9, 2020, 12:36pm UTC](https://discourse.processing.org/t/image-manipulation/24459 "2020-10-09T12:36:09Z")

</div>

Could someone help me? I’m trying to make a code in Processing where you have an image, and on the image an ellipse moves with your mouse. But the ellipse is not blank or filled but rather it warps the image. Bloats, inf…

---

## [Processing mapping function - help](https://discourse.processing.org/t/processing-mapping-function-help/24463)

<div class="topic-metadata">

**Author:** [@Ellie98](https://discourse.processing.org/u/Ellie98)\
**Replies:** 1\
**Last updated:** [October 9, 2020, 12:28pm UTC](https://discourse.processing.org/t/processing-mapping-function-help/24463 "2020-10-09T12:28:22Z")

</div>

Hello, I have to code 2 circles that are following the mouse. But the red one stays inside the square and I have to do it with the map() function but I don’t really understand it. It’s not working. Could someone help me…

---

## [Tint Speed Adjustment](https://discourse.processing.org/t/tint-speed-adjustment/24446)

<div class="topic-metadata">

**Author:** [@stellakramer](https://discourse.processing.org/u/stellakramer)\
**Replies:** 4\
**Last updated:** [October 9, 2020, 10:38am UTC](https://discourse.processing.org/t/tint-speed-adjustment/24446 "2020-10-09T10:38:40Z")

</div>

Helloooo I’m back with another question😊. This time it’s about the tint function. I like being able to set the tint to random but it moves very fast, is there any way to slow down the tint speed? I think I heard somewh…

---

## [How to determine ratio of growth of figure based on distance?](https://discourse.processing.org/t/how-to-determine-ratio-of-growth-of-figure-based-on-distance/24441)

<div class="topic-metadata">

**Author:** [@silphonix](https://discourse.processing.org/u/silphonix)\
**Replies:** 7\
**Last updated:** [October 8, 2020, 5:26pm UTC](https://discourse.processing.org/t/how-to-determine-ratio-of-growth-of-figure-based-on-distance/24441 "2020-10-08T17:26:47Z")

</div>

Hi, I’m new to Processing. I wanted to know the best/simpliest method to achive the following: I need to move a square from right to left and make it scale while moving. The square must be 2x2 at the beggining, and en…

---

## [How to save a previous mouse position](https://discourse.processing.org/t/how-to-save-a-previous-mouse-position/24434)

<div class="topic-metadata">

**Author:** [@moms\_spaghetti](https://discourse.processing.org/u/moms_spaghetti)\
**Replies:** 1\
**Last updated:** [October 8, 2020, 12:58pm UTC](https://discourse.processing.org/t/how-to-save-a-previous-mouse-position/24434 "2020-10-08T12:58:43Z")

</div>

Hello I am having a problem with trying to connect dots ,everytime I click on a position with my mouse I create a dot and what is supposed to happen is that the dots get connected with a line. For this I need to save th…

---

## [Quad() gets drawn twice](https://discourse.processing.org/t/quad-gets-drawn-twice/24382)

<div class="topic-metadata">

**Author:** [@theqxy](https://discourse.processing.org/u/theqxy)\
**Replies:** 13\
**Last updated:** [October 8, 2020, 11:58am UTC](https://discourse.processing.org/t/quad-gets-drawn-twice/24382 "2020-10-08T11:58:16Z")

</div>

Hello, everyone. Lately I’ve been casually working through Daniel Shiffman’s book Learning Processing, to better familiarize myself with Processing. I was working on exercise 14-5 in the book: “Create a three-dimension…

---

## [Better Fast Moving Object Collision Detection](https://discourse.processing.org/t/better-fast-moving-object-collision-detection/23150)

<div class="topic-metadata">

**Author:** [@chuchu](https://discourse.processing.org/u/chuchu)\
**Replies:** 1\
**Last updated:** [October 8, 2020, 9:36am UTC](https://discourse.processing.org/t/better-fast-moving-object-collision-detection/23150 "2020-10-08T09:36:58Z")

</div>

Following on from this post: https://discourse.processing.org/t/double-hit-on-object-collision-and-repeat-trigger/22970 I’m now focusing on the collision detection algorithm used in my program, rather than the simple de…

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

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