예제 #1
0
    def __init__(self, windowSize, x=-1, y=-1):
        self.windowSize = windowSize
        if (x == -1 and y == -1):
            x = int(self.windowSize[0] / 2)

        Mob.__init__(self, x, y)
        self.x = x
        self.y = y

        self.maxSpeed = 1.5
        self.speed = 0

        self.sprite = Sprite("Squizzard/sprites/nelward.png")
        self.sprite.setSize(2)
        self.size = self.sprite.getSize()[0]

        self.drag = 10

        #If he was spawned at the default starting spot,
        #place him in the center of the screen, 3/4ths of the way
        #down
        if (self.y == -1):
            self.y = self.windowSize[1] / 4 * 3 - int(self.size / 2)

        return
예제 #2
0
class Net(Mob):
    def __init__(self, windowSize, x=0, y=0):
        Mob.__init__(self, x, y)

        self.windowSize = windowSize
        self.speed = 2
        self.sprite = Sprite("Squizzard/sprites/net.png")
        self.size = self.sprite.getSize()[0]

        if (self.x == 0 and self.y == 0):
            self.x = randrange(0, int(self.windowSize[1] - self.size / 2))
            self.y = -self.size

        return

    def move(self):
        self.y += self.speed

        if (self.y > self.windowSize[1]):
            self.state = ExistenceState.DESTROY

        return

    def logic(self):
        self.move()

        return

    def draw(self, screen):
        self.sprite.draw(screen, int(self.x), int(self.y))
        return

    def getState(self):
        return self.state
예제 #3
0
class Food(Mob):
    def __init__(self, windowSize, x = 0, y = 0):
        Mob.__init__(self)
        self.windowSize = windowSize
        self.x = x
        self.y = y
        self.speed = 1

        self.sprite = Sprite("Squizzard/sprites/food.png")
        self.size = self.sprite.getSize()[0]

        #If the food was at (0, 0), then place it
        #randomly at the top of the screen
        if (self.x == 0 and self.y == 0):
            self.x = randrange(0, int(self.windowSize[1] - self.size / 2))
            self.y = -self.size

        return

    def draw(self, screen):
        self.sprite.draw(screen, int(self.x), int(self.y))
        return

    def move(self):
        self.y += self.speed

        return

    def logic(self):
        if (self.y > self.windowSize[1]):
            self.state = ExistenceState.DESTROY
        else:
            self.move()

        return
예제 #4
0
    def __init__(self, windowSize, x=0, y=0):
        Mob.__init__(self, x, y)

        self.windowSize = windowSize
        self.speed = 2
        self.sprite = Sprite("Squizzard/sprites/net.png")
        self.size = self.sprite.getSize()[0]

        if (self.x == 0 and self.y == 0):
            self.x = randrange(0, int(self.windowSize[1] - self.size / 2))
            self.y = -self.size

        return
예제 #5
0
    def __init__(self, windowSize, x=0, y=0):
        Mob.__init__(self, x, y)

        self.windowSize = windowSize
        self.sprite = Sprite("Squizzard/sprites/shark.png")
        self.sprite.setSize(2)
        self.size = self.sprite.getSize()[0]
        self.speed = 3

        self.state = ExistenceState.ACTIVE

        if (self.x == 0 and self.y == 0):
            self.x = randrange(0, self.windowSize[0])
            self.y = -self.size

        return
예제 #6
0
    def __init__(self, windowSize, x = 0, y = 0):
        Mob.__init__(self)
        self.windowSize = windowSize
        self.x = x
        self.y = y
        self.speed = 1

        self.sprite = Sprite("Squizzard/sprites/food.png")
        self.size = self.sprite.getSize()[0]

        #If the food was at (0, 0), then place it
        #randomly at the top of the screen
        if (self.x == 0 and self.y == 0):
            self.x = randrange(0, int(self.windowSize[1] - self.size / 2))
            self.y = -self.size

        return
예제 #7
0
class Predator(Mob):
    def __init__(self, windowSize, x=0, y=0):
        Mob.__init__(self, x, y)

        self.windowSize = windowSize
        self.sprite = Sprite("Squizzard/sprites/shark.png")
        self.sprite.setSize(2)
        self.size = self.sprite.getSize()[0]
        self.speed = 3

        self.state = ExistenceState.ACTIVE

        if (self.x == 0 and self.y == 0):
            self.x = randrange(0, self.windowSize[0])
            self.y = -self.size

        return

    def move(self):
        self.y += self.speed

        if (self.y > self.windowSize[1] + self.size):
            self.state = ExistenceState.DESTROY

        return

    def logic(self):
        self.move()
        return

    def getState(self):
        return self.state

    def draw(self, screen):
        self.sprite.draw(screen, int(self.x), int(self.y))
        return
예제 #8
0
class Nelward(Mob):
    def __init__(self, windowSize, x=-1, y=-1):
        self.windowSize = windowSize
        if (x == -1 and y == -1):
            x = int(self.windowSize[0] / 2)

        Mob.__init__(self, x, y)
        self.x = x
        self.y = y

        self.maxSpeed = 1.5
        self.speed = 0

        self.sprite = Sprite("Squizzard/sprites/nelward.png")
        self.sprite.setSize(2)
        self.size = self.sprite.getSize()[0]

        self.drag = 10

        #If he was spawned at the default starting spot,
        #place him in the center of the screen, 3/4ths of the way
        #down
        if (self.y == -1):
            self.y = self.windowSize[1] / 4 * 3 - int(self.size / 2)

        return

    def move(self, keys):
        global windowSize

        #If D is pressed and Nelward isn't going to go offscreen to the right
        #and his speed is <= the max speed, then increase his rightward momentum
        if (keys[pygame.K_d] == 1 and self.x + self.size < self.windowSize[0]
                and (self.speed + self.maxSpeed / self.drag) <= self.maxSpeed):

            self.speed += self.maxSpeed / self.drag

        #If A is pressed and Nelward isn't going to go offscreen to the left
        #and his speed is >= -maxSpeed, then increase his leftward momentum
        elif (keys[pygame.K_a] == 1 and self.x > 0
              and (self.speed - self.maxSpeed / self.drag) >= -self.maxSpeed):

            self.speed -= self.maxSpeed / self.drag

        #If nothing is pressed, slow him down until we're close enough to
        #a speed of 0 to snap to 0, thereby stopping him
        else:
            if (abs(self.speed) <= self.maxSpeed / self.drag):
                self.speed = 0
            elif (self.speed > 0):
                self.speed -= self.maxSpeed / self.drag
            elif (self.speed < 0):
                self.speed += self.maxSpeed / self.drag

        #If he touches the left or right bounds of the screen, stop him
        if (self.x + self.size + self.speed > self.windowSize[0]
                or self.x + self.speed < 0):
            self.speed = 0

        self.x += self.speed

        return

    def draw(self, screen):
        self.sprite.draw(screen, int(self.x), int(self.y))

        return