﻿ 马里奥源代码及A*算法演示代码源代码:BulletBill.java
• 源代码说明.txt
```package competition.cig.robinbaumgarten.astar.sprites;

import competition.cig.robinbaumgarten.astar.LevelScene;

public class BulletBill extends Sprite
{
int height = 24;

public int facing;

public boolean avoidCliffs = false;
public int anim;

public BulletBill(LevelScene world, float x, float y, int dir)
{
kind = Sprite.KIND_BULLET_BILL;     //added by SK
this.x = x;
this.y = y;
this.world = world;
height = 12;
facing = 0;
ya = -5;
this.facing = dir;
}

public void collideCheck()
{

float xMarioD = world.mario.x - x;
float yMarioD = world.mario.y - y;
if (xMarioD > -16 && xMarioD < 16)
{
if (yMarioD > -height && yMarioD < world.mario.height)
{
if (world.mario.ya > 0 && yMarioD <= 0 && (!world.mario.onGround || !world.mario.wasOnGround))
{
world.mario.stomp(this);
//System.out.println("Sim bullet bill stomped on. Mario ya: "+world.mario.ya);

xa = 0;
ya = 1;
}
else
{
world.mario.getHurt();
}
}
}
}

public void move()
{
{

{

spriteContext.removeSprite(this);
}

x += xa;
y += ya;
ya *= 0.95;
ya += 1;

return;
}

float sideWaysSpeed = 4f;

xa = facing * sideWaysSpeed;
move(xa, 0);
}

private boolean move(float xa, float ya)
{
x += xa;
return true;
}

public boolean fireballCollideCheck(Fireball fireball)
{
if (deadTime != 0) return false;

float xD = fireball.x - x;
float yD = fireball.y - y;

if (xD > -16 && xD < 16)
{
if (yD > -height && yD < fireball.height)
{
return true;
}
}
return false;
}

public boolean shellCollideCheck(Shell shell)
{
if (deadTime != 0) return false;

float xD = shell.x - x;
float yD = shell.y - y;

if (xD > -16 && xD < 16)
{
if (yD > -height && yD < shell.height)
{

xa = 0;
ya = 1;

return true;
}
}
return false;
}
}```
﻿