-
Notifications
You must be signed in to change notification settings - Fork 0
/
oldAnimation.js
108 lines (100 loc) · 3.59 KB
/
oldAnimation.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
// const widthSprite = 0;
// const heightSprite = 0;
// const frameWidthSprite = 32;
// const frameHeightSprite = 48;
// const xPosSprite =256;
// const yPosSprite = 128;
// const scaleSprite = 2;
// const fpsSprite = 10;
// const secondsToUpdateSprite = 1 * fpsSprite;
// let frameIndexSprite = 0;
// let countSprite = 0;
// let row = 0;
// --------------------- Image spritesheets ----------------------------------
// const Sprite = new Image();
// Sprite.src = "images/char.png";
// --------------------- State object Pet 1----------------------------------
// const StateSprite = {
// statesSprite: {},
// generateStatesSprite: function(nameSprite, startRow, startIndexSprite, endIndexSprite){
// if (!this.statesSprite[nameSprite]) {
// this.statesSprite[nameSprite] = {
// frameIndexSprite: startIndexSprite,
// row: startRow,
// startIndexSprite: startIndexSprite,
// endIndexSprite: endIndexSprite
// };
// }
// },
// getStateSprite: function(nameSprite){
// if (this.statesSprite[nameSprite]){
// return this.statesSprite[nameSprite];
// }
// }
// };
// ------------individual state generating for pet 1 --------------
// StateSprite.generateStatesSprite("idleDown", 0, 0, 3);
// StateSprite.generateStatesSprite("idleLeft", 1, 0, 3);
// StateSprite.generateStatesSprite("idleRight", 2, 0, 3);
// StateSprite.generateStatesSprite("idleUp", 3, 0, 3);
// --------------------- Animation Function - Pet 1 ----------------------------------
// function animateSprite(statesSprite){
// c.drawImage(gameMap, -500 , -500);
// c.drawImage(
// Sprite,
// statesSprite.frameIndexSprite * frameWidthSprite,
// statesSprite.row * frameHeightSprite,
// frameWidthSprite,
// frameHeightSprite,
// xPosSprite,
// yPosSprite,
// frameWidthSprite * scaleSprite,
// frameHeightSprite * scaleSprite,
// );
// countSprite++;
// if (countSprite > secondsToUpdateSprite) {
// statesSprite.frameIndexSprite++;
// countSprite = 0;
// }
// if (statesSprite.frameIndexSprite > statesSprite.endIndexSprite){
// statesSprite.frameIndexSprite = statesSprite.startIndexSprite;
// }
// }
// --------------------- Idle state Loop - Pet 1 ----------------------------------
// function down() {
// c.clearRect(0,0,widthSprite,heightSprite);
// animateSprite(StateSprite.getStateSprite("idleDown"));
// requestAnimationFrame(down);
// };
// // --------------------- Sit state Loop - Pet 1 ----------------------------------
// function wLeft() {
// c.clearRect(0, 0,widthSprite,heightSprite);
// animateSprite(StateSprite.getStateSprite("walkLeft"));
// requestAnimationFrame(wLeft);
// };
// // --------------------- Sit state Loop - Pet 1 ----------------------------------
// function wRight() {
// c.clearRect(0,0,widthSprite,heightSprite);
// animateSprite(StateSprite.getStateSprite("walkRight"));
// requestAnimationFrame(wRight);
// };
// onload functionality
// gameMap.onload = () => {
// // c.drawImage(gameMap, -500 , -500);
// down();
// }
// --------------------- calling the ALL animaion functions ----------------------------------
// down();
// wLeft();
// wRight();
// sitSprite();
// sitPet2();
// sitPet3();
// lieDownSprite();
// lieDownPet2();
// lieDownPet3();
// const playAgain = document.getElementById("playAgain");
// playAgain.style.display = "none";
// playAgain.addEventListener('click', () => {
// window.location.reload()
// });