diff --git a/index.js b/index.js index b253b5c..711ca2b 100644 --- a/index.js +++ b/index.js @@ -129,15 +129,15 @@ let characterBuilds = { "Cooper": { "Neutral_B": (color,user)=>{return dillionSideB_GrappleDirection(color,user)}, "Side_B": (color,user)=>{return CooperSideB_LongPunch(color, user)}, - "Up_B": (color,user)=>{}, - "Down_B": (summonerColor, user)=>{}, + "Up_B": (color,user)=>{return CooperUpAndDown_PunchStockPhotoHand(color, user, "up")}, + "Down_B": (summonerColor, user)=>{return CooperUpAndDown_PunchStockPhotoHand(summonerColor, user, "down")}, - "Neutral_A": (color,user)=>{}, - "Side_A": (color,user)=>{}, - "LeftSide_A_air": (color,user)=>{}, - "RightSide_A_air": (color,user)=>{}, + "Neutral_A": (color,user)=>{return CooperMilesMorales_NeutralA(color, user)}, + "Side_A": (color,user)=>{return CooperStickyHand_SideA(color,user)}, + "LeftSide_A_air": (color,user)=>{return CooperStickyHand_SideA(color,user)}, + "RightSide_A_air": (color,user)=>{return CooperStickyHand_SideA(color,user)}, "Down_A": (color,user)=>{return CooperDownA_Grenade(color, user)}, - "Up_A": (color,user)=>{}, + "Up_A": (color,user)=>{return CooperPlane_UpA(color, user)}, "Ultimate": (color, user)=>{}, }, @@ -357,14 +357,14 @@ const keys = {} var lastFrameNow = 0 var fpsCounter = document.getElementById("fpsCounter") - +var deltaTimeMS = 0 function animate() { window.requestAnimationFrame(animate) - performanceNow = performance.now() + let performanceNow = performance.now() deltaTimeMS = performanceNow-lastFrameNow - dtMultiplier = deltaTimeMS / 1000 + let dtMultiplier = deltaTimeMS / 1000 lastFrameNow = performanceNow + 0 FPS = 1000 / deltaTimeMS fpsCounter.innerText = Math.round(FPS) diff --git a/js/customAttacks.js b/js/customAttacks.js index 2da78a2..897a74a 100644 --- a/js/customAttacks.js +++ b/js/customAttacks.js @@ -55,7 +55,136 @@ function CooperDownA_Grenade(color, user){ clearInterval(clearingId) }, 1) - return 6000 + return 20000 +} + +function CooperMilesMorales_NeutralA(color, user){ + for(var i=0; i{ + prevPosition = dmgSprite.entity.position + let outOfBounds = false + if(prevPosition.x < 0){outOfBounds=true} + if(prevPosition.x+e.width > canvas.width){outOfBounds=true} + if(dmgSprite.uses == startUses && outOfBounds==false) return + dmgSprite.life = -1 + clearInterval(removeId) + let toTheRight = prevPosition.x-user.position.x > 0 ? true : false + user.velocity.x = 15 * (toTheRight ? 1 : -1) + }, 1); + + return 4000 +} + +function CooperPlane_UpA(color, user){ + setEntityFrozenFrameAndImageSrc( + Infinity, + "./sprites/cooper_stock_photos/plane_"+(user.facingRight ? "right" : "left")+".png", + 1, + user + ) + user.doGravity = false + + // Create bullet to track time + let newProj = new Sprite({ + position: { + x: -1000, + y: -1000, + }, + imageSrc: "./sprites/attacks/bullet.png", + scale: canvasScale * 1, + framesMax: 1, + }) + let dmgSprite = { + entity: newProj, + color: "", + vel: {"x":0,"y":0}, + dmg: 0, + uses: -1, + life: 5000 + } + damageSprites.push(dmgSprite) + + let removeId = setInterval(()=>{ + let plrHitbox = user.generateHitBoxes(1)[0] + for(let i=0;i0) return + clearInterval(removeId) + user.frozenSprite = 0 + user.doGravity = true + },1) + + return 20_000 +} + +function CooperUpAndDown_PunchStockPhotoHand(summonerColor, user, dir){ + let e = new Sprite({ + position: { + "x": user.position.x, + "y": user.position.y, + }, + imageSrc: './sprites/cooper_stock_photos/hand_grab_' +dir+ '.png', + scale: canvasScale * 0.5, + framesMax: 1, + }) + damageSprites.push({ + entity: e, + dmg: 4, + color: summonerColor, + vel: {x:0, y:10 * (dir=="down" ? 1 : -1)}, + uses: 1, + + //pullUser: true, + life: 9000, + }) + + return 2000 } function CooperSideB_LongPunch(summonerColor, user){ @@ -238,4 +367,13 @@ function explosionCreate(summonerColor, position){ uses: 1, life: 500, }) +} + +function setEntityFrozenFrameAndImageSrc(frozenFrameCount, imageSrc, imageMaxFrames, entity){ + let tempImage = new Image() + tempImage.src = imageSrc + + entity.frozenSprite = frozenFrameCount + entity.image = tempImage + entity.framesMax = imageMaxFrames } \ No newline at end of file diff --git a/js/customClasses.js b/js/customClasses.js index 24fd985..48fb0ec 100644 --- a/js/customClasses.js +++ b/js/customClasses.js @@ -205,7 +205,10 @@ class Fighter extends Sprite { this.dead = false this.onGround = false this.stunFrames = 0 + this.frozenSprite = 0 + this.doGravity = true + this.critChance = 0.01 // <-- 1% chance this.attackDamage = 1 @@ -284,6 +287,7 @@ class Fighter extends Sprite { this.animateFrames() this.immunityFrames -= 1 this.stunFrames -= 1 + this.frozenSprite -= deltaTimeMS this.attackRunTime -= deltaTimeMS / 1000 this.isAttacking = this.attackRunTime > 0 @@ -322,7 +326,7 @@ class Fighter extends Sprite { this.velocity.y = 0 this.position.y = floor - (this.height) this.onGround = true - } else{ + } else if(this.doGravity){ this.velocity.y += gravity // let's only set this to false when we do jump //this.onGround = false @@ -378,16 +382,21 @@ class Fighter extends Sprite { this.handleAttack(entities) } - this.determineAndUpdateSprite() + if(this.frozenSprite < 0) this.determineAndUpdateSprite() } handleVelocity(){ let drag = .5 let velX = this.velocity.x + let velY = this.velocity.y if(velX != 0){ this.velocity.x += velX > 0 ? -drag : drag } + if(velY != 0 && this.doGravity==false){ + this.velocity.y += velY > 0 ? -drag : drag + } + let round = 10 this.velocity.x = Math.floor(this.velocity.x*round)/round this.velocity.y = Math.floor(this.velocity.y*round)/round @@ -630,20 +639,26 @@ class Fighter extends Sprite { hasMoved = true this.facingRight = true } + + if(keys[keybinds.Jump]){ + if(this.doGravity) this.jump() + else{ this.velocity.y -= speed/3 } + } + if(keys[keybinds.Shield] && this.doGravity==false){ + this.velocity.y += speed/3 + } } setCooldown(attack, attackData){ if(attackData == null) attackData = 400 + console.log(attackData, attack) this.cooldowns[attack] = attackData } handleInputs(keybinds){ let didAttack = false - - if(keys[keybinds.Jump]){ - this.jump() - } + if (keys[keybinds.Ultimate] && this.ultimateCharge>=100) { this.ultimateCharge = 0 this.attacks["Ultimate"](this.color, this) diff --git a/notes.txt b/notes.txt index f9f6675..d46992e 100644 --- a/notes.txt +++ b/notes.txt @@ -21,18 +21,19 @@ Dillion Attacks and Notes > Spawn Black Hole on current position +// I NEED SPRITES FOR COOPER'S CHARACTER Cooper Attacks and Notes * A Attacks - - Neutral ~ Everyone becomes Miles Morales suprised for X seconds - - Side ~ Stick hand grapple to enemy or wall - - Side Air ~ Same as grapple - ground side - - Down ~ Pull grenade pin and explode everyone - - Up ~ Turn into plane, and blow up one player + - Neutral > Everyone becomes Miles Morales suprised for X seconds + - Side > Stick hand grapple to enemy or wall + - Side Air > Same as grapple - ground side + - Down > Pull grenade pin and explode everyone + - Up > Turn into plane, and blow up one player * B Attacks - - Neutral ~ Pull someone towards you (facing direction) (Side B in Dillion) - - Side ~ Long punch in direction (comically long hand) - - Up ~ Stock Photo hand Punch Up Quickly - - Down ~ Stock Photo hand Punch Down Quickly + - Neutral > Pull someone towards you (facing direction) (Side B in Dillion) + - Side > Long punch in direction (comically long hand) + - Up > Stock Photo hand Punch Up Quickly + - Down > Stock Photo hand Punch Down Quickly * Ultimate ~ Giga Chad for X seconds w/ buff attack and speed diff --git a/sprites/cooper_stock_photos/hand_grab_down.png b/sprites/cooper_stock_photos/hand_grab_down.png new file mode 100644 index 0000000..d15ce65 Binary files /dev/null and b/sprites/cooper_stock_photos/hand_grab_down.png differ diff --git a/sprites/cooper_stock_photos/hand_grab_up.png b/sprites/cooper_stock_photos/hand_grab_up.png new file mode 100644 index 0000000..020387f Binary files /dev/null and b/sprites/cooper_stock_photos/hand_grab_up.png differ diff --git a/sprites/cooper_stock_photos/miles_morales_suprised.png b/sprites/cooper_stock_photos/miles_morales_suprised.png new file mode 100644 index 0000000..9d232bc Binary files /dev/null and b/sprites/cooper_stock_photos/miles_morales_suprised.png differ diff --git a/sprites/cooper_stock_photos/plane_left.png b/sprites/cooper_stock_photos/plane_left.png new file mode 100644 index 0000000..e33579d Binary files /dev/null and b/sprites/cooper_stock_photos/plane_left.png differ diff --git a/sprites/cooper_stock_photos/plane_right.png b/sprites/cooper_stock_photos/plane_right.png new file mode 100644 index 0000000..54008d8 Binary files /dev/null and b/sprites/cooper_stock_photos/plane_right.png differ diff --git a/sprites/cooper_stock_photos/sticky_hand.png b/sprites/cooper_stock_photos/sticky_hand.png deleted file mode 100644 index bab04ae..0000000 Binary files a/sprites/cooper_stock_photos/sticky_hand.png and /dev/null differ diff --git a/sprites/cooper_stock_photos/sticky_hand_left.png b/sprites/cooper_stock_photos/sticky_hand_left.png new file mode 100644 index 0000000..3769a79 Binary files /dev/null and b/sprites/cooper_stock_photos/sticky_hand_left.png differ diff --git a/sprites/cooper_stock_photos/sticky_hand_right.png b/sprites/cooper_stock_photos/sticky_hand_right.png new file mode 100644 index 0000000..3b0ee62 Binary files /dev/null and b/sprites/cooper_stock_photos/sticky_hand_right.png differ