GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Space_Invaders_Greenfoot/Asteroid.java at master · vidgit/Space_Invaders_Greenfoot Expand file tree/ Copy pathAsteroid.javaMore file actions 55 lines (46 loc) · 1.05 KB / Copy pathAsteroid.javaFile metadata and controls55 lines (46 loc) · 1.05 KB 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. |