void character::draw(){ if(health <= 0) return; int ori_use_sphere = get_obj_type(); int ori_color_i = getColorI(); setColorI(color_i); sun_mode(false); glPushMatrix(); switch(jumpping) { case 1: y += 0.1; if(y >= 1) jumpping = 2; break; case 2: y -= 0.1; if(y <= 0) jumpping = 0; break; } glTranslatef(x,y,z); glRotatef (-r, 0.0, 1.0, 0.0); glPushMatrix(); // health bar glTranslatef(0.0,3.0,0.0); glScalef (health / 100.0, 0.1,0.1); sun_mode(true); glutSolidCube(1.0); glPopMatrix(); sun_mode(false); set_obj_type(is_sphere); glPushMatrix(); // body glScalef (1.6, 3.0, 0.75); nextColor(); draw_obj(); glPopMatrix(); glPushMatrix(); // head glTranslatef(0.0,2.0,0.0); nextColor(); draw_obj(); glPopMatrix(); glPushMatrix(); // right foot glTranslatef(0.8,-1.5,0.0); nextColor(); draw_obj(); glPopMatrix(); glPushMatrix(); // left foot glTranslatef(-0.8,-1.5,0.0); nextColor(); draw_obj(); glPopMatrix(); glPushMatrix(); // right hand glTranslatef(0.8,1.0,0.0); glScalef (0.4, 0.4, 0.4); glRotatef (75, 0.0, 0.0, 1.0); glRotatef (90, 0.0, 1.0, 0.0); right->draw(); glPopMatrix(); glPushMatrix(); // left hand glTranslatef(-0.8,1.0,0.0); glScalef (-0.4, 0.4, 0.4); glRotatef (75, 0.0, 0.0, 1.0); glRotatef (90, 0.0, 1.0, 0.0); left->draw(); glPopMatrix(); glPopMatrix(); setColorI(ori_color_i); set_obj_type(ori_use_sphere); }
void GUIAttrEdit::render() { GUIPanel::render(); float lineH = getLineH(); int scroll = getAttrI( "scroll" ); glDisable( GL_BLEND ); float y = myH - lineH; for( int extra=scroll; extra<0; extra++ ) { y -= lineH; if( y < 0 ) break; } int textColor = getAttrI( "textColor" ); int selectedTextColor = getAttrI( "selectedTextColor" ); int highlightedTextColor = getAttrI( "highlightedTextColor" ); ZHashTable *hash = (ZHashTable *)attributeTable->getp( "hashPtr" ); if( !hash ) return; for( int i=0; i<view.count; i++ ) { int highlighted = (i == mouseOver && mouseWasInside); if( i == selected ) { setColorI( selectedTextColor ); } else if( highlighted ) { setColorI( highlightedTextColor ); } else { setColorI( textColor ); } if( i >= scroll ) { char buf[1024]; char *val = hash->getS( view[i] ); sprintf( buf, "%s = %s", view[i], val ); print( buf, 12, y ); y -= lineH; } if( y <= 0 ) { break; } } if( !optMenuUp && selected != -1 ) { glDisable( GL_LINE_SMOOTH ); glLineWidth( 1.f ); glColor3ub( 0xff, 0, 0 ); glBegin( GL_LINES ); glVertex2f( selectX, selectY ); glVertex2f( selectX, mouseY ); float sign = mouseY > selectY ? -1.f : 1.f; glVertex2f( selectX, mouseY ); glVertex2f( selectX-5, mouseY + sign*5 ); glVertex2f( selectX, mouseY ); glVertex2f( selectX+5, mouseY + sign*5 ); glEnd(); } }