Make one world, with a visibility parameter

probably from a large number of questions in my last topic immediately lost the desire to help :D

now interested in this:

how to make a one great location, but it is necessary that the player could only see part of where it is located within the walls.

As an example - a player moved from one room to another - he sees within the limits of this room

up. help somebody. think, its not hard for you

simply sad, use the source, add an attribute to each tile, like roof (this has been made before TE i think donnow)

and if player is within a tile with that attribute only blit tiles that have that attribute.

Im working on this now… only shows parts that would actualy be vis from where you stand so its based on true location and just just a section. its turning to be really cpu heavy so if i can cut it down ill release it…

currently at the phase of using php ( i know it better) for proof of concept… so dont expect anything soon.

my way should be easy enough ^.^

bit hard to code maybe, but just pm me with problems if needed

Your way does sound easy. After you said that i started to think of having a new layer that has tile data

each tile gets assigned a area number then a string of areanumbers viewable from it

so if you are in a room your tile says all tiles numbered 1 are ok to show… as you walk to a corner it would say all tiles numbers 1 and 2 are ok to show soit would open up tiles around the corner ….

Would be easy and much less cpu intensive then my way…

find screen size ( mine has multiple sizes) exmpl (10x10)

divide x and y tiles displayed by two (5x5)

make ratios using those numbers all combos in that range (-5:-5 1:5 -1:5 and so on)

start at player position and using each ratio move out from player untill it hits a block once it hits a block mark all tiles beyond that layer as black.

see crappy example here

http://justprof.it/test.php

Sample of code if it helps any one with an idea


 ".$x." ".$y."";

$xf=$tx+$x;

while(($ty<=$ym ) AND($ty>=0) AND ($tx<=$xm ) AND($tx>=0) ){

if($tx==$xf){

$ty=$ty+$y;

$xf=$xf+$x;

}

echo " x".$tx."y".$ty."b".$block;

if($block>=1){

if($mapprint[$tx][$ty]==1){

}else

{

$mapprint[$tx][$ty]=2;

}

}

if($map[$tx][$ty]==1){

$block=1;

}

if($x!=0){

$tx=$tx+($x/abs($x));

}else

{

$tx=$xm+1;

}

}

/////////

$x=$x+1;

}

$x=0-$qx;

$y=$y+1;

}

////////////////////

$mapprint[$playerlocx][$playerlocy]=5;

$x=0;

$y=0;

?>

=1){

if($mapprint[$x][$y]==1){

echo "O";

}

else

{

echo "x";

}

}

else

{

echo ".....";

}

?>

 |

I think what you want to do is setup a camera. This Camera is going to be fixed on the players location so if the player moves the camera also moves. Then based on that camera you want to only render the objects inside the camera. You can adjust the camera size based on the window size.

I will give you a little pseudo code of the top of my head.


For Y = 0 To CameraHeight / TileSize

     For X = 0 To CameraWidth / TileSize

          Check If camera is out of maps bound. If so exit

          Get the tile info from the map array for the x and y tile position based on your current camera x and y

          Set the tile attributes and texture based on the information from above.

          Render tile based on the X and Y position of the camera.

     Next

Next

Of course you will have to add camera movement somewhere with your player movement so that when the player moves his camera moves with him.

I think what you want to do is setup a camera. This Camera is going to be fixed on the players location so if the player moves the camera also moves. Then based on that camera you want to only render the objects inside the camera. You can adjust the camera size based on the window size.

I will give you a little pseudo code of the top of my head.


For Y = 0 To CameraHeight / TileSize

For X = 0 To CameraWidth / TileSize

Check If camera is out of maps bound. If so exit

Get the tile info from the map array for the x and y tile position based on your current camera x and y

Set the tile attributes and texture based on the information from above.

Render tile based on the X and Y position of the camera.

Next

Next

Of course you will have to add camera movement somewhere with your player movement so that when the player moves his camera moves with him.

To expand on his snippet…

Edit: So you want it where you don’t have to switch to maps, but you can rather walk from map to map? Multi map rendering, I’m working on that right now. I’ll post what I can for you tomorrow.

Log in to reply