void Bullet::Update(float time) { if (name == DIE) { DieAnimation(time); } else if (health <= 0) { InitDie(); return; } if (speed == DEFAULT_BULLET_SPEED) { speed = time; } float distance = sqrt((temp.x - boost.x)*(temp.x - boost.x) + (temp.y - boost.y)*(temp.y - boost.y)); rect.left += (temp.x - boost.x) / distance * speed * GET_HALF; rect.top += (temp.y - boost.y) / distance * speed * GET_HALF; if (rect.left <= 0) rect.left = 1; if (rect.top <= 0) rect.top = 1; for (unsigned int i = 0; i < obj.size(); i++) { if (getRect().intersects(obj[i].rect)) { health = 0; } } sprite.setPosition(rect.left + rect.width / GET_HALF, rect.top + rect.height / GET_HALF); }
int InitChip(struct chipInfo *p_chip,struct ftlInfo *ftl){ unsigned int i; struct dieInfo *p_die; p_chip->die_num = ftl->parameter->die_chip; p_chip->token = 0; p_chip->die = (struct dieInfo *)malloc(ftl->parameter->die_chip * sizeof(struct dieInfo)); AllocAssert(p_chip->die,"p_chip->die"); memset(p_chip->die,0,ftl->parameter->die_chip * sizeof(struct dieInfo)); for (i = 0; i<ftl->parameter->die_chip; i++) { p_die = &(p_chip->die[i]); InitDie( p_die,ftl); } return XST_SUCCESS; }