forums

TNT Basic Forums > Programming Q&A
Vocab Invaders
< Last Thread     Next Thread >
Author
Thread        Post A Reply

10-24-2008 13:15

Posted by:
Roboman

Location:
Long Beach, CA

Click Here to Email Roboman   Find more posts by Roboman

I'm making this game for a school project, for vocabulary practice. However, when I try to run it, it doesn't do anything. Each section of the code works, and the syntax is good, but for some reason, TNT Basic starts up, but the console doesn't show up.

10-24-2008 13:22

Posted by:
Roboman

Location:
Long Beach, CA

Click Here to Email Roboman   Find more posts by Roboman

Here is the source code.

int bankNumber
int x = 500
int y = 0
int x2
int y2
int coordx
int coordy
int time=0
float sprite1
float sprite2
int bool
int blastx=x
int blasty=y
int bool2
int q
int w


w=0
q=0
blastx=x
blasty=y
activate input

delay 200

print "line 27"

hide mouse

load images 128

Main:
graphics mode 1024, 768
load images 128
x2=x2+20
repeat
coordx=mouse x
coordy=mouse y
bool=pressed (49)
if bool=1
goto shoot
end if
set image bank 1, 128
sprite 1,x2,y2,1
y2=y2+1
set image bank 0, 128
sprite 0,x,y,0
draw frame
delay 10
x=coordx
y=coordy
time=time+1
sprite1=sprite col (0,1)
if sprite1 <> -1
sprite off 0
draw frame
delay 1000
time = 1001
end if
while time<1000
wend
print "Game Over!"
goto ending

shoot:
repeat
set image bank 1, 128
sprite 1,x2,y2,1
y2=y2+1
set image bank 0, 128
sprite 0,x,y,0
draw frame
delay 10
x=coordx
y=coordy
time=time+1
sprite1=sprite col (0,1)
if sprite1 <> -1
sprite off 0
draw frame
delay 1000
time = 1000
end if
set image bank 2, 128
sprite 2,blastx,blasty,2
draw frame
blastx=x2
blasty=y2
sprite2=sprite col (2,1)
if sprite2 <> -1
sprite off 1
sprite off 2
delay 1000
goto quiz
end if
until time=1000
print "Game Over"


quiz:
text mode
repeat
q=q+1
if q=1
goto q1
else if q=2
goto q2
else if q=3
goto q3
else if q=4
goto q4
else if q=5
goto q5
else if q=6
goto q6
else if q=7
goto q7
else if q=8
goto q8
else if q=9
goto q9
else if q=10
goto q10
else if q=11
goto q11
else if q=12
goto q12
else if q=13
goto q13
else if q=14
goto q14
else if q=15
goto q15
else if q=16
goto q16
else if q=17
goto q17
else if q=18
goto q18
else if q=19
goto q19
else if q=20
goto q20
else if q=21
goto q21
else if q=22
goto q22
else if q=23
goto q23
else if q=24
goto q24
else if q=25
goto q25
else if q=26
goto q26
else if q=27
goto q27
else if q=28
goto q28
else if q=29
goto q29
else if q=30
goto tally
else
print "error line 166"
end if
while q < 30
wend

q1:
Print "1. Atoms are the basic building blocks of matter."
Print "A. True"
Print "B. False"
repeat
bool=pressed (0)
bool2=pressed (11)
if bool=1
print "correct :)"
goto main
else if bool2=1
w=w+1
print "incorrect :("
goto main
end if
forever


q2:
Print "2. Protons are neutrally charged."
Print "A. True"
Print "B. False"
repeat
bool=pressed (0)
bool2=pressed (11)
if bool2=1
print "correct :)"
goto main
else if bool=1
w=w+1
print "incorrect :("
goto main
end if
forever


q3:
Print "3. Neutrons are neutrally charged."
Print "A. True"
Print "B. False"
repeat
bool=pressed (0)
bool2=pressed (11)
if bool2=1
print "correct :)"
goto main
else if bool=1
w=w+1
print "incorrect :("
goto main
end if
forever


q4:
Print "4. Electrons ore found on energy levels around the nucleus"
Print "A. True"
Print "B. False"
repeat
bool=pressed (0)
bool2=pressed (11)
if bool=1
print "correct :)"
goto main
else if bool2=1
w=w+1
print "incorrect :("
goto main
end if
forever


q5:
Print "5. The nucleus is the least dense part of an atom."
Print "A. True"
Print "B. False"
repeat
bool=pressed (0)
bool2=pressed (11)
if bool2=1
print "correct :)"
goto main
else if bool=1
w=w+1
print "incorrect :("
goto main
end if
forever


