forums

TNT Basic Forums > Programming Q&A
Sprite Help!
< Last Thread     Next Thread >
Author
Thread        Post A Reply

06-14-2003 05:29

Posted by:
wheehah

Click Here to Email wheehah   Find more posts by wheehah

How do I make a sprite go diagonally?
For example, if I wanted a sprite to go diagonally up left by holding down up and left how would I do it?

06-14-2003 12:00

Posted by:
Kevin Harms

Click Here to Email Kevin Harms   Find more posts by Kevin Harms


if Up

06-14-2003 12:02

Posted by:
Kevin Harms

Click Here to Email Kevin Harms   Find more posts by Kevin Harms

if Up
y = y - 1
end if

if Left
x = x - 1
end if

if Down
y = y + 1
end if

if Right
x = x + 1
end if

06-14-2003 14:17

Posted by:
someone

Location:
Quebec ( Canada )

Click Here to Email someone   Find more posts by someone

the sprite command is

sprite id,x,y,image

so you can specify the x and y coords so that they go diagonnaly.

06-15-2003 05:45

Posted by:
wheehah

Click Here to Email wheehah   Find more posts by wheehah

yeah, I know that, but how do I make it go diagonally by holding down two buttons at the same time?

06-15-2003 13:24

Posted by:
someone

Location:
Quebec ( Canada )

Click Here to Email someone   Find more posts by someone

Look at Kevin Harms' second reply

06-16-2003 00:46

Posted by:
anoved

Location:
Upstate NY

Find more posts by anoved

wheehah, what they're trying to explain is that since you can change the x and y position of the sprite independently, you can make it move diagonally by changing both values an appropriate amount (ie, x + 1 and y + 1 will cause the point x,y to move diagonally down and to the right). Therefore if you only change one value (for instance, if only one directional key is down) then the sprite will only move in that one direction.

Does that make sense?

06-16-2003 09:47

Posted by:
wheehah

Click Here to Email wheehah   Find more posts by wheehah

Yeah, I know that, but how do you get it to work HOLDING DOWN TWO BUTTONS AT THE SAME TIME?
Something like

If Down,Right
x=x+1, y=y+1

?

06-16-2003 13:18

Posted by:
mark_667

Location:
England

Click Here to Email mark_667   Find more posts by mark_667

Why do you need to do keypress combinations to get the sprite to move in two directions at once? I thought that if TNT detected two keys been pressed at the same time, it would execute the commands for both simultaeniously making the sprite move to the top-left, or whatever anyway.

06-16-2003 13:52

Posted by:
matteo

Location:
Venice, ITALY!

Click Here to Email matteo   Find more posts by matteo

yeah, TNT works logically:

You are pressing down? then y=y+1

You are pressing right? then x=x+1

You are doing both? then both effects are applied.

06-16-2003 22:15

Posted by:
someone

Location:
Quebec ( Canada )

Click Here to Email someone   Find more posts by someone

And in the case you want your sprite to muse only diagonnaly, use:

if up and right then ...

not

if up,right then ...

The boolean operators are AND,OR,NOT

e.g :
if not(pressed(2)) then actionWhenKeyIsUp()
if ( pressed(2) or pressed(3) ) actionWhenOneOrTwoKeysArePressed
if ( ( pressed(2) or pressed(3)) and not ( pressed(2) and presse(3) ) actionWhenOneKeyOnlyIsPressed

you do not have to use parenthesis but you do do so, otherwise the computer may not intepretit it as you exepected

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.