Skip to content

Instantly share code, notes, and snippets.

@Torxed
Created June 24, 2014 06:12
Show Gist options
  • Save Torxed/d4934d7941b417c4560b to your computer and use it in GitHub Desktop.
Save Torxed/d4934d7941b417c4560b to your computer and use it in GitHub Desktop.
# Part of my main class more often than not,
# this will do the actual drawing of lines
def draw_line(xy, dxy, color=(0.2, 0.2, 0.2, 1)):
glColor4f(color[0], color[1], color[2], color[3])
glBegin(GL_LINES)
glVertex2f(xy[0], xy[1])
glVertex2f(dxy[0], dxy[1])
glEnd()
# How to call it to get a two-line-thickness healthbar.
draw_line((x, y+height_offset), (x+(width * values['hp']), y+height), (0.2, 0.2, 1.0, 1))
draw_line((x, y+height_offset+1), (x+(width * values['hp']), y+height+1), (1.0, 0.2, 0.2, 1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment