예제 #1
0
 def __init__(self, zoom):
     self.vel = Vector()
     self.source = img
     self.centreSource = Vector(307, 307)
     self.dimSource = Vector(614, 614)
     self.moveP = Vector(307, 307)
     self.imgZoom = Vector(614 * zoom, 614 * zoom)
예제 #2
0
 def update(self):
     if self.keyboard.left:
         self.obstacle.vel.add(Vector(0.1, 0))
         # self.tMap.vel.add(Vector(0.1, 0))
     if self.keyboard.right:
         self.obstacle.vel.add(Vector(-0.1, 0))
         # self.tMap.vel.add(Vector(-0.1, 0))
     if self.keyboard.down:
         self.obstacle.vel.add(Vector(0, -0.1))
         # self.tMap.vel.add(Vector(0, -0.1))
     if self.keyboard.up:
         self.obstacle.vel.add(Vector(0, 0.1))
예제 #3
0
class Player:
    def __init__(self):
        self.pos = Vector(CANVASWIDTH / 2, CANVASHEIGHT / 2)
        self.vel = Vector()
        self.radius = 10
        self.colour = 'Green'

    def draw(self, canvas):
        canvas.draw_circle(self.pos.getP(), self.radius, 1, self.colour, self.colour)

    def update(self):
        self.pos.add(self.vel)
        self.vel.multiply(0.85)
예제 #4
0
class Obstacle:
    def __init__(self, x1, y1, x2, y2):
        self.startPos = imgCentre.copy().add(Vector(x1, y1).multiply(mapZoom))
        self.endPos = imgCentre.copy().add(Vector(x2, y2).multiply(mapZoom))
        self.vel = Vector()
        self.colour = 'Blue'

    def draw(self, canvas):
        canvas.draw_line(self.startPos.getP(), self.endPos.getP(), 7, self.colour)

    def update(self):
        self.startPos.add(self.vel)
        self.endPos.add(self.vel)
        self.vel.multiply(0.85)
예제 #5
0
class tMap:
    def __init__(self, zoom):
        self.vel = Vector()
        self.source = img
        self.centreSource = Vector(307, 307)
        self.dimSource = Vector(614, 614)
        self.moveP = Vector(307, 307)
        self.imgZoom = Vector(614 * zoom, 614 * zoom)

    def draw(self, canvas):
        canvas.draw_image(img, self.centreSource.getP(), self.dimSource.getP(), self.moveP.getP(), self.imgZoom.getP())

    def update(self):
        self.moveP.add(self.vel)
        self.vel.multiply(0.85)

    def collide_check(walls):

        for x1, y1, x2, y2 in Obstacle.:
            if Obstacle.startPos.x <= player.pos.x <= Obstacle.endPos.x and Obstacle.startPos.y <= player.pos.y <= Obstacle.endPos.y:
                print("collide with wall (" +  + ", " + y1 + ")" + "(" + x2 + ", " + y2 + ")")
                return True
        return False
예제 #6
0
 def __init__(self, x1, y1, x2, y2):
     self.startPos = imgCentre.copy().add(Vector(x1, y1).multiply(mapZoom))
     self.endPos = imgCentre.copy().add(Vector(x2, y2).multiply(mapZoom))
     self.vel = Vector()
     self.colour = 'Blue'
예제 #7
0
 def __init__(self):
     self.pos = Vector(CANVASWIDTH / 2, CANVASHEIGHT / 2)
     self.vel = Vector()
     self.radius = 10
     self.colour = 'Green'
예제 #8
0
from game_states.user303_0QT2noFSwD_0 import Vector

try:
    import simplegui
except ImportError:
    import SimpleGUICS2Pygame.simpleguics2pygame as simplegui

CANVASHEIGHT = 614
CANVASWIDTH = 614
MIN_RAD = 1
img = simplegui.load_image('https://raw.githubusercontent.com/Bill-Ferny/CS1830-LightsOut/master/gameMap.jpg')
imgCentre = Vector(307, 307)
mapZoom = 2


class Player:
    def __init__(self):
        self.pos = Vector(CANVASWIDTH / 2, CANVASHEIGHT / 2)
        self.vel = Vector()
        self.radius = 10
        self.colour = 'Green'

    def draw(self, canvas):
        canvas.draw_circle(self.pos.getP(), self.radius, 1, self.colour, self.colour)

    def update(self):
        self.pos.add(self.vel)
        self.vel.multiply(0.85)


player = Player()