forums

TNT Basic Forums > Programming Q&A
Map Distortion?
< Last Thread     Next Thread >
Author
Thread        Post A Reply

10-24-2006 22:08

Posted by:
Redd

Location:
uh... *blink*

Click Here to Email Redd   Find more posts by Redd

Didn't find a thread for it anywhere, so here it is:

Whenever I open a map, all the tiles lose their original colours and everything is distorted. In other words:

Map:


Code (directly from the test version):
GRAPHICS MODE 800, 600

LOAD MAP 0
GLOBAL INT maxX = map width * map tile width - 150, maxY = map height * map tile height - 150

OPEN CANVAS 1, map width*map tile width, map height*map tile height
OPEN MAP VIEWPORT 1, 0, 0, 0 TO 100, 100

INT X, Y
WHILE NOT MOUSE BUTTON
IF LEFT THEN X = X-2
IF RIGHT THEN X = X+2
IF UP THEN Y = Y-2
IF DOWN THEN Y = Y+2

IF X < 0 THEN X = 0
IF Y < 0 THEN Y = 0
IF X > maxX THEN X = maxX
IF Y > maxY THEN Y = maxY

SET VIEWPORT OFFSET 1, X, Y

DRAW FRAME
WEND


What happens:


I'm running TNT on OS 9. I'm pretty sure the code is all as it's supposed to be (or close to it), or am I wrong?

10-24-2006 22:53

Posted by:
someone

Location:
Quebec ( Canada )

Click Here to Email someone   Find more posts by someone

i think TNT has lots of these bugs in pre-OSX systems... on my os 8.6 i had similar problem... does it do the same in hardware mode? (replace graphics mode by graphics mode hardware)

10-24-2006 22:55

Posted by:
someone

Location:
Quebec ( Canada )

Click Here to Email someone   Find more posts by someone

