Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let px=100, py=300;
- let n = 0;
- let bx = [], by = []
- let cats = 20
- let cx = [], cy = []
- let speed = 1
- for (let i=0; i<cats; ++i){
- cy[i] = Math.random()*550
- cx[i] = Math.random()*800+800
- }
- function update() {
- for (let j=0; j<cats; ++j){
- if (cx[j] < 0 || areColliding(cx[j], cy[j], 50, 50, px, py, 50, 50)){
- return
- }
- for (let i=0; i<n; ++i){
- if (areColliding(bx[i], by[i], 20, 10, cx[j], cy[j], 50, 50)){
- speed += 0.01
- cx[j] = Math.random()*800+800
- cy[j] = Math.random()*550
- }
- }
- }
- for (let i=0; i<cats; ++i){
- cx[i] -= speed;
- }
- py = mouseY
- if (isKeyPressed[32]){
- bx[n] = px;
- by[n] = py+20;
- n++
- }
- for (let i=0; i<n; ++i){
- bx[i]+=10;
- }
- }
- function draw() {
- drawImage(pirate[0], px, py, 50, 50)
- for (let i=0; i<n; ++i){
- drawImage(bullet, bx[i], by[i], 20, 10);
- }
- for (let i=0; i<cats; ++i){
- drawImage(cat, cx[i], cy[i], 50, 50);
- }
- };
- function keyup(key) {
- };
- function mouseup() {
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement