Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Box:
- def __init__(self, x, y, s):
- self.x = x
- self.y = y
- self.s = s
- def draw(self, cam):
- rect(self.x * cam['z'] - cam['x'], self.y * cam['z'] - cam['y'], self.s * cam['z'], self.s * cam['z'])
- cam = {'x': 0, 'y': 0, 'z': 1}
- boxes = []
- def setup():
- size(800, 600)
- for i in range(20):
- boxes.append(Box(random(-20,20) * 20, random(-20,20) * 20, random(10,30)))
- def draw():
- if mousePressed:
- cam['x'] -= mouseX - pmouseX
- cam['y'] -= mouseY - pmouseY
- background(123)
- wmouseY = (mouseY + cam['y']) / cam['z']
- wmouseX = (mouseX + cam['x']) / cam['z']
- text(str(wmouseX) + ', ' + str(wmouseY), 20, 20)
- for b in boxes:
- b.draw(cam)
- def keyPressed():
- if key == 'e':
- cam['z'] += 0.5
- elif key == 'q':
- cam['z'] -= 0.5
- if cam['z'] < 0.5:
- cam['z'] = 0.5
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement