try to make the camera scrolling better

Signed-off-by: Christine Dodrill <me@christine.website>
This commit is contained in:
Cadey Ratio 2022-07-02 14:32:24 -04:00
parent d8ec754e37
commit 6c4e039b85
2 changed files with 11 additions and 33 deletions

View File

@ -179,49 +179,27 @@ fn move_mara(gamepad: w4.GamePad) void {
if (mara_speed > 0) {
mara_speed -= 1;
}
if (gamepad.up) {
mara_direction = Direction.Up;
mara_speed = 1;
camera.y -= mara_speed;
mara_box.base.y -= mara_speed;
} else if (gamepad.down) {
mara_direction = Direction.Down;
mara_speed = 1;
camera.y += mara_speed;
mara_box.base.y += mara_speed;
} else if (gamepad.left) {
mara_direction = Direction.Left;
mara_speed = 1;
camera.x -= mara_speed;
mara_box.base.x -= mara_speed;
} else if (gamepad.right) {
mara_direction = Direction.Right;
mara_speed = 1;
}
switch (mara_direction) {
.Up => {
if (camera.y == 0 or camera.y == (map.width * tile_size) - (20 * tile_size)) {
mara_box.base.y -= mara_speed;
} else {
camera.y -= mara_speed;
}
},
.Down => {
if (camera.y == 0 or camera.y == (map.width * tile_size) - (20 * tile_size)) {
mara_box.base.y += mara_speed;
} else {
camera.y += mara_speed;
}
},
.Left => {
if (camera.x == 0 or camera.x == (map.width * tile_size) - (20 * tile_size)) {
mara_box.base.x -= mara_speed;
} else {
camera.x -= mara_speed;
}
},
.Right => {
if (camera.x == 0 or camera.x == (map.width * tile_size) - (20 * tile_size)) {
mara_box.base.x += mara_speed;
} else {
camera.x += mara_speed;
}
},
mara_box.base.x += mara_speed;
}
}

View File

@ -176,8 +176,8 @@ pub fn update(gamepad: w4.GamePad) void {
frame();
w4.m.colors._0 = .p3;
w4.m.colors._1 = .p0;
w4.text(curr_text[0..text_index], 8, 136);
w4.m.colors._1 = .transparent;
w4.text(curr_text[0..text_index], 6, 132);
if (gamepad.a) {
w4.trace("dismissing");