Copyright (c) Nikolaj Baer
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. ...
If you think the Android project android-jplay listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
package com.nikolajbaer.game.objects;
//www.java2s.com/* jbox2d */import org.jbox2d.dynamics.Body; import org.jbox2d.dynamics.BodyDef;
import org.jbox2d.common.Vec2;
/* local */import com.nikolajbaer.game.Game;
publicclass ShrapnelObject extends PolygonGameObject {
//private Color m_color;
privateint m_impacts;
privateint m_life;
privateint m_size;
// TODO how do i keep the color?
public ShrapnelObject(Body b,int size){
super(b,newfloat[]{-1,-1,0,1,1,-1});
//m_color=c;
m_impacts=0;
m_size=size;
m_life=30;
}
publicboolean survivesImpact(){
// fade out after first impact
m_impacts++;
return m_impacts<=2;
}
publicboolean doesDamage(){
return false;
}
publicboolean tick(){
if(m_impacts>=1){
m_life--;
return m_life>0;
}
return true;
}
public String getRenderKey(){ return"bullet"; } // return "shrapnel"; }
}