I’ve recently made some progress for my shooter game! I’ve found the equation I’ve needed to find the point where the slope of the direction crosses the boundaries of the rect for the players, with the intention of having a good starting point for bullets to spawn from. It’s also a great way to determine all the points in the perimeter, obviously. But anyways, here’s the code:
#----------------------------------------------------------------------
def sign(x):
"""returns the sign of x: -1, 0, or 1"""
return cmp(x, 0)
#----------------------------------------------------------------------
def intersect_perimeter(x, y, w, h):
"""finds the intersection in a rectangle"""
#if check which side to put the point on
if abs(y*w) > abs(x*h):
return (int(0.5*h * x/abs(y)), int(0.5*h * sin(y)))
else:
return (int(0.5*w * sin(x)), int(0.5*w * y/abs(x)))
I’ve also had the chance to implement some cheap graphics, including bullets, explosions, and a house, drawn by me, but also a background image, drawn by the most angry of my friends. The results are pretty nice, definitely an improvement over the old off-white background. You can see the player, flames behind him, the place holder house, and the background