forums

TNT Basic Forums > Programming Q&A
scaling an animation
< Last Thread     Next Thread >
Author
Thread        Post A Reply

02-17-2004 16:03

Posted by:
Stephen Lund

Location:
Michigan USA

Click Here to Email Stephen Lund   Find more posts by Stephen Lund

Is there a way that you can scale a Animaion by using Sprite scale


This is my code:
graphics mode 1024,768

' load the images 128
load images 128


int deerani = 0

int deerx = -10
int deery = 300

while true
' set the animation
sprite 129,deerx,deery,deerani
delay 25

' Makes it loop
deerani = deerani + 1


' makes the deer run
deerx = deerx + 15


' if the deer = 1024 it = 0
if deerx > 1024 then deerx = 0


' if the animation = 10 then it = 0
if deerani = 10
deerani = 0
end if

' draws the frame
draw frame
wend[u/][b/]

Stephen,

02-17-2004 18:42

Posted by:
eric

Location:
earth

Click Here to Email eric   Find more posts by eric

How about telling us what is it that you are trying to do...

02-17-2004 19:25

Posted by:
puffin

Click Here to Email puffin   Find more posts by puffin

if you want to do sprite scaleing you need to be in hardware mode.

02-17-2004 21:38

Posted by:
charlie

Location:
norfolk, england

Click Here to Email charlie   Find more posts by charlie

ok,this is pretty simple.

your code seems fine, the running deer runs from left to right, when it goes off the righthand side of the screen it returns to the left hand side

to make your sprite scale, use the set sprite scale command, i.e

set sprite x scale 129, scalefactor
set sprite y scale 129,scalefactor

scalefactor is a variable you can adjust within your code, declare it as a variable at the start of your code with something like

int scalefactor=0

then scale the sprite in the main loop with

scalefactor=scalefactor+1

this should do the trick, but you need to be in hardware mode for it to work

all this is in the help file also, wich is pretty simple too understand


good luck
charlie

02-17-2004 23:32

Posted by:
eekaydee

Location:
CA, USA

Click Here to Email eekaydee   Find more posts by eekaydee

quote:
you need to be in hardware mode


In case you don't know how to enter hardware mode, just add "hardware" after "graphics mode":

graphics mode hardware width,height

02-17-2004 23:35

Posted by:
Stephen Lund

Location:
Michigan USA

Click Here to Email Stephen Lund   Find more posts by Stephen Lund

I want to Scale the hole animation, I want to make it like if you click on a button it makes the animation bigger,

Stephen,

02-18-2004 00:15

Posted by:
Stephen Lund

Location:
Michigan USA

Click Here to Email Stephen Lund   Find more posts by Stephen Lund

I found the problem out, It was simple:),
sorry for taking your Time.

Stephen

02-18-2004 00:15

Posted by:
eekaydee

Location:
CA, USA

Click Here to Email eekaydee   Find more posts by eekaydee

Stephen, just use the sprite scale x and sprite scale y commands as Charlie said, using the same scaling factor for both. That will maintain the image's proportions.

02-18-2004 13:32

Posted by:
Stephen Lund

Location:
Michigan USA

Click Here to Email Stephen Lund   Find more posts by Stephen Lund

Thanks

Thats what I did and it worked I hade to change so,e stuff in my code but i worked thanks to your help

Thanks
Stephen,

02-18-2004 13:34

Posted by:
Stephen Lund

Location:
Michigan USA

Click Here to Email Stephen Lund   Find more posts by Stephen Lund

Thanks

Thats what I did and it worked, I hade to change some stuff in my code but i worked thanks to your help ,

Thanks
Stephen,

02-21-2004 01:52

Posted by:
Stephen Lund

Location:
Michigan USA

Click Here to Email Stephen Lund   Find more posts by Stephen Lund

Another thig about scaling. is there a way to scale a sprite smaller then it is,

Stephen,

02-21-2004 03:46

Posted by:
eekaydee

Location:
CA, USA

Click Here to Email eekaydee   Find more posts by eekaydee

Yes

Sure there is. Just use a scaling factor less than one.

02-21-2004 13:54

Posted by:
Stephen Lund

Location:
Michigan USA

Click Here to Email Stephen Lund   Find more posts by Stephen Lund

Thats what I did and it got bigger,

My code:
graphics mode hardware 1024,768
load images 128

int bol = 0

while true
set sprite x scale 128,bol
set sprite y scale 128,bol
sprite 128,300,300,0
draw frame



bol = bol - 1
wend[b/]

and it gets bigger,

Stephen,

02-21-2004 14:57

Posted by:
MapMaker

Location:
Edmonton, Alberta (Canada)

Click Here to Email MapMaker   Find more posts by MapMaker

quote:

Sure there is. Just use a scaling factor less than one.



What eekaydee said is true. The scaling factor has to be smaller than 1.

In your code, the scaling factor goes like this:


0,-1,-2,-3 ...


I think that is also has to be bigger than 0.

That would require you to modify your code like the following:


graphics mode hardware 1024,768
load images 128

float bol = 1

while true and bol > 0
set sprite x scale 128,bol
set sprite y scale 128,bol
sprite 128,300,300,0
draw frame

bol = bol - 0.1
wend


This would the scale levels:


1,0.9,0.8,0.7,0.6.....

down to 0.1

I think this is how its done.

Hope this helps,
MapMaker

02-21-2004 15:38

Posted by:
Stephen Lund

Location:
Michigan USA

Click Here to Email Stephen Lund   Find more posts by Stephen Lund

Thanks

Thanks that helped a lot.

Stephen

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.