forums

TNT Basic Forums > Games In Progress
Get things kicking...
< Last Thread     Next Thread >
Author
Thread        Post A Reply

09-19-2006 13:05

Posted by:
appleide

Click Here to Email appleide   Find more posts by appleide

Source code of my first TNT basic in 15 minutes:
apostrophes indicate comments. I plan to expand this to some sort of space invaders. maybe someone could give me advice on how to improve this... There are 4 images (get them yourself!), a robot, a player character, a bullet, and a explosion. All into the same bank.
128 is pc
129 is bullet
130 is robot
131 is explosion

image bank 129:
000 is player
001 is robot
002 is explosion
003 is bullet





window mode 640,480

load images 129
int x=0
int y=0
int bulletx=0
int bullety=0
int endgame=0
int bulletfired=0
int robotx=320
int roboty=100
int robotmove=1

sprite 130,640,100,001

while endgame=0
x=mouse x
y=mouse y
sprite 128,x,y,0
'move player character to whereever the mouse goes.

if robotmove=1
robotx=robotx+random(-10,10)
roboty=roboty+random(-10,10)
sprite 130,robotx,roboty,001
end if
'sets robot into random movement

if robotx<0
robotx=320
end if
if roboty<0
roboty=100
end if
if robotx>640
robotx=320
end if
if roboty>480
roboty=100
end if
'if he goes off the edge, put him back
if mouse button
if bulletfired=0
bulletfired=1
bulletx=x
bullety=y
sprite 129,bulletx,bullety,003
end if
end if
'when mousebutton is hit, put sprite of frost attack on player character



'######################Problems with this part######################
if bulletx>=robotx
if bulletx<=robotx+20
if bullety>=roboty
if bullety<=roboty+20
sprite off 130
robotmove=0
sprite 131,robotx,roboty,002
end if
end if
end if
end if
'if sprite col rect (129,robotx,roboty to robotx+20,roboty+20)
'sprite off 130
'sprite 130,500,50,001
'end if
'if bullet collides with robot, kill him
'######################'######################'######################



if bulletfired=1
bulletx=bulletx
bullety=bullety-5
sprite 129,bulletx,bullety,003
end if
'if there is a bullet on the field, move it upwards.


if bullety<0
bulletfired=0
sprite off 129
end if
'when bullet reaches edge, delete it, also restore variables so that the game knows bullet not on field

draw frame
'draws frame
if mouse x=0
if mouse y=0
endgame=1
end if
end if
'when mouse is on corner, quit
wend

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.