forums

TNT Basic Forums > Programming Q&A
Animated and/or alpha channeled maps?
< Last Thread     Next Thread >
Author
Thread        Post A Reply

07-14-2003 16:42

Posted by:
Boo

Click Here to Email Boo   Find more posts by Boo

Howdy-

I've been experimenting with maps to see if they could be used to make a RPG-style game, and I'm getting somewhat frustrated with them. There are two features which I seem unable to figure out how to do. Perhaps someone knows something I don't:

* How can you animate the tiles on the map? I've got water tiles, waterfalls, lava flows, waving flags, etc. The only way I can see doing it is to have an identical map for each frame of animation, which seems like quite a waste. Alternatively, I guess I could go through the entire map and change the tile number each frame, but that, too, seems like overkill, and would probably be slow for large maps.

* How can you make multi-layer maps? Currently, I can do this by drawing the maps into a canvas, but the tiles don't have alpha-channel support, so it's largely useless. What I'd like to be able to do would be to have a base terrain layer, and then be able to lay tiles over that to create smooth edges between, say, water and land, or to add features, such as pictures on walls or flowers on fields. Ideally, this would be done by making the area around the flowers transparent, so that I could drop it onto dark grass or light grass or whatever.

Both these problems could be solved if I could have the maps pull their tiles out of an image bank instead of an image resource - that way, I could specify the frame for the tiles, and I could specify a mask for drawing multiple layers onto the canvas - but there doesn't seem to be a way to do that.

Any ideas? How have other people built RPG-like maps?

07-15-2003 03:25

Posted by:
ohlsonvox

Click Here to Email ohlsonvox   Find more posts by ohlsonvox

not sure but......

I am a real newbie to TNT basic, but in my researching, I recall that there is a paste sprite command that pastes a sprite to the map. Maybe you can do somethign with this.

ohlssonvox

07-16-2003 04:06

Posted by:
jamie

Click Here to Email jamie   Find more posts by jamie

solution?

sounds to me like you'll need to use sprites for both of those functions. Build your base map out of tiles and anything 'extra' you need as in animations etc. add in as sprites.

07-16-2003 18:50

Posted by:
eekaydee

Location:
CA, USA

Click Here to Email eekaydee   Find more posts by eekaydee

At first I was thinking that to have a top layer, I'd have to use objects and put sprites there, but that's a little tedious and will create a lot of sprites. I just got another idea: for any top layers, draw the layer in another canvas and make a big sprite out of it. You could use black as a mask color or mask it where there are no tiles. Not sure though, will this kill speed?

As for the animated tiles, the set map tile would probably do the job, just go through the tiles that are on the screen.

07-16-2003 20:18

Posted by:
someone

Location:
Quebec ( Canada )

Click Here to Email someone   Find more posts by someone

I don't know why people think a sprite-based map would be slow. I've already done it, and it's almost as fast as a normal viewport. You do not need a lot of sprites ( not one sprite for each tile on the map but one sprite for each visible tile onscreen ) I've done a map with sprites, maybe if you want I could try and post it so you see how it works.

07-16-2003 20:28

Posted by:
Boo

Click Here to Email Boo   Find more posts by Boo

Well, yeah, I know I could always do the "brute force" method - since I can draw an arbitrary bitmap anywhere on the screen I want, that's always an option (mod speed, of course).

I was just hoping to avoid having to roll my own map engine, especially since TNT Basic already provides one. Since TNT Basic is apparently aimed at game creation, I was surprised to find that animated map tiles and/or transparent tiles were not supported.

And I'd love to see an example of someone's sprite-based map engine in action. I'm confident I could code one myself, but I'd like to see what the performance is like before taking the time to do it...

07-17-2003 02:51

Posted by:
eekaydee

Location:
CA, USA

Click Here to Email eekaydee   Find more posts by eekaydee

Doh!

My browser went back to the last page when I pressed delete...I have to re-reply

I was always under the impression that sprites slow things down a lot. When I put a 200x300 box sprite on the screen, fps goes down around 25. Is it my code's fault?

Anyway, I'm with Boo. It would be great if you could post the code, Matthew.

Eric

07-17-2003 20:21

Posted by:
someone

Location:
Quebec ( Canada )

Click Here to Email someone   Find more posts by someone

I'll try. ( But I'm with Boo too. Transparent tiles and parallax scrolling built in TNT would be SO cool! ) It's because the code's in my game and I don't want to give the whole source away ;) anyway I don't know where to post it ( maybe in the downloads section of TNTbasic.com? ) I'll try to have it done by tomorrow.

07-19-2003 14:10

Posted by:
someone

Location:
Quebec ( Canada )

Click Here to Email someone   Find more posts by someone

The file is at

<A href=http://TNTbasic_files.site.voila.fr/ >Lien</A>
http://TNTbasic_files.site.voila.fr/

07-19-2003 14:11

Posted by:
someone

Location:
Quebec ( Canada )

Click Here to Email someone   Find more posts by someone

The file is at

<A href=http://TNTbasic_files.site.voila.fr/ >Link</A>
http://TNTbasic_files.site.voila.fr/

07-20-2003 00:34

Posted by:
eekaydee

Location:
CA, USA

Click Here to Email eekaydee   Find more posts by eekaydee

Cool!

Wow, you're right, it's not that slow! I think that's the way to go if I'm going to do multi layer maps!

And don't worry, I won't copy/ paste your code or anything :D. I know how hard it is to give out code like that.

Thanks

eekaydee

07-20-2003 15:42

Posted by:
someone

Location:
Quebec ( Canada )

Click Here to Email someone   Find more posts by someone

Well, you CAN copy and paste it, 'cause I removed everything I din't want people to see! :D

07-21-2003 23:20

Posted by:
Mark Tully

Location:
TNT HQ, England

Click Here to Email Mark Tully   Find more posts by Mark Tully

It's a bit of a pain, but the only way to do animated tiles at the moment is with sprites.

An easy way to animate them would be to use moan. That way you can place all your animating trees/flowers/water etc when you load the map, set them animating and then forget all about them.

Try the animate sprite command:

global int gTreeSpritesIndex=1000

' places an animated tree on the map at pixel coordinates treex,treey. the tree will animate for ever.
procedure PlaceTree(int treex,int treey)
sprite gTreeSpritesIndex, treeX, treeY, kTreeFrame0
animate sprite gTreeSpritesIndex, -1, kTreeFrame0,kTreeFrameTime to kTreeFrame0+1,kTreeFrameTime to kTreeFrame0+2,kTreeFrameTime
gTreeSpritesIndex=gTreeSpritesIndex+1
end proc

To make your sprites draw behind one another and get characters drawing behind the tree when they're above it and in front when they're below it, you could set the sprite priority of the trees you place to their y position in the world. This will automatically sort them so ones near the bottom of the screen (big y) are drawn over the top of the ones higher up the screen (small y). Then you just have to set the priority of a sprite to it's y value whenever you move it, so just do this for the characters that move around and they will automatically move behind static things in backdrop.

' move hero
sprite kHeroSprite, herox,heroy,heroimage
set sprite priority kHeroSprite, heroy

We really should have automatic support for this - sorry!

Good luck

Mark

07-22-2003 17:05

Posted by:
Martin

Click Here to Email Martin   Find more posts by Martin

Mathew, I very much appreciate the sprite scrolling game and the code. So far - and I haven't yet really understood everything - but it's been a eye-opener. Marvelous! Thanks again.

Martin

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.