Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>It's now in it's own place and is only called when the player actually moves.</p> </blockquote> <p>Yay!</p> <blockquote> <p>I was just asking if there was a better way than using four <code>for</code>'s.</p> </blockquote> <p>Here's my suggestion:</p> <ol> <li>Set the lower-left to the player's location minus 15. <pre>ll.x = [player_ location].x - 15.0; ll.y = [player_ location].y - 15.0;</pre></li> <li>Make sure that it does not exceed the bounds of the view. <pre>if (ll.x &lt; 0.0) ll.x = 0.0; if (ll.y &lt; 0.0) ll.y = 0.0; if (ll.x &gt; [currentMap_ width] - 30.0) ll.x = [currentMap_ width] - 30.0; if (ll.y &gt; [currentMap_ height] - 30.0) ll.y = [currentMap_ height] - 30.0;</pre></li> <li>Multiply by your tile size and set as the new bounds origin. location.x = ll.x * 20.0; location.y = ll.y * 20.0; [self setBoundsOrigin: location];</li> </ol> <p>I also suggest that you not hard-code the tile size and player sight range.</p> <p>For the tile size, you may prefer to give your view a couple of properties expressing width and height in tiles, then using the CTM to scale to <code>(widthInPoints / widthInTiles), (heightInPoints / heightInTiles)</code>. Then you can let the user resize your window to change the tile size.</p> <p>For the player's sight range (currently 30 tiles square), you may want to make this a property of the player, so that it can change with skill stats, items equipped, and the effects of potions, monster attacks, and wraths of the gods. One caveat: If the player's sight range can become longer than the game window will fit (especially vertically), you'll want to add a check for that to the above code, and handle it by putting the player dead-center and possibly zooming out.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload