source: nagslang/utils.py@ 334:a3f1b2f0e3fb

Last change on this file since 334:a3f1b2f0e3fb was 334:a3f1b2f0e3fb, checked in by Jeremy Thurgood <firxen@…>, 8 years ago

Physics-related cleanup.

File size: 514 bytes
Line 
1import pygame
2from pymunk.vec2d import Vec2d
3
4
5def convert_colour(colour):
6 if isinstance(colour, pygame.Color):
7 return colour
8 if isinstance(colour, tuple):
9 return pygame.Color(*colour)
10 if isinstance(colour, basestring):
11 return pygame.Color(colour)
12 raise ValueError()
13
14
15def vec_from_angle(angle, length=1):
16 vec = Vec2d(length, 0)
17 vec.angle = angle
18 return vec
19
20
21def vec_with_length(coords, length=1):
22 vec = Vec2d(coords)
23 vec.length = length
24 return vec
Note: See TracBrowser for help on using the repository browser.