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/Asteroid.java at master · vidgit/Space_Invaders_Greenfoot

Expand file tree

/

Asteroid.java

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
55 lines (46 loc) · 1.05 KB
/

Asteroid.java

Copy path

File metadata and controls

55 lines (46 loc) · 1.05 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
import greenfoot.*;
/**
* Generates asteroids
* asteroids are obstacles which will not attack the player instead they will create path hinderence
*
* @author (your name)
* @version (a version number or a date)
*/
public class Asteroid extends Actor
{ private int imgnumber;
private int hit=10;
int dx=0;
int dy=1;
public Asteroid(){
imgnumber=Greenfoot.getRandomNumber(12)+1;
setImage("a"+imgnumber+".png");
}
public int gethit()
{return hit;}
public void sethit(int d)
{hit-=d;
}
public void act()
{
int i=1;
if(imgnumber>=144)
{imgnumber=1;
}
else
imgnumber++;
i=1+imgnumber/12;
setImage("a"+i+".png");
move();
}
public void move()
{ setLocation(getX(), getY()+dy);
checkWalls();
}
private void checkWalls()
{
if (getY() == getWorld().getHeight()-1)
{
getWorld().removeObject(this);
}
}
}
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.