also, maybe you should check if your tiles have some sort of color compression. (i remember seeing similar things in OpenGL if you'd specify a wrong pixel format - however i have no idea if/how this can apply to TNT)

10-24-2006 23:33

Posted by:
swagIT

Location:
Great Wet North (Vancouver)

Find more posts by swagIT

ran the same code OSX with one of my maps - it worked perfectly.

what format are your map tiles in?

10-25-2006 06:48

Posted by:
Redd

Location:
uh... *blink*

Click Here to Email Redd   Find more posts by Redd

>>
i think TNT has lots of these bugs in pre-OSX systems... on my os 8.6 i had similar problem... does it do the same in hardware mode? (replace graphics mode by graphics mode hardware)
>>

Hardware mode slows the game down too much... I'll try it anyways.

>>
also, maybe you should check if your tiles have some sort of color compression. (i remember seeing similar things in OpenGL if you'd specify a wrong pixel format - however i have no idea if/how this can apply to TNT)
>>

>>
ran the same code OSX with one of my maps - it worked perfectly.

what format are your map tiles in?

>>
I made a picture clipping using ClarisWorks (dragged the picture off the drawing area). I wouldn't know how this affects everything, but if it's the case I'll try using jpg's.

10-25-2006 06:58

Posted by:
Redd

Location:
uh... *blink*

Click Here to Email Redd   Find more posts by Redd

Oh... ?

Converting the picture to a .jpg worked.

What I can't understand is why the graphics work with sprites, but not maps. Am I missing something?

10-25-2006 17:47

Posted by:
someone

Location:
Quebec ( Canada )

Click Here to Email someone   Find more posts by someone

Avoid clippings at any cost :) they're handy but unsupported for anything else than viewing.

>>
What I can't understand is why the graphics work with sprites, but not maps. Am I missing something?
>>

(AFAIK) Sprites and maps have different drawing code - probably the code that draws maps has a limitation the code that draws sprites doesn't

10-25-2006 17:53

Posted by:
someone

Location:
Quebec ( Canada )

Click Here to Email someone   Find more posts by someone

and you should use PNG or TGA rather than JPG, since JPG will degrade the quality of your images (and once you get them into TNT they won't be smaller anyway)

10-25-2006 19:51

Posted by:
swagIT

Location:
Great Wet North (Vancouver)

Find more posts by swagIT

Also - in Hardware mode .jpg's can cause a problem with mask colours -
I only use .png's and things work well.

For mac OSX 10.3.9 and above there is an awesome Freeware app called pixen

http://www.opensword.org/Pixen/

which allows you to save to many formats inclusing .png

10-25-2006 20:30

Posted by:
Redd

Location:
uh... *blink*

Click Here to Email Redd   Find more posts by Redd

>>
For mac OSX 10.3.9 and above there is an awesome Freeware app called pixen
>>

Too bad I won't be able to use it for a while =]

>>
Avoid clippings at any cost :) they're handy but unsupported for anything else than viewing.
>>

I only use them when I think I'll be having a lot of graphics to handle. I don't like having a full HD because of growing projects (the Finder's giving problems already).

I know .gif's lose colour, but .jpg? Seems like one learns something new everyday. XD

10-25-2006 21:36

Posted by:
Redd

Location:
uh... *blink*

Click Here to Email Redd   Find more posts by Redd

I still can't understand how to block the player from moving over certain tiles. Can someone please explain it to me?

Let's say I don't want the sprite to move over the gray area (above map), how would I code it?

I don't want to resort to pre-drawn images, mainly because I'm not good with a pencil (or computer art). If I can't understand tiles properly, I'll use those kinds of images.

10-25-2006 22:48

Posted by:
someone

Location:
Quebec ( Canada )

Click Here to Email someone   Find more posts by someone

i'm willing to help you with tile collision, but please first post what you've tried so far...

10-26-2006 15:21

Posted by:
Redd

Location:
uh... *blink*

Click Here to Email Redd   Find more posts by Redd

>>
i'm willing to help you with tile collision, but please first post what you've tried so far...
>>

This is what the code looks like:

GRAPHICS MODE 800, 600

LOAD MAP 0
GLOBAL INT maxX = map width * map tile width-25, maxY = map height * map tile height-25

OPEN CANVAS 1, map width*map tile width, map height*map tile height
OPEN MAP VIEWPORT 1, 0, 225, 125 TO 575, 475

INT X, Y, IMAGE
WHILE NOT MOUSE BUTTON
IF LEFT THEN X = X-2 : IMAGE = 0
IF RIGHT THEN X = X+2 : IMAGE = 1
IF UP THEN Y = Y-2 : IMAGE = 2
IF DOWN THEN Y = Y+2 : IMAGE = 3

IF X < 0 THEN X = 0
IF Y < 0 THEN Y = 0
IF X > maxX THEN X = maxX
IF Y > maxY THEN Y = maxY

SPRITESET()

DRAW FRAME
WEND

PROCEDURE SPRITESET()
SPRITE 0, X, Y, IMAGE
END PROC


---

That's the best I could do. I don't know where to begin with the tile (proper) blocking code.

10-26-2006 22:13

Posted by:
someone

Location:
Quebec ( Canada )

Click Here to Email someone   Find more posts by someone

okay... i'm willing to help, but i think you'll learn better if i don't spew code at you and just guide you a bit...

TNT Basic Help > Maps > Map Tile

Syntax
number = Map Tile (x,y,z)

Description
x, y and z are the coords in the map to get the current tile from.
number is the index of the tile at those coordinates.

You need to call this command to get which tile is at a certain location - and then, if it's a tile number the sprite can go on, you m ove it. otherwise you don't. Just note that x and y are in tiles, not in pixels.

Now please at least try writing some code with it! If you have too many problems it may be that you have problems with BASIC in general rather than with collisions in particular. Especially as you say "I don't know where to begin with the tile (proper) blocking code." It would be very important for you to understand how it works before trying to do fancy stuff

10-27-2006 16:42

Posted by:
Redd

Location:
uh... *blink*

Click Here to Email Redd   Find more posts by Redd

>>
Now please at least try writing some code with it! If you have too many problems it may be that you have problems with BASIC in general rather than with collisions in particular. Especially as you say "I don't know where to begin with the tile (proper) blocking code." It would be very important for you to understand how it works before trying to do fancy stuff
>>

I understand what's written in the Documentation. One of the things I don't understand is what the z is for in the Map Tile code.

That's what my main concern is.

10-27-2006 22:09

Posted by:
someone

Location:
Quebec ( Canada )

Click Here to Email someone   Find more posts by someone

simple =) it's the layer (TNT offers the capabilty to create multiple layers in a map, although only being able to display one...) so it will be 0 or 1 by default (can't remember which one)

(if you need more help just ask)

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.