forums

TNT Basic Forums > Programming Q&A
HOw to have custom 'classes'?
< Last Thread     Next Thread >
Author
Thread        Post A Reply

09-27-2006 05:04

Posted by:
appleide

Click Here to Email appleide   Find more posts by appleide

eg. In RPG game, you have different units. Each unit have hp/attack/defense, etc,etc,etc...

How do you tie these properties to the sprites?

When this problem arose, the immediately solution was create a new type of 'object' (called class?). I would then define some custom properties for this type of 'object', and tie it to the graphics on the screen..

But then I realised I have no idea how this is done in TNT basic...

09-27-2006 05:08

Posted by:
appleide

Click Here to Email appleide   Find more posts by appleide

By the way... I thought of creating variables for each of these properties... but depending on the circumstances there will be different number and varieties of these 'units', and that means, if using variables, to keep creating and shutting them down...

What about using "File read", and save, etc, and put everything into the hard disk? I think that would be too slow though. (i have to refresh 60 times a second..)

09-27-2006 11:34

Posted by:
Orteil

Location:
Somewhere in France

Find more posts by Orteil

Some suggestions

What about using datas to read the units' stats from, and/or arrays to keep them in memory ?
I guess 60 frames/sec is a bit hard to reach, until you make a very light game.

What is the program you used before ?

09-27-2006 17:22

Posted by:
someone

Location:
Quebec ( Canada )

Click Here to Email someone   Find more posts by someone

"create a new type of 'object' (called class?)"

indeed this is called object-oriented programming, it's very handy for this kind of stuff, and isn't supported by TNT.

The way to go would probably to create arrays, and resize them when needed (not efficient, not handy, but i can't think of any better way in TNT right now)

09-27-2006 17:25

Posted by:
someone

Location:
Quebec ( Canada )

Click Here to Email someone   Find more posts by someone

Orteil : read 60 times per second doesn't mean 60fps, he may be reading stats more than once per frame.

And i'm pretty sure writing it to a file would be too slow.
Even though it depends if you READ the stats 60 times per second, or if you USE stats 60 times. If you USE them 60 times/second, you could just load them once from the file and use them 60 times then. Could be done i guess.

I stillbelieve the arrays are a better way though

09-30-2006 13:45

Posted by:
appleide

Click Here to Email appleide   Find more posts by appleide

I'll drop it to 20 frames per second... :(


I used to use realBasic...

I guess I CAN'T avoid arrays any longer... (I have avoided it for this and last year, when I started to learn BASIC)

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.