forums

TNT Basic Forums > Programming Q&A
how to replace a tile by an another tile
< Last Thread     Next Thread >
Author
Thread        Post A Reply

04-24-2004 17:42

Posted by:
Leorik The Creator

Location:
Montréal,Québec(canada)

Find more posts by Leorik The Creator

in my game when u arriveda at a specific destination you open the door but to do this i need to change the tile (closed door) to the tile (opendoor) how can i do that ??

It's always a pleasure to program in TNT Basic ... so register tnt basic to encourage the fantastic tnt's authors !

Cheers

Leorik

04-24-2004 17:52

Posted by:
MapMaker

Location:
Edmonton, Alberta (Canada)

Click Here to Email MapMaker   Find more posts by MapMaker

For that you would use the 'set map tile' command:

Set Map Tile x,y,z,n

Where x and y are the tile locations in the editor, z is the layer, and n is the the tile set number of the new tile.



04-24-2004 20:23

Posted by:
Leorik The Creator

Location:
Montréal,Québec(canada)

Find more posts by Leorik The Creator

exemple

can you help me a little put with a code exemple there what i use :



int z
int door

map tile (3,12,0)

if tileplayerx=3 and tileplayery=12
set map tile 3,12,z,door
draw frame
end if


the tile image is 376 and i want to change it for 378
how can i do it ?

04-25-2004 09:59

Posted by:
philipp

Location:
Switzerland

Click Here to Email philipp   Find more posts by philipp

hi,
if I understood you right, int door stands for 376 or 378.
I would consider making an array out of it:

int z
int door[2]

door[0]=376
door[1]=378

if tileplayerx=3 and tileplayery=12
set map tile 3,12,z,door[1]
else
set map tile 3,12,z,door[2]
end if

draw frame

Further I think you've got more than just one door... then you could extend the door array and store its coordinates like this:

'let's say you've got 100 doors:

int z
int doorpix[100,2]
int door_coordinates[100,2]

int player_was_in_door

int i
for i=0 to 99
doorpix[i,0]=376
doorpix[i,1]=378
next

'of course it's stupid to make an array with 100 equal elements, but perhaps you don't want to use the same picture for each door, then you simply can define them new

door_coordinates[0,0]=3
door_coordinates[0,1]=12
....
door_coordinates[99,1]=876

'here you have to define the x and the y coordinates of each door, sure it's a pain but you just have to do it lol..

procedure check_doors()
int i
i=0
while i<=99
if tileplayerx=door_coordinates[i,0] and tileplayery=door_coordinates[i,1]
set map tile door_coordinates[player_was_in_door,0],door_coordinates[player_was_in_door,1],z,doorpix[player_was_in_door,0]
set map tile door_coordinates[i,0],door_coordinates[i,1],z,doorpix[i,1]
player_was_in_door=i
break
else
i=i+1
end if
wend
end proc


'this is the procedure that checks wether the player passes a door or not. For optimisation I made a break once the right door was found. Also for optimisation it only redefines the picture the door that was passed before, that's why there is a variable called player_was_in_door. Here the index of the door passed is stored.

well that's all I think... perhaps I've understood you wrong lol then I'm sorry. If there are any questions about the code you're welcome to ask me... perhaps there are also some mistakes in it...
I hope I've helped you with that

regards,
Philipp

04-25-2004 15:35

Posted by:
Leorik The Creator

Location:
Montréal,Québec(canada)

Find more posts by Leorik The Creator

Thanks phillip

Thank you , your help is very appreciated , and you'v done really great work !

Cheers,

Leorik

All times are GMT        Post A Reply

Forum Jump:
< Last Thread     Next Thread >

< Contact Us - TNT Basic >

Powered by: vBulletin Lite Version 1.0.1 Lite
Copyright © Jelsoft Enterprises Limited 2000.