Tell me more ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Now I've built games in xna so I think I'll be ok with the framework mono touch, but I've only ever worked on really simple games in xna so I need to ask a few questions that will help me get started:

If I want to build a world thats bigger than my screen and when the character moves, keep him in the center of the screen but have him move towards the destination that was touched (move the world not the character ?!). Then when world space runs out allow the character to move from the centre on that axis - how would this be implemented? Is there an algorithm or does this have a name so I can look into it?

I want to get started on a simple a* path finding solution, does anyone have any ideas how this would be tied into the question above.

Cheers

share|improve this question
2  
Both of your questions have been answered before separately. A* pathfinding and movement can be developed independently. Search keep player centered and a* pathfinding – Byte56 Aug 13 '12 at 22:42
1  
OK well, I followed up on my own comment and looked through the links for keeping the character centered. They're not great. However, it's simple, essentially, you make a camera that follow the character. Like this, or this, or this – Byte56 Aug 13 '12 at 23:02
Thanks for taking the time to find those posts. The thing is I'm not sure how I link them both together, do I just setup the camera to follow the character, then move the character using a* ? – Lewis Aug 13 '12 at 23:33
1  
A* is only used for finding the path, moving the character is entirely different. That's why I said they can be developed independently. The link between them is simply a list of positions. A* will output a list of positions (a path) and your movement algorithm will take a list of positions and move your character. – Byte56 Aug 14 '12 at 0:01
1  
There should be nothing stopping you from linking the two together. You should be tracking character location in terms of a "world location", not the "screen location" of the character. Therefore, the A* manipulates the character's world location, and the camera-tracking just changes the view on the screen. – Jimmy Aug 14 '12 at 1:38
show 2 more comments

closed as not a real question by Tetrad Feb 28 at 20:23

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, see the FAQ.

1 Answer

FOr simplicity, consider basic case of only orthogonal movement: Up, Down, Left, Right. Then whenever character moves one step, the background should move one step the other direction to keep the character centred. Try implementing properties like this:

public int PlayerX {
  get { return playerX; }
  set { backgroundX += (playerX-value); playerX = BoundaryCheck(value,playerY).X; }
} int playerX;
public int PlayerY {
  get { return playerY; }
  set { backgroundY += (playerY-value); playerY = BoundaryCheck(playerX,value).Y; }
} int playerY;

public Point PlayerPosition { get { return new Point(playerX,playerY); } }

public int MapX {
  get ( return mapX; }
  set { mapX = Math.Max(0, Math.Min(MapWidth-1, value)); }
} int mapX;
public int MapY {
  get ( return mapY; }
  set { mapY = Math.Max(0, Math.Min(MapHeight-1, value)); }
} int mapY;

If you are taking advantage of an auto-scrolling control, your backing fields for the map will be the AutoScroll instead of mapX and mapY.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.