forums

TNT Basic Forums > Programming Q&A
How do you OPTIMIZE ?
< Last Thread     Next Thread >
Author
Thread        Post A Reply

01-11-2003 18:57

Posted by:
Toast

Click Here to Email Toast   Find more posts by Toast

I notice when I put animated graphics (man walking) on the scrolling example that the animation slows down while walking across the scrolling screen. I also notice that Holmes Futrell marks different procedures as being optimized. I tried to scrutinize what that all meant, but I can't quite see what he means by, "optimized". I also noticed that his sprites are numbered in the thousands. ?? ie, 9000+n etc or 41000+n. He also uses arrays a lot. Is that faster than using a for/next loop? I tried to use his explosion sprites on a simple blank background with a for/next loop and it just jerked its way from frame to frame. Holmes' explosions are smooth and he has moving sprites, sounds, and scrolling backgrounds. So optimizing must have a great effect on all that. I looked all through the tutorials to see how I could do that smoothly but I didn't find any help. Can someone help me?

01-11-2003 23:23

Posted by:
matteo

Location:
Venice, ITALY!

Click Here to Email matteo   Find more posts by matteo

what?

Sprite animations really should not bother TNT more than a still sprite:

try something like this:

put your explosions as sprites from 0 to 15 (Those explosions are free from iDev, if I dont go wrong)


...
repeat
t= t+1
if t<10 then explosionimage=0
if t>=10 and t<20 then explosionimage=1
if t>=20 and t<30 then explosionimage=2
...
if t>150 then t=0
...
sprite 0,x,y,explosionimage
...
until mouse button
...

Hope this does not help
Regards
Matteo
(If you wanna get the coolest game for TNT, tell me)

01-12-2003 04:55

Posted by:
Holmes

Location:
Santa Rosa, Ca

Click Here to Email Holmes   Find more posts by Holmes

To comment on my code:

At one point I changed the way it loops through when performing actions for each enemy to only include ones in a certain range. If it was looping for the actions of enemy 0-100 and enemy number 100 died, it would only loop from 0-99 and not even bother checking if 100 was even alive to see if it should perform its actions. If enemy 0 died, it would then start looping at 1. It would have been much better if I could have used a linked list, but TNT doesn't support pointers, and therefore doesn't support these. When I changed the code for each type of enemy to support the looping range, I marked it with the comment 'optimized'.

Raptor's code may not be the best example. It really doesn't conform to good coding standards AT ALL. Its downright awful, in fact.

I incremented in the thousands to make sure types of enemies wouldn't use conflicting sprite numbers. A better way to do this would be to use variables instead of numbers. Define a variable

enemyTypeIndex =somenumber

then when refferencing a particular enemy of that types graphics say enemyTypeIndex+n

The best coding standard is to define variables like this so you never end up using any numbers in your code except for say 0 and 1.

Its hard discussing code over this forum, so if you send me your code (holmes@neatosoftware.com) I'll see if I can help.

01-12-2003 07:01

Posted by:
Danlab games

Click Here to Email Danlab games   Find more posts by Danlab games

MMMMMMOOOOOOOOAAAAAAANNNNN

if you want animate some things.. try MOAN
its very easy using this
Moan can run animation or move sprite for you..

01-12-2003 18:59

Posted by:
Toast

Click Here to Email Toast   Find more posts by Toast

Thanks for the help

matteo, I tried your repeat loop and it worked very well after I changed t=t+1 to t=t+3. I also experimented with the in between counts ie,
if t<10 then explosionimage=0
if t>=10 and t<20 then explosionimage=1
if t>=20 and t<30 then explosionimage=2...
reducing the count between greater than and less than, with some interesting results. Without the time lapse the explosion sprite went to fast. That was a good algorithm and it also worked with a "while" loop.
Holmes, thanks for your explanations as well and your offer to help with programming. Right now I am just getting my feet wet with TNT and just experimenting with code and sprite animation etc. Nothing quite like "Raptor". Great job! Even if you felt the coding was unconventional. Gotta start somewhere.
Danlab, I'm not quite ready for MOAN yet. You amaze me with how many games you have programmed. Do you release any of your source codes. Like, how did you make that sparkly cursor?
So, much to learn, so little time. :> )Thanks again for all your help. I'll be back, many times I am sure.
Oh yea, Thanks eLL for pointing me to TNT from the Coldstone forums.

01-12-2003 22:52

Posted by:
eLL

Click Here to Email eLL   Find more posts by eLL

So You've Caught The Comet's Tail

Well DanLab has released some code,

Angle and twinCards Source
-------------
as far as the sparkly cursor dealy, try the 'particles yum' example on the main site.
-------------
Glad you found something more suited to your development needs.
Well i try to leave a gigantic paper trail behind me where ever i go.

01-13-2003 03:41

Posted by:
eLL

Click Here to Email eLL   Find more posts by eLL

Angle source code address


the URL for the Angle source code is here:

http://ellrx.250free.com/angles.sit

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.