Skip to content

Commit

Permalink
Merge pull request #26 from Kyando2/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
xxxAnn authored Apr 12, 2022
2 parents fd6e070 + 25895ff commit c9ec94b
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 53 deletions.
Binary file modified CLIENT/.DS_Store
Binary file not shown.
14 changes: 1 addition & 13 deletions CLIENT/js/classes/bird.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class Bird {
this.dashing.orgpos.rot = this.rotatation
this.dashing.dir = dir
this.dashing.dive = dive
this.movingToCenter.t = false
if ((this.x<0.1*sctx.canvas.clientWidth && dir == -1) || (this.x > 0.9*sctx.canvas.clientWidth && dir == 1)) {
this.dashing.t = false
} else {
Expand Down Expand Up @@ -196,19 +197,6 @@ class Bird {
if (this.immune) return false
let bird = this.animations[0].sprite
let r = bird.height/4 +bird.width/4

// pipe.pipes.every((e,i) => {
// if (e.x <= this.x+r && e.x+pipe.w >= this.x - r) {
// x = e.x
// y = e.y
// return false
// } else if (e.x >= this.x-r) {
// x = e.x
// y = e.y
// return false
// }
// return true
// })
var x, y, g
if (state.gameStage == games.fireball.id) {
var HIT = false
Expand Down
1 change: 1 addition & 0 deletions CLIENT/js/classes/pipe.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class PipeSet {
}

if (this.end && this.pipes.length==0) {
bird.movingToCenter.t = false
state.gameStage = 1
}

Expand Down
40 changes: 24 additions & 16 deletions CLIENT/js/classes/setting.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,21 +115,30 @@ class Setting {
sctx.drawImage(this.cog, -this.gearPos.w/2, -this.gearPos.h/2, this.gearPos.w, this.gearPos.h)
sctx.imageSmoothingEnabled = false;
sctx.rotate(-RAD * this.rotation)
sctx.translate(-this.gearPos.x-this.cog.width * i, -this.gearPos.y - this.cog.height * i)
sctx.translate(-this.gearPos.x-this.cog.width * i, -this.gearPos.y - this.cog.height * i)
}
openSettings(sctx, scrn, sfx) {
sctx.beginPath()
sctx.roundRect(this.menuPos.x, this.menuPos.y, this.menuPos.w, this.menuPos.h, [this.menuPos.radius])
sctx.fillStyle = "grey"
sctx.fill()
if (this.menuPos.current > 0) {
this.menuPos.h = easeInOut(this.menuPos.current/MENU_OPEN_LENGTH)*this.menuPos.w
this.menuPos.current--

this.menuPos.y = (scrn.height-this.menuPos.h)/2
if (this.PAGEON) {
if (this.menuPos.current > 0) {
this.menuPos.h = easeInOut(this.menuPos.current/MENU_OPEN_LENGTH)*this.menuPos.w
this.menuPos.current--

this.menuPos.y = (scrn.height-this.menuPos.h)/2
return
}
this.drawButtons(sctx, sfx)
return
}
this.drawButtons(sctx, sfx)
// else :
this.menuPos.w = easeInOut(this.menuPos.current/MENU_OPEN_LENGTH)*this.menuPos.h
this.menuPos.current++

this.menuPos.x = (scrn.width-this.menuPos.w)/2
return
}
checkButtonHover(mousePos, buttonPos, hoveringState) {
if (mousePos.x < buttonPos.x) return false
Expand Down Expand Up @@ -168,18 +177,17 @@ class Setting {
}

function easeInOut(t) {
const x0 = 0
const x0 = 1
const y0 = 1
const x1 = 0.4
const y1 = 1
const x2 = 0.6
const y2 = 0
const x3 = 1
const x1 = 1
const y1 = 0
const x2 = 0
const y2 = 1
const x3 = 0
const y3 = 0
const i = {
x: (1-t)*((1-t)*((1-t)*x0+t*x1)+t*((1-t)*x1+t*x2))+t*((1-t)*((1-t)*x1+t*x2)+t*((1-t)*x2+t*x3)),
y: (1-t)*((1-t)*((1-t)*y0+t*y1)+t*((1-t)*y1+t*y2))+t*((1-t)*((1-t)*y1+t*y2)+t*((1-t)*y2+t*y3))
}
return i.y
};

return i.x
};
4 changes: 2 additions & 2 deletions CLIENT/js/utils/consts.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const BIRD_DEFAULTS = {
const DASHLENGTH = 5
const DASHDISTANCE = 100
const MAXDASH = 1.5
const DEFAULT_DASH_CD = 30
const DEFAULT_DASH_CD = 20

const PIPE_APPEARANCE_SPEED = 1/150 // (0-1), preferably <0.05, game starts breaking at ~0.03
const PIPE_DEFAULT_MOVESPEED = 1.5
Expand Down Expand Up @@ -81,6 +81,6 @@ const SOUND_VOLUME = 0.2

const MENU_OPEN_LENGTH = 20

const LINEWIDTH = 3
const LINEWIDTH = 5

let mousePos
28 changes: 6 additions & 22 deletions CLIENT/js/utils/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ function init() {


document.onmousemove = (e) => {
if (state.curr !== state.getReady) return
const rect = scrn.getBoundingClientRect()
mousePos = {x:e.x-rect.x, y:e.y-rect.y}
const hover = sett.handleMouseMove(mousePos, scrn)
Expand All @@ -90,7 +91,7 @@ function init() {
if (hover) {
scrn.style.cursor = 'pointer'
} else {
scrn.style.cursor = 'default'
scrn.style.cursor = 'auto'
}
}
document.onclick = () => {
Expand All @@ -99,6 +100,7 @@ function init() {
}
}
document.onmouseup = () => {
if (!sett.moving) return
sett.moving = false
scrn.style.cursor = 'auto'
}
Expand Down Expand Up @@ -193,11 +195,12 @@ function draw(scrn, sctx, sfx, bg, games, bird, gnd, ui, state, sett) {
gnd.draw(sctx, scrn)
sfx.drawSong(scrn, sctx)
ui.draw(state, sctx, scrn)
if (sett.PAGEON===true) {
if (sett.menuPos.current !== MENU_OPEN_LENGTH || sett.PAGEON) {
sett.openSettings(sctx, scrn, sfx)
} else {
sett.menuPos.w = scrn.width * 0.8
sett.menuPos.h = 0
sett.menuPos.current = MENU_OPEN_LENGTH
sett.menuPos.x = (scrn.width-sett.menuPos.w)/2
}
if (state.curr == state.Play) {
let r = 35
Expand All @@ -207,19 +210,6 @@ function draw(scrn, sctx, sfx, bg, games, bird, gnd, ui, state, sett) {
sctx.save()

sctx.translate(sctx.canvas.clientWidth/2, sctx.canvas.clientHeight-ydelta)
// sctx.beginPath()
// sctx.arc(p, p, r+5, 0, Math.PI * 2, true)
// sctx.closePath()
// sctx.fillStyle = "black"
// sctx.fill()

// sctx.beginPath()
// sctx.arc(p, p, r, 0, Math.PI * 2, true)
// sctx.closePath()
// sctx.fillStyle = "white"
// sctx.fill()



if (!bird.dashing.t && !(0==Math.max(bird.dashing.CD, 0))) {
sctx.beginPath()
Expand All @@ -236,9 +226,6 @@ function draw(scrn, sctx, sfx, bg, games, bird, gnd, ui, state, sett) {
sctx.arc(p, p, r, -Math.PI/2, ((Math.PI * 2) * ((DEFAULT_DASH_CD-Math.max(bird.dashing.CD, 0)))/DEFAULT_DASH_CD)-Math.PI/2)
sctx.stroke()
sctx.closePath()
// sctx.globalAlpha = 0.25
// sctx.fillStyle = "grey"
// sctx.fill()
} else {
sctx.beginPath()
sctx.lineWidth = LINEWIDTH
Expand All @@ -248,9 +235,6 @@ function draw(scrn, sctx, sfx, bg, games, bird, gnd, ui, state, sett) {
sctx.fill()
sctx.stroke()
sctx.closePath()
// sctx.globalAlpha = 0.25
// sctx.fillStyle = "grey"
// sctx.fill()
}
sctx.drawImage(DASHSPRITE, -s/2, -s/2, s, s)

Expand Down

0 comments on commit c9ec94b

Please sign in to comment.