bugfixes, formatted code

This commit is contained in:
Mottributo 2023-03-23 16:46:18 +03:00
parent a813bbb804
commit f460141ff0

View File

@ -165,7 +165,7 @@ function startGame(full_start, update_objects) {
if (i == 0) { if (i == 0) {
collectables[0] = { collectables[0] = {
x: 600, x: 600,
y: floorPos_y, y: gameChar.possibleGroundPosY[0],
size: 75, size: 75,
isFound: false, isFound: false,
}; };
@ -556,9 +556,12 @@ function drawCanyon(t_canyon) {
function drawCollectable(t_collectable) { function drawCollectable(t_collectable) {
push(); push();
// animating the coin's jiggle // animating the coin's jiggle
a = 0.1; b = 3; c = 0.2; d = 2; // a - vert. intensity, c - hor. intensity, b - vert. speed, d - hor. speed a = 0.1;
t_collectable.y -= sin(frameCount*a)*b; b = 3;
t_collectable.x += sin(frameCount*c)*d; c = 0.2;
d = 2; // a - vert. intensity, c - hor. intensity, b - vert. speed, d - hor. speed
t_collectable.y -= sin(frameCount * a) * b;
t_collectable.x += sin(frameCount * c) * d;
stroke(0.2); stroke(0.2);
fill(palette.coin_outer); fill(palette.coin_outer);
ellipse(t_collectable.x, t_collectable.y, 0.7 * t_collectable.size); ellipse(t_collectable.x, t_collectable.y, 0.7 * t_collectable.size);
@ -567,8 +570,8 @@ function drawCollectable(t_collectable) {
fill(palette.coin_inner); fill(palette.coin_inner);
ellipse(t_collectable.x, t_collectable.y, 0.5 * t_collectable.size); ellipse(t_collectable.x, t_collectable.y, 0.5 * t_collectable.size);
// restoring coin's coordinates to preserve game logic // restoring coin's coordinates to preserve game logic
t_collectable.y += sin(frameCount*a)*b; t_collectable.y += sin(frameCount * a) * b;
t_collectable.x -= sin(frameCount*c)*d; t_collectable.x -= sin(frameCount * c) * d;
pop(); pop();
} }
function drawClouds() { function drawClouds() {
@ -577,7 +580,7 @@ function drawClouds() {
translate((frameCount / clouds[i].y) * 20, 0); // imitating clouds movement, upper ones should go faster translate((frameCount / clouds[i].y) * 20, 0); // imitating clouds movement, upper ones should go faster
// Adding counter-translating to implement parallax, the feeling of depth // Adding counter-translating to implement parallax, the feeling of depth
// TODO: fix jitter during movement (possibly by implementing vectorized movement) // TODO: fix jitter during movement (possibly by implementing vectorized movement)
translate(cameraPosX/1.1, 0); translate(cameraPosX / 1.1, 0);
noStroke(); noStroke();
fill(palette.cloud0); fill(palette.cloud0);
ellipse( ellipse(
@ -613,7 +616,7 @@ function drawMountains() {
for (i = 0; i < mountains.length; i++) { for (i = 0; i < mountains.length; i++) {
push(); push();
// slowing down translation to add parallax, the feeling of depth // slowing down translation to add parallax, the feeling of depth
translate(cameraPosX/8, 0); translate(cameraPosX / 8, 0);
noStroke(); noStroke();
fill(palette.mountain_shadow); fill(palette.mountain_shadow);
triangle( triangle(