forums

TNT Basic Forums > Programming Q&A
10.3 game
< Last Thread     Next Thread >
Author
Thread        Post A Reply

12-17-2003 19:57

Posted by:
charlie

Location:
norfolk, england

Click Here to Email charlie   Find more posts by charlie

this may not be the right forum for this one but here goes

the following little game worked perfectly in 10.2 and now just crashes tnt completely in 10.3

assuming that others have had similar problems, can any body identify a problem with the following code

graphics mode 800,600

load images 128

'load sounds 128
'load music 128
'play music
set framerate max

hide mouse


global int bgx[200],bgy[200],i,init=true,n
global int bgx2[150],bgy2[150],o,m
global int bgx3[100],bgy3[100],u,b
global int bgx4[100],bgy4[100],y,v
global int shipx=100,shipy=300,shipy2=300,shipx2=100
global int speed=7,lives=5,game=false,points=0,expl=3,bullettime=0
global int mx[20],my[20],mexists[20],loop,loop2,time=0,shooting=false
global int bx[30],by[30],bexists[30],men[30],q,a,spaceup=true,coll=false,z

while not space

bullettime=bullettime+1


starfield()
drawplayer()
meteorites(a)
rules()
if bullettime=2 'and spaceup=true
repeat
q=random(0,29)
until bexists[q]=false
bexists[q]=true
bx[q]=shipx
by[q]=shipy
spaceup=false
bullettime=0
end if
if not bullettime=5 then spaceup=true and bullettime=0



draw frame
wend
procedure starfield()

set pen colour black
paint canvas
if init =true
for i = 0 to 50
bgx=random (0,800)
bgy=random(0,600)
next
for o = 0 to 40
bgx2[o]=random (0,800)
bgy2[o]=random(0,600)
next
for u = 0 to 30
bgx3=random (0,800)
bgy3=random(0,600)
next
for y = 0 to 10
bgx4[y]=random (0,800)
bgy4[y]=random(0,600)
next
init=false
end if
for n=0 to 50
set pen colour blue
fill rect bgx[n]-1,bgy[n]-1 to bgx[n]+3,bgy[n]+3
set pen colour white
fill rect bgx[n],bgy[n] to bgx[n]+2,bgy[n]+2
bgx[n]=bgx[n]-8
if bgx[n]<0 then bgx[n]=810
next
for m=0 to 40
set pen colour blue
fill rect bgx2[m]-1,bgy2[m]-1 to bgx2[m]+4,bgy2[m]+4
set pen colour white
fill rect bgx2[m],bgy2[m] to bgx2[m]+3,bgy2[m]+3
bgx2[m]=bgx2[m]-12
if bgx2[m]<0 then bgx2[m]=810
next
for v=0 to 10
set pen colour blue
fill rect bgx4[v]-1,bgy4[v]-1 to bgx4[v]+6,bgy4[v]+6
set pen colour white
fill rect bgx4[v],bgy4[v] to bgx4[v]+5,bgy4[v]+5
bgx4[v]=bgx4[v]-25
if bgx4[v]<0 then bgx4[v]=810
next
for b=0 to 30
set pen colour blue
fill rect bgx3-1,bgy3-1 to bgx3+5,bgy3+5
set pen colour white
fill rect bgx3,bgy3 to bgx3+4,bgy3+4
bgx3=bgx3-16
if bgx3<0 then bgx3=810
next
end proc
procedure drawplayer()
sprite 100,shipx,shipy,0
shipx=mouse x
shipy=mouse y
'if up
' shipy=shipy-speed
'end if
'if down
'shipy=shipy+speed
'end if
'if left
'shipx=shipx-speed
'end if
'if right
'shipx=shipx+speed
'end if
if shipy>=590 then shipy=590
if shipy<10 then shipy=10
if shipx>=775 then shipx=775
if shipx<26 then shipx=25
end proc
procedure meteorites(int num)
time=time+1
if time =4
repeat
loop=random( 0 , 19)
until mexists[loop]=false
mexists[loop]=true
mx[loop]=850
my[loop]=random(0,700)
men[loop]=random(5 , 20)
time=0
end if
for loop2=0 to 19


if mexists[loop2]=true
mx[loop2]=mx[loop2]-25
sprite loop2,mx[loop2],my[loop2],2
if mx[loop2]<=-100
sprite off loop2
mexists[loop2]=false
end if
end if



for a=0 to 29

if bexists[a]=true
bx[a]=bx[a]+1
sprite a+50,bx[a],by[a]-15,1
if bx[a]>800
sprite off a
bexists[a]=false
end if
end if
if sprite col(a+50,loop2)=loop2
points=points+10
bexists[a]=false
sprite off a+50
men[loop2]=men[loop2]-1
if men[loop2]=0
''play sound(0)
mexists[loop2]=false
sprite off loop2
points=points+50
end if

end if
next

if sprite col (100,loop2)=loop2
lives=lives-1
'play sound(1)
mexists[loop2]=false
sprite off loop2
end if

set pen colour red
draw text mx[loop2]-5,my[loop2],as string (men[loop2])

next

end proc
procedure rules()
if lives<=0 then game=true
if game=true
set pen colour red
text size 100
draw text 150,150,"Game Over"
draw text 20,400,"score"
draw text 350,400,as string (points)
draw frame

wait mouse click
end
end if
set pen colour black
fill rect 0,0 to 200,50
set pen colour white
draw text 10,10,"lives"
draw text 50,10,as string (lives)
draw text 100,10,"score"
draw text 150,10,as string (points)
end proc

i remmed out sounds and music, youll need 3 sprites for a ship,meteor and bullets

its just a simple game i wrote a while back and it worked fine then, i havent changed the code at all

is it me?

or is this another 10.3 issue like the flickering graphics in some of my other projects?

thanks
charlie

12-17-2003 20:05

Posted by:
charlie

Location:
norfolk, england

Click Here to Email charlie   Find more posts by charlie

oh yes i forgot about that!

you will need to add some square bracketed i , u and b in the loops

id forgotten about the USEFULL/LESS MARKUP CODES

CHEERS
CHARLIE

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.