-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathdeeler.py
108 lines (90 loc) · 3.6 KB
/
deeler.py
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import pygame
from pygame.locals import *
from spiderenemy import *
from stateimagelibrary import *
import random
from time import *
from math import *
from rng import *
class Deeler(SpiderEnemy):
"Spider"
def __init__(self,xx,yy,ww,hh,hp):
SpiderEnemy.__init__(self, xx, yy, ww, hh, hp)
self.image = pygame.image.load('./pics/dealer1-48x48.bmp').convert()
self.image.set_colorkey((0,0,255))
self.image2 = pygame.image.load('./pics/dealerup1-48x48.bmp').convert()
self.image2.set_colorkey((0,0,255))
self.silkimage = pygame.image.load('./pics/silk-2x2.bmp').convert()
self.silkimage.set_colorkey((0,0,255))
self.silkspideroffset = 12
self.talkcounter = 0
self.direction = "down"
self.crawling = 1
self.up = 0
def draw(self, screen, room):
if self.crawling == 0:
# Draw spider silk cord
for i in range(self.yy,self.y+self.silkspideroffset):
screen.blit(self.silkimage, (self.x-self.w/2+room.relativex,i))
# Draw Spider
screen.blit(self.image, (self.x-40+room.relativex,self.y+room.relativey))
else:
screen.blit(self.image2, (self.x-40+room.relativex,self.y+room.relativey))
def update(self,room,player):
if abs(player.x-(self.x+room.relativex)) < 5:
self.crawling = 0
# movement in trees towards player
if self.crawling:
if player.x <= self.x-room.relativex:
self.x -= 6
elif player.x > self.x-room.relativex:
self.x += 6
return
# lowering to bite
else:
if self.up:
self.y -= 6
if self.y <= self.yy:
self.up = 0
self.crawling = 1
return
if self.y < 300:
self.y += 6
elif self.y >= 300:
self.up = 1
def collide(self, room, player):
# FIX BUG
#print 'gameobject x=%d y=%d player x=%d y=%d' % (self.x,self.y,player.x-room.relativex,player.y-room.relativey)
if (player.x-room.relativex > self.x-self.w and
player.x-room.relativex < self.x+self.w+self.w and
player.y-room.relativey > self.y-self.h and
player.y-room.relativey < self.y + self.h +self.h):
#print "collision with Deeler!"
return 1
else:
return 0 ## for game self.talker
def collidewithsword(self, room, player):
#print 'Digdogger x=%d y=%d player x=%d y=%d' % (self.x,self.y,player.x-room.relativex,player.y-room.relativey)
if (player.x-room.relativex > self.x -self.w and
player.x-room.relativex < self.x+self.w and
player.y-room.relativey > self.y -self.h and
player.y-room.relativey < self.y + self.h):
#print "collision with Sword Dealer!"
return 1
else:
return 0
def collideup(self, room, player):
return 0
def fight(self,room,player,keydown = -1):
1