void Pumpkin::draw() { ci::gl::enable(GL_CULL_FACE); ci::gl::enable(GL_TEXTURE_2D); ci::gl::enableAlphaBlending(); ci::gl::pushModelView(); if(mPumpkinName == "Pumpkin1") drawPumpkin(mPumpkin1); if(mPumpkinName == "Pumpkin2") drawPumpkin(mPumpkin2); ci::gl::popModelView(); ci::gl::disableAlphaBlending(); ci::gl::disable(GL_TEXTURE_2D); ci::gl::disable(GL_CULL_FACE); }
void ViewSimple2D::redraw( bool paused ) { vec2f ctr; ctr = vec2f( 300, 300 ); // 2d part glMatrixMode( GL_PROJECTION ); glLoadIdentity(); gluOrtho2D( 0, 800, 0, 600 ) ; glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); // Draw pumpkins in a ring int i, j, k; float t, sz=60; int x, y; Pumpkin p; // the "board" glDisable( GL_TEXTURE_2D ); glLineWidth( 3.0 ); vec4f fill = vec4f( 0.5f, 0.7f, 0.6f, 0.5f ), line = vec4f( 0.8f, 0.3f, 0.8f, 1.0f ), fill_dest = vec4f( 0.9f, 0.4f, 0.5f, 0.5f ), line_dest = vec4f( 0.2f, 1.0f, 0.2f, 1.0f ); // The center "storage ring" drawCircle( ctr, 50, SHAPE_LINE_AND_FILL, fill, line, 100 ); // The outer ring drawCircle( ctr, 250, SHAPE_LINE, fill, line, 100 ); gfEnableFont( m_fontId, 25 ); // a bunch of dots for the board vec2f freeze_pos, freeze_dir; vec2f queue_pos, queue_dir; vec2f station_pos; vec4f color, linecolor; char *label = NULL; for (i = 0; i < MACHINE_SLOTS; i++) { t = (2.0*M_PI)/MACHINE_SLOTS * i; x = ctr[0] + cos(t)*250.0; y = ctr[1] - sin(t)*250.0; label = NULL; if ((i >= DEST_SLOT_NDX) && (i < DEST_SLOT_NDX+5)) { color = fill_dest; linecolor = line_dest; if (i==DEST_SLOT_NDX+2) label = "Destination"; } else if (i==FREEZER_NDX) { color = vec4f( 0.0f, 1.0f, 1.0f, 0.6f ); linecolor = vec4f( 1.0f, 1.0f, 1.0f, 1.0f ); label = "Freeze"; // draw freezer slots freeze_dir = vec2f( cos(t), -sin(t) ); freeze_pos = vec2f( x, y ) - freeze_dir*sz; for (int j=0; j < FREEZER_CAPACITY; j++) { drawCircle( freeze_pos - (freeze_dir*30*j), 15, SHAPE_LINE_AND_FILL, vec4f( 1.0, 1.0, 1.0, 1.0 ), vec4f( 0.0, 1.0, 1.0, 1.0), 12 ); } } else if (i==PRODUCTION_NDX) { color = fill; linecolor = line; // draw production slots queue_dir = vec2f( cos(t), -sin(t) ); queue_pos = vec2f( x, y ) + queue_dir*sz*0.6f; queue_dir = vec2f( 0.0, 1.0 ); // vertical queue for (int j=0; j < PRODUCTION_CAPACITY; j++) { drawCircle( queue_pos + (queue_dir*30*j), 15, SHAPE_LINE_AND_FILL, vec4f( 1.0, 1.0, 1.0, 1.0 ), vec4f( 0.5, 0.5, 0.5, 1.0), 12 ); } } else if (i==TORCHY_NDX) { color = vec4f( 1.0f, 0.0f, 0.0f, 0.6f ); linecolor = vec4f( 1.0f, 1.0f, 0.0f, 1.0f ); label = "Torchy"; } else { color = fill; linecolor = line; } // draw swap lines if ((i==SWAP_NDX1)||(i==SWAP_NDX2)||(i==SWAP_NDX3)) { glColor4f( linecolor[0], linecolor[1], linecolor[2], linecolor[3] ); glBegin( GL_LINES ); glVertex3f( ctr[0], ctr[1], 0 ); glVertex3f( x, y, 0 ); glEnd(); label = "Swap"; } // draw circle drawCircle( vec2f( x, y ), 25, SHAPE_LINE_AND_FILL, color, linecolor, 8 ); // draw current station if (m_station==i) { station_pos = vec2f(x, y ); } // draw label if (label) { glColor4f( linecolor[0], linecolor[1], linecolor[2], linecolor[3] ); gfBeginText(); float lx = x - (gfGetStringWidth( label )/2.0); glTranslated( (lx<5.0)?5.0:lx, y, 0.0 ); gfDrawString( label ); gfEndText(); glDisable( GL_TEXTURE_2D ); } } // draw combos color = fill; linecolor = line; vec2f rmin(610,545), rmax(795, 595); for (i=0; i < m_game->getNumCombos(); i++) { Combo c = m_game->getCombo( i ); glDisable( GL_TEXTURE_2D ); drawRect( rmin, rmax, SHAPE_LINE_AND_FILL, color, vec4f( 0.0, 0.9, 0.9, 1.0) ); gfEnableFont( m_fontId, 15 ); gfBeginText(); glTranslated( (rmin[0] + (rmax[0]-rmin[0])/2.0) - gfGetStringWidth( c.m_name.c_str() )/2.0 , rmax[1]-12, 0.0 ); gfDrawString( c.m_name.c_str() ); gfEndText(); // draw combo Value gfEnableFont( m_fontId, 25 ); gfBeginText(); glTranslated( rmax[0]-30 , rmax[1]-35, 0.0 ); gfDrawStringFmt( "%d", c.m_value ); gfEndText(); // draw combo pumpkins glBindTexture( GL_TEXTURE_2D, m_texPumpkinIcons ); vec2f px(rmin[0]+5, rmin[1]+5); for (j=0; j < c.m_groups.size(); j++) { p = Pumpkin(); p.m_type = c.m_groups[j].m_item; if ( (p.m_type == ANY_PUMPKIN) || (p.m_type == ANY_ITEM) ) { glColor3f( m_groupColor[j][0], m_groupColor[j][1], m_groupColor[j][2] ); } else { glColor3f( 1.0, 1.0, 1.0 ); } for (k=0; k < c.m_groups[j].m_count; k++ ) { drawPumpkin( px, p, sz*0.5, false ); px[0] = px[0] + sz*0.5; } } rmin[1] = rmin[1] - 55; rmax[1] = rmax[1] - 55; } gfEnableFont( m_fontId, 25 ); if (!paused) { // Draw pumpkins in the machine glEnable( GL_TEXTURE_2D ); glBindTexture( GL_TEXTURE_2D, m_texPumpkinIcons ); glColor3f( 1.0, 1.0, 1.0 ); vec2f v; for (i = 0; i < MACHINE_SLOTS; i++) { p = m_game->getPumpkin( i ); if (p.m_type == EMPTY) continue; v = calcPosFromNdx( i ); x = v[0] - (sz/2); y = v[1] - (sz/2); drawPumpkin( vec2f( x, y ), p, sz ); } // draw frozen pumpkins for ( j=0; j < m_game->getFreezerUsage(); j++) { p = m_game->getFrozenFood( j ); // shouldn't be empty, but... if (p.m_type != EMPTY) { drawPumpkin( (freeze_pos+ - (freeze_dir*30*j)) - vec2f(sz*0.25,sz*0.25), p, sz*0.5 ); } } // draw queued pumpkins for ( j=0; j < m_game->getProdQueueSize(); j++) { p = m_game->getQueuedPumpkin( j ); // shouldn't be empty, but... if (p.m_type != EMPTY) { drawPumpkin( (queue_pos+ (queue_dir*30*j)) - vec2f(sz*0.25,sz*0.25), p, sz*0.5 ); } } // draw center pumpkin p = m_game->getCenterPumpkin(); if (p.m_type != EMPTY) { drawPumpkin( vec2f( ctr[0]-(sz*1.5/2), ctr[1]-(sz*1.5/2)), p, sz*1.5 ); } } // Draw last combo acheived if (m_lastComboAge < COMBO_DISPLAY_TIME) { char buff[200]; t = 1.0 - (m_lastComboAge/COMBO_DISPLAY_TIME); gfEnableFont( m_fontId, 25 ); gfBeginText(); sprintf( buff, "%d - %s - %d", m_lastCombo.m_value, m_lastCombo.m_name.c_str(), m_lastCombo.m_value ); glColor3f( 1.0, t, t ); glTranslated( ctr[0] - gfGetStringWidth( buff )/2, ctr[1]+50-(50.0*t)+j*5, 0.0 ); gfDrawString( buff ); gfEndText(); } glDisable( GL_TEXTURE_2D ); // draw cursor drawCircle( station_pos, 30, SHAPE_LINE, color, vec4f( 0.0, 1.0, 1.0, 1.0), 8 ); drawCircle( station_pos, 35, SHAPE_LINE, color, vec4f( 0.0f, 0.8f, 0.8f, 1.0f), 8 ); // Draw animated pumpkins if (!paused) { glEnable( GL_TEXTURE_2D ); glBindTexture( GL_TEXTURE_2D, m_texPumpkinIcons ); PumpkinAnim pa; for (i = 0; i < m_panim.size(); i++) { pa = m_panim[i]; glPushMatrix(); glTranslated( pa.m_pos[0] - sz/2, pa.m_pos[1]-sz/2, 0.0 ); drawPumpkin( vec2f( 0.0, 0.0 ), pa, sz ); glPopMatrix(); } } // draw particles drawParts(); }