A Flash Developer Resource Site

+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Senior Member
    Join Date
    Aug 2000
    Posts
    104
    Hi there,

    I'm at the moment building a game where the characters need to follow the main character if he enters there space.

    Is it possible in flash and if so does anyone know of any tutorials or articles about it..or samples

    cheers, stu

  2. #2
    Senior Member catbert303's Avatar
    Join Date
    Aug 2001
    Location
    uk
    Posts
    11,222
    I think the best way to do this is using a tile based game world, to do this you can create a 2D array to represent the playing area as a grid. A little like this

    grid = new Array();
    grid[0] = [0, 0, 0, 0, 0, 0, 0, 0];
    grid[1] = [0, 1, 1, 1, 1, 1, 1, 0];
    grid[2] = [0, 1, 1, 1, 1, 1, 1, 0];
    grid[3] = [0, 0, 0, 0, 0, 0, 0, 0];

    where 0's represent walls and 1's represent walkable tiles. You can then base your characters movement on the position in the array. eg if the character is positioned at grid[1][1] to move down you could do grid[1 + 1][1]. You can define areas of the grid that are patrolled by the enemy and if the player goes in one of these the enemy can calculate which direction he needs to move to follow the player (assuming he can move in that direction, i.e. no wall blocks the path) I'm sure there has been plenty of stuff written about this type of game over on the games forum http://board.flashkit.com/board/foru....php?forumid=5

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts




Click Here to Expand Forum to Full Width


HTML5 Development Center