forums

TNT Basic Forums > Programming Q&A
Horribly dumb question, but...
< Last Thread     Next Thread >
Author
Thread        Post A Reply

11-07-2009 06:15

Posted by:
Jimm

Location:
Winnipeg, MB

Click Here to Email Jimm   Find more posts by Jimm

I'm really new to this, and all I really want to do is have a sprite move around when I press keys. No frills or directional changes, just simple motion. What would be the easiest way for me to be able to do this?

11-07-2009 09:10

Posted by:
allnodcoms

Location:
hertfordshire (England)

Click Here to Email allnodcoms   Find more posts by allnodcoms

Not a dumb question at all...

...that's why we're here, and Welcome to the boards ;)

First place to look is the 'Learning Zone'. Have a quick read of the Introduction Tutorials on Programming, Input and Sprites.
Taking the Quick Tour of the editor environment might be a good idea as well...

In some sort of order:
You need to draw your sprite and get it into your project -The Quick Tour will help here.
Set the Graphics Mode of your program.
You then load the Sprite - Sprite Tutorial
Set Variables to hold the Sprite position - Programming Tutorial (and see below)
Display it - Sprite
Create a 'Loop' to continually redraw the image - Programming
Inside the loop, check the state of the directional keys - Input
If a direction key is pressed then move the sprite...

To move the sprite you just need to change its X and Y coordinates then redraw it. Screen coordinates indicate a position on screen, X indicates how far across the screen a point is with 0 (zero) being far left. The higher the number the further right the point. Y is how far down the screen it is with 0 being at the top.
So to move your sprite:
Left: Decrease X
Right: Increase X
Up: Decrease Y
Down: Increase Y

That should help you along your way, have a little play with that and if you get stuck just let us know.
Understanding the logical steps behind the problem, then finding how to implement those steps in TNT is the best way to learn.

Good luck and enjoy TNTBasic

Danny (nod the mod)

11-07-2009 17:40

Posted by:
Jimm

Location:
Winnipeg, MB

Click Here to Email Jimm   Find more posts by Jimm

Thanks!

Thank you very much! With your help I was able to get my sprite to move. I think I was doing something incorrect with a "then" statement. What is the syntax for using "then?"

11-07-2009 22:22

Posted by:
allnodcoms

Location:
hertfordshire (England)

Click Here to Email allnodcoms   Find more posts by allnodcoms

AHA! You spotted our deliberate mistake!

OK, that's bizarre... I've been board moderator now for a few years, and I've never noticed that there is no documentation for 'then'...

OK, here it is, the official documentation for the 'then' keyword:

The 'then' keyword is only required when the 'if' statement occupies a single line of code. For example:

if a>b then myProc()

The procedure 'myProc' is called if a is greater than b. Note that there is no 'end if', the end of the line of code marks the end of the 'if' construct.

For compound statements which span multiple lines, 'then' is omitted and 'end if' is used to mark the end of the construct:

if a>b
myProc()
myProc2() 'not very imaginative I know, but it's getting late...
end if


Single LIne: then, but no end if
Multi Line: end if, but no then

Hope that clears things up for you, glad I could help out with the sprite problem - and thanks for pointing out our 'deliberate mistake'!

Danny (nod the mod)

11-08-2009 06:56

Posted by:
Jimm

Location:
Winnipeg, MB

Click Here to Email Jimm   Find more posts by Jimm

Glad to be helpful ;)

Another problem I'm having is with music files... as of this writing I've only been able to import a single .xm file, and it doesn't even seem to be a "normal" .xm file (whatever that means... it's confusing, lol). Mp3 files and other formats simply do not work. I can import most files into the Sound section just fine, but when trying for music I get the following error message:

The file xxx.mp3 cannot be imported.
No error description available for error code -10.

Signal raised.
hr_ApproveResCreatorEditorSessMultiple() - null info handle passed, bailing...
File : Hieroglyph Res Creators.cpp
Line : 89

Any idea what that means? :S

11-08-2009 07:40

Posted by:
allnodcoms

Location:
hertfordshire (England)

Click Here to Email allnodcoms   Find more posts by allnodcoms

Morning Jimm

Can you let me know what version of the OS you are running, and are you on PPC or Intel? Your Quicktime version would help to...

TNT runs under Rosetta on Intel Macs, and while this works fine for most things we have had a few issues with QT updates breaking things. I'm currently heading a team of three who are re-writing TNT from the ground up. Progress has been slow due to other work commitments etc, but we are looking to get something out there soon.

I'll take a look at the source and see if I can see why this is happening, but in the meantime you might like to check out the Bugs Board: TNT 1.3 has been around a while now, and most bugs have been nailed down and solved. This post looks pretty similar and may be worth a look.

Danny (nod the mod)

11-08-2009 17:23

Posted by:
Jimm

Location:
Winnipeg, MB

Click Here to Email Jimm   Find more posts by Jimm

Morning! :)

I'm running Mac OS X 10.5.8 on an intel mac, with quicktime 7.6.4.

Hope that helps!

11-08-2009 20:47

Posted by:
allnodcoms

Location:
hertfordshire (England)

Click Here to Email allnodcoms   Find more posts by allnodcoms

Evening!

No, not all... I'm just really nosey! ;)

Danny (nod the mod)

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.