forums

TNT Basic Forums > Programming Q&A
move sprites
< Last Thread     Next Thread >
Author
Thread        Post A Reply

11-04-2003 03:58

Posted by:
Dalek

Find more posts by Dalek

could someone tell me how to move sprites with the keyboard like say press left to move the sprite left. Am supposed to use ifs or something? I know it's probably obvious but I just don't know what to type. help
thanks

11-04-2003 06:09

Posted by:
eekaydee

Location:
CA, USA

Click Here to Email eekaydee   Find more posts by eekaydee

Yes, use if statements and variables:

quote:
repeat
if right then x=x+1
if left then x=x-1
if up then y=y+1
if down then y=y-1
sprite 0,x,y,image
draw frame
until mouse button


If you want you can take a look at my shooting example

11-05-2003 16:43

Posted by:
Shinigami

Location:
France

Click Here to Email Shinigami   Find more posts by Shinigami

So his procedure move the sprite. Me I have used an ohter solution. but I try you're method eekayde.

11-07-2003 02:04

Posted by:
Dalek

Find more posts by Dalek

I don't want to keep asking these questions but it says that identifiers x and y haven't been declared. How do I use them as the x and y of the sprite I want to move? Please help, I'm a begginer.

11-07-2003 05:33

Posted by:
eekaydee

Location:
CA, USA

Click Here to Email eekaydee   Find more posts by eekaydee

Oh, you have to declare x and y as variables.
Variables can be almost anything without a space and that isn't a command; ie. "x", "jeff", and "ThisCountsAsAVariable12121" are all valid variable names.
Variables are delcared as either:

integers, which hold non decimal numbers-

quote:
int x


strings, which are pieces of text-
quote:
str x


and floats, which can be any decimal number-
quote:
float x


So what you must do is add this somewhere before you use x and y:
quote:
int x
int y


Check the tutorials and examples that come with TNT.

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.