Skip to content

Commit

Permalink
Added Gun recoil effect
Browse files Browse the repository at this point in the history
  • Loading branch information
blueSparrow2000 committed Jun 20, 2024
1 parent e79c5f0 commit 0221a7a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,14 @@ or
2024.6.19 Smooth vehicle movement


2024.6.20 Added airdrop gun: Lynx (penetrates players & enemies) / Added airstrike: emergency cover & plane speeds adjusted / Consumable update: Added adrenaline & drink / Armor update: anti-blast & turtle / Inventory selection show up
2024.6.20 Added airdrop gun: Lynx (penetrates players & enemies) / Added airstrike: emergency cover & plane speeds adjusted / Consumable update: Added adrenaline & drink / Armor update: anti-blast & turtle / Inventory selection show up / Added Gun recoil effect


Future plan:
- Melee update: frisby / sakura (jett skill)
- vehicle-vehicle collision
- Military base: finish structures / add trees (object) in the dense forest

- Gun recoil effect
- SONA (shows location of enemy in the map & direction for 1 seconds)
- smarter AI (zombies shoots projectiles)
- wind update
Expand Down
9 changes: 8 additions & 1 deletion public/classes/Player.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class Player{
this.start_offset = 16
this.rotation_alpha = Math.PI/6
this.healthboost = healthboost
this.recoil = 0

}
drawPlayer(canvas, skin, xloc, yloc){
Expand Down Expand Up @@ -109,7 +110,13 @@ class Player{

if (currentHoldingItem.itemtype==='gun'){
const itemSize = currentHoldingItem.size
const itemlength = itemSize.length*2
const itemlength = itemSize.length*2 - this.recoil
if (this.recoil<0.05){
this.recoil =0
}else{
this.recoil -= this.recoil/10
}

const gunmainwidth = itemSize.width*2
let angle = Math.atan2(
(this.cursorPos.y) - this.canvasHeight/2,
Expand Down
4 changes: 2 additions & 2 deletions public/frontend.js
Original file line number Diff line number Diff line change
Expand Up @@ -540,13 +540,13 @@ function shootCheck(event,holding = false){
listen = false // block

socket.emit("shoot", {angle:getAngle(event),currentGun:currentGunName,currentHoldingItemId,holding})

if (!(currentHoldingItem.itemtype==='melee')){ // not malee, i.e. gun!
// decrease ammo here!!!!!
currentHoldingItem.ammo -= 1
//console.log(`${currentGunName} ammo: ${currentHoldingItem.ammo}`)
}

frontEndPlayer.recoil = 5
//console.log("fired")
fireTimeout = window.setTimeout(function(){ if (!frontEndPlayer) {clearTimeout(fireTimeout);return};clearTimeout(fireTimeout);listen = true},GUNFIRERATE)
//console.log("ready to fire")
Expand Down

0 comments on commit 0221a7a

Please sign in to comment.