Page 2 of 2 FirstFirst 12
Results 11 to 13 of 13

Thread: Jedi-SDL / Recognizing Tiles

  1. #11

    Jedi-SDL / Recognizing Tiles

    a T-turn is really simple.
    Basically, you can test to see if both left and right options are available to you and use some algorithm to choose between them.

    Code:
    if( testTileIsObstacle( currentAngle, currentspeed ) = false )
    begin
    
    end
    else
    begin
    
    
    left := testTileIsObstacle( currentAngle - 90, currentspeed );
    right := testTileIsObstacle( currentAngle + 90, currentspeed );
    
    if (left and right) then
    begin
       if (random(10)>5) then
       begin
          direction :=-90;
       end
       else
       begin
          direction := 90;
       end;
    end;
    if (left) then
    begin 
       direction := -90;
    end;
    if (right) then
    begin
       direction := -90;
    end;
    if(left=false and right=false) then
    begin
       direction := 180;
    end;
    end;
    something along those lines might help..
    Or, if you don't want random, you can always have some controlling variable which alternates between left and right so one unit goes left the next goes right in the event of a T-Junction

    This sort of logic is what Pac Man used. Only pacman included the player's location in relation to the monster to make them chase or run away.

  2. #12

    Jedi-SDL / Recognizing Tiles

    Well, my goal is hopefully to make it so they choose the route they are most likely to survive in. I'm mostly experimenting with this game, so the more I can put in like that, the better off I will be. I'm using this game as a learning experience..

    On another note, I think you guys have given me enough info for me to 'formulate' my own method of doing this, which was what I was trying to do all along All I needed was some example code

    Thanks JasonF and arthurprs! If I need anymore help, I'll just post again...
    --MagicRPG--

  3. #13

    Jedi-SDL / Recognizing Tiles

    Quote Originally Posted by DarknessX
    Yes, thats good, but what happens when the road becomes a T-turn, and the person has 2 methods to go? that would make your method extremely complex, because it would add another entire dimension to it.
    Just add "Troad" to TITLEdirection ?
    From brazil (:

    Pascal pownz!

Page 2 of 2 FirstFirst 12

Bookmarks

Posting Permissions

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