hi im making a game engine, and another problem im having is finding out what tile im on. its tile*tile atm, and ive worked out when im going to another tile by going posx = playerpos/16 and posy = playerpos/16, but because you start in the middle of a 40x40 map i dont know how the engine can read if you are standing on, say, tile number 5 for example.
anyone with ideas?
i have tried
for x = 1 to 40 etc
If map(x,y) = 5 then
bla bla bla
and also
if playerposx = 16 and playerposy = 16 '(where there is a tile 5 located)
then ontile5 = "true"
which doesnt work
finding what tile the player is on
-
- Veteran
- Posts: 288
- Joined: Sat Feb 18, 2006 4:02 pm
yeah sorry im at uni and the program is at home :/
yeah the tiles are 16*16. i can sort of pseudo-code here:
screen 13
open map for input as #1
for x = 1 to 40
for y = 1 to 40
input #1,map (x,y)
next
next
' in a sub
select case map(x,y)
case 1
put(x,y),grass,pset
case 2
put(x,y),house,pset
etc
etc
'in another sub
sub putplaypic
'playerY = 96
'playerX = 160
put (worlddata.playerX, world data.PlayerY), player, pset
Do
if key is pressed
up, down, left, right, exit
loop
'END HERE---------------------
do you get the idea? the player always starts in the middle of the map and screen. so how would i read the map to see if you are standing on tile 5?
i thought that you could do it by working out posX = worlddata.playerX/16
which would find the place you are standing, so i could work out from where u start where tile 5 is (which means that tile 5 would have to be pre-defined in the map rather than being worked out)
for example, map data:
1,1,1,1,1,1,1,1,1,1,1,1
1,1,1,1,1,1,5,1,1,1,1,1
1,1,1,1,1,1,1,1,1,1,1,1
1,1,1,1,1,1,1,1,1,1,1,1
1,1,1,1,1,1,8,1,1,1,1,1
1,1,1,1,1,1,1,1,1,1,1,1
1,1,1,1,1,1,1,1,1,1,1,1
you start at 8, i want to find out when im standing on 5
yeah the tiles are 16*16. i can sort of pseudo-code here:
screen 13
open map for input as #1
for x = 1 to 40
for y = 1 to 40
input #1,map (x,y)
next
next
' in a sub
select case map(x,y)
case 1
put(x,y),grass,pset
case 2
put(x,y),house,pset
etc
etc
'in another sub
sub putplaypic
'playerY = 96
'playerX = 160
put (worlddata.playerX, world data.PlayerY), player, pset
Do
if key is pressed
up, down, left, right, exit
loop
'END HERE---------------------
do you get the idea? the player always starts in the middle of the map and screen. so how would i read the map to see if you are standing on tile 5?
i thought that you could do it by working out posX = worlddata.playerX/16
which would find the place you are standing, so i could work out from where u start where tile 5 is (which means that tile 5 would have to be pre-defined in the map rather than being worked out)
for example, map data:
1,1,1,1,1,1,1,1,1,1,1,1
1,1,1,1,1,1,5,1,1,1,1,1
1,1,1,1,1,1,1,1,1,1,1,1
1,1,1,1,1,1,1,1,1,1,1,1
1,1,1,1,1,1,8,1,1,1,1,1
1,1,1,1,1,1,1,1,1,1,1,1
1,1,1,1,1,1,1,1,1,1,1,1
you start at 8, i want to find out when im standing on 5