Skip to content

Commit

Permalink
Finished Cooper (minus sprites)
Browse files Browse the repository at this point in the history
Cooper is finished (yay!)
I just need sprites for him (only 23 sprites)
  • Loading branch information
BoomBoomMushroom committed Dec 15, 2023
1 parent 121bec5 commit 2762f93
Show file tree
Hide file tree
Showing 12 changed files with 180 additions and 26 deletions.
20 changes: 10 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)=>{},
},
Expand Down Expand Up @@ -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)
Expand Down
140 changes: 139 additions & 1 deletion js/customAttacks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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<entities.length; i++){
setEntityFrozenFrameAndImageSrc(
1000 * 3,
"./sprites/cooper_stock_photos/miles_morales_suprised.png",
1,
entities[i]
)
// 3 Seconds
}
}

function CooperStickyHand_SideA(color, user){
let spriteName = user.facingRight ? "right" : "left"

let e = new Sprite({
position: {
"x": user.position.x,
"y": user.position.y,
},
imageSrc: './sprites/cooper_stock_photos/sticky_hand_' +spriteName+ '.png',
scale: canvasScale * 0.5,
framesMax: 1,
})
e.width = 150
e.height = 40
let dmgSprite = {
entity: e,
dmg: 4,
color: color,
vel: {x:10 * (user.facingRight ? 1 : -1), y:0},
uses: 1,

//pullUser: true,
life: 9000,
}
damageSprites.push(dmgSprite)

let prevPosition = null
let startUses = dmgSprite.uses+0
let removeId = setInterval(()=>{
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;i<entities.length;i++){
if(entities[i].color == user.color) continue
if(user.hitBoxCollision(plrHitbox, entities[i].generateHitBoxes(1)[0])){
entities[i].takeHit(randomInt(10, 50), user.position)
user.damage += randomInt(2, 30)
dmgSprite.life = -10
}
}

user.image.src = "./sprites/cooper_stock_photos/plane_"+(user.facingRight ? "right" : "left")+".png"
if(dmgSprite.life>0) 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){
Expand Down Expand Up @@ -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
}
27 changes: 21 additions & 6 deletions js/customClasses.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
19 changes: 10 additions & 9 deletions notes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Binary file added sprites/cooper_stock_photos/hand_grab_down.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sprites/cooper_stock_photos/hand_grab_up.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sprites/cooper_stock_photos/plane_left.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sprites/cooper_stock_photos/plane_right.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed sprites/cooper_stock_photos/sticky_hand.png
Binary file not shown.
Binary file added sprites/cooper_stock_photos/sticky_hand_left.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sprites/cooper_stock_photos/sticky_hand_right.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 2762f93

Please sign in to comment.