Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hi! I cleaned up your code for you! #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
*.pyc

# Logs and databases #
######################
*.log

# OS generated files #
######################
.DS_Store*
ehthumbs.db
Icon?
Thumbs.db
14 changes: 7 additions & 7 deletions FHFighter.pde
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void draw(){
bullets.remove(i);
continue;
}
bullet.draw();
bullet.draw();

for (int j=0;j<enemies.size(); j++){
if (((Enemy) enemies.get(j)).blah.intersects(bullet.hitbox)){
Expand All @@ -61,16 +61,16 @@ void draw(){
}
}

void keyPressed()
{
void keyPressed()
{
sf.keyPressed();

}
}

void keyReleased()
{
void keyReleased()
{
sf.keyReleased();
}
}



Expand Down
2 changes: 1 addition & 1 deletion bullet.pde
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Bullet{

void move(){
this.hitbox.setLocation((int) (this.hitbox.getX() + this.speedX), (int) (this.hitbox.getY() + this.speedY));

}

void draw() {
Expand Down
8 changes: 4 additions & 4 deletions enemy.pde
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Enemy{
this.hitpoints=_hp;
this.blah = new Rectangle(_x, _y, 10, 10);
this.dir = 1;

}
void move(){

Expand All @@ -18,11 +18,11 @@ class Enemy{
}
this.blah.setLocation((int) this.blah.getX() + 3*this.dir, (int) this.blah.getY());


}

void draw(){

this.move();
//ellipse(this.x, this.y, this.enemyHeight, this.enemyWidth);
rect((float) this.blah.getX(), (float) this.blah.getY(), (float) this.blah.getWidth(), (float) this.blah.getHeight());
Expand Down
50 changes: 25 additions & 25 deletions starfighter.pde
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,26 @@ class Starfighter{

void keyPressed(){

if(keyCode==UP)
this.keyUp=true;
else if(keyCode==DOWN)
this.keyDown=true;

if(keyCode==LEFT)
this.keyLeft=true;
else if(keyCode==RIGHT)
this.keyRight=true;
if(keyCode==UP)
this.keyUp=true;
else if(keyCode==DOWN)
this.keyDown=true;

if(keyCode==LEFT)
this.keyLeft=true;
else if(keyCode==RIGHT)
this.keyRight=true;
}

void keyReleased(){
if(keyCode==UP)
this.keyUp=false;
else if(keyCode==DOWN)
this.keyDown=false;
if(keyCode==LEFT)
this.keyLeft=false;
else if(keyCode==RIGHT)
this.keyRight=false;
if(keyCode==UP)
this.keyUp=false;
else if(keyCode==DOWN)
this.keyDown=false;
if(keyCode==LEFT)
this.keyLeft=false;
else if(keyCode==RIGHT)
this.keyRight=false;
if (key == ' ') this.shoot();
}

Expand All @@ -61,34 +61,34 @@ class Starfighter{
if(this.keyLeft){
this.targetX-=this.lionel;
}


if (this.x - this.shipWidth/2 < 0 && this.targetX < 0) {
this.targetX *= -1;
}
}
else if (this.x + this.shipWidth/2 > width && this.targetX > width) {
this.targetX = width - (this.targetX - width);
}
if (this.y < 0 && this.targetY < 0) {
this.targetY *= -1;
}
}
else if (this.y + this.shipHeight > height && this.targetY + this.shipHeight > height) {
this.targetY = height - (this.targetY - height) - this.shipHeight;
}


this.x+=(this.targetX-this.x)/this.acceleration;
this.y+=(this.targetY-this.y)/this.acceleration;




}

void shoot(){
bullets.add(new Bullet(this.x, this.y, this.targetX - this.x, this.targetY - this.y));
}


void draw(){
this.move();
Expand Down