summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLogan Hunt <loganthebean222@gmail.com>2020-08-13 12:24:02 -0600
committerLogan Hunt <loganthebean222@gmail.com>2020-08-13 12:24:02 -0600
commit3020917b0b1b03acb52cf9c26a45132c73715de3 (patch)
tree78eeb7aff02bea3346dbb85e54c24a79620baeb0
parent4c5b382ef964ccc46f9c26221be237cf54da7576 (diff)
downloadgeometry-dash-gba-3020917b0b1b03acb52cf9c26a45132c73715de3.tar.gz
geometry-dash-gba-3020917b0b1b03acb52cf9c26a45132c73715de3.zip
Added camera, working on ground level
-rw-r--r--source/main.c18
-rw-r--r--source/map.c2
2 files changed, 15 insertions, 5 deletions
diff --git a/source/main.c b/source/main.c
index 589db1a..5842b60 100644
--- a/source/main.c
+++ b/source/main.c
@@ -28,17 +28,24 @@ int main() {
REG_DISPCNT= DCNT_OBJ | DCNT_OBJ_1D;
playerObject player = createPlayerObject(&obj_buffer[0], &obj_aff_buffer[0],0, 0);
- player.camera = createCamera(10, 0);
+ player.camera = createCamera(-10, 0);
+ int currentGroundLevel = 140;
+ int currentXLevel = 1;
while(1) {
vid_vsync();
+ player.camera.x += 1;
key_poll();
+ if (player.camera.x % 16 == 15) {
+ currentXLevel++;
+ }
+
if ((key_is_down(KEY_A) || key_hit(KEY_A)) && !player.isJumping) {
player.vel.dy -= 9 << FIX_SHIFT;
}
- updatePlayer(&player, 80);
+ //updatePlayer(&player, 80);
obj_affine_copy(obj_aff_mem, player.affine, 1);
obj_copy(obj_mem, player.obj, 1);
@@ -60,12 +67,15 @@ int main() {
y = (i * 16);
applyCameraShift(&player.camera, &x, &y);
if (map1[i][j] == 1) {
+ if (j == currentXLevel) {
+ updatePlayer(&player, 16 * i - 16);
+ }
obj_set_pos(&blockObject, x, y);
- obj_copy(obj_mem + (17 * i + j) + 1, &blockObject, 1);
+ obj_copy(obj_mem + (16 * i + j) + 1, &blockObject, 1);
}
else if (map1[i][j] == 2) {
obj_set_pos(&spikeObject, x, y);
- obj_copy(obj_mem + (17 * i + j) + 1, &spikeObject, 1);
+ obj_copy(obj_mem + (16 * i + j) + 1, &spikeObject, 1);
}
}
}
diff --git a/source/map.c b/source/map.c
index 88bf41c..fd08e39 100644
--- a/source/map.c
+++ b/source/map.c
@@ -8,5 +8,5 @@ const int map1[9][20] = {
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
- {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
+ {1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
};