Hi.
I'm making a tank game.
So, Naturally, I need bullet code.
Here's what I have so far
rem making missiles
make object cube 16,10
make object cube 17,10
color object 16,rgb(255,0,0)
color object 17,rgb(255,0,0)
scale object 16,50,50,100
scale object 17,50,50,100
position object 16,1500,1500,-25
position object 17,1500,1500,-50
if returnkey()
position object 16,object position x(1),object position y(1)+40,object position z(1)
yrotate object 16,object angle y(1)
endif
if returnkey()
position object 16,object position x(1),object position y(1)+40,object position z(1)
yrotate object 16,object angle y(1)
endif
rem missile properties
if object position y(16)=object position y(1)+40 then move object 16,15
if object position y(17)=object position y(2)+40 then move object 17,15
Now, I thought this would work but it doesn't. For some reason when I fire the bullet moves the direction I want it to but when I move my tank at all the bullet just stops and I'm pretty sure I'm using the right axis.
Just in case, here's my entire code.
Rem Project: Tank Arena
Rem Created: 1/18/2007 3:34:29 PM
Rem ***** Main Source File *****
rem basic settings
hide mouse
sync on : sync rate 60
color backdrop rgb(0,0,0)
backdrop off
rem instructions menu and loading prompt
sync
print "Tank Arena: Controls"
print "Player 1 Controls:"
print "num pad 8=forward, num pad 5=reverse, num pad 4=turn left, num pad 6=turn right"
print "Player 2 Controls:"
print "W=forward, S=reverse, A=turn left, D=turn right"
print "Press ESCAPE to exit"
print "Press any key when ready."
sync
disable escapekey
wait key
backdrop on
sync : center text screen width()/2, screen height()/2,"Loading..." : sync
wait 3000
enable escapekey
rem loading media
load object "media\Warrior.x",1 : load object "media\Warrior.x",2 : load object "media\Wood Crate.x",8
load object "media\Wood Crate.x",9 : load object "media\Wood Crate.x",10 : load object "media\Wood Crate.x",11
load object "media\Oil-Drum.x",12 : load object "media\Oil-Drum.x",13 : load object "media\Oil-Drum.x",14
load object "media\Oil-Drum.x",15
load image "media\sandstone_T.bmp",1 : load image "media\bunker.bmp",2
rem making world
make matrix 1,3000,3000,1,1
prepare matrix texture 1,1,1,1
rem making building
make object cube 7,750
texture object 7,2
rem making missiles
make object cube 16,10
make object cube 17,10
color object 16,rgb(255,0,0)
color object 17,rgb(255,0,0)
rem creating boundary lines and collision spheres
make object cube 3,50
make object cube 4,50
make object cube 5,50
make object cube 6,50
hide object 3
hide object 4
hide object 5
hide object 6
make object sphere 18,125
make object sphere 19,125
hide object 18
hide object 19
rem adjusting size and orientation of models
scale object 1,50,50,50
xrotate object 1,-90
yrotate object 1,45
scale object 2,50,50,50
xrotate object 2,-90
yrotate object 2,-135
scale object 3,4800,50,50
scale object 4,4800,50,50
scale object 5,50,50,4800
scale object 6,50,50,4800
scale object 8,500,500,500
scale object 9,500,500,500
scale object 10,500,500,500
scale object 11,500,500,500
scale object 12,250,250,250
xrotate object 12,-90
scale object 13,250,250,250
xrotate object 13,-90
scale object 14,250,250,250
xrotate object 14,-90
scale object 15,250,250,250
xrotate object 15,-90
scale object 16,50,50,100
scale object 17,50,50,100
rem positioning
position object 1,425,0,425
position object 2,2575,0,2575
position object 3,1500,25,300
position object 4,1500,25,2700
position object 5,300,25,1500
position object 6,2700,25,1500
position object 7,1500,350,1500
position object 8,750,100,750
position object 9,2250,100,750
position object 10,750,100,2250
position object 11,2250,100,2250
position object 12,2250,0,1450
position object 13,2300,0,1500
position object 14,2250,0,1550
position object 15,2250,115,1500
position object 16,1500,1500,-25
position object 17,1500,1500,-50
position object 18,object position x(1),object position y(1)+25,object position z(1)
position object 19,object position x(2),object position y(2)+25,object position z(2)
rem making and editing cameras
make camera 1
set camera range 1,1,4000
set camera view 1,0,0,1024,384
set camera aspect 1,1.7
color backdrop 1,rgb(150,150,255)
position camera 1,object position x(1)-300,150,object position z(1)-300
point camera 1,object position x(1),object position y(1),object position z(1)
make camera 2
set camera range 2,1,4000
set camera view 2,0,384,1024,768
set camera aspect 2,1.7
color backdrop 2,rgb(150,150,255)
position camera 2,object position x(2)+300,150,object position z(2)+300
point camera 2,object position x(2),object position y(2),object position z(2)
rem main loop
do
rem setting up player 1 and player 2
Health_1=100
text 0,0,str$(Health_1)
if keystate(72) then move object down 1,5
if keystate(76) then move object up 1,5
if keystate(75) then yrotate object 1,object angle y(1)-2
if keystate(77) then yrotate object 1,object angle y(1)+2
if returnkey()
position object 16,object position x(1),object position y(1)+40,object position z(1)
yrotate object 16,object angle y(1)
endif
position object 18,object position x(1),object position y(1)+25,object position z(1)
Health_2=100
text 0,384,str$(Health_2)
if keystate(17) then move object down 2,5
if keystate(31) then move object up 2,5
if keystate(30) then yrotate object 2,object angle y(2)-2
if keystate(32) then yrotate object 2,object angle y(2)+2
if returnkey()
position object 16,object position x(1),object position y(1)+40,object position z(1)
yrotate object 16,object angle y(1)
endif
position object 19,object position x(2),object position y(2)+25,object position z(2)
rem setting camera to follow players
position camera 1,object position x(1)-300,150,object position z(1)-300
point camera 1,object position x(1),object position y(1),object position z(1)
position camera 2,object position x(2)+300,150,object position z(2)+300
point camera 2,object position x(2),object position y(2),object position z(2)
rem boundaries and physics
if object collision(1,2) then move object up 1,5 : move object up 2,5
for A=3 to 15
if object collision(18,A) and keystate(72) then move object up 1,5
if object collision(18,A) and keystate(76) then move object down 1,5
if object collision(19,A) and keystate(17) then move object up 2,5
if object collision(19,A) and keystate(31) then move object down 2,5
next A
rem missile properties
if object position y(16)=object position y(1)+40 then move object 16,15
if object position y(17)=object position y(2)+40 then move object 17,15
rem updating screen
sync
rem end loop
loop
If at first you don't succeed, lower your expectations.