TNT Basic Forums > Beyond Basic
Platform Game
< Last Thread     Next Thread >
Thread        Post A Reply

03-21-2006 16:59

Posted by:

San Francisco, CA

Click Here to Email Jacob   Find more posts by Jacob

I'm making a platform game that has four layers.
The speed of the game is fine until you draw tiles that come in front of everything, because these tiles are made with sprites so that they can come in front of other sprites such as the player.

If you add water that comes in front of you so it looks like the player is swimming, the game goes so slow that it's not worth playing. Other than the speed my game is good.

This game is the game I extracted out the exact tile colissions for Ian.

There's three solutions to my problem:
1) Don't make tiles that come in front of the player. (I don't want to do that one ;) )
2) Have Mark speed up sprite drawing if possible.
3) Look for a better way to do it.

Any help is welcome!

03-23-2006 06:02

Posted by:

Somewhere in space...

Find more posts by Farmer


Here's one solution...

When you use water, I'm assuming that it will simply reach up to a designated height and then stop. Not like a fancy canal system or anything, I hope. If this is the case, viewports would help.

I'm not sure if you're familiar with them, but viewports basically act as windows to a canvas other than the main one that is copied to the screen, (Canvas 0). So what you can do is open a canvas, open a viewport to that canvas THAT ONLY COVERS THE BOTTOM HALF OF THE SCREEN, and then draw your water on there. You can open another viewport (probably a map viewport, if you're using complicated levels and such that require the map designer) that leads to another canvas and, as long as you remember to draw your hero sprite on the background canvas, it should effortlessly sink in and behind the water. (Not that that's a feat for any normal human, for for a computer program...)

Code might look like this:

Window Mode 400,400' This could be Graphics Mode instead. (I like the new windowed look. :D )

Open Canvas 1, 400,400' This canvas is for the level.
Open Canvas 2, 400,400' This canvas is for the water.

Load Map 128' Load your level map.

Open Map Viewport 1,0, 0,0 to 400,300
' This opens a map viewport to canvas 1 using the first layer
' of the loaded map and drawing it ONLY AS FAR AS THE
' (Leaves the bottome 100 pixels empty. :) )
Open Viewport 2, 0,300 to 400,400
' This opens a viewport to canvas 2 covering only the bottom
' 100 pixels of the screen, (where the water should be!).

Draw Picture pictureID,2' Draws your water image to canvas 2.
' (If you want to have moving water, you should look at the scrolling
' viewports tutorial here. DON'T try to use sprites. It's way too slow.

Canvas 1' Tells the computer to draw everything after this, (including sprites), on the canvas with the map on it.

Load Images 128' Remember to load the sprite images.
Sprite 0,190,290,0' Puts the sprite on the line between the water and the sky.

Draw Frame' Shows you what you've done!

Please substitute your own numbers into the above. I made a quick TNT program that demonstrates how this works, and if you don't get it I'll see if I can get it to you.

Best of luck and God bless!

03-23-2006 14:09

Posted by:

San Francisco, CA

Click Here to Email Jacob   Find more posts by Jacob

Okay, now let me get this straight: The water has transparency and the water can be on any of the tiles on the screen.
You can make five tiles on one side of the screen water and five on the other side water, or you can make any certain tile water.

03-23-2006 22:48

Posted by:

Quebec ( Canada )

Click Here to Email someone   Find more posts by someone

you might want to post a feature request, because i don't believe this is possible to do in TNT atm. Tough i believe transparent tiles are already a goal, for when the graphics engine is ready to be enhanced

03-24-2006 00:49

Posted by:

San Francisco, CA

Click Here to Email Jacob   Find more posts by Jacob

It's not only water, it can be anything.
Whatever tiles I want to come in front come in front.
Transparency works fine because I paste a sprite with the image of the tile.

And I do not use the TNT Basic map editor, I made my own because I wanted it to be included in the game when I build and distribute it.

But your right Someone (whoever you are), that is a good idea to be able to have transparent tiles. I will make that request.

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.