forums

TNT Basic Forums > TNT Basic - The Open Source Edition
TNT Lib
< Last Thread     Next Thread >
Author
Thread        Post A Reply

08-11-2007 20:03

Posted by:
someone

Location:
Quebec ( Canada )

Click Here to Email someone   Find more posts by someone

I have recently been toying with a sprite library written in OpenGL i needed for my own apps. I just gave a little go and adapted it to have a syntax very similar to TNT's :

That's C++ but could be adapted for C

int main(int argc, char* argv[])
{
windowMode(512,512);

loadMusic("song.S3M");
playMusic();

std::string images[] = {"test.png","alga.png"};
ImageBank* bank = new ImageBank(images, 2);
bank->loadImages();
setImageBank(bank);

int x1=25, y1=0, xspeed1=1, yspeed1=1;
int x2=100, y2=100, xspeed2=-1, yspeed2=1;
int transp = 0, trans_change = 1;

int angle = 0;

while(true)
{
x1 += xspeed1;
y1 += yspeed1;
if(x1 > 512) xspeed1 = -1;
if(y1 > 512) yspeed1 = -1;
if(x1 < 0) xspeed1 = 1;
if(y1 < 0) yspeed1 = 1;
sprite(1,x1,y1,0);

transp += trans_change;
if(transp < 0) trans_change = 1;
if(transp > 100) trans_change = -1;
setSpriteTransparency(1,transp);

setSpriteXScale( 1, transp/50.0 );
setSpriteYScale( 1, transp/50.0 );

x2 += xspeed2;
y2 += yspeed2;
if(x2 > 512) xspeed2 = -1;
if(y2 > 512) yspeed2 = -1;
if(x2 < 0) xspeed2 = 1;
if(y2 < 0) yspeed2 = 1;
sprite(2,x2,y2,1);

angle += 1;
if(angle > 360) angle -= 360;

setSpriteRotation( 2, angle );

drawFrame();
}

bank->unloadImages();
delete bank;

freeTNT();

return 0;

}


i'm not sure this can be of any use in the upcoming TNT2 but it is interesting nonetheless :)

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.