# Coding Questions

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

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

**Page:** 157

---

## [Class arrays for my game](https://discourse.processing.org/t/class-arrays-for-my-game/7253)

<div class="topic-metadata">

**Author:** [@bernbernm](https://discourse.processing.org/u/bernbernm)\
**Replies:** 6\
**Last updated:** [January 6, 2019, 11:15pm UTC](https://discourse.processing.org/t/class-arrays-for-my-game/7253 "2019-01-06T23:15:43Z")

</div>

Hey, i’m new to processing and programming in general and i’m trying to do a game where there are birds coming for each edge of the screen at random heights with different speeds. The problem with this is that when i try…

---

## [Shapes not in their correct place](https://discourse.processing.org/t/shapes-not-in-their-correct-place/6918)

<div class="topic-metadata">

**Author:** [@Ginazx](https://discourse.processing.org/u/Ginazx)\
**Replies:** 3\
**Last updated:** [January 6, 2019, 11:11pm UTC](https://discourse.processing.org/t/shapes-not-in-their-correct-place/6918 "2019-01-06T23:11:37Z")

</div>

Hiya. I just need help understanding this code. I found this code online in order to create some moving blobs float yOffset = 0.0; Blob blobz1 = new Blob(); Blob bloz2 = new Blob(); void setup() { size(800, 8…

---

## ["Mirroring" PShape objects (translation / rotation issue)](https://discourse.processing.org/t/mirroring-pshape-objects-translation-rotation-issue/7099)

<div class="topic-metadata">

**Author:** [@solub](https://discourse.processing.org/u/solub)\
**Replies:** 6\
**Last updated:** [January 6, 2019, 5:55pm UTC](https://discourse.processing.org/t/mirroring-pshape-objects-translation-rotation-issue/7099 "2019-01-06T17:55:17Z")

</div>

Hi, I’m trying to “mirror” a PShape object like in the picture below: The tricky part is not to invert the shape but to rotate it (and maybe translating it ?) so as it sticks to the preceding shape. I’ve been trying …

---

## [Program which changes the color of a circle based on which key is pressed](https://discourse.processing.org/t/program-which-changes-the-color-of-a-circle-based-on-which-key-is-pressed/7233)

<div class="topic-metadata">

**Author:** [@Umar2003](https://discourse.processing.org/u/Umar2003)\
**Replies:** 5\
**Last updated:** [January 6, 2019, 10:47am UTC](https://discourse.processing.org/t/program-which-changes-the-color-of-a-circle-based-on-which-key-is-pressed/7233 "2019-01-06T10:47:21Z")

</div>

I’m trying to write a Write a program which changes the color of a circle based on which key is pressed. Here are the colors and their corresponding keys: Nothing Pressed - Black Y - Yellow G - Green R - Red B - Bl…

---

## [How to deduct 1 health point if a moving triangle collides with a moving point?](https://discourse.processing.org/t/how-to-deduct-1-health-point-if-a-moving-triangle-collides-with-a-moving-point/7240)

<div class="topic-metadata">

**Author:** [@francium401](https://discourse.processing.org/u/francium401)\
**Replies:** 4\
**Last updated:** [January 6, 2019, 2:36am UTC](https://discourse.processing.org/t/how-to-deduct-1-health-point-if-a-moving-triangle-collides-with-a-moving-point/7240 "2019-01-06T02:36:57Z")

</div>

I want to figure out how to deduct 1 health point if a moving triangle collides with any moving point, and make that one particular point that has the triangle collided with disappear (if that’s possible). Just to note t…

---

## [Functions Problem; Rows of squares](https://discourse.processing.org/t/functions-problem-rows-of-squares/7231)

<div class="topic-metadata">

**Author:** [@Umer1](https://discourse.processing.org/u/Umer1)\
**Replies:** 5\
**Last updated:** [January 6, 2019, 12:52am UTC](https://discourse.processing.org/t/functions-problem-rows-of-squares/7231 "2019-01-06T00:52:07Z")

</div>

Hi does anyone know how to do rows of squares using functions? This is what I have so far: void setup() { size(500,500); background(255); } void draw() { background(255); stroke(5); int x = 10; int …

---

## [Program which draws an \`I\` if no keys are pressed, and an \`E\`or an \`F\`if those keys are pressed](https://discourse.processing.org/t/program-which-draws-an-i-if-no-keys-are-pressed-and-an-e-or-an-f-if-those-keys-are-pressed/7207)

<div class="topic-metadata">

**Author:** [@Umar2003](https://discourse.processing.org/u/Umar2003)\
**Replies:** 9\
**Last updated:** [January 5, 2019, 9:49pm UTC](https://discourse.processing.org/t/program-which-draws-an-i-if-no-keys-are-pressed-and-an-e-or-an-f-if-those-keys-are-pressed/7207 "2019-01-05T21:49:04Z")

</div>

I’m trying to write a program which draws an I if no keys are pressed, and an Eor an Fif those keys are pressed. Use straight lines to draw these letters. The window size is (120,120).

---

## [Problem with this triangle that keeps randomly changing size](https://discourse.processing.org/t/problem-with-this-triangle-that-keeps-randomly-changing-size/7232)

<div class="topic-metadata">

**Author:** [@francium401](https://discourse.processing.org/u/francium401)\
**Replies:** 1\
**Last updated:** [January 5, 2019, 9:48pm UTC](https://discourse.processing.org/t/problem-with-this-triangle-that-keeps-randomly-changing-size/7232 "2019-01-05T21:48:39Z")

</div>

I’m only guessing that it has something to do with the fact that the moving circles are changing size, that it somehow makes the triangle do so as well. How would I go about keeping the triangle at a fixed size? (917, y…

---

## [Perspective bug in eclipse?](https://discourse.processing.org/t/perspective-bug-in-eclipse/7220)

<div class="topic-metadata">

**Author:** [@vjjv](https://discourse.processing.org/u/vjjv)\
**Replies:** 3\
**Last updated:** [January 5, 2019, 9:26pm UTC](https://discourse.processing.org/t/perspective-bug-in-eclipse/7220 "2019-01-05T21:26:34Z")

</div>

hello! im trying to do this en eclipse, using perspective to set the nearClip (is there any other way to set the near and far clip without the perspective() function?) in eclipse the function dont work fine, please take …

---

## [Screen with two buttons not showing the buttons](https://discourse.processing.org/t/screen-with-two-buttons-not-showing-the-buttons/7230)

<div class="topic-metadata">

**Author:** [@Banansplitt](https://discourse.processing.org/u/Banansplitt)\
**Replies:** 1\
**Last updated:** [January 5, 2019, 7:46pm UTC](https://discourse.processing.org/t/screen-with-two-buttons-not-showing-the-buttons/7230 "2019-01-05T19:46:18Z")

</div>

I tried making a programme that shows a screen with two buttons but all it shows is a blank screen. This is my code: int rect1X, rect1Y; //Position Button 1 (Option 1) int rect2X, rect2Y; //Position Button 2 (Option 2) …

---

## [Catching Balls Game Collision Problem](https://discourse.processing.org/t/catching-balls-game-collision-problem/7221)

<div class="topic-metadata">

**Author:** [@yamiyugi](https://discourse.processing.org/u/yamiyugi)\
**Replies:** 1\
**Last updated:** [January 5, 2019, 6:06pm UTC](https://discourse.processing.org/t/catching-balls-game-collision-problem/7221 "2019-01-05T18:06:16Z")

</div>

Hello, I’m trying to make a game with a stick figure with a basket that you can move with the right and left arrow key to catch balls falling from the top. So far I have the figure that moves and one ball falling and I …

---

## [\[Pong Game\] More relistic ball ricochet?](https://discourse.processing.org/t/pong-game-more-relistic-ball-ricochet/7215)

<div class="topic-metadata">

**Author:** [@Sky](https://discourse.processing.org/u/Sky)\
**Replies:** 1\
**Last updated:** [January 5, 2019, 2:20pm UTC](https://discourse.processing.org/t/pong-game-more-relistic-ball-ricochet/7215 "2019-01-05T14:20:16Z")

</div>

I am going to program a 2pl pong game, and I was wondering if there was a way to make ball ricochet a bit more realistic, because now I use a random num that I add to my Y. (The players will be on the left and right of …

---

## [Pixel Processing: Grabbing the Canvas, and Where's the Alpha?](https://discourse.processing.org/t/pixel-processing-grabbing-the-canvas-and-wheres-the-alpha/7162)

<div class="topic-metadata">

**Author:** [@Aleksi](https://discourse.processing.org/u/Aleksi)\
**Replies:** 14\
**Last updated:** [January 5, 2019, 12:03pm UTC](https://discourse.processing.org/t/pixel-processing-grabbing-the-canvas-and-wheres-the-alpha/7162 "2019-01-05T12:03:19Z")

</div>

Hello again. I’d like to be able to grab a small area from the canvas and process the pixels in such a way that I can alter the color of intersecting lines. Here’s an example of what I’m trying to accomplish. void setu…

---

## [Basic calculator code error: "it looks like you are mixing active and static modes"](https://discourse.processing.org/t/basic-calculator-code-error-it-looks-like-you-are-mixing-active-and-static-modes/7194)

<div class="topic-metadata">

**Author:** [@bossofeng](https://discourse.processing.org/u/bossofeng)\
**Replies:** 13\
**Last updated:** [January 5, 2019, 7:15am UTC](https://discourse.processing.org/t/basic-calculator-code-error-it-looks-like-you-are-mixing-active-and-static-modes/7194 "2019-01-05T07:15:32Z")

</div>

I have a error it looks like you are mixing active and static modes can you help me My code: String input = ""; float input1 = 0; float input2 = 0; float result = 0; int operator = 0; boolean drawResult = false; vo…

---

## [Unable to figure out how to make these objects go in the opposite direction](https://discourse.processing.org/t/unable-to-figure-out-how-to-make-these-objects-go-in-the-opposite-direction/7155)

<div class="topic-metadata">

**Author:** [@francium401](https://discourse.processing.org/u/francium401)\
**Replies:** 3\
**Last updated:** [January 5, 2019, 6:44am UTC](https://discourse.processing.org/t/unable-to-figure-out-how-to-make-these-objects-go-in-the-opposite-direction/7155 "2019-01-05T06:44:04Z")

</div>

I want to make these circles go in the opposite direction (right to left, instead of left to right), but I can’t seem to figure out how. I managed to get them moving right to left by changing the speed value to a negati…

---

## [Basic calculator for android](https://discourse.processing.org/t/basic-calculator-for-android/7172)

<div class="topic-metadata">

**Author:** [@bossofeng](https://discourse.processing.org/u/bossofeng)\
**Replies:** 5\
**Last updated:** [January 4, 2019, 10:53pm UTC](https://discourse.processing.org/t/basic-calculator-for-android/7172 "2019-01-04T22:53:03Z")

</div>

I have a basic problem i write a basic calculator it works but i pressed then equal symbol if i press a new number first answer stay there and new answer write up last answer my english not very well so i will upload a p…

---

## [Pong Game glitch!](https://discourse.processing.org/t/pong-game-glitch/7158)

<div class="topic-metadata">

**Author:** [@Benasin](https://discourse.processing.org/u/Benasin)\
**Replies:** 6\
**Last updated:** [January 4, 2019, 12:47pm UTC](https://discourse.processing.org/t/pong-game-glitch/7158 "2019-01-04T12:47:22Z")

</div>

I have been using Processing for a week and I have created a simple pong game but I have a problem is that when the ball hit the side parts of the rectangle movable bar it shows glitches and the ball doesn’t bounce but m…

---

## [Buddhabrot : What is wrong in this algo?](https://discourse.processing.org/t/buddhabrot-what-is-wrong-in-this-algo/7075)

<div class="topic-metadata">

**Author:** [@NaoSi](https://discourse.processing.org/u/NaoSi)\
**Replies:** 0\
**Last updated:** [January 1, 2019, 6:57pm UTC](https://discourse.processing.org/t/buddhabrot-what-is-wrong-in-this-algo/7075 "2019-01-01T18:57:09Z")

</div>

Hey, I’m working in buddhabrot and I have a little issue in my algorithm and I don’t know how I can fix it. I followed lot of pseudo code in Google but it’s not enough… Can you help me? I think my problem is when I s…

---

## [Problem with char coordinates](https://discourse.processing.org/t/problem-with-char-coordinates/7120)

<div class="topic-metadata">

**Author:** [@lolonulu](https://discourse.processing.org/u/lolonulu)\
**Replies:** 3\
**Last updated:** [January 3, 2019, 6:42pm UTC](https://discourse.processing.org/t/problem-with-char-coordinates/7120 "2019-01-03T18:42:53Z")

</div>

Hello everybody, I would like to select the same chars in a String and to give each char the same coordinate… Here is my attempt below. I can only move the last char, why ?! Thanks alot in advance for your help. Best, …

---

## [P3D, transparency, and overlapping objects](https://discourse.processing.org/t/p3d-transparency-and-overlapping-objects/7123)

<div class="topic-metadata">

**Author:** [@ragona](https://discourse.processing.org/u/ragona)\
**Replies:** 2\
**Last updated:** [January 2, 2019, 10:31pm UTC](https://discourse.processing.org/t/p3d-transparency-and-overlapping-objects/7123 "2019-01-02T22:31:59Z")

</div>

Hi all, I want to use Processing for a visualization of a 3D search algorithm. There are 1000 points in 3D space, and I’m rendering them with spheres. So far so good. I now want to place a second, larger sphere around t…

---

## [Resize PImage: "width or height must be \> 0 for resize"](https://discourse.processing.org/t/resize-pimage-width-or-height-must-be-0-for-resize/7109)

<div class="topic-metadata">

**Author:** [@amaia](https://discourse.processing.org/u/amaia)\
**Replies:** 2\
**Last updated:** [January 2, 2019, 7:02pm UTC](https://discourse.processing.org/t/resize-pimage-width-or-height-must-be-0-for-resize/7109 "2019-01-02T19:02:05Z")

</div>

Hello: I want to scale myImage to fit in the height of the screen FIRST: divide the width and height of the screen by the width and height of myImage. SECOND: multiply the width and height of myImage by one of the …

---

## [Problem in making two balls bounce eachother](https://discourse.processing.org/t/problem-in-making-two-balls-bounce-eachother/7085)

<div class="topic-metadata">

**Author:** [@Hjtunfgb](https://discourse.processing.org/u/Hjtunfgb)\
**Replies:** 1\
**Last updated:** [January 2, 2019, 6:31pm UTC](https://discourse.processing.org/t/problem-in-making-two-balls-bounce-eachother/7085 "2019-01-02T18:31:00Z")

</div>

Hi there! I am trying to make two balls bounce once they hit each other, but for some reason, they are being thrown away insanely fast! My calculations are based on linear momentum conservation and a fixed coefficient of…

---

## [Hatching a rect() with diagonal lines](https://discourse.processing.org/t/hatching-a-rect-with-diagonal-lines/7068)

<div class="topic-metadata">

**Author:** [@eltrem](https://discourse.processing.org/u/eltrem)\
**Replies:** 5\
**Last updated:** [January 2, 2019, 5:15am UTC](https://discourse.processing.org/t/hatching-a-rect-with-diagonal-lines/7068 "2019-01-02T05:15:21Z")

</div>

Hi all! this is my first post in the forum, and i’m a total noob with processing… please be patient… I want to fill a rect() with diagonal lines. I don’t want to use mask() or PGraphics, because i want to have the fina…

---

## [\[SOLVED\] Am I normal? (Shapes and Coordinates)](https://discourse.processing.org/t/solved-am-i-normal-shapes-and-coordinates/7019)

<div class="topic-metadata">

**Author:** [@Sky](https://discourse.processing.org/u/Sky)\
**Replies:** 3\
**Last updated:** [January 1, 2019, 11:41am UTC](https://discourse.processing.org/t/solved-am-i-normal-shapes-and-coordinates/7019 "2019-01-01T11:41:17Z")

</div>

Is it normal to use a graphic calculator to draw shapes? I was wondring if there was something made to draw shapes and knowing theyr vertex coordinates :thinking::thinking::thinking:

---

## [Help with grid layout and detection](https://discourse.processing.org/t/help-with-grid-layout-and-detection/6862)

<div class="topic-metadata">

**Author:** [@ezpzpt](https://discourse.processing.org/u/ezpzpt)\
**Replies:** 2\
**Last updated:** [January 1, 2019, 3:43am UTC](https://discourse.processing.org/t/help-with-grid-layout-and-detection/6862 "2019-01-01T03:43:30Z")

</div>

New to processing, had a small module of it in a visual computing course. Lets say that I want to define a 4x4 grid, named 1,2,3,etc. and that when mouse hovers it, it prints the name of that cell. I managed to do it m…

---

## [Simple Pendulum Project](https://discourse.processing.org/t/simple-pendulum-project/7048)

<div class="topic-metadata">

**Author:** [@oheuysal](https://discourse.processing.org/u/oheuysal)\
**Replies:** 1\
**Last updated:** [December 31, 2018, 8:28am UTC](https://discourse.processing.org/t/simple-pendulum-project/7048 "2018-12-31T08:28:51Z")

</div>

I have a project.This is very important to me.I have similar code to this project but this code is too hard and not understanding to me.I want to very easy code because this project wants to be some calculation and simpl…

---

## [Saving objects from different classes into the same array](https://discourse.processing.org/t/saving-objects-from-different-classes-into-the-same-array/6818)

<div class="topic-metadata">

**Author:** [@MichaelPCgamer](https://discourse.processing.org/u/MichaelPCgamer)\
**Replies:** 8\
**Last updated:** [December 31, 2018, 2:00am UTC](https://discourse.processing.org/t/saving-objects-from-different-classes-into-the-same-array/6818 "2018-12-31T02:00:00Z")

</div>

This is my first post here ever so I’m gonna format it intuitively. I’m attempting to remake a game I already made months ago (using scratch) into processing. Here’s the game in scratch… https://scratch.mit.edu/projec…

---

## [\[SOLVED\] Code not working for a strange reason](https://discourse.processing.org/t/solved-code-not-working-for-a-strange-reason/7030)

<div class="topic-metadata">

**Author:** [@bilo](https://discourse.processing.org/u/bilo)\
**Replies:** 2\
**Last updated:** [December 30, 2018, 11:51pm UTC](https://discourse.processing.org/t/solved-code-not-working-for-a-strange-reason/7030 "2018-12-30T23:51:30Z")

</div>

i have wrote a simple code that supposed to make a ball bounce aroud the screen so what\`s happening is that the if,elseif and else statment are getting followed in the case of the width but not the heigth if someone can…

---

## [There is a delay when i use keypressed() to change value](https://discourse.processing.org/t/there-is-a-delay-when-i-use-keypressed-to-change-value/7028)

<div class="topic-metadata">

**Author:** [@Jani](https://discourse.processing.org/u/Jani)\
**Replies:** 3\
**Last updated:** [December 30, 2018, 11:27pm UTC](https://discourse.processing.org/t/there-is-a-delay-when-i-use-keypressed-to-change-value/7028 "2018-12-30T23:27:09Z")

</div>

Hi all! I am a newbie of processing. I find that the keyPressed() can’t change the value directly until the all codes in draw() are executed for one time. Like my example below,I want to use keyPressed() function to cha…

---

## [Solution to prevent spam for keyReleased()?](https://discourse.processing.org/t/solution-to-prevent-spam-for-keyreleased/6996)

<div class="topic-metadata">

**Author:** [@immortalTech](https://discourse.processing.org/u/immortalTech)\
**Replies:** 2\
**Last updated:** [December 30, 2018, 7:02pm UTC](https://discourse.processing.org/t/solution-to-prevent-spam-for-keyreleased/6996 "2018-12-30T19:02:10Z")

</div>

Hello! So basically I have programmed a breakout game. I made a pause feature going, but it’ll break if it’s spammed (and practically anything will break if spammed, but this pause feature is like a critical component to…

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

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