Hello guys, i would like to ask you about c++ language. i have an assignment and i want to do a movement for the hero?
i have an assignment and i want to do a movement for the hero which will be controled by the keyboard.i apologise because my english isn't very well
the map is similar to this:
|------|------|------|
| h
|------|------|------|
h = the hero, d= move right , a= move left ,if the user enter 'd' so i want the hero to move to next room and when the user press 'd' again so the hero should move to the last room , i tried many times just know but i couldn't do it
i tried to do this soultotion
1- i use a lot of functions to do the movement for the hero but my problem is i put every room for each of functions
for example if the user key 'a' so the hero will be in the left room, but if he key 'd' to go back to the middle , the hero will move to the right room because i put the function called 'hero_right' and the position of the hero is alaways right
thats why i put another key (control by keboards) called 'm' for the middle position
a = left room
d = right room
m = middle room
but my solution not very well because i want the hero to move freely
waiting for you