#include "config.h" #include "bullet.h" #include #include #include #include #include extern bopti_image_t img_bullet_normal; extern bopti_image_t img_bullet_blue; extern bopti_image_t img_bullet_laser; extern bopti_image_t img_bullet_enemy_blue; extern bopti_image_t img_bullet_enemy_red; extern bopti_image_t img_bullet_enemy_green; Bullet::Bullet( uint16_t lx, uint16_t ly, int16_t dx, int16_t dy, uint8_t id ) { x = libnum::num( lx ); y = libnum::num( ly ); sx = libnum::num( dx ); sy = libnum::num( dy ); ID=id; if (ID==BULLET_NORMAL) { strength = 5; } else if (ID==BULLET_BLUE) { strength = 2; } else if (ID==BULLET_LASER) { strength = 1; } else if (ID==BULLET_ENEMY_BLUE) { strength = 2; } else if (ID==BULLET_ENEMY_RED) { strength = 3; } else if (ID==BULLET_ENEMY_GREEN) { strength = 5; } toberemoved = false; } Bullet::~Bullet() { } void Bullet::Update( float dt ) { libnum::num a = libnum::num( dt / 12000.0f ); x += sx * a; y += sy * a; if (x<-10 || x>azrp_width+10 || y<-10 || y>azrp_height+10) toberemoved=true; } void Bullet::Render( ) { int16_t px = (int) x; int16_t py = (int) y; if (ID==BULLET_NORMAL) { azrp_image_p8( px-img_bullet_normal.width/2, py-img_bullet_normal.height/2, &img_bullet_normal, DIMAGE_NONE ); return; } else if (ID==BULLET_BLUE) { azrp_image_p8( px-img_bullet_blue.width/2, py-img_bullet_blue.height/2, &img_bullet_blue, DIMAGE_NONE ); return; } else if (ID==BULLET_LASER) { azrp_image_p8( px-img_bullet_laser.width/2, py-img_bullet_laser.height/2, &img_bullet_laser, DIMAGE_NONE ); return; } else if (ID==BULLET_ENEMY_BLUE) { azrp_image_p8( px-img_bullet_enemy_blue.width/2, py-img_bullet_enemy_blue.height/2, &img_bullet_enemy_blue, DIMAGE_NONE ); return; } else if (ID==BULLET_ENEMY_RED) { azrp_image_p8( px-img_bullet_enemy_red.width/2, py-img_bullet_enemy_red.height/2, &img_bullet_enemy_red, DIMAGE_NONE ); return; } else if (ID==BULLET_ENEMY_GREEN) { azrp_image_p8( px-img_bullet_enemy_green.width/2, py-img_bullet_enemy_green.height/2, &img_bullet_enemy_green, DIMAGE_NONE ); return; } }