-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathStaticEntity.py
More file actions
84 lines (69 loc) · 2.37 KB
/
StaticEntity.py
File metadata and controls
84 lines (69 loc) · 2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import Entity
import pygame
import Tile
import Keyboard
import random
import Client
import gui
import copy
class StaticEntity(Entity.Entity):
def __init__(self,level, x, y):
super(StaticEntity,self).__init__(level,x,y)
self.x = x
self.y = y
self.id = len(level.entities)
self.basicFont = pygame.font.SysFont(None, 32)
self.blocksPath = True
self.img = pygame.transform.scale(self.img, (32, 32))
self.canPlace = True
self.tile = Tile.water
def CanPlace(self):
for e in self.level.entities:
if e.x == self.x and e.y == self.y:
self.canPlace = False
return
if self.blocksPath == True:
if self.level.willBlockTreasure(self,self.x>>5,self.y>>5,False):
self.canPlace = False
return
self.canPlace = True
def placeInLevel(self):
if self.canPlace:
#self.level.entities.append(copy.copy(self))
self.level.setTile(self.x>>5,self.y>>5,self.tile)
print "Placed Entity"
self.CanPlace()
print self.x>>5,self.y>>5
self.level.willBlockTreasure(self,self.x>>5,self.y>>5,True)#update paths
return True
return False
"""Determins if the entity has collided
@Params:
None
@Return:
hasCollided(boolean): if the entity has collided
"""
def hasCollided(self,xa, ya):
return False
"""Updates logic associated with entity
@Params:
None
@Retrun:
None
"""
def tick(self):
global x,y
super(StaticEntity,self).tick()
if self.entityCollidedWith!=None:
print "Bang"
self.entityCollidedWith = None
"""Renders the entity to the screen
@Params:
screen(pygame.Surface): suface to draw to
xoff(int): x offset of screen
yoff(int): y offset of screen
@Return:
None
"""
def render(self,screen,xoff,yoff):
screen.blit(self.tile.img, (self.x-xoff,self.y-yoff))