mirror of
https://github.com/dylanbenzi/terminaltrainers.git
synced 2026-11-27 07:47:01 +00:00
add basic character movement
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 45 KiB |
@@ -5,13 +5,15 @@ using namespace std;
|
||||
|
||||
int main() {
|
||||
terminal_open();
|
||||
terminal_set("window: size=40x20, title='Terminal Trainers'");
|
||||
terminal_set("window: size=225x65, title='Terminal Trainers'");
|
||||
|
||||
int x = 10;
|
||||
int y = 10;
|
||||
|
||||
int mapHeight = 20;
|
||||
int mapLength = 40;
|
||||
|
||||
int x = 20;
|
||||
int y = 20;
|
||||
|
||||
int mapHeight = 100;
|
||||
int mapLength = 100;
|
||||
int mapSize = mapHeight * mapLength;
|
||||
|
||||
char map[mapSize + mapHeight];
|
||||
@@ -39,21 +41,44 @@ int main() {
|
||||
|
||||
|
||||
bool running = true;
|
||||
|
||||
while (running) {
|
||||
terminal_clear();
|
||||
|
||||
terminal_print_ext(0, 0, 40, 20, TK_ALIGN_LEFT, map);
|
||||
terminal_put(x, y, 0x20AC);
|
||||
|
||||
terminal_refresh();
|
||||
|
||||
terminal_set("0xE000: characters.png, size=16x16, spacing=0x0, resize=32x32, transparent=#EBEBEB");
|
||||
|
||||
terminal_put(x, y, 0xE001);
|
||||
|
||||
while (running) {
|
||||
terminal_refresh();
|
||||
terminal_clear();
|
||||
|
||||
|
||||
//terminal_print_ext(0, 0, mapLength, mapHeight, TK_ALIGN_LEFT, map);
|
||||
// terminal_put(x, y, 0x20AC);
|
||||
|
||||
//terminal_put(x, y, 0xE000);
|
||||
|
||||
int key = terminal_read();
|
||||
if (key == TK_ESCAPE) running = false;
|
||||
else if (key == TK_UP || key == TK_W) y--;
|
||||
else if (key == TK_DOWN || key == TK_S) y++;
|
||||
else if (key == TK_LEFT || key == TK_A) x--;
|
||||
else if (key == TK_RIGHT || key == TK_D) x++;
|
||||
if (key == TK_ESCAPE) {
|
||||
running = false;
|
||||
}else if (key == TK_UP || key == TK_W) {
|
||||
y--;
|
||||
|
||||
terminal_put(x, y, 0xE001);
|
||||
terminal_refresh();
|
||||
}else if (key == TK_DOWN || key == TK_S) {
|
||||
y++;
|
||||
|
||||
terminal_put(x, y, 0xE000);
|
||||
terminal_refresh();
|
||||
}else if (key == TK_LEFT || key == TK_A) {
|
||||
x--;
|
||||
|
||||
terminal_put(x, y, 0xE002);
|
||||
}else if (key == TK_RIGHT || key == TK_D) {
|
||||
x++;
|
||||
|
||||
terminal_put(x, y, 0xE002);
|
||||
}
|
||||
}
|
||||
|
||||
terminal_close();
|
||||
|
||||
Reference in New Issue
Block a user