processing

How to make image disappear upon collision with rectangle in processing?

和自甴很熟 提交于 2019-12-11 14:14:44
问题 I am making a game for my college project and I need help. I am making a game where you control a car with your mouse on the y-coordinate. You have to avoid the people and collect coins that are moving on the y-coordinate as well. I want the images I put in of the people and the coins to disappear upon collision with the rectangle part of my car in Processing 3 . This is my code: PImage img,img1,img2,img3,img4,img5; int x,y; float ypos=0; float ypos2=4; void setup() { size(1000,585); img =

Processing: How to convert a char datatype into its utf-8 int representation?

爱⌒轻易说出口 提交于 2019-12-11 13:44:06
问题 How can I convert a char datatype into its utf-8 int representation in Processing? So if I had an array ['a', 'b', 'c'] I'd like to obtain another array [61, 62, 63]. 回答1: After my answer I figured out a much easier and more direct way of converting to the types of numbers you wanted. What you want for 'a' is 61 instead of 97 and so forth. That is not very hard seeing that 61 is the hexadecimal representation of the decimal 97. So all you need to do is feed your char into a specific method

Bouncing Balls, struggling with getting more than 1 (processing)

。_饼干妹妹 提交于 2019-12-11 13:28:19
问题 so I want to have 10 Balls bouncing up and down. So far I have managed to get 1 Ball to bounce, and to have something like gravity. But now I want to add more balls, but I just can`t manage to do so. So far I tried to add an array, and then to use a loop, but nothing I tried worked for me yet. Would appreciate if somebody could point me out to the Solution. Ball b; void setup() { size(940, 660); b = new Ball(); } void draw() { background(50); fill(255); b.display(); b.move(); } and the class:

Is there a way to change the color of PShape without entering begin/end?

我是研究僧i 提交于 2019-12-11 13:05:51
问题 I've been writing a program which redraws lots of (several hundred) the same PShape in different colors. However, I haven't found a way to redraw the PShape in different colors without actually recreating the PShape, i.e. going through the begin/end shape redoing all the vertices and simply changing the fill and then assigning it to a new PShape variable. I've tried things like tint(), fill(), setFill() and they all seem to require being called in begin/end shape. Is there a way to redraw a

Why is the function being called multiple times in a loop?

那年仲夏 提交于 2019-12-11 12:05:10
问题 I've made a graphical calculator app using the Processing Development Environment and have incorporated a Java Operation class. Then I called instances of the Operation class in my main file - calculator.pde. When I call the method on the multiple instances, conditionally, it prints output from the method multiple times because of the loop and conditional from which the method is called. Here's the calculate() method of Operation class: String calculate() { int operationIndex = userInput

How can I transform the code I wrote down below?

牧云@^-^@ 提交于 2019-12-11 12:02:06
问题 I am suppose to code the snake game in java with processing for IT classes and since I had no idea how to do it I searched for a YouTube tutorial. Now I did find one but he used the keys 'w','s','d','a' to move the snake around - I on the other hand want to use the arrow keys. Could someone explain to me how I transform this code: if (keyPressed == true) { int newdir = key=='s' ? 0 : (key=='w' ? 1 : (key=='d' ? 2 : (key=='a' ? 3 : -1))); } if(newdir != -1 && (x.size() <= 1 || !(x.get(1) ==x

How to increase stack size to allow more recursion?

房东的猫 提交于 2019-12-11 11:40:42
问题 I'm running a recursion method in processing, but when the job is too big, it give me this error: crashed in event thread due to Timeout occurred while waiting for packet 139. But it works when the recursion is small. Is there any way to increase the stack for bigger recursion problems? This is my code is for painting figures on the screen. It works for small figures, but not for bigger ones. boolean pit; int xc; int yc; color negro; color rojo; color c; long tiempoI; long tiempoF; long

Adobe AIR desktop application communicate with Processing application

☆樱花仙子☆ 提交于 2019-12-11 11:22:59
问题 I have a Processing application that must talk to a desktop Adobe AIR application. Can anyone suggest the best options considering the following? If sockets are the answer, which type of Socket, UDP(Datagram Class), ServerSocket or just plain Socket? -both apps reside on same machine -latency important, smaller better -signals being sent are small, consisting of 3 values -communication is 1 way only, processing TO Adobe AIR 回答1: On the Processing side you can use oscP5: import oscP5.*; import

I have been trying to make this ball bounce for a day. Why doesnt it work?

青春壹個敷衍的年華 提交于 2019-12-11 11:00:44
问题 I am making a ball class, and in that class i want to make the ball bounce off the wall, but it remains stuck. I have tried making the ball bounce in the draw function, but then it didnt even stopped at the wall. I tried setting the this.x and this.y away from the limit so it doesnt loop, but no succes. I am left without choises. I dont know what to do. I am just starting out and im quite enjoying coding, but this is giving me a headache. let r; let g; let b; let xpos; let ypos; let size; let

How to install the “sound” library for Processing in a simple way?

纵然是瞬间 提交于 2019-12-11 10:54:00
问题 It's just so weird that Processing does't come with a "sound" library while the official information provides related information(https://processing.org/reference/libraries/sound/). This only leads me to the Github source code page(https://github.com/processing/processing-sound) and I literally do not know how to install this thing... Yes, I could use the "Minim" or "Sonia" library. But I have a bunch of example programs which use the "sound" library, each with a "import processing.sound.*;"