# I need help asap BEFORE 19:00 PM

**URL:** https://discourse.processing.org/t/i-need-help-asap-before-19-00-pm/24469
**Category:** Coding Questions
**Tags:** homework
**Created:** [October 9, 2020, 3:52pm UTC](https://discourse.processing.org/t/i-need-help-asap-before-19-00-pm/24469 "2020-10-09T15:52:26Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![INEEDHELP](https://avatars.discourse-cdn.com/v4/letter/i/eada6e/32.png) [@INEEDHELP](https://discourse.processing.org/u/INEEDHELP)
#### Post date: [October 9, 2020, 3:52pm UTC](https://discourse.processing.org/t/i-need-help-asap-before-19-00-pm/24469/1 "2020-10-09T15:52:26Z")

</div>

> please format code with \</\> button \* [homework policy](https://discourse.processing.org/faq/#homework) \* [asking questions](https://discourse.processing.org/t/2147)
> 
> 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

---

<div class="post-metadata">

### Author: ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)
#### Post date: [October 9, 2020, 3:57pm UTC](https://discourse.processing.org/t/i-need-help-asap-before-19-00-pm/24469/2 "2020-10-09T15:57:13Z")

</div>

- [JeffreyThompson.org/collision-detection/point-circle.php](http://JeffreyThompson.org/collision-detection/point-circle.php)

---

<div class="post-metadata">

### Author: ![INEEDHELP](https://avatars.discourse-cdn.com/v4/letter/i/eada6e/32.png) [@INEEDHELP](https://discourse.processing.org/u/INEEDHELP)
#### Post date: [October 9, 2020, 3:58pm UTC](https://discourse.processing.org/t/i-need-help-asap-before-19-00-pm/24469/3 "2020-10-09T15:58:53Z")

</div>

Can you use it in my code and //explain.?

int x, y, z, r;  
boolean moveUp = false; //kulan starts utan att röra sig  
float bulletY = 650; // kulans position  
float bulletX = 350; // kulans position  
float gunX = 350; // bollens position  
int i;

void setup() {  
size(800, 800);  
background(255);  
x=400;  
y=700;  
z=100;  
}

void draw() {  
fill(0);  
frameRate(20);  
ellipse(x, y, 30, 30);

fill(0, 0, 255);  
for (i = 50; i \<= 700; i += 49) {

```
// (i += 50) = (i=i+50)

rect(i, 100, 30, 30);

```

}  
fill(255, 0, 0);  
for (i = 50; i \<= 700; i += 49) {  
rect(i, 200, 30, 30);  
}

fill(0, 255, 0);  
for (i = 50; i \<= 700; i += 49) {  
rect(i, 300, 30, 30);  
}  
}

void keyPressed() {  
if (key == CODED){  
if (keyCode == LEFT) {  
x = x - 10;

```
} else if (keyCode == RIGHT) 
x = x + 10;

}

```

}

---

<div class="post-metadata">

### Author: ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)
#### Post date: [October 9, 2020, 4:30pm UTC](https://discourse.processing.org/t/i-need-help-asap-before-19-00-pm/24469/4 "2020-10-09T16:30:52Z")

</div>

the link provided by @GoToLoop is a great resource. However it seems that you may not be willing to take the time to do the work. Your assignment is important not just so you can pass your semester and get some credits but because it teaches you skills necessary to become a good programmer. Knowing how to read documentation, trying techniques from different sources and evaluating the best one, and problem solving, or learning how to approach a problem and find a solution. I can guarantee you that you will benefit more from working at it, than by having someone simply give you the answer, especially if you also get given points for explaining why you arrived at the solution you did.

Ultimately in the real world a lot of code is found online, stackoverflow etc, however being given small snippets of code is useless if you do not know how to incorporate it.

---

<div class="post-metadata">

### Author: ![INEEDHELP](https://avatars.discourse-cdn.com/v4/letter/i/eada6e/32.png) [@INEEDHELP](https://discourse.processing.org/u/INEEDHELP)
#### Post date: [October 9, 2020, 4:45pm UTC](https://discourse.processing.org/t/i-need-help-asap-before-19-00-pm/24469/5 "2020-10-09T16:45:29Z")

</div>

I couldn’t find anything and i understand but please i need help!!!

thank you:

---

<div class="post-metadata">

### Author: ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)
#### Post date: [October 9, 2020, 4:53pm UTC](https://discourse.processing.org/t/i-need-help-asap-before-19-00-pm/24469/6 "2020-10-09T16:53:15Z")

</div>

Please do not duplicate posts.

[https://discourse.processing.org/t/how-to-shoot-bullets/24470](https://discourse.processing.org/t/how-to-shoot-bullets/24470)

---

<div class="post-metadata">

### Author: ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)
#### Post date: [October 9, 2020, 4:58pm UTC](https://discourse.processing.org/t/i-need-help-asap-before-19-00-pm/24469/7 "2020-10-09T16:58:15Z")

</div>

this is all I’m going to provide, as I cannot complete your assignment, if you have been paying attention in your class then this should make sense to you, and should be fairly straight forward. However this alone will not be able to pass you assignment

```auto
void setup(){
  size(600,600);
};
float x,y = 150;;
void draw(){
  background(50);
  line(100,100,100,200);
  ellipse(x+=10,y,10,10);
  if(x>width)x=0;
};

  boolean check_lineP(PVector a, PVector b, PVector c) {

    boolean k = false;
    float d1 = dist(a.x, a.y, b.x, b.y);
    float d2 = dist(a.x, a.y, c.x, c.y);
    float d3 = dist(b.x, b.y, c.x, c.y);
    float d4 = d2 + d3;
    //point(c.x,c.y);
    if (d4 <= d1 + res && d4 >= d1 - res) {
      k = true;
    }
    return k;
  };

```

---

<div class="post-metadata">

### Author: ![INEEDHELP](https://avatars.discourse-cdn.com/v4/letter/i/eada6e/32.png) [@INEEDHELP](https://discourse.processing.org/u/INEEDHELP)
#### Post date: [October 9, 2020, 5:02pm UTC](https://discourse.processing.org/t/i-need-help-asap-before-19-00-pm/24469/8 "2020-10-09T17:02:20Z")

</div>

[quote=“paulgoux, post:7, topic:24469”]  
`if (d4 \<= d1 + res && d4 \>= d1 - **res** ) {  
It says “res cannot be resolved to a variable”

---

<div class="post-metadata">

### Author: ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)
#### Post date: [October 9, 2020, 5:06pm UTC](https://discourse.processing.org/t/i-need-help-asap-before-19-00-pm/24469/9 "2020-10-09T17:06:28Z")

</div>

res is a placeholder for the distance between the point and the line. Set it to whatever you want it. the lower it is the more accurate it will be.

Again though this code is just the intersection code. You have to apply it to your code to make it work.

---

<div class="post-metadata">

### Author: ![INEEDHELP](https://avatars.discourse-cdn.com/v4/letter/i/eada6e/32.png) [@INEEDHELP](https://discourse.processing.org/u/INEEDHELP)
#### Post date: [October 9, 2020, 5:07pm UTC](https://discourse.processing.org/t/i-need-help-asap-before-19-00-pm/24469/10 "2020-10-09T17:07:19Z")

</div>

OK!  
Thanks for helping me out

---

<div class="post-metadata">

### Author: ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)
#### Post date: [October 9, 2020, 5:15pm UTC](https://discourse.processing.org/t/i-need-help-asap-before-19-00-pm/24469/11 "2020-10-09T17:15:15Z")

</div>

here’s a tiny extra step with the collision working

```auto
float x,y = 150,res = 0.5;
boolean k = false;
PVector a,b,c;

void setup(){
  size(600,600);
  a = new PVector(0,150);
  b = new PVector(100,100);
  c = new PVector(100,200);
  
};

void draw(){
  background(50);
  line(b.x,b.y,c.x,c.y);
  fill(0);
  if(checkLineP(b,c,a))k = true;
  else k = false;
  if(k)fill(255,0,0);
  ellipse(a.x+=10,a.y,10,10);
  if(a.x>width)a.x=0;
  
};

boolean checkLineP(PVector a, PVector b, PVector c) {

  boolean k = false;
  float d1 = dist(a.x, a.y, b.x, b.y);
  float d2 = dist(a.x, a.y, c.x, c.y);
  float d3 = dist(b.x, b.y, c.x, c.y);
  float d4 = d2 + d3;
  //point(c.x,c.y);
  if (d4 <= d1 + res && d4 >= d1 - res) {
    k = true;
  }
  return k;
};

```

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [October 9, 2020, 5:23pm UTC](https://discourse.processing.org/t/i-need-help-asap-before-19-00-pm/24469/12 "2020-10-09T17:23:17Z")

</div>

> BEFORE 19:00 PM

which time zone?

😉

---

<div class="post-metadata">

### Author: ![INEEDHELP](https://avatars.discourse-cdn.com/v4/letter/i/eada6e/32.png) [@INEEDHELP](https://discourse.processing.org/u/INEEDHELP)
#### Post date: [October 9, 2020, 5:33pm UTC](https://discourse.processing.org/t/i-need-help-asap-before-19-00-pm/24469/13 "2020-10-09T17:33:18Z")

</div>

Im from sweden 🇸🇪
