# Trouble with creating two player game

**URL:** https://discourse.processing.org/t/trouble-with-creating-two-player-game/35968
**Category:** Coding Questions
**Tags:** homework
**Created:** [March 27, 2022, 9:04pm UTC](https://discourse.processing.org/t/trouble-with-creating-two-player-game/35968 "2022-03-27T21:04:58Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![mary](https://avatars.discourse-cdn.com/v4/letter/m/e99b99/32.png) [@mary](https://discourse.processing.org/u/mary)
#### Post date: [March 27, 2022, 9:04pm UTC](https://discourse.processing.org/t/trouble-with-creating-two-player-game/35968/1 "2022-03-27T21:04:58Z")

</div>

Hello. I’m writing a two-player game and I’m hitting a lot of roadblocks. (I’m a complete beginner).

I’m having trouble making classes since I trip up on the basics. I don’t know how to create limits(with if statements), use logic, how to code objects interacting with each other, how to make an object grab an object, how to show a health bar, how to code taking+giving damage (bombs and arrows), how to make the enemy follow the player and attack them.

int x;  
int y;  
int health = 100;  
Baby baby;  
/\*objects all soon to be implemented/created, including Baby, Devil, Angel. methods will be created for functionality that hits objects, picks up objects, displays hp,  
heat and freeze components will be added in later versions once the basic fundamentals are laid down.

\*/  
void setup() {  
size(500, 680);  
background(0, 170, 250);  
baby = new Baby(width/2, height-50,30);  
}

void draw() {  
earth();  
hell() ;  
angel();  
devil();

}

void hell() {  
fill(203, 242, 207); //light blue  
rect(0, height-80, width, height/8);  
fill(89, 9, 9); //dark maroon  
rect(0, height-80_2, width, height/8);  
fill(153, 18, 0); //rusty red  
rect(0, height-80_3, width, height/8);  
fill(171, 9, 9); //crimson  
rect(0, height-80_4, width, height/8);  
fill(231, 82, 30);//orange  
rect(0, height-80_5, width, height/8);  
fill(255, 167, 15);//yellow  
rect(0, height-80_6, width, height/8);  
fill(228, 4, 10);//red  
}  
void earth() {  
fill(114, 114, 255);  
rect(0, height-80_8, width, height/4);  
}  
void angel() {  
String myText = "x: " + mouseX + "\ny: " + mouseY;  
text(myText,mouseX,mouseY);

```
}

```

}  
}  
void devil() {  
fill(250,0,200);

```
ellipse(radians(x),radians(y),30,30);
if(mousePressed){
 //throw bomb
 
 ellipse(x,y,20,20);
 x+=3;
 y+=8;
 line(x+700, y+900, 30,30);
 

 }

}

// code that states if hit by line of trajectory, minus this much hp
//code that throws bombs 
//code that moves based off the movements of the angels positions, i.e. following it and targetting it
//code that shows health bar on devil, will use if(health >= 70) show as green, if (health < 50) show red. hit by arrows knocks down health by 10 points. 100 total for all objects

```

//class for baby  
// code that shows health bar on baby
