forums

TNT Basic Forums > Programming Q&A
machine gun
< Last Thread     Next Thread >
Author
Thread        Post A Reply

03-26-2003 19:15

Posted by:
puffin

Click Here to Email puffin   Find more posts by puffin

i need to make a gun fire repeatadly like a machine gun, here is the code i'm working on:

while mouse button
sprite 0, 400, 300, 0
repeat
move sprite 0, xdist , ydist , 20
draw frame
until mouse button = false
wend

seems like it should work to me, but it dosn't. any explainations?

03-26-2003 21:47

Posted by:
Machi

Click Here to Email Machi   Find more posts by Machi

It would seem to me that your tight little loop here is probably flying along at a reasonably high frame rate, which means that you are constantly overwriting the sprite (ie repositioning it) too fast for you to see any movement.

You are not giving the sprite time to move before you execute another sprite operation.

Regards,
Mark

03-27-2003 00:35

Posted by:
Machi

Click Here to Email Machi   Find more posts by Machi

Okay - forget my previous post, I didn't look closely enough

1) You only have one sprite, I'm assuming that you want a stream of bullets which requires a bunch of sprites. using an array for the sprite number and looping through the array value would generate multiple sprites.

2) Once you take your finger of the mouse button, you stop drawing frames, which means that the screen is going to freeze with the bullet wherever it was when you took your finger off

03-27-2003 18:23

Posted by:
puffin

Click Here to Email puffin   Find more posts by puffin

thanks

thanks for your advise. i played with the code a little bit to prevent the program from stopping when i let of the mouse button and accidentally found i could get the effect i'm looking for by just making the bullet move faster, so i only need one sprite. no bullet will follow on the heals of another, but it behaves like i want.

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.