| Kovs95 (52) | |||
|
Hi! I'm creating a dungeon crawler game. I created a 2d array called grid[7][10]. I want the player to start at the top left corner so I declared two variables "x" and "y" and made those variables equal to 0. Then I said grid[x][y] = player, which starts the player at the top left hand corner. I already made bounderies for the game board, but I am having trouble changing the players position. For example, if the user says "down", I want the player's position to be grid[x][y +1] = player, or if the user says "right", it should be grid[x + 1][y]. I think this is the right way to code the changing of position. My problem is that it highlights the grid[x][y] under each "if" statement. I bolded these parts below to show the parts im referring to. The compiler says "error C2109: subscript requires array or pointer type"? I thought I declared the array properly at the top of the code. Can somebody please help? Thanks The "up" "if" statement has a different structure than the other "if" statements. I said that if the player is here, here, or here, "do this", else "the move is valid". That's my thinking behind the validity of moves. I am in the middle of writing this program so I hope this isn't confusing. Some of the code might not be uniform throughout because I am trying different methods.
| |||
|
|
|||
| cire (2362) | |
| On line 48 you declare a function called grid that takes no arguments and returns nothing. That function name hides the array name. Remove it. | |
|
|
|
| Kovs95 (52) | |
| Thanks! I forgot to delete that! My grid keeps appearing as a straight line like "................................." and I need it to be in a square. It was working earlier. I need my rows basically going down | |
|
|
|