forums

TNT Basic Forums > Programming Q&A
Mapping HELP
< Last Thread     Next Thread >
Author
Thread        Post A Reply

04-17-2008 18:23

Posted by:
tntfan3

Find more posts by tntfan3

Hi, I have been using TNT basic for a while at a basic level and have decided to start mapping. My map has many problems. It seems to not scroll perfectly. Also, MY MAIN PROBLEM IS: I can not get my map tile command to work. PLEASE HELP!

NOTE: The program is already in graphics mode 640,480

NOTE: All variables that you do not see declared below WERE declared globally.

NOTE: The map dimensions are as follows:

Map Width: 1920
Map Height: 480

Tile Width: 65
Tile Height: 65

# of Tiles: 65



ALL RELEVANT CODE BELOW:



procedure Defeat_Foes_and_Beat_Obstacles()

int map_onexone= 0

int map_oneyone= 0

int map_onextwo= 640

int map_oneytwo= 480

int map_one_tile


int viewoffset_x,viewoffset_y

int viewoffset_xx,viewoffset_yy



clear keyboard

vbl sync off 'this allows for a greater frame rate

set framerate 60 'this increases the frame rate to 60

hide mouse


load map 128

load images 130


open map viewport 5,0,map_onexone,map_oneyone to map_onextwo,map_oneytwo

while not mouse button

if right then viewoffset_xx= viewoffset_xx+2

if left then viewoffset_xx= viewoffset_xx-2

if up then viewoffset_yy= viewoffset_yy-2

if down then viewoffset_yy= viewoffset_yy+2


viewoffset_x=viewoffset_xx

viewoffset_y=viewoffset_yy


if viewoffset_x< 0 then viewoffset_x= 0

if viewoffset_y< 0 then viewoffset_y= 0


if viewoffset_x> map width()*65-640 then viewoffset_x= map width()*65-640
if viewoffset_y> map height()*65-480 then viewoffset_y= map height()*65-480


map_one_tile= map tile ((sprite_Defeat_Foes_and_Beat_Obstacles_charx+viewoffset_xx)/65,(sprite_Defeat_Foes_and_Beat_Obstacles_chary+viewoffset_yy)/65,0)


'insert tile reactions here


test=test+1

if test>1000 and map_one_tile<> 0 and map_one_tile<> 3 and map_one_tile<> -1 then test_a_variable(map_one_tile) 'ADDED MORE CONDITIONS
TO GET AN ACTUAL TILE # (IN HOPES OF)

sprite 5,sprite_Defeat_Foes_and_Beat_Obstacles_charx-(viewoffset_x-viewoffset_xx),sprite_Defeat_Foes_and_Beat_Obstacles_chary-(viewoffset_y-viewoffset_yy),0


set viewport offset 5,viewoffset_x,viewoffset_y


draw frame


wend


end proc



procedure test_a_variable(int test_var)


text mode

print test_var

end


end proc

04-17-2008 19:28

Posted by:
tntfan3

Find more posts by tntfan3

Just to clarify, I read the mapping tutorial but did not fully understand the tile collisions. Please correct any errors you see in my code and give me as much help as ultimately possible. Thanks.

04-20-2008 03:14

Posted by:
appleide

Click Here to Email appleide   Find more posts by appleide

I am not so familiar with TNTBasic anymore, but...
In

map_one_tile= map tile ((sprite_Defeat_Foes_and_Beat_Obstacles_charx+viewoffset_xx)/65,(sprite_Defeat_Foes_and_Beat_Obstacles_chary+viewoffset_yy)/65,0)


Try printing out the numbers (sprite_Defeat_Foes_and_Beat_Obstacles_charx+viewoffset_xx)/65 and (sprite_Defeat_Foes_and_Beat_Obstacles_chary+viewoffset_yy)/65 to see if they're valid numbers to use with the map Tile. (eg, they might be too big or too small or rounding errors or ...)

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.