GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Space_Invaders_Greenfoot/EnemyBullets.java at master · vidgit/Space_Invaders_Greenfoot

Expand file tree

/

EnemyBullets.java

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
75 lines (67 loc) · 1.96 KB
/

EnemyBullets.java

Copy path

File metadata and controls

75 lines (67 loc) · 1.96 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import greenfoot.*;
/**
* Write a description of class EnemyBullets here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class EnemyBullets extends SmoothMover
{
private int Damage=10;
public EnemyBullets(){
GreenfootImage img=getImage();
img.scale(img.getHeight()/4,img.getWidth()/4);
setImage(img);
}
public EnemyBullets( Vector movement, int rotate)
{
GreenfootImage img=getImage();
img.scale(img.getHeight()/6,img.getWidth()/6);
setImage(img);
addForce(movement);
turn(rotate);
}
/**
* Act - do whatever the Bullet wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{ if(BackDrop.pause==true)
{
move(-10);
if(!ifCollides())
checkWalls();
}
}
private void checkWalls()
{
if (getY() == 0|| getY() == getWorld().getHeight()-1) {
getWorld().removeObject(this);
}
else if(getX()==0||getX()==getWorld().getWidth()-1)
{
getWorld().removeObject(this);
}
}
public boolean ifCollides()
{
if(canSee(Ship.class))
{ Ship s=(Ship)getOneObjectAtOffset(0,0,Ship.class);
World myWorld=getWorld();
BackDrop bd=(BackDrop)myWorld;
Health hb=bd.getHealth();
hb.sethealth(5);
hb.update();
if(hb.health<=0){
getWorld().addObject(new Explosion(),getX(),getY());
//myWorld.removeObject(this);
FullScreenExplosion FSE=new FullScreenExplosion(true);
getWorld().addObject(FSE,getWorld().getWidth()/2,getWorld().getHeight()/2);
//bd.setDead();
}
getWorld().removeObject(this);
return true;
}
return false;
}
}
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.