turns out eating wasnt working right. it does now! only for dur 4
This commit is contained in:
parent
8a6aa8beab
commit
d372e109fa
|
@ -131,8 +131,12 @@ const hatConfig = {
|
|||
cap: { x: 3.5, y: -13 },
|
||||
top_hat: { x: 2, y: -20 },
|
||||
center_box_full: { x: 0, y: 0 },
|
||||
center_box_hollow: { x: 0, y: 0 },
|
||||
// Add more hats with their specific offsets here
|
||||
center_box_hollow: { x: 0, y: 0 }
|
||||
};
|
||||
|
||||
const foodConfig = {
|
||||
apple: { sizeMult: 3.5, n: 4 },
|
||||
nothing: { sizeMult: 2, n: 5 },
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -66,12 +66,14 @@ class Larry extends BaseShape {
|
|||
|
||||
this.bodyImage = new Image();
|
||||
this.headImage = new Image();
|
||||
this.foodImage = new Image();
|
||||
this.hatImage = new Image();
|
||||
this.shellImage = new Image();
|
||||
this.backgroundImage = new Image();
|
||||
|
||||
this.bodyImage.src = 'larry_photos/body.png';
|
||||
this.headImage.src = 'larry_photos/head.png';
|
||||
this.foodImage.src = 'larry_photos/';
|
||||
this.hatImage.src = '';
|
||||
this.shellImage.src = '';
|
||||
this.backgroundImage.src = '';
|
||||
|
@ -103,14 +105,22 @@ class Larry extends BaseShape {
|
|||
const headX = bodyX + (53.5 * this.magnitude - this.headWidth * this.magnitude / 2);
|
||||
let headY = bodyY + (this.bodyHeight * this.magnitude - 7 * this.magnitude) - this.headHeight * this.magnitude;
|
||||
|
||||
//eating
|
||||
if (timestamp < this.eatEndTimestamp) {
|
||||
console.log("eating")
|
||||
const adjustedTimestamp = timestamp -this.eatEndTimestamp + parseInt(this.eatDuration)/(1000/60);
|
||||
console.log(adjustedTimestamp)
|
||||
const adjustedTimestamp = this.eatEndTimestamp - timestamp + parseInt(this.eatDuration) / (1000 / 60);
|
||||
|
||||
const eatMaxHeight = 20;
|
||||
// const eatingYOffset = ((Math.cos((adjustedTimestamp -Math.PI/2+ 0.5 * Math.PI) * (this.eatSpeed/100)*0.1 - Math.PI / 2) + 1) / 2) * eatMaxHeight;
|
||||
const eatingYOffset = ((Math.sin((adjustedTimestamp * 2 * Math.PI * this.eatSpeed / 100 * 0.1) - Math.PI / 2) + 1) / 2) * eatMaxHeight;
|
||||
headY -= eatingYOffset;
|
||||
const n = this.eatDuration
|
||||
console.log(adjustedTimestamp)
|
||||
console.log((-adjustedTimestamp + 10 * n) / 10)
|
||||
console.log(Math.floor((-adjustedTimestamp + (10/(this.eatSpeed/100)) * n) / (10/(this.eatSpeed/100))))
|
||||
const frame = Math.floor((-adjustedTimestamp + (10/(this.eatSpeed/100)) * n) / (10/(this.eatSpeed/100)))
|
||||
this.foodImage.src = "larry_photos/foods/" + document.getElementById('elselectedFood').value+ frame + ".png";
|
||||
ctx.drawImage(this.foodImage, centerX, centerY,200,226.5)
|
||||
}
|
||||
ctx.drawImage(this.headImage, headX, headY, this.headWidth * this.magnitude, this.headHeight * this.magnitude);
|
||||
|
||||
|
@ -141,8 +151,9 @@ class Larry extends BaseShape {
|
|||
|
||||
startEating() {
|
||||
console.log("Larry starts eating");
|
||||
this.foodImage.src = document.getElementById('elselectedFood').value
|
||||
this.isEating = true;
|
||||
this.eatEndTimestamp = this.lastTimestamp + (parseInt(this.eatDuration)/3)*1000/(1000/60);
|
||||
this.eatEndTimestamp = this.lastTimestamp + (parseInt(this.eatDuration)/(6*(this.eatSpeed/100))) * 1000 / (1000 / 60);
|
||||
console.log(this.eatEndTimestamp)
|
||||
// setTimeout(() => {
|
||||
// this.isEating = false;
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 666 KiB |
Binary file not shown.
After Width: | Height: | Size: 641 KiB |
Binary file not shown.
After Width: | Height: | Size: 467 KiB |
Binary file not shown.
After Width: | Height: | Size: 339 KiB |
Loading…
Reference in New Issue