Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
started adding head class
  • Loading branch information
Harris Davidson
Harris Davidson committed Oct 21, 2017
commit 256aa6ba6968019b1f699ce48eff1a197e119036
32 changes: 28 additions & 4 deletions head.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,30 @@
screen = pygame.display.set_mode((640, 480))
pygame.display.set_caption('Head Movement')

class Head(object):

def __init__(self,x,y,direction):

self.x = x
self.y = y
self.direction = direction
self.size = 30
self.speed = 10
self.sprite = pygame.Rect(x,y,self.size,self.size)

def __repr__(self):

return 'Head position: ('+str(self.x)+','+str(self.y)+') direction: '+str(direction)

def step():
'''
pos = sprite.center
vel = self.direction
self.sprite.center = sprite.center[0]+self.direction[0]*self.speed
'''
pass



HEAD_WIDTH = 30
HEAD_HEIGHT = 30
Expand All @@ -13,9 +37,9 @@
HEAD_COLOR = pygame.color.Color("red")
clock = pygame.time.Clock()

pygame.font.init()
myfont = pygame.font.SysFont('Comic Sans MS', 30)
textsurface = myfont.render('You lost', False, (0, 0, 0))
#pygame.font.init()
#myfont = pygame.font.SysFont('Comic Sans MS', 30)
#textsurface = myfont.render('You lost', False, (0, 0, 0))

direction = (0,0) #right, down
running = True
Expand All @@ -40,7 +64,7 @@
direction = (0,1)
#p1head.top = p1head.top + headSpeedX * 10
if p1head.left <= 0 or p1head.left >= 640:
screen.blit(textsurface,(0,0))
#screen.blit(textsurface,(0,0))
running = False
if p1head.top <= 0 or p1head.top >= 480:
running = False
Expand Down
Binary file added intro_ball.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions time_testing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import time
pos = 1,1
body = [pos]*100
start = time.perf_counter()
body.pop(0)
print((time.perf_counter()-start)*1000)