I need some help making an ascii movement system.

I'm trying to make a movement system where the @ is the player and I want to find a way to do it without making a separate if statement for each possibility. Does anyone know any way that this could be possible? I'm using repl.it for now just because I have a ton of more access to my Chromebook and I can test on the spot (if anyone knows any better alternatives for Chromebook I would greatly appreciate it). But any help would be extremely helpful.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
 #include <iostream>
#include <string>

using namespace std;

int main() {
  string input;
  int xPos = 1;
  int yPos = 1;
  getline(cin, input);
  cout << input ;
  if (input == "up") {
    yPos = yPos + 1;
  }
  else if (input == "down") {
    yPos = yPos - 1;
  }
  else if (input == "left") {
    xPos-=1 ;
  }
  cout << "" << endl;
  cout << yPos << endl;
  cout << xPos << endl;
  
  cout << "□□□□□ \n □□□□□ \n □□@□□ \n □□□□□ \n □□□□□" <<endl;
}
Topic archived. No new replies allowed.