//this is my custom movement fucntion unique to the ascii man class void ascii_man::move(void) { //dont move if i already moved it somewhere else if (did_move()==false && did_collide()==false) { //temp move i think is now not used if (get_temp_mv_p()==NULL) {set_pt(get_pt()+get_mv());} else { set_pt(get_pt()+get_temp_mv()); set_temp_mv(NULL); } did_move(true); } //this is where i set the direction the dude is moving if (get_mv().get_x() != 0) {set_dir((int)(get_mv().get_x()/abs(get_mv().get_x())));} }
int draw(t_mlx *f) { int x; int y; x = 0; if (f->draw == 1) new_img(f); while (x < f->x - 1) { y = 0; while (y <= f->y - 1) { draw_square(f, get_pt(x, y, f->map[x][y]),\ get_pt(x + 1, y, f->map[x + 1][y]),\ get_pt(x, y + 1, f->map[x][y + 1])); draw_square(f, get_pt(x + 1, y + 1, f->map[x + 1][y + 1]),\ get_pt(x + 1, y, f->map[x + 1][y]),\ get_pt(x, y + 1, f->map[x][y + 1])); y++; } x++; } f->draw = 1; mlx_put_image_to_window(f->mlx, f->win, f->img, 0, 0); display(f); return (0); }
void ascii_man::collide(object *obj2, float adj, vector2d temp_mv, float x_over, float y_over) { set_hit_object(obj2); if(x_over > y_over) { if(this->get_pt().get_x() < obj2->get_pt().get_x()) {set_hitR(true);} else {set_hitL(true);} } if(x_over < y_over) { if(this->get_pt().get_y() < obj2->get_pt().get_y()) {set_hitD(true);} else {set_hitU(true);} } if (adj < 0.0001) {adj=1;} set_pt(get_pt() + (get_mv()* adj)); set_mv(temp_mv * obj2->get_mass()); if(this->get_mv().get_y() > 0 && get_hitD()==true && obj2->is_fixed()==true) {set_mv(get_mv().get_x(),0);} if (can_die()==true) { set_health(get_health()-obj2->get_damage()); } if (get_health() <= 0) { isdead(true); } did_collide(true); did_move(true); }