OK it just works. See bellow.

Changed some stuff in levels.lua.
Added levels.c to .gitignore.
New player function `reset_old_pos`.
master
KikooDX 3 years ago
parent 2d39739cf4
commit 167d02da10
  1. 1
      .gitignore
  2. 4
      levels.lua
  3. BIN
      platform.g3a
  4. 13
      src/levels.c
  5. 12
      src/main.c
  6. 6
      src/player.c
  7. 1
      src/player.h

1
.gitignore vendored

@ -1 +1,2 @@
build*/**
src/levels.c

@ -17,8 +17,8 @@ levels = {[[
-0.........................-
-0.........................-
-0.........................-
-0........................00
-0........................0-
-0.......................000
-0.......................00-
-00000000000000000000000000-
----------------------------
]],

Binary file not shown.

@ -1,13 +0,0 @@
#include "levels.h"
#include <gint/std/string.h>
void set_level(int level_id, char *level) {
switch (level_id)
{
case 0:
memcpy(level, "-----------------------------00000000000000000000000000--0........................0--0........................0--0........................0--0........................0--0........................0--0........................0--0........................0--0........................00-0.........................--0.........................--0.........................--0........................00-0........................0--00000000000000000000000000-----------------------------", 476);
break;
case 1:
memcpy(level, "-----------------------------00000000000000000000000000--00000000000000000000000000--000000000000000000000000000-00000000000...............--0000000000................--0000000000....0000000000000-0000000000.....00000000000--00000000..........00000000-000000.............00000000--..........-.00000000000000--..........0000000000000000--.......0000000000000000000-000000000000000000000000000--00000000000000000000000000--00000000000000000000000000-----------------------------", 476);
break;
}
}

@ -114,21 +114,23 @@ int main(void)
player_y = start_y;
}
//borders collision
else if (player_x <= 2)
if (player_x <= 8)
{
level_id--;
player_x = 229;
level_id -= 1;
player_x = 201;
set_start_pos(&start_x, &start_y, player_x, player_y);
set_level(level_id, level);
draw_level(level);
reset_old_pos(&old_x, &old_y);
}
else if (player_x >= 222)
else if (player_x >= 208)
{
level_id++;
level_id += 1;
player_x = 9;
set_start_pos(&start_x, &start_y, player_x, player_y);
set_level(level_id, level);
draw_level(level);
reset_old_pos(&old_x, &old_y);
}
//exit
if (keydown(KEY_EXIT)) return 0;

@ -22,3 +22,9 @@ void set_start_pos(int *start_x, int *start_y, int x, int y)
*start_x = x;
*start_y = y;
}
void reset_old_pos(int *old_x, int *old_y)
{
*old_x = -8;
*old_y = -8;
}

@ -1,2 +1,3 @@
void jump_test(char *jump_pressed, char *jump_buffer, unsigned int *jump_hold);
void set_start_pos(int *start_x, int *start_y, int x, int y);
void reset_old_pos(int *old_x, int *old_y);

Loading…
Cancel
Save