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) {
collectables[0] = {
x: 600,
y: floorPos_y,
y: gameChar.possibleGroundPosY[0],
size: 75,
isFound: false,
};
@ -556,9 +556,12 @@ function drawCanyon(t_canyon) {
function drawCollectable(t_collectable) {
push();
// 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
t_collectable.y -= sin(frameCount*a)*b;
t_collectable.x += sin(frameCount*c)*d;
a = 0.1;
b = 3;
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);
fill(palette.coin_outer);
ellipse(t_collectable.x, t_collectable.y, 0.7 * t_collectable.size);
@ -567,8 +570,8 @@ function drawCollectable(t_collectable) {
fill(palette.coin_inner);
ellipse(t_collectable.x, t_collectable.y, 0.5 * t_collectable.size);
// restoring coin's coordinates to preserve game logic
t_collectable.y += sin(frameCount*a)*b;
t_collectable.x -= sin(frameCount*c)*d;
t_collectable.y += sin(frameCount * a) * b;
t_collectable.x -= sin(frameCount * c) * d;
pop();
}
function drawClouds() {
@ -577,7 +580,7 @@ function drawClouds() {
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
// TODO: fix jitter during movement (possibly by implementing vectorized movement)
translate(cameraPosX/1.1, 0);
translate(cameraPosX / 1.1, 0);
noStroke();
fill(palette.cloud0);
ellipse(
@ -613,7 +616,7 @@ function drawMountains() {
for (i = 0; i < mountains.length; i++) {
push();
// slowing down translation to add parallax, the feeling of depth
translate(cameraPosX/8, 0);
translate(cameraPosX / 8, 0);
noStroke();
fill(palette.mountain_shadow);
triangle(