q6:
Print "6. Mass is the measure of the amount of space a given amount of matter occupies at any given point of time."
Print "A. True"
Print "B. False"
repeat
clear keyboard
bool=pressed (0)
bool2=pressed (11)
if bool=1
print "correct :)"
goto main
else if bool2=1
w=w+1
print "incorrect :("
goto main
end if
forever

q7:
Print "7. Matter is made of atoms."
Print "A. True"
Print "B. False"
repeat
clear keyboard
bool=pressed (0)
bool2=pressed (11)
if bool=1
print "correct :)"
goto main
else if bool2=1
w=w+1
print "incorrect :("
goto main
end if
forever

q8:
Print "8. Elements make up energy."
Print "A. True"
Print "B. False"
repeat
clear keyboard
bool=pressed (0)
bool2=pressed (11)
if bool2=1
print "correct :)"
goto main
else if bool=1
w=w+1
print "incorrect :("
goto main
end if
forever

q9:
Print "9. The atomic is the number of protons in an atom."
Print "A. True"
Print "B. False"
repeat
clear keyboard
bool=pressed (0)
bool2=pressed (11)
if bool=1
print "correct :)"
goto main
else if bool2=1
w=w+1
print "incorrect :("
goto main
end if
forever

q10:
Print "10. The mass number/atomic mass is the sum of the protons and neutrons in an atom's nucleus."
Print "A. True"
Print "B. False"
repeat
clear keyboard
bool=pressed (0)
bool2=pressed (11)
if bool=1
print "correct :)"
goto main
else if bool2=1
w=w+1
print "incorrect :("
goto main
end if
forever

q11:
Print "11. Isotope is just a fancy word for element."
Print "A. True"
Print "B. False"
repeat
clear keyboard
bool=pressed (0)
bool2=pressed (11)
if bool2=1
print "correct :)"
goto main
else if bool=1
w=w+1
print "incorrect :("
goto main
end if
forever

q12:
Print "12. Properties aren't the physical and chemical characteristics of an element."
Print "A. True"
Print "B. False"
repeat
clear keyboard
bool=pressed (0)
bool2=pressed (11)
if bool2=1
print "correct :)"
goto main
else if bool=1
w=w+1
print "incorrect :("
goto main
end if
forever


q13:
Print "13. Periods are the rows on the periodic table of elements."
Print "A. True"
Print "B. False"
repeat
clear keyboard
bool=pressed (0)
bool2=pressed (11)
if bool=1
print "correct :)"
goto main
else if bool2=1
w=w+1
print "incorrect :("
goto main
end if
forever

q14:
Print "14. Groups are the columns on the periodic table."
Print "A. True"
Print "B. False"
repeat
clear keyboard
bool=pressed (0)
bool2=pressed (11)
if bool=1
print "correct :)"
goto main
else if bool2=1
w=w+1
print "incorrect :("
goto main
end if
forever

q15:
print "15. Metals aren't malleable."
Print "A. True"
Print "B. False"
repeat
clear keyboard
bool=pressed (0)
bool2=pressed (11)
if bool2=1
print "correct :)"
goto main
else if bool=1
w=w+1
print "incorrect :("
goto main
end if
forever

q16:
print "16. Noble gases are ductile."
Print "A. True"
Print "B. False"
repeat
clear keyboard
bool=pressed (0)
bool2=pressed (11)
if bool2=1
print "correct :)"
goto main
else if bool=1
w=w+1
print "incorrect :("
goto main
end if
forever

q17:
Print "17. Nonmetals have luster."
Print "A. True"
Print "B. False"
repeat
clear keyboard
bool=pressed (0)
bool2=pressed (11)
if bool2=1
print "correct :)"
goto main
else if bool=1
w=w+1
print "incorrect :("
goto main
end if
forever

q18:
Print "18. Metals conduct heat and electricity"
Print "A. True"
Print "B. False"
repeat
clear keyboard
bool=pressed (0)
bool2=pressed (11)
if bool=1
print "correct :)"
goto main
else if bool2=1
w=w+1
print "incorrect :("
goto main
end if
forever

q19:
Print "19. Noble gases are inert."
Print "A. True"
Print "B. False"
repeat
clear keyboard
bool=pressed (0)
bool2=pressed (11)
if bool=1
print "correct :)"
goto main
else if bool2=1
w=w+1
print "incorrect :("
goto main
end if
forever

q20:
Print "20. Valence electrons are on the innermost energy level."
Print "A. True"
Print "B. False"
repeat
clear keyboard
bool=pressed (0)
bool2=pressed (11)
if bool2=1
print "correct :)"
goto main
else if bool=1
w=w+1
print "incorrect :("
goto main
end if
forever

