forums

TNT Basic Forums > Bugs!
Move sprite..speed
< Last Thread     Next Thread >
Author
Thread        Post A Reply

12-17-2007 16:52

Posted by:
Maxime

Location:
Paris France

Find more posts by Maxime

I can't succed in using that command, like in :


graphics mode hardware 640,480 ' switch to graphics mode
load images 128 ' load images of bank 128
Set Pen colour Make Colour( 0,120,30) : Paint Canvas 'green canvas
int speed=500
sprite 1, 200,200,1 'sprite to move
sprite 2, 200,200,1 'to mark the start place
draw frame

'while sprite moving (1)
Move Sprite 1,100,100,speed
draw frame
'wend

beep
wait mouse click
end

I tried with the while or without. The sprite moves in one time speed pixels (if speed<100), and that's all.
If I change the speed for 300 or anything above 100, it moves 100.
I tried in window mode or in not hardware mode with the same result,
What is wrong ?
I searched in examples, and every moving thing manages the moves with some dx, dy, never with "Move".
Thanks to help (or to tell me to use anything else...)

12-17-2007 16:58

Posted by:
Maxime

Location:
Paris France

Find more posts by Maxime

while loop

Sorry, the while loop above is stupid : it tests before launching !
Anyway, it should work without, I believe...

12-18-2007 11:41

Posted by:
allnodcoms

Location:
hertfordshire (England)

Click Here to Email allnodcoms   Find more posts by allnodcoms

You got that a bit wrong...

Try "Move Sprite 1, 100, 100, 1"...


The '1' is the sprite you are moving, the two '100's are how far it will move IN TOTAL, and the last number ('1' above) is how many pixels to move IN ONE FRAME of animation. In your example it will jump 100 pixels and stop, because that's what you've told it to do.

The Move Sprite command is a part of the MOAN subsystem (something I've never really got round to using) and is best suited to moving things that will just carry on doing the same thing, alien attack waves in a SEU for example. If you want finer control over where you want your sprites, if you want to control them with the mouse / keyboard etc. then just use 'Sprite spriteID, x, y, img', it gives you far more scope when it comes to placement.

Hope that helps...

Danny (nod the mod)

12-18-2007 12:05

Posted by:
Maxime

Location:
Paris France

Find more posts by Maxime

sprite move

Thanks Danny
I quite agree and understand what you say (I think), which I read of course in the book. But, if "1" is the number of pixels per frame, how do you explain it will jump directly 100,100 (my frame rate is 89, it would last around 1,3 seconds ?). I should see intermediate positions, I wanted the sprite to slide, not to change position abruptly !
Secondly, as "1" is rather fast (if it worked), is it possible to go slower than 1, for instance 0.1 ?
Third : I have already implemented as you say, managing myself the x,y, but it is sad not to use move which seems built for that.

Maxime

12-18-2007 12:09

Posted by:
Maxime

Location:
Paris France

Find more posts by Maxime

Sorry, some precision : Evidently, in the piece of code I sent, I used all possible values of speed, especially "1", not only 500 which was my last try before I copied the code. But it always jumps.

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.