forums

TNT Basic Forums > Programming Q&A
Getting a sprite to shoot
< Last Thread     Next Thread >
Author
Thread        Post A Reply

06-29-2003 10:13

Posted by:
wheehah

Click Here to Email wheehah   Find more posts by wheehah

How do I get a sprite to shoot adding to the code I already have? say if the bullet was in sprite bank 129

graphics mode 800,600 'sets graphics mode

int x,y

set pen colour green 'sets background colour
fill rect 0,0 to 800,600

while not mouse button
hide mouse

load images 128 'loads images
sprite 128,x,y,0 'sets position of sprite
draw frame

if pressed (124) 'input
x=x+15
else if pressed (125)
y=y+15
else if pressed (123)
x=x-15
else if pressed (126)
y=y-15
draw frame
end if 'end input

draw frame

wend

06-29-2003 15:50

Posted by:
mark_667

Location:
England

Click Here to Email mark_667   Find more posts by mark_667

Ooh, dear! You'll never make a game with just that, oh well to get you started, have a look at the post:

http://www.tntbasic.com/community/forums/showthread.php?threadid=515

Hope this helps,
Mark_667

06-30-2003 05:15

Posted by:
wheehah

Click Here to Email wheehah   Find more posts by wheehah

quote:
Ooh, dear! You'll never make a game with just that


thanks for the encouragement.

still a bit hard to comprehend, but I'm working on it.

06-30-2003 14:33

Posted by:
someone

Location:
Quebec ( Canada )

Click Here to Email someone   Find more posts by someone

It's always difficult in programmation to start. I remember the first game I created in Game Maker... I worked 45 minutes to debugg a script that would play a sound every 15 seconds :) The best tip is: don't try to do more than you are able to and take another's code, and put comments on everyline, this helps a lot in comprehending how a code is made.

07-03-2003 05:54

Posted by:
Freefall

Click Here to Email Freefall   Find more posts by Freefall

Also, just as a part of good programming you should always assign a value to any integers you declare, for instance:

int x,y

x = 0
y = 0

Or else you may end up getting a int you declared, but because you never specified a number, the computer will do it for you. Occasionally, it will assign it something other than 0, which can cause significant problems.

07-03-2003 07:29

Posted by:
eekaydee

Location:
CA, USA

Click Here to Email eekaydee   Find more posts by eekaydee

you can also initialize the variable with a value when you declare it

int x=0

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.