q21:
Print "21. Radioactive decay is when bacteria eat away at a radioactive element."
Print "A. True"
Print "B. False"
repeat
clear keyboard
bool=pressed (0)
bool2=pressed (11)
if bool2=1
print "correct :)"
goto main
else if bool=1
w=w+1
print "incorrect :("
goto main
end if
forever

q22:
Print "22. Radioactive elements transmit sounds that can be heard with radios."
Print "A. True"
Print "B. False"
repeat
clear keyboard
bool=pressed (0)
bool2=pressed (11)
if bool2=1
print "correct :)"
goto main
else if bool=1
w=w+1
print "incorrect :("
goto main
end if
forever

q23:
Print "23. Physical properties include the reactivity of an element."
Print "A. True"
Print "B. False"
repeat
clear keyboard
bool=pressed (0)
bool2=pressed (11)
if bool2=1
print "correct :)"
goto main
else if bool=1
w=w+1
print "incorrect :("
goto main
end if
forever

q24:
Print "24. Physical change is when an atom's physical properties are altered."
Print "A. True"
Print "B. False"
repeat
clear keyboard
bool=pressed (0)
bool2=pressed (11)
if bool=1
print "correct :)"
goto main
else if bool2=1
w=w+1
print "incorrect :("
goto main
end if
forever

q25:
Print "25. Bohr created the modern atomic model."
Print "A. True"
Print "B. False"
repeat
clear keyboard
bool=pressed (0)
bool2=pressed (11)
if bool=1
print "correct :)"
goto main
else if bool2=1
w=w+1
print "incorrect :("
goto main
end if
forever

q26:
Print "26. Nonmetals aren't brittle."
Print "A. True"
Print "B. False"
repeat
clear keyboard
bool=pressed (0)
bool2=pressed (11)
if bool2=1
print "correct :)"
goto main
else if bool=1
w=w+1
print "incorrect :("
goto main
end if
forever

q27:
Print "27. Metals are metallic."
Print "A. True"
Print "B. False"
repeat
clear keyboard
bool=pressed (0)
bool2=pressed (11)
if bool=1
print "correct :)"
goto main
else if bool2=1
w=w+1
print "incorrect :("
goto main
end if
forever

q28:
Print "28. Inert elements don't react with anything."
Print "A. True"
Print "B. False"
repeat
clear keyboard
bool=pressed (0)
bool2=pressed (11)
if bool=1
print "correct :)"
goto main
else if bool2=1
w=w+1
print "incorrect :("
goto main
end if
forever

q29:
Print "29. The Lanthanide series includes rare-earth elements."
Print "A. True"
Print "B. False"
repeat
clear keyboard
bool=pressed (0)
bool2=pressed (11)
if bool=1
print "correct :)"
goto main
else if bool2=1
w=w+1
print "incorrect :("
goto main
end if
forever

tally:
Text mode
Print w
Print "incorrect"
goto ending


ending:
end

10-25-2008 01:02

Posted by:
JHVipond

Location:
South Dakota

Find more posts by JHVipond

I don't know why the console doesn't appear when you start TNT Basic, but I do have a suggestion. Consider having the program read your true-false questions from an external data file.

10-25-2008 18:04

Posted by:
Harbinger

Location:
Florida,USA

Click Here to Email Harbinger   Find more posts by Harbinger

I see that you are loading image bank 128 twice....

How big is your image files? I found for very large image banks it takes forever to load them, and it may even be crashing if TNT has not reserved memory for it. Put in a progress bar or something to let you know where it gets to. I see you have an indicator to let you know if it reaches "line 27". Do that for more lines.

You may have to strip it down to the bare minimum to see what's being processed. But unusually long delays are graphics vs memory.

What OS and CPU speed are you using, in your response...

10-25-2008 20:22

Posted by:
swagIT

Location:
Great Wet North (Vancouver)

Find more posts by swagIT

I think the problem is with the all the 'goto' and 'forever' statements.......

Try using 'procedures' instead of all the 'goto' and 'markers:'

cheers

barry

10-26-2008 11:10

Posted by:
appleide

Click Here to Email appleide   Find more posts by appleide

yes, gotos are evil.

10-26-2008 20:44

Posted by:
Roboman

Location:
Long Beach, CA

Click Here to Email Roboman   Find more posts by Roboman

I've got a 2003 iBook G4 running a 1.05 gHz PowerPC G4 processor. Mac OSX 10.3.9 w/ 512mb of ram.

I stripped it down to text-only, and that seems to work fine. When I was testing the graphics only, they worked fine, until I added the "Quiz" routine. I've only got three sprites in image bank 128, so it shouldn't slow it down at all.

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.